35 #include <ConstraintEvaluator.h> 39 #include "BESDapTransmit.h" 40 #include "BESContainer.h" 41 #include "BESDapNames.h" 42 #include "BESDataNames.h" 43 #include "BESResponseNames.h" 45 #include "BESDASResponse.h" 46 #include "BESDDSResponse.h" 47 #include "BESDataDDSResponse.h" 49 #include "BESDMRResponse.h" 51 #include "BESContextManager.h" 52 #include "BESDapError.h" 53 #include "BESInternalFatalError.h" 56 #include "BESDapResponseBuilder.h" 74 string response_string = get_request_type();
76 send_internal(obj, dhi);
78 catch (InternalErr &e) {
79 string err =
"libdap error transmitting " + response_string +
": " + e.get_error_message();
80 throw BESDapError(err,
true, e.get_error_code(), __FILE__, __LINE__);
83 string err =
"libdap error transmitting " + response_string +
": " + e.get_error_message();
84 throw BESDapError(err,
false, e.get_error_code(), __FILE__, __LINE__);
89 catch (
const std::exception &e) {
90 string msg =
"std::exception caught transmitting " + response_string +
": " + e.what()
91 +
" (caught in BESDapTransmit).";
95 string s =
"unknown error caught transmitting " + response_string +
": ";
102 bool get_print_mime()
const 105 string protocol = BESContextManager::TheManager()->
get_context(
"transmit_protocol", found);
106 bool print_mime =
false;
107 if (found && protocol ==
"HTTP") {
116 virtual string get_request_type()
const = 0;
122 class SendDAS:
public Sender
125 virtual string get_request_type()
const 136 DAS *das = bdas->get_das();
138 bool print_mime = get_print_mime();
142 rb.send_das(dhi.get_output_stream(), *das, print_mime);
148 class SendDDS:
public Sender
151 virtual string get_request_type()
const 162 DDS *dds = bdds->get_dds();
163 ConstraintEvaluator & ce = bdds->get_ce();
166 bool print_mime = get_print_mime();
171 BESDEBUG(
"dap",
"dhi.data[POST_CONSTRAINT]: " << dhi.
data[POST_CONSTRAINT] << endl);
172 rb.
send_dds(dhi.get_output_stream(), *dds, ce,
true, print_mime);
176 class SendDataDDS:
public Sender
179 virtual string get_request_type()
const 190 DataDDS *dds = bdds->get_dds();
191 ConstraintEvaluator & ce = bdds->get_ce();
194 bool print_mime = get_print_mime();
200 rb.set_async_accepted(dhi.
data[ASYNC]);
201 rb.set_store_result(dhi.
data[STORE_RESULT]);
203 BESDEBUG(
"dap",
"dhi.data[POST_CONSTRAINT]: " << dhi.
data[POST_CONSTRAINT] << endl);
208 class SendDDX:
public Sender
211 virtual string get_request_type()
const 222 DDS *dds = bdds->get_dds();
223 ConstraintEvaluator & ce = bdds->get_ce();
226 bool print_mime = get_print_mime();
231 rb.
send_ddx(dhi.get_output_stream(), *dds, ce, print_mime);
235 class SendDMR:
public Sender
238 virtual string get_request_type()
const 245 BESDEBUG(
"dap",
"Entering SendDMR::send_internal ..." << endl);
250 DMR *dmr = bdmr->get_dmr();
260 rb.set_async_accepted(dhi.
data[ASYNC]);
261 rb.set_store_result(dhi.
data[STORE_RESULT]);
263 rb.send_dmr(dhi.get_output_stream(), *dmr, get_print_mime());
267 class SendDap4Data:
public Sender
270 virtual string get_request_type()
const 282 DMR *dmr = bdmr->get_dmr();
292 rb.set_async_accepted(dhi.
data[ASYNC]);
293 rb.set_store_result(dhi.
data[STORE_RESULT]);
295 rb.send_dap4_data(dhi.get_output_stream(), *dmr, get_print_mime());
302 BESDapTransmit::BESDapTransmit() :
305 add_method(DAS_SERVICE, BESDapTransmit::send_basic_das);
306 add_method(DDS_SERVICE, BESDapTransmit::send_basic_dds);
307 add_method(DDX_SERVICE, BESDapTransmit::send_basic_ddx);
308 add_method(DATA_SERVICE, BESDapTransmit::send_basic_data);
310 add_method(DMR_SERVICE, BESDapTransmit::send_basic_dmr);
311 add_method(DAP4DATA_SERVICE, BESDapTransmit::send_basic_dap4data);
314 BESDapTransmit::~BESDapTransmit()
316 remove_method(DAS_SERVICE);
317 remove_method(DDS_SERVICE);
318 remove_method(DDX_SERVICE);
319 remove_method(DATA_SERVICE);
321 remove_method(DMR_SERVICE);
322 remove_method(DAP4DATA_SERVICE);
328 sender.send(obj, dhi);
334 sender.send(obj, dhi);
340 sender.send(obj, dhi);
346 sender.send(obj, dhi);
352 sender.send(obj, dhi);
358 sender.send(obj, dhi);
exception thrown if an internal error is found and is fatal to the BES
exception thrown if inernal error encountered
Represents an OPeNDAP DDS DAP2 data object within the BES.
virtual void send_dap2_data(std::ostream &data_stream, libdap::DDS &dds, libdap::ConstraintEvaluator &eval, bool with_mime_headers=true)
Transmit data.
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.
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.
string get_real_name() const
retrieve the real name for this container, such as a file name.
virtual void set_dataset_name(const std::string _dataset)
Set the dataset pathname.
virtual void set_dap4function(std::string _func)
virtual void send_ddx(std::ostream &out, libdap::DDS &dds, libdap::ConstraintEvaluator &eval, bool with_mime_headers=true)
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.
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 set_dap4ce(std::string _ce)
BESContainer * container
pointer to current container in this interface
virtual void send_dds(std::ostream &out, libdap::DDS &dds, libdap::ConstraintEvaluator &eval, bool constrained=false, bool with_mime_headers=true)
Transmit a DDS.