38 #include <sys/types.h> 47 #include <ConstraintEvaluator.h> 50 #include <BESInternalError.h> 51 #include <BESDapError.h> 52 #include <TheBESKeys.h> 53 #include <BESContextManager.h> 54 #include <BESDataDDSResponse.h> 55 #include <BESDDSResponse.h> 56 #include <BESDapNames.h> 57 #include <BESDataNames.h> 58 #include <BESDapResponseBuilder.h> 60 #include <DapFunctionUtils.h> 62 #include "FoDapJsonTransmitter.h" 63 #include "FoDapJsonTransform.h" 67 #define FO_JSON_TEMP_DIR "/tmp" 69 string FoDapJsonTransmitter::temp_dir;
87 if (FoDapJsonTransmitter::temp_dir.empty()) {
90 string key =
"FoJson.Tempdir";
92 if (!found || FoDapJsonTransmitter::temp_dir.empty()) {
93 FoDapJsonTransmitter::temp_dir = FO_JSON_TEMP_DIR;
95 string::size_type len = FoDapJsonTransmitter::temp_dir.length();
96 if (FoDapJsonTransmitter::temp_dir[len - 1] ==
'/') {
97 FoDapJsonTransmitter::temp_dir = FoDapJsonTransmitter::temp_dir.substr(0, len - 1);
119 BESDEBUG(
"fojson",
"FoDapJsonTransmitter::send_data - BEGIN" << endl);
124 BESDEBUG(
"fojson",
"FoJsonTransmitter::send_data - Reading data into DataDDS" << endl);
137 ostream &o_strm = dhi.get_output_stream();
139 throw BESInternalError(
"Output stream is not set, can not return as JSON", __FILE__, __LINE__);
143 ft.transform(o_strm,
true );
146 throw BESDapError(
"Failed to read data: " + e.get_error_message(),
false, e.get_error_code(), __FILE__, __LINE__);
151 catch (std::exception &e) {
152 throw BESInternalError(
"Failed to read data: STL Error: " +
string(e.what()), __FILE__, __LINE__);
155 throw BESInternalError(
"Failed to get read data: Unknown exception caught", __FILE__, __LINE__);
158 BESDEBUG(
"fojson",
"FoDapJsonTransmitter::send_data - done transmitting JSON" << endl);
178 BESDEBUG(
"fojson",
"FoDapJsonTransmitter::send_data - BEGIN transmitting JSON" << endl);
186 ostream &o_strm = dhi.get_output_stream();
188 throw BESInternalError(
"Output stream is not set, can not return as JSON", __FILE__, __LINE__);
196 ft.transform(o_strm,
false );
199 throw BESDapError(
"Failed to transform data to JSON: " + e.get_error_message(),
false, e.get_error_code(),
206 throw BESInternalError(
"Failed to transform to JSON: Unknown exception caught", __FILE__, __LINE__);
209 BESDEBUG(
"fojson",
"FoDapJsonTransmitter::send_data - done transmitting JSON" << endl);
virtual libdap::DDS * intern_dap2_data(BESResponseObject *obj, BESDataHandlerInterface &dhi)
exception thrown if inernal error encountered
static void conditional_timeout_cancel()
void get_value(const std::string &s, std::string &val, bool &found)
Retrieve the value of a given key, if set.
static void send_data(BESResponseObject *obj, BESDataHandlerInterface &dhi)
The static method registered to transmit OPeNDAP data objects as a JSON file.
Abstract exception class for the BES with basic string message.
static TheBESKeys * TheKeys()
error object created from libdap error objects and can handle those errors
Structure storing information used by the BES to handle the request.
FoDapJsonTransmitter()
Construct the FoW10nJsonTransmitter.
Abstract base class representing a specific set of information in response to a request to the BES.
static void send_metadata(BESResponseObject *obj, BESDataHandlerInterface &dhi)
The static method registered to transmit OPeNDAP data objects as a JSON file.
virtual libdap::DDS * process_dap2_dds(BESResponseObject *obj, BESDataHandlerInterface &dhi)
Process a DDS (i.e., apply a constraint) for a non-DAP transmitter.