36 #include <ConstraintEvaluator.h>
40 #include "BESDapTransmit.h"
41 #include "BESContainer.h"
42 #include "BESDapNames.h"
43 #include "BESDataNames.h"
44 #include "BESResponseNames.h"
46 #include "BESDASResponse.h"
47 #include "BESDDSResponse.h"
48 #include "BESDataDDSResponse.h"
50 #include "BESDMRResponse.h"
52 #include "BESContextManager.h"
53 #include "BESDapError.h"
54 #include "BESInternalFatalError.h"
57 #include "BESDapResponseBuilder.h"
78 string response_string = get_request_type();
80 send_internal(obj, dhi);
82 catch (InternalErr &e) {
83 string err =
"libdap error transmitting " + response_string +
": " + e.get_error_message();
84 throw BESDapError(err,
true, e.get_error_code(), __FILE__, __LINE__);
87 string err =
"libdap error transmitting " + response_string +
": " + e.get_error_message();
88 throw BESDapError(err,
false, e.get_error_code(), __FILE__, __LINE__);
93 catch (
const std::exception &e) {
94 string msg =
"std::exception caught transmitting " + response_string +
": " + e.what()
95 +
" (caught in BESDapTransmit).";
99 string s =
"unknown error caught transmitting " + response_string +
": ";
106 bool get_print_mime()
const
109 string protocol = BESContextManager::TheManager()->
get_context(
"transmit_protocol", found);
110 bool print_mime =
false;
111 if (found && protocol ==
"HTTP") {
120 virtual string get_request_type()
const = 0;
126 class SendDAS:
public Sender
129 virtual string get_request_type()
const
140 DAS *das = bdas->get_das();
142 bool print_mime = get_print_mime();
146 rb.send_das(dhi.get_output_stream(), *das, print_mime);
152 class SendDDS:
public Sender
155 virtual string get_request_type()
const
167 ConstraintEvaluator & ce = bdds->
get_ce();
170 bool print_mime = get_print_mime();
175 BESDEBUG(
"dap",
"dhi.data[POST_CONSTRAINT]: " << dhi.
data[POST_CONSTRAINT] << endl);
176 rb.
send_dds(dhi.get_output_stream(), &dds, ce,
true, print_mime);
181 class SendDataDDS:
public Sender
184 virtual string get_request_type()
const
195 DDS *dds = bdds->get_dds();
196 ConstraintEvaluator & ce = bdds->get_ce();
199 bool print_mime = get_print_mime();
205 rb.set_async_accepted(dhi.
data[ASYNC]);
206 rb.set_store_result(dhi.
data[STORE_RESULT]);
208 BESDEBUG(
"dap",
"dhi.data[POST_CONSTRAINT]: " << dhi.
data[POST_CONSTRAINT] << endl);
214 class SendDDX:
public Sender
217 virtual string get_request_type()
const
229 ConstraintEvaluator & ce = bdds->
get_ce();
232 bool print_mime = get_print_mime();
237 rb.
send_ddx(dhi.get_output_stream(), &dds, ce, print_mime);
242 class SendDMR:
public Sender
245 virtual string get_request_type()
const
252 BESDEBUG(
"dap",
"Entering SendDMR::send_internal ..." << endl);
257 DMR *dmr = bdmr->get_dmr();
267 rb.set_async_accepted(dhi.
data[ASYNC]);
268 rb.set_store_result(dhi.
data[STORE_RESULT]);
270 rb.send_dmr(dhi.get_output_stream(), *dmr, get_print_mime());
274 class SendDap4Data:
public Sender
277 virtual string get_request_type()
const
289 DMR *dmr = bdmr->get_dmr();
299 rb.set_async_accepted(dhi.
data[ASYNC]);
300 rb.set_store_result(dhi.
data[STORE_RESULT]);
302 rb.send_dap4_data(dhi.get_output_stream(), *dmr, get_print_mime());
309 BESDapTransmit::BESDapTransmit() :
312 add_method(DAS_SERVICE, BESDapTransmit::send_basic_das);
313 add_method(DDS_SERVICE, BESDapTransmit::send_basic_dds);
314 add_method(DDX_SERVICE, BESDapTransmit::send_basic_ddx);
315 add_method(DATA_SERVICE, BESDapTransmit::send_basic_data);
317 add_method(DMR_SERVICE, BESDapTransmit::send_basic_dmr);
318 add_method(DAP4DATA_SERVICE, BESDapTransmit::send_basic_dap4data);
321 BESDapTransmit::~BESDapTransmit()
323 remove_method(DAS_SERVICE);
324 remove_method(DDS_SERVICE);
325 remove_method(DDX_SERVICE);
326 remove_method(DATA_SERVICE);
328 remove_method(DMR_SERVICE);
329 remove_method(DAP4DATA_SERVICE);
335 sender.send(obj, dhi);
341 sender.send(obj, dhi);
347 sender.send(obj, dhi);
353 sender.send(obj, dhi);
359 sender.send(obj, dhi);
365 sender.send(obj, dhi);