Represents the classic CGI interface into OPeNDAP. More...
#include <BESCgiInterface.h>
Public Member Functions | |
BESCgiInterface (const string &type, DODSFilter &df) | |
Instantiate an instance of the BESCgiInterface interface. | |
virtual void | dump (ostream &strm) const |
dumps information about this object | |
virtual int | execute_request (const string &from) |
Executes the given request to generate a specified response object. | |
virtual int | finish_with_error (int status) |
virtual | ~BESCgiInterface () |
Static Public Member Functions | |
static void | add_end_callback (p_bes_end end) |
static void | add_init_callback (p_bes_init init) |
Protected Member Functions | |
virtual void | build_data_request_plan () |
Build the data request plan using the given DODSFilter. | |
virtual void | clean () |
Clean up after the request. | |
virtual void | end_request () |
End the BES request. | |
virtual int | exception_manager (BESError &e) |
Manage any exceptions thrown during the whole process. | |
virtual void | execute_data_request_plan () |
Execute the data request plan. | |
virtual int | finish (int status) |
virtual void | initialize () |
Initialize the BES object. | |
virtual void | invoke_aggregation () |
Aggregate the resulting response object. | |
virtual void | log_status () |
Log the status of the request. | |
virtual void | report_request () |
Report the request and status of the request to BESReporterList::TheList(). | |
virtual void | transmit_data () |
Transmit the resulting response object. | |
virtual void | validate_data_request () |
Validate the incoming request information. | |
Protected Attributes | |
BESDataHandlerInterface * | _dhi |
BESTransmitter * | _transmitter |
Represents the classic CGI interface into OPeNDAP.
OPeNDAP data handlers have been mainly accessed through a CGI interface. A person goes to a website with an OPeNDAP server and makes a certain request of that server for files available to that site.
This class provides an interface into the BES framework for the CGI interface. It greatly simplifies server coding for developers using the CGI interface.
Information from the DODSFilter class is placed in the BESDataHandlerInterface and a BESContainer is built from this information so that BES can handle the request, building the proper response using the appropriate data handler. BESCgiInterface also creates a Transmitter that interacts with the DODSFilter object for sending the response back to the user.
For example, a server to handle requests for the cedar data type would look something like this:
CedarFilter df(argc, argv); BESCgiInterface d( "cedar", df ) ; d.execute_request() ;
And that's it!
Definition at line 75 of file BESCgiInterface.h.
BESCgiInterface::BESCgiInterface | ( | const string & | type, | |
DODSFilter & | df | |||
) |
Instantiate an instance of the BESCgiInterface interface.
Creates a BESFilterTransmitter to transmit the response back to the caller. Only the build_data_request_plan method is implemented in this class. All other methods are inherited from BESInterface.
type | data type handled by this OPeNDAP CGI server | |
df | DODSFilter object built from command line arguments |
Definition at line 54 of file BESCgiInterface.cc.
References BESInterface::_dhi, BESInterface::_transmitter, and BESDataHandlerInterface::transmit_protocol.
BESCgiInterface::~BESCgiInterface | ( | ) | [virtual] |
Definition at line 64 of file BESCgiInterface.cc.
References BESInterface::_transmitter, and BESInterface::clean().
void BESInterface::add_end_callback | ( | p_bes_end | end | ) | [static, inherited] |
Definition at line 464 of file BESInterface.cc.
void BESInterface::add_init_callback | ( | p_bes_init | init | ) | [static, inherited] |
Definition at line 282 of file BESInterface.cc.
void BESCgiInterface::build_data_request_plan | ( | ) | [protected, virtual] |
Build the data request plan using the given DODSFilter.
The BESDSDataHandlerInterace is built using information from the DODSFilter object passed to the constructor of this object. The constraint, data type, dataset, and action are retrieved from the DODSFilter to build the request plan.
Implements BESInterface.
Definition at line 83 of file BESCgiInterface.cc.
References BESInterface::_dhi, BESDataHandlerInterface::action, BESDEBUG, BESDataHandlerInterface::containers, BESResponseHandlerList::find_handler(), BESDataHandlerInterface::response_handler, and BESResponseHandlerList::TheList().
void BESInterface::clean | ( | ) | [protected, virtual, inherited] |
Clean up after the request.
Reimplemented in BESBasicInterface, and BESXMLInterface.
Definition at line 500 of file BESInterface.cc.
References BESInterface::_dhi, and BESDataHandlerInterface::clean().
Referenced by ~BESCgiInterface().
void BESCgiInterface::dump | ( | ostream & | strm | ) | const [virtual] |
dumps information about this object
Displays the pointer value of this instance along with information about the DODSFilter and the type of data handled by this interface.
strm | C++ i/o stream to dump the information to |
Reimplemented from BESInterface.
Definition at line 118 of file BESCgiInterface.cc.
References BESIndent::Indent(), BESIndent::LMarg(), and BESIndent::UnIndent().
void BESInterface::end_request | ( | ) | [protected, virtual, inherited] |
End the BES request.
This method allows developers to add callbacks at the end of a request, to do any cleanup or do any extra work at the end of a request
Definition at line 475 of file BESInterface.cc.
References BESInterface::_dhi, BESDEBUG, BESDataHandlerInterface::container, BESDataHandlerInterface::data, DATA_REQUEST, BESDataHandlerInterface::first_container(), BESDataHandlerInterface::next_container(), and BESContainer::release().
Referenced by BESInterface::finish().
int BESInterface::exception_manager | ( | BESError & | e | ) | [protected, virtual, inherited] |
Manage any exceptions thrown during the whole process.
Specific responses are generated given a specific Exception caught. If additional exceptions are thrown within derived systems then implement those in the derived exception_manager methods. This is a catch-all manager and should be called once derived methods have caught their exceptions.
e | BESError to be managed |
Reimplemented in BESApacheInterface.
Definition at line 519 of file BESInterface.cc.
References BESInterface::_dhi, BESExceptionManager::handle_exception(), and BESExceptionManager::TheEHM().
Referenced by BESInterface::execute_request(), BESInterface::finish(), and BESInterface::finish_with_error().
void BESInterface::execute_data_request_plan | ( | ) | [protected, virtual, inherited] |
Execute the data request plan.
Given the information in the BESDataHandlerInterface, execute the request. To do this we simply find the response handler given the action in the BESDataHandlerInterface and tell it to execute.
If no BESResponseHandler can be found given the action then an exception is thrown.
Reimplemented in BESBasicInterface, and BESXMLInterface.
Definition at line 338 of file BESInterface.cc.
References BESInterface::_dhi, BESDataHandlerInterface::action, BESDEBUG, BESDataHandlerInterface::data, DATA_REQUEST, BESResponseHandler::execute(), BESInterface::invoke_aggregation(), BESDataHandlerInterface::response_handler, and BESInterface::transmit_data().
Referenced by BESInterface::execute_request().
int BESInterface::execute_request | ( | const string & | from | ) | [virtual, inherited] |
Executes the given request to generate a specified response object.
Execute the request by: 1. initializing BES 2. validating the request, make sure all elements are present 3. build the request plan (ie filling in the BESDataHandlerInterface) 4. execute the request plan using the BESDataHandlerInterface 5. transmit the resulting response object 6. log the status of the execution 7. notify the reporters of the request 8. end the request, which allows developers to add callbacks to notify them of the end of the request
If an exception is thrown in any of these steps the exception is handed over to the exception manager in order to generate the proper response. Control is returned back to the calling method if an exception is thrown and it is the responsibility of the calling method to call finish_with_error in order to transmit the error message back to the client.
Reimplemented in BESBasicInterface, and BESXMLInterface.
Definition at line 117 of file BESInterface.cc.
References BESInterface::_dhi, BESInterface::build_data_request_plan(), BESDataHandlerInterface::data, DATA_REQUEST, BESInterface::exception_manager(), BESInterface::execute_data_request_plan(), BESDataHandlerInterface::executed, BESInterface::finish(), BESInterface::initialize(), REQUEST_FROM, SERVER_PID, BESDataHandlerInterface::set_output_stream(), BESLog::TheLog(), and BESInterface::validate_data_request().
int BESInterface::finish | ( | int | status | ) | [protected, virtual, inherited] |
Definition at line 177 of file BESInterface.cc.
References BESInterface::_dhi, BESInterface::end_request(), BESDataHandlerInterface::error_info, BESInterface::exception_manager(), BESError::get_message(), BESInterface::log_status(), BESInfo::print(), BESInterface::report_request(), BESLog::TheLog(), and BESInterface::transmit_data().
Referenced by BESInterface::execute_request(), and BESInterface::finish_with_error().
int BESInterface::finish_with_error | ( | int | status | ) | [virtual, inherited] |
Definition at line 268 of file BESInterface.cc.
References BESInterface::_dhi, BESDataHandlerInterface::error_info, BESInterface::exception_manager(), and BESInterface::finish().
Referenced by BESApacheWrapper::call_BES().
void BESInterface::initialize | ( | ) | [protected, virtual, inherited] |
Initialize the BES object.
This method must be called by all derived classes as it will initialize the environment
Reimplemented in BESApacheInterface, BESBasicInterface, and BESXMLInterface.
Definition at line 293 of file BESInterface.cc.
References BESInterface::_dhi, BESDEBUG, BESDataHandlerInterface::data, and DATA_REQUEST.
Referenced by BESInterface::execute_request().
void BESInterface::invoke_aggregation | ( | ) | [protected, virtual, inherited] |
Aggregate the resulting response object.
Reimplemented in BESBasicInterface, and BESXMLInterface.
Definition at line 365 of file BESInterface.cc.
References BESInterface::_dhi, AGG_CMD, AGG_HANDLER, BESAggregationServer::aggregate(), BESDEBUG, BESDataHandlerInterface::data, BESAggFactory::find_handler(), and BESAggFactory::TheFactory().
Referenced by BESInterface::execute_data_request_plan().
void BESInterface::log_status | ( | ) | [protected, virtual, inherited] |
Log the status of the request.
Reimplemented in BESBasicInterface, and BESXMLInterface.
Definition at line 437 of file BESInterface.cc.
Referenced by BESInterface::finish().
void BESInterface::report_request | ( | ) | [protected, virtual, inherited] |
Report the request and status of the request to BESReporterList::TheList().
If interested in reporting the request and status of the request then one must register a BESReporter with BESReporterList::TheList().
If no BESReporter objects are registered then nothing happens.
Reimplemented in BESXMLInterface.
Definition at line 453 of file BESInterface.cc.
References BESInterface::_dhi, BESDEBUG, BESDataHandlerInterface::data, DATA_REQUEST, BESReporterList::report(), and BESReporterList::TheList().
Referenced by BESInterface::finish().
void BESInterface::transmit_data | ( | ) | [protected, virtual, inherited] |
Transmit the resulting response object.
The derived classes are responsible for specifying a transmitter object for use in transmitting the response object. Again, the BESResponseHandler knows how to transmit itself.
If no response handler or no response object or no transmitter is specified then do nothing here.
Reimplemented in BESBasicInterface, and BESXMLInterface.
Definition at line 401 of file BESInterface.cc.
References BESInterface::_dhi, BESInterface::_transmitter, BESDEBUG, BESDataHandlerInterface::data, DATA_REQUEST, BESDataHandlerInterface::error_info, BESInfo::print(), BESDataHandlerInterface::response_handler, BESResponseHandler::transmit(), and BESInfo::transmit().
Referenced by BESInterface::execute_data_request_plan(), and BESInterface::finish().
void BESInterface::validate_data_request | ( | ) | [protected, virtual, inherited] |
Validate the incoming request information.
Reimplemented in BESApacheInterface, BESBasicInterface, and BESXMLInterface.
Definition at line 320 of file BESInterface.cc.
Referenced by BESInterface::execute_request().
BESDataHandlerInterface* BESInterface::_dhi [protected, inherited] |
Definition at line 136 of file BESInterface.h.
Referenced by BESCgiInterface(), BESCmdInterface::BESCmdInterface(), BESXMLInterface::BESXMLInterface(), BESXMLInterface::build_data_request_plan(), BESCmdInterface::build_data_request_plan(), build_data_request_plan(), BESBasicInterface::build_data_request_plan(), BESXMLInterface::clean(), BESInterface::clean(), BESBasicInterface::clean(), BESInterface::dump(), BESInterface::end_request(), BESInterface::exception_manager(), BESApacheInterface::exception_manager(), BESXMLInterface::execute_data_request_plan(), BESInterface::execute_data_request_plan(), BESBasicInterface::execute_data_request_plan(), BESInterface::execute_request(), BESInterface::finish(), BESInterface::finish_with_error(), BESInterface::initialize(), BESBasicInterface::initialize(), BESApacheInterface::initialize(), BESInterface::invoke_aggregation(), BESBasicInterface::invoke_aggregation(), BESXMLInterface::log_status(), BESBasicInterface::log_status(), BESXMLInterface::report_request(), BESInterface::report_request(), BESXMLInterface::transmit_data(), BESInterface::transmit_data(), and BESBasicInterface::transmit_data().
BESTransmitter* BESInterface::_transmitter [protected, inherited] |
Definition at line 137 of file BESInterface.h.
Referenced by BESCgiInterface(), BESBasicInterface::build_data_request_plan(), BESInterface::dump(), BESBasicInterface::initialize(), BESXMLInterface::transmit_data(), BESInterface::transmit_data(), and ~BESCgiInterface().