33 #include "BESCatalogResponseHandler.h" 34 #include "BESInfoList.h" 36 #include "BESRequestHandlerList.h" 37 #include "BESRequestHandler.h" 39 #include "BESDataNames.h" 40 #include "BESCatalogList.h" 41 #include "BESCatalog.h" 42 #include "BESCatalogEntry.h" 43 #include "BESCatalogUtils.h" 44 #include "BESSyntaxUserError.h" 45 #include "BESNotFoundError.h" 47 #include "BESStopWatch.h" 49 BESCatalogResponseHandler::BESCatalogResponseHandler(
const string &name )
54 BESCatalogResponseHandler::~BESCatalogResponseHandler( )
71 if (BESISDEBUG( TIMING_LOG ))
72 sw.
start(
"BESCatalogResponseHandler::execute", dhi.
data[REQUEST_ID]);
74 BESInfo *info = BESInfoList::TheList()->build_info();
77 string container = dhi.
data[CONTAINER];
82 string err = (string)
"Not able to find the default catalog " 88 string::size_type notslash = container.find_first_not_of(
"/", 0);
89 if (notslash != string::npos) {
90 container = container.substr(notslash);
95 string::size_type slash = container.find_first_of(
"/", 0);
96 if (slash != string::npos) {
97 catname = container.substr(0, slash);
107 if (slash != string::npos) {
108 container = container.substr(slash + 1);
111 notslash = container.find_first_not_of(
"/", 0);
112 if (notslash != string::npos) {
113 container = container.substr(notslash);
120 if (container.empty())
123 string coi = dhi.
data[CATALOG_OR_INFO];
127 entry = catobj->show_catalog(container, coi, entry);
131 entry = defcat->show_catalog(container, coi, entry);
136 if (container ==
"/" && num_cats > 1) {
143 string err = (string)
"Failed to find node " + container;
149 if (coi == CATALOG_RESPONSE) {
151 dhi.action_name = CATALOG_RESPONSE_STR;
154 dhi.action_name = SHOW_INFO_RESPONSE_STR;
158 BESCatalogUtils::display_entry(entry, info);
161 if (coi == CATALOG_RESPONSE) {
162 BESCatalogEntry::catalog_citer ei = entry->get_beginning_entry();
163 BESCatalogEntry::catalog_citer ee = entry->get_ending_entry();
164 for (; ei != ee; ei++) {
165 BESCatalogUtils::display_entry((*ei).second, info);
166 info->end_tag(
"dataset");
169 info->end_tag(
"dataset");
172 info->end_response();
197 info->
transmit( transmitter, dhi ) ;
210 strm << BESIndent::LMarg <<
"BESCatalogResponseHandler::dump - (" 211 << (
void *)
this <<
")" << endl ;
212 BESIndent::Indent() ;
214 BESIndent::UnIndent() ;
218 BESCatalogResponseHandler::CatalogResponseBuilder(
const string &name )
error thrown if the resource requested cannot be found
response handler that returns nodes or leaves within the catalog either at the root or at a specified...
exception thrown if inernal error encountered
virtual BESCatalog * find_catalog(const string &catalog_name)
find the catalog in the list with the specified name
virtual void execute(BESDataHandlerInterface &dhi)
executes the command 'show catalog|leaves [for <node>];' by returning nodes or leaves at the top leve...
virtual void transmit(BESTransmitter *transmitter, BESDataHandlerInterface &dhi)=0
transmit the informational object
virtual void dump(ostream &strm) const
dumps information about this object
virtual BESCatalogEntry * show_catalogs(BESDataHandlerInterface &dhi, BESCatalogEntry *entry, bool show_default=true)
show the list of catalogs
virtual bool start(string name)
handler object that knows how to create a specific response object
informational response object
abstract base class catalog object. Derived classes know how to show nodes and leaves in a catalog...
Structure storing information used by the BES to handle the request.
map< string, string > data
the map of string data that will be required for the current request.
virtual void dump(ostream &strm) const
dumps information about this object
virtual void begin_response(const string &response_name, BESDataHandlerInterface &dhi)
begin the informational response
static BESCatalogList * TheCatalogList()
returns the singleton BESCatalogList instance. The pthreads library insures that only one instance ca...
virtual void transmit(BESTransmitter *transmitter, BESDataHandlerInterface &dhi)
transmit the response object built by the execute command using the specified transmitter object ...