38 #include <sys/types.h>
44 #include <libdap/DataDDS.h>
45 #include <libdap/BaseType.h>
46 #include <libdap/escaping.h>
47 #include <libdap/ConstraintEvaluator.h>
50 #include <BESInternalError.h>
51 #include <BESSyntaxUserError.h>
52 #include <BESDapError.h>
53 #include <TheBESKeys.h>
54 #include <BESContextManager.h>
55 #include <BESDataDDSResponse.h>
56 #include <BESDDSResponse.h>
57 #include <BESDapNames.h>
58 #include <BESDataNames.h>
59 #include <BESDapResponseBuilder.h>
61 #include <DapFunctionUtils.h>
63 #include "FoDapCovJsonTransmitter.h"
64 #include "FoDapCovJsonTransform.h"
68 #define FO_COVJSON_TEMP_DIR "/tmp"
70 string FoDapCovJsonTransmitter::temp_dir;
88 if (FoDapCovJsonTransmitter::temp_dir.empty()) {
91 string key =
"FoCovJson.Tempdir";
93 if (!found || FoDapCovJsonTransmitter::temp_dir.empty()) {
94 FoDapCovJsonTransmitter::temp_dir = FO_COVJSON_TEMP_DIR;
96 string::size_type len = FoDapCovJsonTransmitter::temp_dir.length();
97 if (FoDapCovJsonTransmitter::temp_dir[len - 1] ==
'/') {
98 FoDapCovJsonTransmitter::temp_dir = FoDapCovJsonTransmitter::temp_dir.substr(0, len - 1);
120 BESDEBUG(
"focovjson",
"FoDapCovJsonTransmitter::send_data - BEGIN" << endl);
125 BESDEBUG(
"focovjson",
"FoCovJsonTransmitter::send_data - Reading data into DataDDS" << endl);
144 catch(std::exception &e) {
145 throw BESSyntaxUserError(
string(
"Caught a C++ standard exception in responseBuilder.intern_dap2_data. The error was: ").append(e.what()), __FILE__, __LINE__);
148 ostream &o_strm = dhi.get_output_stream();
150 throw BESInternalError(
"Output stream is not set, can not return as COVJSON", __FILE__, __LINE__);
153 ft.transform(o_strm,
true,
false);
156 throw BESDapError(
"Failed to read data: " + e.get_error_message(),
false, e.get_error_code(), __FILE__, __LINE__);
161 catch (std::exception &e) {
162 throw BESInternalError(
"Failed to read data: STL Error: " +
string(e.what()), __FILE__, __LINE__);
165 throw BESInternalError(
"Failed to get read data: Unknown exception caught", __FILE__, __LINE__);
168 BESDEBUG(
"focovjson",
"FoDapCovJsonTransmitter::send_data - done transmitting COVJSON" << endl);
188 BESDEBUG(
"focovjson",
"FoDapCovJsonTransmitter::send_data - BEGIN transmitting COVJSON" << endl);
196 ostream &o_strm = dhi.get_output_stream();
198 throw BESInternalError(
"Output stream is not set, can not return as COVJSON", __FILE__, __LINE__);
206 ft.transform(o_strm,
false,
false);
209 throw BESDapError(
"Failed to transform data to COVJSON: " + e.get_error_message(),
false, e.get_error_code(),
216 throw BESInternalError(
"Failed to transform to COVJSON: Unknown exception caught", __FILE__, __LINE__);
219 BESDEBUG(
"focovjson",
"FoDapCovJsonTransmitter::send_data - done transmitting COVJSON" << endl);
error object created from libdap error objects and can handle those errors
virtual libdap::DDS * process_dap2_dds(BESResponseObject *obj, BESDataHandlerInterface &dhi)
Process a DDS (i.e., apply a constraint) for a non-DAP transmitter.
virtual libdap::DDS * intern_dap2_data(BESResponseObject *obj, BESDataHandlerInterface &dhi)
Structure storing information used by the BES to handle the request.
Abstract exception class for the BES with basic string message.
exception thrown if internal error encountered
Abstract base class representing a specific set of information in response to a request to the BES.
error thrown if there is a user syntax error in the request or any other user error
static void conditional_timeout_cancel()
Checks if the timeout alarm should be canceled based on the value of the BES key BES....
static void send_data(BESResponseObject *obj, BESDataHandlerInterface &dhi)
The static method registered to transmit OPeNDAP data objects as a JSON file.
static void send_metadata(BESResponseObject *obj, BESDataHandlerInterface &dhi)
The static method registered to transmit OPeNDAP data objects as a JSON file.
FoDapCovJsonTransmitter()
Construct the FoW10nJsonTransmitter.
void get_value(const std::string &s, std::string &val, bool &found)
Retrieve the value of a given key, if set.
static TheBESKeys * TheKeys()