39 #include <D4BaseTypeFactory.h> 40 #include <Ancillary.h> 41 #include <InternalErr.h> 42 #include <mime_util.h> 44 #include <BESResponseHandler.h> 45 #include <BESDapError.h> 47 #include <BESDapNames.h> 48 #include <BESResponseNames.h> 49 #include <BESDASResponse.h> 50 #include <BESDDSResponse.h> 51 #include <BESDataDDSResponse.h> 52 #include <BESDMRResponse.h> 54 #include <BESVersionInfo.h> 55 #include <BESConstraintFuncs.h> 56 #include <BESServiceRegistry.h> 61 #include "FitsRequestHandler.h" 62 #include "fits_read_attributes.h" 63 #include "fits_read_descriptors.h" 67 #define FITS_NAME "fits" 69 FitsRequestHandler::FitsRequestHandler(
const string &name) :
72 add_method(DAS_RESPONSE, FitsRequestHandler::fits_build_das);
73 add_method(DDS_RESPONSE, FitsRequestHandler::fits_build_dds);
74 add_method(DATA_RESPONSE, FitsRequestHandler::fits_build_data);
79 add_method(VERS_RESPONSE, FitsRequestHandler::fits_build_vers);
80 add_method(HELP_RESPONSE, FitsRequestHandler::fits_build_help);
83 FitsRequestHandler::~FitsRequestHandler()
95 DAS *das = bdas->get_das();
98 if (!fits_handler::fits_read_attributes(*das, accessed, fits_error)) {
99 throw BESDapError(fits_error,
false, unknown_error, __FILE__, __LINE__);
101 Ancillary::read_ancillary_das(*das, accessed);
104 catch( InternalErr &e ) {
105 throw BESDapError(e.get_error_message(),
true, e.get_error_code(), __FILE__, __LINE__);
108 throw BESDapError(e.get_error_message(),
false, e.get_error_code(), __FILE__, __LINE__);
114 throw BESDapError(
"Unknown exception caught building FITS das response",
true, unknown_error, __FILE__, __LINE__);
131 if (!fits_handler::fits_read_descriptors(*dds, accessed, fits_error)) {
132 throw BESDapError(fits_error,
false, unknown_error, __FILE__, __LINE__);
135 Ancillary::read_ancillary_dds(*dds, accessed);
139 if (!fits_handler::fits_read_attributes(*das, accessed, fits_error)) {
140 throw BESDapError(fits_error,
false, unknown_error, __FILE__, __LINE__);
142 Ancillary::read_ancillary_das(*das, accessed);
144 dds->transfer_attributes(das);
150 catch( InternalErr &e ) {
151 throw BESDapError(e.get_error_message(),
true, e.get_error_code(), __FILE__, __LINE__);
154 throw BESDapError(e.get_error_message(),
false, e.get_error_code(), __FILE__, __LINE__);
160 string err =
"Unknown exception caught building FITS dds response";
161 throw BESDapError(err,
true, unknown_error, __FILE__, __LINE__);
175 DDS *dds = bdds->get_dds();
178 if (!fits_handler::fits_read_descriptors(*dds, accessed, fits_error)) {
179 throw BESDapError(fits_error,
false, unknown_error, __FILE__, __LINE__);
181 Ancillary::read_ancillary_dds(*dds, accessed);
186 if (!fits_handler::fits_read_attributes(*das, accessed, fits_error)) {
187 throw BESDapError(fits_error,
false, unknown_error, __FILE__, __LINE__);
189 Ancillary::read_ancillary_das(*das, accessed);
191 dds->transfer_attributes(das);
197 catch( InternalErr &e ) {
198 throw BESDapError(e.get_error_message(),
true, e.get_error_code(), __FILE__, __LINE__);
201 throw BESDapError(e.get_error_message(),
false, e.get_error_code(), __FILE__, __LINE__);
207 string err =
"Unknown exception caught building FITS data response";
208 throw BESDapError(err,
true, unknown_error, __FILE__, __LINE__);
230 BaseTypeFactory factory;
231 DDS dds(&factory, name_path(data_path),
"3.2");
232 dds.filename(data_path);
237 if (!fits_handler::fits_read_descriptors(dds, data_path, fits_error))
238 throw BESDapError(fits_error,
false, unknown_error, __FILE__, __LINE__);
241 if (!fits_handler::fits_read_attributes(das, data_path, fits_error))
242 throw BESDapError(fits_error,
false, unknown_error, __FILE__, __LINE__);
243 Ancillary::read_ancillary_das(das, data_path);
245 dds.transfer_attributes(&das);
247 catch( InternalErr &e ) {
248 throw BESDapError(e.get_error_message(),
true, e.get_error_code(), __FILE__, __LINE__);
251 throw BESDapError(e.get_error_message(),
false, e.get_error_code(), __FILE__, __LINE__);
257 throw BESDapError(
"Unknown exception caught building FITS DMR response",
true, unknown_error, __FILE__, __LINE__);
268 DMR *dmr = bdmr.get_dmr();
269 dmr->set_factory(
new D4BaseTypeFactory);
270 dmr->build_using_dds(dds);
285 info->add_module(PACKAGE_NAME, PACKAGE_VERSION);
287 info->add_module(MODULE_NAME, MODULE_VERSION);
295 BESInfo *info = dynamic_cast<BESInfo *>(response);
298 map<string, string> attrs;
299 attrs[
"name"] = MODULE_NAME ;
300 attrs[
"version"] = MODULE_VERSION ;
302 attrs[
"name"] = PACKAGE_NAME;
303 attrs[
"version"] = PACKAGE_VERSION;
305 list<string> services;
307 if (services.size() > 0) {
309 attrs[
"handles"] = handles;
311 info->begin_tag(
"module", &attrs);
312 info->end_tag(
"module");
326 strm << BESIndent::LMarg <<
"FitsRequestHandler::dump - (" << (
void *)
this <<
")" << endl;
329 BESIndent::UnIndent();
exception thrown if inernal error encountered
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
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
Abstract exception class for the BES with basic string message.
virtual void dump(ostream &strm) const
dumps information about this object
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.
virtual void dump(ostream &strm) const
dumps information about this object
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
static bool fits_build_dmr(BESDataHandlerInterface &dhi)