37 #include <ConstraintEvaluator.h> 40 #include <D4ConstraintEvaluator.h> 42 #include <InternalErr.h> 45 #include <mime_util.h> 48 #include <BESDapNames.h> 49 #include <BESDataNames.h> 50 #include <BESDapTransmit.h> 51 #include <BESContainer.h> 52 #include <BESDataDDSResponse.h> 53 #include <BESDMRResponse.h> 54 #include <BESDapResponseBuilder.h> 57 #include <BESDapError.h> 58 #include <BESForbiddenError.h> 59 #include <BESInternalFatalError.h> 60 #include <DapFunctionUtils.h> 64 #include "BESAsciiTransmit.h" 65 #include "get_ascii.h" 66 #include "get_ascii_dap4.h" 68 using namespace dap_asciival;
70 BESAsciiTransmit::BESAsciiTransmit() :
73 add_method(DATA_SERVICE, BESAsciiTransmit::send_basic_ascii);
79 BESDEBUG(
"ascii",
"BESAsciiTransmit::send_basic_ascii() - BEGIN" << endl);
95 auto_ptr<DDS> ascii_dds(datadds_to_ascii_datadds(loaded_dds));
97 get_data_values_as_ascii(ascii_dds.get(), dhi.get_output_stream());
98 dhi.get_output_stream() << flush;
101 throw BESDapError(
"Failed to get values as ascii: " + e.get_error_message(),
false, e.get_error_code(), __FILE__, __LINE__);
106 catch (std::exception &e) {
107 throw BESInternalError(
"Failed to read data: STL Error: " +
string(e.what()), __FILE__, __LINE__);
110 throw BESInternalError(
"Failed to get values as ascii: Unknown exception caught", __FILE__, __LINE__);
113 BESDEBUG(
"ascii",
"Done BESAsciiTransmit::send_basic_ascii()" << endl);
121 BESDEBUG(
"ascii",
"BESAsciiTransmit::send_dap4_csv" << endl);
126 DMR *dmr = bdmr->get_dmr();
128 string dap4Constraint = www2id(dhi.
data[DAP4_CONSTRAINT],
"%",
"%20%26");
129 string dap4Function = www2id(dhi.
data[DAP4_FUNCTION],
"%",
"%20%26");
142 if (!dap4Constraint.empty()) {
143 D4ConstraintEvaluator d4ce(dmr);
144 bool parse_ok = d4ce.parse(dap4Constraint);
145 if (!parse_ok)
throw Error(malformed_expr,
"Constraint Expression (" + dap4Constraint +
") failed to parse.");
148 dmr->root()->set_send_p(
true);
151 if (dmr->response_limit() != 0 && (dmr->request_size(
true) > dmr->response_limit())) {
152 string msg =
"The Request for " + long_to_string(dmr->request_size(
true))
153 +
"KB is too large; requests for this server are limited to " + long_to_string(dmr->response_limit())
162 print_values_as_ascii(dmr, dhi.get_output_stream());
163 dhi.get_output_stream() << flush;
166 throw BESDapError(
"Failed to return values as ascii: " + e.get_error_message(),
false, e.get_error_code(),__FILE__, __LINE__);
172 throw BESInternalError(
"Failed to return values as ascii: Unknown exception caught", __FILE__, __LINE__);
175 BESDEBUG(
"ascii",
"Done BESAsciiTransmit::send_dap4_csv" << endl);
virtual libdap::DDS * intern_dap2_data(BESResponseObject *obj, BESDataHandlerInterface &dhi)
exception thrown if an internal error is found and is fatal to the BES
exception thrown if inernal error encountered
static void conditional_timeout_cancel()
virtual bool add_method(const string &name, p_request_handler_method method)
add a handler method to the request handler that knows how to fill in a specific response object
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
static void send_dap4_csv(BESResponseObject *obj, BESDataHandlerInterface &dhi)
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.
void first_container()
set the container pointer to the first container in the containers list
Abstract base class representing a specific set of information in response to a request to the BES.