30#include <libdap/BaseType.h>
31#include <libdap/Sequence.h>
32#include <libdap/ConstraintEvaluator.h>
33#include <libdap/DataDDS.h>
35#include <libdap/escaping.h>
36#include <libdap/InternalErr.h>
37#include <libdap/util.h>
38#include <libdap/mime_util.h>
39#include <libdap/XMLWriter.h>
42#include <BESDapTransmit.h>
43#include <BESContainer.h>
44#include <BESDataNames.h>
45#include <BESDataDDSResponse.h>
46#include <BESDapError.h>
47#include <BESInternalFatalError.h>
49#include <DapFunctionUtils.h>
50#include <RequestServiceTimer.h>
52#include "BESXDTransmit.h"
53#include "get_xml_data.h"
55using namespace xml_data;
58#define MODULE "xml_data"
59#define prolog string("BESXDTransmit::").append(__func__).append("() - ")
63 BESDEBUG(
"xd",
"BESXDTransmit::send_base_ascii() - BEGIN" << endl);
68 DDS *dds = bdds->get_dds();
69 ConstraintEvaluator & ce = bdds->get_ce();
73 string constraint = www2id(dhi.
data[POST_CONSTRAINT],
"%",
"%20%26");
76 BESDEBUG(
"xd",
"BESXDTransmit::send_base_ascii() - " "parsing constraint: " << constraint << endl);
77 ce.parse_constraint(constraint, *dds);
79 catch (InternalErr &e) {
80 string err =
"Failed to parse the constraint expression: " + e.get_error_message();
81 throw BESDapError(err,
true, e.get_error_code(), __FILE__, __LINE__);
84 string err =
"Failed to parse the constraint expression: " + e.get_error_message();
85 throw BESDapError(err,
false, e.get_error_code(), __FILE__, __LINE__);
88 string err = (string)
"Failed to parse the constraint expression: " +
"Unknown exception caught";
92 BESDEBUG(
"xd",
"BESXDTransmit::send_base_ascii() - " "tagging sequences" << endl);
93 dds->tag_nested_sequences();
95 BESDEBUG(
"xd",
"BESXDTransmit::send_base_ascii() - " "accessing container" << endl);
98 BESDEBUG(
"xd",
"BESXDTransmit::send_base_ascii() - dataset_name = " << dataset_name << endl);
100 bool functional_constraint =
false;
103 if (ce.function_clauses()) {
104 BESDEBUG(
"xd",
"BESXDTransmit::send_base_ascii() Processing functional constraint clause(s)." << endl);
105 DDS *tmp_dds = ce.eval_function_clauses(*dds);
118 promote_function_output_structures(dds);
123 for (DDS::Vars_iter i = dds->var_begin(); i != dds->var_end(); i++) {
124 if ((*i)->send_p()) {
126 (*i)->intern_data(ce, *dds);
131 catch (InternalErr &e) {
132 if (functional_constraint)
134 string err =
"Failed to read data: " + e.get_error_message();
135 throw BESDapError(err,
true, e.get_error_code(), __FILE__, __LINE__);
138 if (functional_constraint)
140 string err =
"Failed to read data: " + e.get_error_message();
141 throw BESDapError(err,
false, e.get_error_code(), __FILE__, __LINE__);
147 if (functional_constraint)
149 string err =
"Failed to read data: Unknown exception caught";
156 BESDEBUG(
"xd",
"converting to xd datadds" << endl);
157 DDS *xd_dds = dds_to_xd_dds(dds);
166 BESDEBUG(
"xd",
"getting xd values" << endl);
168 get_data_values_as_xml(xd_dds, &writer);
169 dhi.get_output_stream() << writer.get_doc();
171 BESDEBUG(
"xd",
"got the ascii values" << endl);
172 dhi.get_output_stream() << flush;
175 BESDEBUG(
"xd",
"done transmitting ascii" << endl);
177 catch (InternalErr &e) {
178 if (functional_constraint)
180 string err =
"Failed to get values as ascii: " + e.get_error_message();
181 throw BESDapError(err,
true, e.get_error_code(), __FILE__, __LINE__);
184 if (functional_constraint)
186 string err =
"Failed to get values as ascii: " + e.get_error_message();
187 throw BESDapError(err,
false, e.get_error_code(), __FILE__, __LINE__);
193 if (functional_constraint)
195 string err =
"Failed to get values as ascii: Unknown exception caught";
199 if (functional_constraint)
virtual std::string access()=0
returns the true name of this container
error object created from libdap error objects and can handle those errors
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 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.
static void conditional_timeout_cancel()
Checks if the timeout alarm should be canceled based on the value of the BES key BES....
static RequestServiceTimer * TheTimer()
Return a pointer to a singleton timer instance. If an instance does not exist it will create and init...
void throw_if_timeout_expired(const std::string &message, const std::string &file, const int line)
Checks the RequestServiceTimer to determine if the time spent servicing the request at this point has...