38 #include <sys/types.h> 47 #include <ConstraintEvaluator.h> 49 #include <BESInternalError.h> 50 #include <BESDapError.h> 51 #include <TheBESKeys.h> 52 #include <BESContextManager.h> 53 #include <BESDataDDSResponse.h> 54 #include <BESDDSResponse.h> 55 #include <BESDapNames.h> 56 #include <BESDataNames.h> 57 #include <BESDapResponseBuilder.h> 60 #include "FoInstanceJsonTransmitter.h" 61 #include "FoInstanceJsonTransform.h" 65 #define FO_JSON_TEMP_DIR "/tmp" 67 string FoInstanceJsonTransmitter::temp_dir;
84 if (FoInstanceJsonTransmitter::temp_dir.empty()) {
87 string key =
"FoJson.Tempdir";
89 if (!found || FoInstanceJsonTransmitter::temp_dir.empty()) {
90 FoInstanceJsonTransmitter::temp_dir = FO_JSON_TEMP_DIR;
92 string::size_type len = FoInstanceJsonTransmitter::temp_dir.length();
93 if (FoInstanceJsonTransmitter::temp_dir[len - 1] ==
'/') {
94 FoInstanceJsonTransmitter::temp_dir = FoInstanceJsonTransmitter::temp_dir.substr(0, len - 1);
120 BESDEBUG(
"fojson",
"FoJsonTransmitter::send_data - BEGIN transmitting JSON" << endl);
128 ostream &o_strm = dhi.get_output_stream();
130 throw BESInternalError(
"Output stream is not set, can not return as JSON", __FILE__, __LINE__);
134 ft.transform(o_strm,
false );
137 throw BESDapError(
"Failed to transform data to JSON: " + e.get_error_message(),
false, e.get_error_code(),
144 throw BESInternalError(
"Failed to transform to JSON: Unknown exception caught", __FILE__, __LINE__);
147 BESDEBUG(
"fojson",
"FoJsonTransmitter::send_data - done transmitting JSON" << endl);
167 BESDEBUG(
"fojson",
"FoJsonTransmitter::send_data - BEGIN transmitting JSON" << endl);
172 BESDEBUG(
"fojson",
"FoJsonTransmitter::send_data - Reading data into DataDDS" << endl);
180 ostream &o_strm = dhi.get_output_stream();
182 throw BESInternalError(
"Output stream is not set, can not return as JSON", __FILE__, __LINE__);
186 ft.transform(o_strm,
true );
189 throw BESDapError(
"Failed to read data: " + e.get_error_message(),
false, e.get_error_code(), __FILE__, __LINE__);
194 catch (std::exception &e) {
195 throw BESInternalError(
"Failed to read data: STL Error: " +
string(e.what()), __FILE__, __LINE__);
198 throw BESInternalError(
"Failed to get read data: Unknown exception caught", __FILE__, __LINE__);
201 BESDEBUG(
"fojson",
"FoJsonTransmitter::send_data - done transmitting JSON" << endl);
virtual libdap::DDS * intern_dap2_data(BESResponseObject *obj, BESDataHandlerInterface &dhi)
exception thrown if inernal error encountered
static void send_data(BESResponseObject *obj, BESDataHandlerInterface &dhi)
The static method registered to transmit OPeNDAP data objects as a JSON file.
void get_value(const std::string &s, std::string &val, bool &found)
Retrieve the value of a given key, if set.
FoInstanceJsonTransmitter()
Construct the FoJsonTransmitter.
Abstract exception class for the BES with basic string message.
static TheBESKeys * TheKeys()
static void send_metadata(BESResponseObject *obj, BESDataHandlerInterface &dhi)
The static method registered to transmit OPeNDAP data objects as a JSON file.
error object created from libdap error objects and can handle those errors
Structure storing information used by the BES to handle the request.
Abstract base class representing a specific set of information in response to a request to the BES.
virtual libdap::DDS * process_dap2_dds(BESResponseObject *obj, BESDataHandlerInterface &dhi)
Process a DDS (i.e., apply a constraint) for a non-DAP transmitter.