35#include "BESCatalogResponseHandler.h"
36#include "BESInfoList.h"
39#include "BESDataNames.h"
40#include "BESCatalogList.h"
41#include "BESCatalog.h"
42#include "BESCatalogEntry.h"
43#include "BESCatalogUtils.h"
44#include "BESStopWatch.h"
45#include "BESNotFoundError.h"
52const auto MODULE=
"BESCatalog";
53#define prolog std::string("BESCatalogResponseHandler::").append(__func__).append("() - ")
56BESCatalogResponseHandler::BESCatalogResponseHandler(
const string &name) :
61BESCatalogResponseHandler::~BESCatalogResponseHandler()
76 BES_STOPWATCH_START_DHI(MODULE, prolog +
"Timer", &dhi);
78 BESInfo *info = BESInfoList::TheList()->build_info();
79 d_response_object = info;
82 string container = dhi.
data[CONTAINER];
83 string::size_type notslash = container.find_first_not_of(
"/", 0);
84 if (notslash != string::npos) {
85 container = container.substr(notslash);
87 if (container.empty()) container =
"/";
90 string catalog = dhi.
data[CATALOG];
93 besCatalog = BESCatalogList::TheCatalogList()->default_catalog();
98 besCatalog = BESCatalogList::TheCatalogList()->find_catalog(catalog);
100 string err = (string)
"Not able to find the catalog '" + catalog +
"'";
110 string err = (string)
"Failed to find node " + container;
117 dhi.action_name = CATALOG_RESPONSE_STR;
120 BESCatalogUtils::display_entry(entry, info);
122 BESCatalogEntry::catalog_citer ei = entry->get_beginning_entry();
123 BESCatalogEntry::catalog_citer ee = entry->get_ending_entry();
124 for (; ei != ee; ei++) {
125 BESCatalogUtils::display_entry((*ei).second, info);
126 info->end_tag(
"dataset");
129 info->end_tag(
"dataset");
132 info->end_response();
150 if (d_response_object) {
165 strm << BESIndent::LMarg <<
"BESCatalogResponseHandler::dump - (" << (
void *)
this <<
")" << endl;
168 BESIndent::UnIndent();
172BESCatalogResponseHandler::CatalogResponseBuilder(
const string &name)
response handler that returns nodes or leaves within the catalog either at the root or at a specified...
virtual void execute(BESDataHandlerInterface &dhi)
Execute the showCatalog command.
virtual void transmit(BESTransmitter *transmitter, BESDataHandlerInterface &dhi)
transmit the response object built by the execute command using the specified transmitter object
virtual void dump(std::ostream &strm) const
dumps information about this object
Catalogs provide a hierarchical organization for data.
virtual BESCatalogEntry * show_catalog(const std::string &container, BESCatalogEntry *entry)=0
virtual std::string get_catalog_name() const
Get the name for this catalog.
Structure storing information used by the BES to handle the request.
std::map< std::string, std::string > data
the map of string data that will be required for the current request.
informational response object
virtual void transmit(BESTransmitter *transmitter, BESDataHandlerInterface &dhi)=0
transmit the informational object
virtual void begin_response(const std::string &response_name, BESDataHandlerInterface &dhi)
begin the informational response
exception thrown if internal error encountered
error thrown if the resource requested cannot be found
handler object that knows how to create a specific response object
void dump(std::ostream &strm) const override
dumps information about this object