32 #include <ConstraintEvaluator.h>
36 #include <InternalErr.h>
38 #include <mime_util.h>
39 #include <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>
51 #include "BESXDTransmit.h"
52 #include "get_xml_data.h"
54 using namespace xml_data;
59 BESDEBUG(
"xd",
"BESXDTransmit::send_base_ascii() - BEGIN" << endl);
64 DDS *dds = bdds->get_dds();
65 ConstraintEvaluator & ce = bdds->get_ce();
69 string constraint = www2id(dhi.
data[POST_CONSTRAINT],
"%",
"%20%26");
72 BESDEBUG(
"xd",
"BESXDTransmit::send_base_ascii() - " "parsing constraint: " << constraint << endl);
73 ce.parse_constraint(constraint, *dds);
75 catch (InternalErr &e) {
76 string err =
"Failed to parse the constraint expression: " + e.get_error_message();
77 throw BESDapError(err,
true, e.get_error_code(), __FILE__, __LINE__);
80 string err =
"Failed to parse the constraint expression: " + e.get_error_message();
81 throw BESDapError(err,
false, e.get_error_code(), __FILE__, __LINE__);
84 string err = (string)
"Failed to parse the constraint expression: " +
"Unknown exception caught";
88 BESDEBUG(
"xd",
"BESXDTransmit::send_base_ascii() - " "tagging sequences" << endl);
89 dds->tag_nested_sequences();
91 BESDEBUG(
"xd",
"BESXDTransmit::send_base_ascii() - " "accessing container" << endl);
94 BESDEBUG(
"xd",
"BESXDTransmit::send_base_ascii() - dataset_name = " << dataset_name << endl);
96 bool functional_constraint =
false;
99 if (ce.function_clauses()) {
100 BESDEBUG(
"xd",
"BESXDTransmit::send_base_ascii() Processing functional constraint clause(s)." << endl);
101 DDS *tmp_dds = ce.eval_function_clauses(*dds);
114 promote_function_output_structures(dds);
119 for (DDS::Vars_iter i = dds->var_begin(); i != dds->var_end(); i++) {
120 if ((*i)->send_p()) {
121 (*i)->intern_data(ce, *dds);
126 catch (InternalErr &e) {
127 if (functional_constraint)
129 string err =
"Failed to read data: " + e.get_error_message();
130 throw BESDapError(err,
true, e.get_error_code(), __FILE__, __LINE__);
133 if (functional_constraint)
135 string err =
"Failed to read data: " + e.get_error_message();
136 throw BESDapError(err,
false, e.get_error_code(), __FILE__, __LINE__);
142 if (functional_constraint)
144 string err =
"Failed to read data: Unknown exception caught";
151 BESDEBUG(
"xd",
"converting to xd datadds" << endl);
152 DDS *xd_dds = dds_to_xd_dds(dds);
158 BESDEBUG(
"xd",
"getting xd values" << endl);
160 get_data_values_as_xml(xd_dds, &writer);
161 dhi.get_output_stream() << writer.get_doc();
163 BESDEBUG(
"xd",
"got the ascii values" << endl);
164 dhi.get_output_stream() << flush;
167 BESDEBUG(
"xd",
"done transmitting ascii" << endl);
169 catch (InternalErr &e) {
170 if (functional_constraint)
172 string err =
"Failed to get values as ascii: " + e.get_error_message();
173 throw BESDapError(err,
true, e.get_error_code(), __FILE__, __LINE__);
176 if (functional_constraint)
178 string err =
"Failed to get values as ascii: " + e.get_error_message();
179 throw BESDapError(err,
false, e.get_error_code(), __FILE__, __LINE__);
185 if (functional_constraint)
187 string err =
"Failed to get values as ascii: Unknown exception caught";
191 if (functional_constraint)