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__);
267 DDS *dds = bdds->get_dds();
269 dds->filename(accessed);
270 ff_read_descriptors(*dds, accessed);
271 Ancillary::read_ancillary_dds(*dds, accessed);
276 ff_get_attributes(*das, accessed);
277 Ancillary::read_ancillary_das(*das, accessed);
279 dds->transfer_attributes(das);
284 }
catch (InternalErr & e) {
285 BESDapError ex(e.get_error_message(),
true, e.get_error_code(), __FILE__, __LINE__);
287 }
catch (
Error & e) {
288 BESDapError ex(e.get_error_message(),
false, e.get_error_code(), __FILE__, __LINE__);
318 BaseTypeFactory factory;
319 DDS dds(&factory, name_path(data_path),
"3.2");
320 dds.filename(data_path);
323 ff_read_descriptors(dds, data_path);
328 ff_get_attributes(das, data_path);
329 Ancillary::read_ancillary_das(das, data_path);
330 dds.transfer_attributes(&das);
332 catch (InternalErr &e) {
333 throw BESDapError(e.get_error_message(),
true, e.get_error_code(), __FILE__, __LINE__);
336 throw BESDapError(e.get_error_message(),
false, e.get_error_code(), __FILE__, __LINE__);
339 throw BESDapError(
"Caught unknown error build FF DMR response",
true, unknown_error, __FILE__, __LINE__);
349 DMR *dmr = bdmr.get_dmr();
350 dmr->set_factory(
new D4BaseTypeFactory);
351 dmr->build_using_dds(dds);
372 map < string, string > attrs;
373 attrs[
"name"] = MODULE_NAME ;
374 attrs[
"version"] = MODULE_VERSION ;
376 attrs[
"name"] = PACKAGE_NAME;
377 attrs[
"version"] = PACKAGE_VERSION;
379 list < string > services;
381 if (services.size() > 0) {
383 attrs[
"handles"] = handles;
385 info->begin_tag(
"module", &attrs);
386 info->end_tag(
"module");
399 info->add_module(PACKAGE_NAME, PACKAGE_VERSION);
401 info->add_module(MODULE_NAME, MODULE_VERSION);