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);
std::string get_real_name() const
retrieve the real name for this container, such as a file name.
virtual std::string get_context(const std::string &name, bool &found)
retrieve the value of the specified context from the BES
Represents an OPeNDAP DAS DAP2 data object within the BES.
Holds a DDS object within the BES.
void set_dds(libdap::DDS *ddsIn)
libdap::ConstraintEvaluator & get_ce()
Represents an OPeNDAP DMR DAP4 data object within the BES.
error object created from libdap error objects and can handle those errors
virtual void set_dataset_name(const std::string _dataset)
Set the dataset pathname.
virtual void set_dap4ce(std::string _ce)
virtual void send_dds(std::ostream &out, libdap::DDS **dds, libdap::ConstraintEvaluator &eval, bool constrained=false, bool with_mime_headers=true)
Transmit a DDS.
virtual void send_ddx(std::ostream &out, libdap::DDS **dds, libdap::ConstraintEvaluator &eval, bool with_mime_headers=true)
virtual void set_dap4function(std::string _func)
virtual void set_ce(std::string _ce)
Represents an OPeNDAP DataDDS DAP2 data object within the BES.
void set_dds(libdap::DDS *ddsIn)
Structure storing information used by the BES to handle the request.
std::map< std::string, std::string > data
the map of string data that will be required for the current request.
void first_container()
set the container pointer to the first container in the containers list
BESContainer * container
pointer to current container in this interface
Abstract exception class for the BES with basic string message.
exception thrown if internal error encountered
exception thrown if an internal error is found and is fatal to the BES
Abstract base class representing a specific set of information in response to a request to the BES.