35#include <libdap/DAS.h>
36#include <libdap/DDS.h>
37#include <libdap/DataDDS.h>
38#include <libdap/DMR.h>
39#include <libdap/D4BaseTypeFactory.h>
40#include <libdap/Ancillary.h>
41#include <libdap/InternalErr.h>
42#include <libdap/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>
62#include "FitsRequestHandler.h"
63#include "fits_read_attributes.h"
64#include "fits_read_descriptors.h"
68#define FITS_NAME "fits"
70FitsRequestHandler::FitsRequestHandler(
const string &name) :
73 add_method(DAS_RESPONSE, FitsRequestHandler::fits_build_das);
74 add_method(DDS_RESPONSE, FitsRequestHandler::fits_build_dds);
75 add_method(DATA_RESPONSE, FitsRequestHandler::fits_build_data);
80 add_method(VERS_RESPONSE, FitsRequestHandler::fits_build_vers);
81 add_method(HELP_RESPONSE, FitsRequestHandler::fits_build_help);
84FitsRequestHandler::~FitsRequestHandler()
96 DAS *das = bdas->get_das();
99 if (!fits_handler::fits_read_attributes(*das, accessed, fits_error)) {
100 throw BESDapError(fits_error,
false, unknown_error, __FILE__, __LINE__);
102 Ancillary::read_ancillary_das(*das, accessed);
105 catch( InternalErr &e ) {
106 throw BESDapError(e.get_error_message(),
true, e.get_error_code(), __FILE__, __LINE__);
109 throw BESDapError(e.get_error_message(),
false, e.get_error_code(), __FILE__, __LINE__);
115 throw BESDapError(
"Unknown exception caught building FITS das response",
true, unknown_error, __FILE__, __LINE__);
132 if (!fits_handler::fits_read_descriptors(*dds, accessed, fits_error)) {
133 throw BESDapError(fits_error,
false, unknown_error, __FILE__, __LINE__);
136 Ancillary::read_ancillary_dds(*dds, accessed);
140 if (!fits_handler::fits_read_attributes(*das, accessed, fits_error)) {
141 throw BESDapError(fits_error,
false, unknown_error, __FILE__, __LINE__);
143 Ancillary::read_ancillary_das(*das, accessed);
145 dds->transfer_attributes(das);
151 catch( InternalErr &e ) {
152 throw BESDapError(e.get_error_message(),
true, e.get_error_code(), __FILE__, __LINE__);
155 throw BESDapError(e.get_error_message(),
false, e.get_error_code(), __FILE__, __LINE__);
161 string err =
"Unknown exception caught building FITS dds response";
162 throw BESDapError(err,
true, unknown_error, __FILE__, __LINE__);
176 DDS *dds = bdds->get_dds();
179 if (!fits_handler::fits_read_descriptors(*dds, accessed, fits_error)) {
180 throw BESDapError(fits_error,
false, unknown_error, __FILE__, __LINE__);
182 Ancillary::read_ancillary_dds(*dds, accessed);
186 BESDEBUG(FITS_NAME,
"Data ACCESS build_data(): set the including attribute flag to false: "<<accessed << endl);
187 bdds->set_ia_flag(
false);
190 catch( InternalErr &e ) {
191 throw BESDapError(e.get_error_message(),
true, e.get_error_code(), __FILE__, __LINE__);
194 throw BESDapError(e.get_error_message(),
false, e.get_error_code(), __FILE__, __LINE__);
200 string err =
"Unknown exception caught building FITS data response";
201 throw BESDapError(err,
true, unknown_error, __FILE__, __LINE__);
223 BaseTypeFactory factory;
224 DDS dds(&factory, name_path(data_path),
"3.2");
225 dds.filename(data_path);
230 if (!fits_handler::fits_read_descriptors(dds, data_path, fits_error))
231 throw BESDapError(fits_error,
false, unknown_error, __FILE__, __LINE__);
234 if (!fits_handler::fits_read_attributes(das, data_path, fits_error))
235 throw BESDapError(fits_error,
false, unknown_error, __FILE__, __LINE__);
236 Ancillary::read_ancillary_das(das, data_path);
238 dds.transfer_attributes(&das);
240 catch( InternalErr &e ) {
241 throw BESDapError(e.get_error_message(),
true, e.get_error_code(), __FILE__, __LINE__);
244 throw BESDapError(e.get_error_message(),
false, e.get_error_code(), __FILE__, __LINE__);
250 throw BESDapError(
"Unknown exception caught building FITS DMR response",
true, unknown_error, __FILE__, __LINE__);
261 DMR *dmr = bdmr.get_dmr();
262 dmr->set_factory(
new D4BaseTypeFactory);
263 dmr->build_using_dds(dds);
278 info->add_module(PACKAGE_NAME, PACKAGE_VERSION);
280 info->add_module(MODULE_NAME, MODULE_VERSION);
291 map<string, string> attrs;
292 attrs[
"name"] = MODULE_NAME ;
293 attrs[
"version"] = MODULE_VERSION ;
295 attrs[
"name"] = PACKAGE_NAME;
296 attrs[
"version"] = PACKAGE_VERSION;
298 list<string> services;
300 if (services.size() > 0) {
302 attrs[
"handles"] = handles;
304 info->begin_tag(
"module", &attrs);
305 info->end_tag(
"module");
319 strm << BESIndent::LMarg <<
"FitsRequestHandler::dump - (" << (
void *)
this <<
")" << endl;
322 BESIndent::UnIndent();
331 DDS *dds = bdds->get_dds();
337 if (!fits_handler::fits_read_attributes(*das, accessed, fits_error)) {
338 throw BESDapError(fits_error,
false, unknown_error, __FILE__, __LINE__);
340 Ancillary::read_ancillary_das(*das, accessed);
342 dds->transfer_attributes(das);
343 BESDEBUG(FITS_NAME,
"Data ACCESS in add_attributes(): set the including attribute flag to true: "<<accessed << endl);
344 bdds->set_ia_flag(
true);
std::string get_symbolic_name() const
retrieve the symbolic name for this container
virtual std::string access()=0
returns the true name of this container
Represents an OPeNDAP DAS DAP2 data object within the BES.
virtual void clear_container()
clear the container in the DAP response object
virtual void set_container(const std::string &cn)
set the container in the DAP response object
Holds a DDS object within the BES.
virtual void set_container(const std::string &cn)
set the container in the DAP response object
virtual void clear_container()
clear the container in the DAP response object
Represents an OPeNDAP DMR DAP4 data object within the BES.
error object created from libdap error objects and can handle those errors
virtual void set_dap4_function(BESDataHandlerInterface &dhi)
set the constraint depending on the context
virtual void set_dap4_constraint(BESDataHandlerInterface &dhi)
set the constraint depending on the context
virtual void set_constraint(BESDataHandlerInterface &dhi)
set the constraint depending on the context
Represents an OPeNDAP DataDDS DAP2 data object within the BES.
virtual void set_container(const std::string &cn)
set the container in the DAP response object
virtual void clear_container()
clear the container in the DAP response object
Structure storing information used by the BES to handle the request.
BESContainer * container
pointer to current container in this interface
Base exception class for the BES with basic string message.
informational response object
exception thrown if internal error encountered
Represents a specific data type request handler.
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.
virtual void services_handled(const std::string &handler, std::list< std::string > &services)
returns the list of servies provided by the handler in question
static std::string implode(const std::list< std::string > &values, char delim)
virtual void dump(std::ostream &strm) const
dumps information about this object
static bool fits_build_dmr(BESDataHandlerInterface &dhi)