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);
210 rb.send_dap2_data(dhi, &dds, ce, print_mime);
215 class SendDDX:
public Sender
218 virtual string get_request_type()
const
230 ConstraintEvaluator & ce = bdds->
get_ce();
233 bool print_mime = get_print_mime();
238 rb.
send_ddx(dhi.get_output_stream(), &dds, ce, print_mime);
243 class SendDMR:
public Sender
246 virtual string get_request_type()
const
253 BESDEBUG(
"dap",
"Entering SendDMR::send_internal ..." << endl);
258 DMR *dmr = bdmr->get_dmr();
268 rb.set_async_accepted(dhi.
data[ASYNC]);
269 rb.set_store_result(dhi.
data[STORE_RESULT]);
271 rb.send_dmr(dhi.get_output_stream(), *dmr, get_print_mime());
275 class SendDap4Data:
public Sender
278 virtual string get_request_type()
const
290 DMR *dmr = bdmr->get_dmr();
300 rb.set_async_accepted(dhi.
data[ASYNC]);
301 rb.set_store_result(dhi.
data[STORE_RESULT]);
303 rb.send_dap4_data(dhi.get_output_stream(), *dmr, get_print_mime());
310 BESDapTransmit::BESDapTransmit() :
313 add_method(DAS_SERVICE, BESDapTransmit::send_basic_das);
314 add_method(DDS_SERVICE, BESDapTransmit::send_basic_dds);
315 add_method(DDX_SERVICE, BESDapTransmit::send_basic_ddx);
316 add_method(DATA_SERVICE, BESDapTransmit::send_basic_data);
318 add_method(DMR_SERVICE, BESDapTransmit::send_basic_dmr);
319 add_method(DAP4DATA_SERVICE, BESDapTransmit::send_basic_dap4data);
322 BESDapTransmit::~BESDapTransmit()
324 remove_method(DAS_SERVICE);
325 remove_method(DDS_SERVICE);
326 remove_method(DDX_SERVICE);
327 remove_method(DATA_SERVICE);
329 remove_method(DMR_SERVICE);
330 remove_method(DAP4DATA_SERVICE);
336 sender.send(obj, dhi);
342 sender.send(obj, dhi);
348 sender.send(obj, dhi);
354 sender.send(obj, dhi);
360 sender.send(obj, dhi);
366 sender.send(obj, dhi);