00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #include <sstream>
00034
00035 using std::ostringstream;
00036
00037 #include "BESDapTransmit.h"
00038 #include "DODSFilter.h"
00039 #include "BESContainer.h"
00040 #include "BESDataNames.h"
00041 #include "cgi_util.h"
00042 #include "BESDASResponse.h"
00043 #include "BESDDSResponse.h"
00044 #include "BESDataDDSResponse.h"
00045 #include "BESTransmitException.h"
00046 #include "Error.h"
00047
00048 void
00049 BESDapTransmit::send_basic_das(BESResponseObject * obj,
00050 BESDataHandlerInterface & dhi)
00051 {
00052 BESDASResponse *bdas = dynamic_cast < BESDASResponse * >(obj);
00053 DAS *das = bdas->get_das();
00054 dhi.first_container();
00055
00056 try {
00057 DODSFilter df;
00058 df.set_dataset_name(dhi.container->get_real_name());
00059 df.send_das(dhi.get_output_stream(), *das, "", false);
00060 dhi.get_output_stream() << flush ;
00061 }
00062 catch(Error & e) {
00063 ostringstream s;
00064 s << "libdap exception transmitting DAS"
00065 << ": error_code = " << e.get_error_code()
00066 << ": " << e.get_error_message();
00067 BESTransmitException ex(s.str(), __FILE__, __LINE__);
00068 throw ex;
00069 }
00070 catch(...) {
00071 string s = "unknown exception caught transmitting DAS";
00072 BESTransmitException ex(s, __FILE__, __LINE__);
00073 throw ex;
00074 }
00075 }
00076
00077 void BESDapTransmit::send_http_das(BESResponseObject * obj,
00078 BESDataHandlerInterface & dhi)
00079 {
00080 set_mime_text(dhi.get_output_stream(), dods_das);
00081 BESDapTransmit::send_basic_das(obj, dhi);
00082 }
00083
00084 void BESDapTransmit::send_basic_dds(BESResponseObject * obj,
00085 BESDataHandlerInterface & dhi)
00086 {
00087 BESDDSResponse *bdds = dynamic_cast < BESDDSResponse * >(obj);
00088 DDS *dds = bdds->get_dds();
00089 ConstraintEvaluator & ce = bdds->get_ce();
00090 dhi.first_container();
00091
00092 try {
00093 DODSFilter df;
00094 df.set_dataset_name(dhi.container->get_real_name());
00095 df.set_ce(dhi.data[POST_CONSTRAINT]);
00096 df.send_dds(dhi.get_output_stream(), *dds, ce, true, "", false);
00097 dhi.get_output_stream() << flush ;
00098 }
00099 catch(Error & e) {
00100 ostringstream s;
00101 s << "libdap exception transmitting DDS"
00102 << ": error_code = " << e.get_error_code()
00103 << ": " << e.get_error_message();
00104 BESTransmitException ex(s.str(), __FILE__, __LINE__);
00105 throw ex;
00106 }
00107 catch(...) {
00108 string s = "unknown exception caught transmitting DDS";
00109 BESTransmitException ex(s, __FILE__, __LINE__);
00110 throw ex;
00111 }
00112 }
00113
00114 void BESDapTransmit::send_http_dds(BESResponseObject * obj,
00115 BESDataHandlerInterface & dhi)
00116 {
00117 set_mime_text(dhi.get_output_stream(), dods_dds);
00118 BESDapTransmit::send_basic_dds(obj, dhi);
00119 }
00120
00121 void BESDapTransmit::send_basic_data(BESResponseObject * obj,
00122 BESDataHandlerInterface & dhi)
00123 {
00124 BESDataDDSResponse *bdds = dynamic_cast < BESDataDDSResponse * >(obj);
00125 DataDDS *dds = bdds->get_dds();
00126 ConstraintEvaluator & ce = bdds->get_ce();
00127 dhi.first_container();
00128
00129 try {
00130 DODSFilter df;
00131 df.set_dataset_name(dds->filename());
00132 df.set_ce(dhi.data[POST_CONSTRAINT]);
00133 df.send_data(*dds, ce, dhi.get_output_stream(), "", false);
00134 dhi.get_output_stream() << flush ;
00135 }
00136 catch(Error & e) {
00137 ostringstream s;
00138 s << "libdap exception transmitting DataDDS"
00139 << ": error_code = " << e.get_error_code()
00140 << ": " << e.get_error_message();
00141 BESTransmitException ex(s.str(), __FILE__, __LINE__);
00142 throw ex;
00143 }
00144 catch(...) {
00145 string s = "unknown exception caught transmitting DataDDS";
00146 BESTransmitException ex(s, __FILE__, __LINE__);
00147 throw ex;
00148 }
00149 }
00150
00151 void BESDapTransmit::send_http_data(BESResponseObject * obj,
00152 BESDataHandlerInterface & dhi)
00153 {
00154
00155 BESDapTransmit::send_basic_data(obj, dhi);
00156 }
00157
00158 void BESDapTransmit::send_basic_ddx(BESResponseObject * obj,
00159 BESDataHandlerInterface & dhi)
00160 {
00161 BESDDSResponse *bdds = dynamic_cast < BESDDSResponse * >(obj);
00162 DDS *dds = bdds->get_dds();
00163 ConstraintEvaluator & ce = bdds->get_ce();
00164 dhi.first_container();
00165
00166 try {
00167 DODSFilter df;
00168 df.set_dataset_name(dhi.container->get_real_name());
00169 df.set_ce(dhi.data[POST_CONSTRAINT]);
00170 df.send_ddx(*dds, ce, dhi.get_output_stream(), false);
00171 dhi.get_output_stream() << flush ;
00172 }
00173 catch(Error & e) {
00174 ostringstream s;
00175 s << "libdap exception transmitting DDX"
00176 << ": error_code = " << e.get_error_code()
00177 << ": " << e.get_error_message();
00178 BESTransmitException ex(s.str(), __FILE__, __LINE__);
00179 throw ex;
00180 }
00181 catch(...) {
00182 string s = "unknown exception caught transmitting DAS";
00183 BESTransmitException ex(s, __FILE__, __LINE__);
00184 throw ex;
00185 }
00186 }
00187
00188 void BESDapTransmit::send_http_ddx(BESResponseObject * obj,
00189 BESDataHandlerInterface & dhi)
00190 {
00191 set_mime_text(dhi.get_output_stream(), dods_dds);
00192 BESDapTransmit::send_basic_ddx(obj, dhi);
00193 }