34#include <libdap/DDS.h>
35#include <libdap/DAS.h>
36#include <libdap/DataDDS.h>
37#include <libdap/ConstraintEvaluator.h>
39#include <libdap/Error.h>
41#include "BESDapTransmit.h"
42#include "BESContainer.h"
43#include "BESDapNames.h"
44#include "BESDataNames.h"
45#include "BESResponseNames.h"
47#include "BESDASResponse.h"
48#include "BESDDSResponse.h"
49#include "BESDataDDSResponse.h"
51#include "BESDMRResponse.h"
53#include "BESContextManager.h"
54#include "BESDapError.h"
55#include "BESInternalFatalError.h"
58#include "BESDapResponseBuilder.h"
64#define prolog std::string("DapTransmit::").append(__func__).append("() - ")
82 string response_string = get_request_type();
84 send_internal(obj, dhi);
86 catch (InternalErr &e) {
87 string err =
"libdap error transmitting " + response_string +
": " + e.get_error_message();
88 throw BESDapError(err,
true, e.get_error_code(), __FILE__, __LINE__);
91 string err =
"libdap error transmitting " + response_string +
": " + e.get_error_message();
92 throw BESDapError(err,
false, e.get_error_code(), __FILE__, __LINE__);
97 catch (
const std::exception &e) {
98 string msg =
"std::exception caught transmitting " + response_string +
": " + e.what()
99 +
" (caught in BESDapTransmit).";
103 string s =
"unknown error caught transmitting " + response_string +
": ";
110 bool get_print_mime()
const
113 string protocol = BESContextManager::TheManager()->
get_context(
"transmit_protocol", found);
114 bool print_mime =
false;
115 if (found && protocol ==
"HTTP") {
124 virtual string get_request_type()
const = 0;
130class SendDAS:
public Sender
133 virtual string get_request_type()
const
144 DAS *das = bdas->get_das();
146 bool print_mime = get_print_mime();
150 rb.send_das(dhi.get_output_stream(), *das, print_mime);
156class SendDDS:
public Sender
159 virtual string get_request_type()
const
171 ConstraintEvaluator & ce = bdds->
get_ce();
174 bool print_mime = get_print_mime();
179 BESDEBUG(MODULE, prolog <<
"dhi.data[POST_CONSTRAINT]: " << dhi.
data[POST_CONSTRAINT] << endl);
180 rb.
send_dds(dhi.get_output_stream(), &dds, ce,
true, print_mime);
185class SendDataDDS:
public Sender
188 virtual string get_request_type()
const
199 DDS *dds = bdds->get_dds();
200 ConstraintEvaluator & ce = bdds->get_ce();
203 bool print_mime = get_print_mime();
209 rb.set_async_accepted(dhi.
data[ASYNC]);
210 rb.set_store_result(dhi.
data[STORE_RESULT]);
212 BESDEBUG(MODULE, prolog <<
"dhi.data[POST_CONSTRAINT]: " << dhi.
data[POST_CONSTRAINT] << endl);
214 rb.send_dap2_data(dhi, &dds, ce, print_mime);
219class SendDDX:
public Sender
222 virtual string get_request_type()
const
234 ConstraintEvaluator & ce = bdds->
get_ce();
237 bool print_mime = get_print_mime();
242 rb.
send_ddx(dhi.get_output_stream(), &dds, ce, print_mime);
247class SendDMR:
public Sender
250 virtual string get_request_type()
const
257 BESDEBUG(MODULE, prolog <<
"SendDMR::send_internal() - BEGIN" << endl);
262 DMR *dmr = bdmr->get_dmr();
264 BESDEBUG(MODULE, prolog <<
"SendDMR::send_internal() - dmr->request_xml_base(): '"<< dmr->request_xml_base() << endl);
274 rb.set_async_accepted(dhi.
data[ASYNC]);
275 rb.set_store_result(dhi.
data[STORE_RESULT]);
277 rb.send_dmr(dhi.get_output_stream(), *dmr, get_print_mime());
278 BESDEBUG(MODULE, prolog <<
"SendDMR::send_internal() - END" << endl);
282class SendDap4Data:
public Sender
285 virtual string get_request_type()
const
291 BESDEBUG(MODULE, prolog <<
"SendDap4Data::send_internal() - BEGIN" << endl);
298 DMR *dmr = bdmr->get_dmr();
300 BESDEBUG(MODULE, prolog <<
"SendDap4Data::send_internal() - dmr->request_xml_base(): '"<< dmr->request_xml_base() << endl);
310 rb.set_async_accepted(dhi.
data[ASYNC]);
311 rb.set_store_result(dhi.
data[STORE_RESULT]);
313 rb.send_dap4_data(dhi.get_output_stream(), *dmr, get_print_mime());
314 BESDEBUG(MODULE, prolog <<
"SendDap4Data::send_internal() - END" << endl);
321BESDapTransmit::BESDapTransmit() :
324 add_method(DAS_SERVICE, BESDapTransmit::send_basic_das);
325 add_method(DDS_SERVICE, BESDapTransmit::send_basic_dds);
326 add_method(DDX_SERVICE, BESDapTransmit::send_basic_ddx);
327 add_method(DATA_SERVICE, BESDapTransmit::send_basic_data);
329 add_method(DMR_SERVICE, BESDapTransmit::send_basic_dmr);
330 add_method(DAP4DATA_SERVICE, BESDapTransmit::send_basic_dap4data);
333BESDapTransmit::~BESDapTransmit()
335 remove_method(DAS_SERVICE);
336 remove_method(DDS_SERVICE);
337 remove_method(DDX_SERVICE);
338 remove_method(DATA_SERVICE);
340 remove_method(DMR_SERVICE);
341 remove_method(DAP4DATA_SERVICE);
347 sender.send(obj, dhi);
353 sender.send(obj, dhi);
359 sender.send(obj, dhi);
365 sender.send(obj, dhi);
371 sender.send(obj, dhi);
377 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.
libdap::ConstraintEvaluator & get_ce()
void set_dds(libdap::DDS *ddsIn)
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
Base 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.