38#include <BESResponseHandler.h>
39#include <BESResponseNames.h>
40#include <BESVersionInfo.h>
41#include <BESDataNames.h>
42#include <BESDataNames.h>
43#include <TheBESKeys.h>
47#include "FONcRequestHandler.h"
50std::string FONcRequestHandler::temp_dir;
51bool FONcRequestHandler::byte_to_short;
52bool FONcRequestHandler::use_compression;
53bool FONcRequestHandler::use_shuffle;
54unsigned long long FONcRequestHandler::chunk_size;
55bool FONcRequestHandler::classic_model;
56bool FONcRequestHandler::reduce_dim;
57bool FONcRequestHandler::no_global_attrs;
58unsigned long long FONcRequestHandler::request_max_size_kb;
59bool FONcRequestHandler::nc3_classic_format;
72static void read_key_value(
const string &key_name,
bool &key,
const bool default_value)
74 bool key_found =
false;
80 key = (value ==
"true" || value ==
"yes");
87static void read_key_value(
const string &key_name,
string &key,
const string &default_value)
89 bool key_found =
false;
100static void read_key_value(
const string &key_name,
size_t &key,
const int default_value)
102 bool key_found =
false;
107 istringstream iss(value);
110 if (iss.bad() || iss.fail()) key = default_value;
117static void read_key_value(
const string &key_name,
unsigned long long &key,
const unsigned long long default_value)
119 bool key_found =
false;
127 catch (
const std::invalid_argument& ia) {
146 : BESRequestHandler( name )
151 if (FONcRequestHandler::temp_dir.empty()) {
152 read_key_value(FONC_TEMP_DIR_KEY, FONcRequestHandler::temp_dir, FONC_TEMP_DIR);
156 read_key_value(FONC_BYTE_TO_SHORT_KEY, FONcRequestHandler::byte_to_short, FONC_BYTE_TO_SHORT);
158 read_key_value(FONC_USE_COMP_KEY, FONcRequestHandler::use_compression, FONC_USE_COMP);
160 read_key_value(FONC_USE_SHUFFLE_KEY, FONcRequestHandler::use_shuffle, FONC_USE_SHUFFLE);
162 read_key_value(FONC_CHUNK_SIZE_KEY, FONcRequestHandler::chunk_size, FONC_CHUNK_SIZE);
164 read_key_value(FONC_CLASSIC_MODEL_KEY, FONcRequestHandler::classic_model, FONC_CLASSIC_MODEL);
166 read_key_value(FONC_REDUCE_DIM_KEY, FONcRequestHandler::reduce_dim, FONC_REDUCE_DIM);
168 read_key_value(FONC_NO_GLOBAL_ATTRS_KEY, FONcRequestHandler::no_global_attrs, FONC_NO_GLOBAL_ATTRS);
170 read_key_value(FONC_REQUEST_MAX_SIZE_KB_KEY, FONcRequestHandler::request_max_size_kb, FONC_REQUEST_MAX_SIZE_KB);
172 read_key_value(FONC_NC3_CLASSIC_FORMAT_KEY, FONcRequestHandler::nc3_classic_format, FONC_NC3_CLASSIC_FORMAT);
174 BESDEBUG(
"fonc",
"FONcRequestHandler::temp_dir: " << FONcRequestHandler::temp_dir << endl);
175 BESDEBUG(
"fonc",
"FONcRequestHandler::byte_to_short: " << FONcRequestHandler::byte_to_short << endl);
176 BESDEBUG(
"fonc",
"FONcRequestHandler::use_compression: " << FONcRequestHandler::use_compression << endl);
177 BESDEBUG(
"fonc",
"FONcRequestHandler::use_shuffle: " << FONcRequestHandler::use_shuffle << endl);
178 BESDEBUG(
"fonc",
"FONcRequestHandler::chunk_size: " << FONcRequestHandler::chunk_size << endl);
179 BESDEBUG(
"fonc",
"FONcRequestHandler::classic_model: " << FONcRequestHandler::classic_model << endl);
180 BESDEBUG(
"fonc",
"FONcRequestHandler::reduce_dim: " << FONcRequestHandler::reduce_dim << endl);
181 BESDEBUG(
"fonc",
"FONcRequestHandler::turn_off_global_attrs: " << FONcRequestHandler::no_global_attrs << endl);
182 BESDEBUG(
"fonc",
"FONcRequestHandler::request_max_size_kb: " << FONcRequestHandler::request_max_size_kb << endl);
183 BESDEBUG(
"fonc",
"FONcRequestHandler::nc3_classic_format " << FONcRequestHandler::nc3_classic_format << endl);
210 string key =
"FONc.Reference";
213 if (ref.empty()) ref =
"https://docs.opendap.org/index.php/BES_-_Modules_-_FileOut_Netcdf";
214 map<string, string, std::less<>> attrs;
215 attrs[
"name"] = MODULE_NAME;
216 attrs[
"version"] = MODULE_VERSION;
217 attrs[
"reference"] = ref;
218 info->begin_tag(
"module", &attrs);
219 info->end_tag(
"module");
237 info->add_module(MODULE_NAME, MODULE_VERSION);
251 strm << BESIndent::LMarg <<
"FONcRequestHandler::dump - ("
252 << (
void *)
this <<
")" << endl ;
253 BESIndent::Indent() ;
255 BESIndent::UnIndent() ;
Structure storing information used by the BES to handle the request.
informational response object
exception thrown if internal error encountered
virtual bool add_method(const std::string &name, p_request_handler_method method)
add a handler method to the request handler that knows how to fill in a specific response object
virtual void dump(std::ostream &strm) const
dumps information about this object
virtual BESResponseObject * get_response_object()
return the current response object
Abstract base class representing a specific set of information in response to a request to the BES.
static std::string lowercase(const std::string &s)
static void trim_if_trailing_slash(std::string &value)
If the string ends in a slash, remove it This function works for empty strings (doing nothing)....
virtual void dump(std::ostream &strm) const
dumps information about this object
virtual ~FONcRequestHandler(void)
Any cleanup that needs to take place.
FONcRequestHandler(const std::string &name)
Constructor for FileOut NetCDF module.
static bool build_help(BESDataHandlerInterface &dhi)
adds help information for FileOut NetCDF to a help request
static bool build_version(BESDataHandlerInterface &dhi)
add version information to a version response
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.