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"
70string FoDapCovJsonTransmitter::temp_dir;
92 if (FoDapCovJsonTransmitter::temp_dir.empty()) {
95 string key =
"FoCovJson.Tempdir";
97 if (!found || FoDapCovJsonTransmitter::temp_dir.empty()) {
98 FoDapCovJsonTransmitter::temp_dir = FO_COVJSON_TEMP_DIR;
100 string::size_type len = FoDapCovJsonTransmitter::temp_dir.size();
101 if (FoDapCovJsonTransmitter::temp_dir[len - 1] ==
'/') {
102 FoDapCovJsonTransmitter::temp_dir = FoDapCovJsonTransmitter::temp_dir.substr(0, len - 1);
124 BESDEBUG(
"focovjson",
"FoDapCovJsonTransmitter::send_data - BEGIN" << endl);
129 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);
157 throw BESDapError(
"Failed to read data: " + e.get_error_message(),
false, e.get_error_code(), __FILE__, __LINE__);
162 catch (std::exception &e) {
163 throw BESInternalError(
"Failed to read data: STL Error: " +
string(e.what()), __FILE__, __LINE__);
166 throw BESInternalError(
"Failed to get read data: Unknown exception caught", __FILE__, __LINE__);
169 BESDEBUG(
"focovjson",
"FoDapCovJsonTransmitter::send_data - done transmitting COVJSON" << endl);
189 BESDEBUG(
"focovjson",
"FoDapCovJsonTransmitter::send_data - BEGIN transmitting COVJSON" << endl);
197 ostream &o_strm = dhi.get_output_stream();
199 throw BESInternalError(
"Output stream is not set, can not return as COVJSON", __FILE__, __LINE__);
207 ft.transform(o_strm,
false,
false);
211 throw BESDapError(
"Failed to transform data to COVJSON: " + e.get_error_message(),
false, e.get_error_code(),
218 throw BESInternalError(
"Failed to transform to COVJSON: Unknown exception caught", __FILE__, __LINE__);
221 BESDEBUG(
"focovjson",
"FoDapCovJsonTransmitter::send_data - done transmitting COVJSON" << endl);
241 BESDEBUG(
"focovjson",
"FoDapCovJsonTransmitter::send_dap4data - BEGIN" << endl);
246 BESDEBUG(
"focovjson",
"FoCovJsonTransmitter::send_dap4data - Reading data into DMR" << endl);
261 catch(std::exception &e) {
262 throw BESSyntaxUserError(
string(
"Caught a C++ standard exception in responseBuilder.intern_dap4_data. The error was: ").append(e.what()), __FILE__, __LINE__);
265 ostream &o_strm = dhi.get_output_stream();
267 throw BESInternalError(
"Output stream is not set, can not return as COVJSON", __FILE__, __LINE__);
270 ft.transform_dap4(o_strm,
true,
false);
273 throw BESDapError(
"Failed to read dap4 data: " + e.get_error_message(),
false, e.get_error_code(), __FILE__, __LINE__);
275 catch (std::exception &e) {
276 throw BESInternalError(
"Failed to read dap4 data: STL Error: " +
string(e.what()), __FILE__, __LINE__);
279 throw BESInternalError(
"Failed to read dap4 data: Unknown exception caught", __FILE__, __LINE__);
282 BESDEBUG(
"focovjson",
"FoDapCovJsonTransmitter::send_dap4data - done transmitting COVJSON" << endl);
302 BESDEBUG(
"focovjson",
"FoDapCovJsonTransmitter::send_dap4metadata - BEGIN transmitting COVJSON" << endl);
308 DMR *processed_dmr = responseBuilder.process_dap4_dmr(obj, dhi);
310 ostream &o_strm = dhi.get_output_stream();
312 throw BESInternalError(
"Output stream is not set, can not return as COVJSON", __FILE__, __LINE__);
320 ft.transform_dap4(o_strm,
false,
false);
323 throw BESDapError(
"Failed to transform data to COVJSON: " + e.get_error_message(),
false, e.get_error_code(),
327 throw BESInternalError(
"Failed to transform to COVJSON: Unknown exception caught", __FILE__, __LINE__);
330 BESDEBUG(
"focovjson",
"FoDapCovJsonTransmitter::send_dap4metadata - done transmitting COVJSON" << endl);
error object created from libdap error objects and can handle those errors
virtual libdap::DMR * intern_dap4_data(BESResponseObject *obj, BESDataHandlerInterface &dhi)
virtual libdap::DDS * process_dap2_dds(BESResponseObject *obj, BESDataHandlerInterface &dhi)
Transmit data.
virtual libdap::DDS * intern_dap2_data(BESResponseObject *obj, BESDataHandlerInterface &dhi)
Structure storing information used by the BES to handle the request.
Base 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.
static void send_dap4metadata(BESResponseObject *obj, BESDataHandlerInterface &dhi)
The static method registered to transmit OPeNDAP data objects as a JSON file.
static void send_dap4data(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()
Access to the singleton.