41#include "ShowBesKeyCommand.h"
42#include "SiteMapResponseHandler.h"
45#include "BESTextInfo.h"
46#include "BESDataNames.h"
48#include "TheBESKeys.h"
49#include "BESCatalog.h"
50#include "BESCatalogList.h"
54#include "BESStopWatch.h"
58const auto MODULE =
"bes";
59#define prolog string("SiteMapResponseHandler::").append(__func__).append("() - ")
61SiteMapResponseHandler::SiteMapResponseHandler(
const string &name) :
66SiteMapResponseHandler::~SiteMapResponseHandler()
82 BES_STOPWATCH_START_DHI(MODULE, prolog +
"Timing", &dhi);
87 d_response_object = info;
89 if (dhi.
data[SITE_MAP_RESPONSE] != SITE_MAP_RESPONSE)
90 throw BESInternalError(
"Not a Site Map command in SiteMapResponseHandler::execute().", __FILE__, __LINE__);
93 if (*(dhi.
data[PREFIX].end()-1) ==
'/')
94 dhi.
data[PREFIX].erase(dhi.
data[PREFIX].end()-1);
97 const BESCatalogList *catalog_list = BESCatalogList::TheCatalogList();
104 if (dhi.
data[CATALOG].empty()) {
105 BESCatalogList::catalog_citer i = catalog_list->
first_catalog();
106 BESCatalogList::catalog_citer e = catalog_list->
end_catalog();
107 for (; i != e; ++i) {
110 throw BESInternalError(
string(
"Build site map found a null catalog in the catalog list."), __FILE__, __LINE__);
117 catalog->get_site_map(prefix, dhi.
data[NODE_SUFFIX], dhi.
data[LEAF_SUFFIX], oss,
"/");
128 BESCatalog *catalog = catalog_list->find_catalog(dhi.
data[CATALOG]);
130 throw BESInternalError(
string(
"Build site map could not find the catalog: ") + dhi.
data[CATALOG], __FILE__, __LINE__);
133 catalog->get_site_map(prefix, dhi.
data[NODE_SUFFIX], dhi.
data[LEAF_SUFFIX], oss,
"/");
142 info->end_response();
158 if (d_response_object) {
160 if (!info)
throw BESInternalError(
"Could not get the Info object in SiteMapResponseHandler::transmit()", __FILE__, __LINE__);
173 strm << BESIndent::LMarg <<
"SiteMapResponseHandler::dump - (" << (
void *)
this <<
")" << std::endl;
176 BESIndent::UnIndent();
180SiteMapResponseHandler::SiteMapResponseBuilder(
const string &name)
List of all registered catalogs.
virtual std::string default_catalog_name() const
The name of the default catalog.
virtual catalog_citer end_catalog() const
Iterator to the last catalog.
virtual catalog_citer first_catalog() const
Iterator to the first catalog.
Catalogs provide a hierarchical organization for data.
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 add_data(const std::string &s)
add data to this informational object. If buffering is not set then the information is output directl...
virtual void begin_response(const std::string &response_name, BESDataHandlerInterface &dhi)
begin the informational response
exception thrown if internal error encountered
handler object that knows how to create a specific response object
void dump(std::ostream &strm) const override
dumps information about this object
represents simple text information in a response object, such as version and help information.
Response handler that returns a site map.
virtual void dump(std::ostream &strm) const
dumps information about this object
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)
transmit the response object built by the execute command using the specified transmitter object