27 #include "config_ff.h" 37 #include <D4BaseTypeFactory.h> 38 #include <Ancillary.h> 40 #include <InternalErr.h> 41 #include <mime_util.h> 44 #include <BESResponseHandler.h> 45 #include <BESResponseNames.h> 46 #include <BESDapNames.h> 47 #include <BESDASResponse.h> 48 #include <BESDDSResponse.h> 49 #include <BESDataDDSResponse.h> 50 #include <BESDMRResponse.h> 51 #include <BESVersionInfo.h> 53 #include <BESDapError.h> 54 #include <BESInternalFatalError.h> 55 #include <BESDataNames.h> 56 #include <TheBESKeys.h> 57 #include <BESServiceRegistry.h> 60 #include <BESContextManager.h> 62 #include "FFRequestHandler.h" 64 #include "ff_ce_functions.h" 76 extern void ff_read_descriptors(DDS & dds,
const string & filename);
77 extern void ff_get_attributes(DAS & das,
string filename);
79 bool FFRequestHandler::d_RSS_format_support =
false;
80 string FFRequestHandler::d_RSS_format_files =
"";
82 bool FFRequestHandler::d_Regex_format_support =
false;
83 std::map<string,string> FFRequestHandler::d_fmt_regex_map;
85 FFRequestHandler::FFRequestHandler(
const string &name) :
88 add_method(DAS_RESPONSE, FFRequestHandler::ff_build_das);
89 add_method(DDS_RESPONSE, FFRequestHandler::ff_build_dds);
90 add_method(DATA_RESPONSE, FFRequestHandler::ff_build_data);
95 add_method(HELP_RESPONSE, FFRequestHandler::ff_build_help);
96 add_method(VERS_RESPONSE, FFRequestHandler::ff_build_version);
98 ff_register_functions();
100 bool key_found =
false;
105 if (doset ==
"true" || doset ==
"yes")
106 FFRequestHandler::d_RSS_format_support =
true;
108 FFRequestHandler::d_RSS_format_support =
false;
111 FFRequestHandler::d_RSS_format_support =
false;
117 FFRequestHandler::d_RSS_format_files = path;
119 FFRequestHandler::d_RSS_format_files =
"";
121 BESDEBUG(
"ff",
"d_RSS_format_support: " << d_RSS_format_support << endl);
122 BESDEBUG(
"ff",
"d_RSS_format_files: " << d_RSS_format_files << endl);
130 if (regex_doset ==
"true" || regex_doset ==
"yes")
131 FFRequestHandler::d_Regex_format_support =
true;
133 FFRequestHandler::d_Regex_format_support =
false;
136 FFRequestHandler::d_Regex_format_support =
false;
137 BESDEBUG(
"ff",
"d_Regex_format_support: " << d_Regex_format_support << endl);
141 vector<string> regex_fmt_files;
143 vector<string>::iterator it;
144 for (it = regex_fmt_files.begin(); it != regex_fmt_files.end(); it++) {
145 string fmt_entry = *it;
146 int index = fmt_entry.find(
":");
148 string regex = fmt_entry.substr(0, index);
149 string file = fmt_entry.substr(index + 1);
150 BESDEBUG(
"ff",
"regex: '" << regex <<
"' file: " << file << endl);
151 d_fmt_regex_map.insert(pair<string, string>(regex, file));
154 string(
"The configuration entry for the ")
156 +
" was incorrectly formatted. entry: " 157 + fmt_entry, __FILE__, __LINE__);
162 FFRequestHandler::~FFRequestHandler()
175 DAS *das = bdas->get_das();
178 ff_get_attributes(*das, accessed);
181 if (FFRequestHandler::get_RSS_format_support()) {
182 name = find_ancillary_rss_das(accessed);
185 name = Ancillary::find_ancillary_file(accessed,
"das",
"",
"");
189 if (!name.empty() && (stat(name.c_str(), &st) == 0)) {
194 }
catch (InternalErr & e) {
195 BESDapError ex(e.get_error_message(),
true, e.get_error_code(), __FILE__, __LINE__);
197 }
catch (
Error & e) {
198 BESDapError ex(e.get_error_message(),
false, e.get_error_code(), __FILE__, __LINE__);
219 dds->filename(accessed);
221 BESDEBUG(
"ff",
"FFRequestHandler::ff_build_dds, accessed: " << accessed << endl);
223 ff_read_descriptors(*dds, accessed);
225 BESDEBUG(
"ff",
"FFRequestHandler::ff_build_dds, reading attributes" << endl);
230 ff_get_attributes(*das, accessed);
231 Ancillary::read_ancillary_das(*das, accessed);
233 BESDEBUG(
"ff",
"FFRequestHandler::ff_build_dds, transferring attributes" << endl);
235 dds->transfer_attributes(das);
241 }
catch (InternalErr & e) {
242 BESDapError ex(e.get_error_message(),
true, e.get_error_code(), __FILE__, __LINE__);
244 }
catch (
Error & e) {
245 BESDapError ex(e.get_error_message(),
false, e.get_error_code(), __FILE__, __LINE__);
268 DDS *dds = bdds->get_dds();
270 dds->filename(accessed);
271 ff_read_descriptors(*dds, accessed);
272 Ancillary::read_ancillary_dds(*dds, accessed);
277 ff_get_attributes(*das, accessed);
278 Ancillary::read_ancillary_das(*das, accessed);
280 dds->transfer_attributes(das);
285 }
catch (InternalErr & e) {
286 BESDapError ex(e.get_error_message(),
true, e.get_error_code(), __FILE__, __LINE__);
288 }
catch (
Error & e) {
289 BESDapError ex(e.get_error_message(),
false, e.get_error_code(), __FILE__, __LINE__);
319 BaseTypeFactory factory;
320 DDS dds(&factory, name_path(data_path),
"3.2");
321 dds.filename(data_path);
324 ff_read_descriptors(dds, data_path);
329 ff_get_attributes(das, data_path);
330 Ancillary::read_ancillary_das(das, data_path);
331 dds.transfer_attributes(&das);
333 catch (InternalErr &e) {
334 throw BESDapError(e.get_error_message(),
true, e.get_error_code(), __FILE__, __LINE__);
337 throw BESDapError(e.get_error_message(),
false, e.get_error_code(), __FILE__, __LINE__);
340 throw BESDapError(
"Caught unknown error build FF DMR response",
true, unknown_error, __FILE__, __LINE__);
350 DMR *dmr = bdmr.get_dmr();
351 dmr->set_factory(
new D4BaseTypeFactory);
352 dmr->build_using_dds(dds);
369 BESInfo *info = dynamic_cast<BESInfo *>(response);
373 map < string, string > attrs;
374 attrs[
"name"] = MODULE_NAME ;
375 attrs[
"version"] = MODULE_VERSION ;
377 attrs[
"name"] = PACKAGE_NAME;
378 attrs[
"version"] = PACKAGE_VERSION;
380 list < string > services;
382 if (services.size() > 0) {
384 attrs[
"handles"] = handles;
386 info->begin_tag(
"module", &attrs);
387 info->end_tag(
"module");
400 info->add_module(PACKAGE_NAME, PACKAGE_VERSION);
402 info->add_module(MODULE_NAME, MODULE_VERSION);
static bool ff_build_dmr(BESDataHandlerInterface &dhi)
exception thrown if an internal error is found and is fatal to the BES
exception thrown if inernal error encountered
static string lowercase(const string &s)
Holds a DDS object within the BES.
virtual void clear_container()
clear the container in the DAP response object
virtual void set_dap4_constraint(BESDataHandlerInterface &dhi)
set the constraint depending on the context
void get_value(const std::string &s, std::string &val, bool &found)
Retrieve the value of a given key, if set.
virtual void set_container(const std::string &cn)
set the container in the DAP response object
virtual string access()=0
returns the true name of this container
virtual void clear_container()
clear the container in the DAP response object
virtual void set_dap4_function(BESDataHandlerInterface &dhi)
set the constraint depending on the context
informational response object
static string implode(const list< string > &values, char delim)
virtual BESResponseObject * get_response_object()
return the current response object
static TheBESKeys * TheKeys()
void get_values(const std::string &s, std::vector< std::string > &vals, bool &found)
Retrieve the values of a given key, if set.
virtual void set_constraint(BESDataHandlerInterface &dhi)
set the constraint depending on the context
Represents an OPeNDAP DMR DAP4 data object within the BES.
error object created from libdap error objects and can handle those errors
Represents an OPeNDAP DataDDS DAP2 data object within the BES.
virtual void clear_container()
clear the container in the DAP response object
Represents a specific data type request handler.
Structure storing information used by the BES to handle the request.
virtual void set_container(const string &cn)
set the container in the DAP response object
Represents an OPeNDAP DAS DAP2 data object within the BES.
virtual void set_container(const string &cn)
set the container in the DAP response object
Abstract base class representing a specific set of information in response to a request to the BES.
BESContainer * container
pointer to current container in this interface
virtual void services_handled(const string &handler, list< string > &services)
returns the list of servies provided by the handler in question
string get_symbolic_name() const
retrieve the symbolic name for this container