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