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"
58SiteMapResponseHandler::SiteMapResponseHandler(
const string &name) :
63SiteMapResponseHandler::~SiteMapResponseHandler()
85 d_response_object = info;
87 if (dhi.
data[SITE_MAP_RESPONSE] != SITE_MAP_RESPONSE)
88 throw BESInternalError(
"Not a Site Map command in SiteMapResponseHandler::execute().", __FILE__, __LINE__);
91 if (*(dhi.
data[PREFIX].end()-1) ==
'/')
92 dhi.
data[PREFIX].erase(dhi.
data[PREFIX].end()-1);
102 if (dhi.
data[CATALOG].empty()) {
103 BESCatalogList::catalog_citer i = catalog_list->
first_catalog();
104 BESCatalogList::catalog_citer e = catalog_list->
end_catalog();
105 for (; i != e; ++i) {
108 throw BESInternalError(
string(
"Build site map found a null catalog in the catalog list."), __FILE__, __LINE__);
115 catalog->get_site_map(prefix, dhi.
data[NODE_SUFFIX], dhi.
data[LEAF_SUFFIX], oss,
"/");
126 BESCatalog *catalog = catalog_list->find_catalog(dhi.
data[CATALOG]);
128 throw BESInternalError(
string(
"Build site map could not find the catalog: ") + dhi.
data[CATALOG], __FILE__, __LINE__);
131 catalog->get_site_map(prefix, dhi.
data[NODE_SUFFIX], dhi.
data[LEAF_SUFFIX], oss,
"/");
140 info->end_response();
156 if (d_response_object) {
158 if (!info)
throw BESInternalError(
"Could not get the Info object in SiteMapResponseHandler::transmit()", __FILE__, __LINE__);
171 strm << BESIndent::LMarg <<
"SiteMapResponseHandler::dump - (" << (
void *)
this <<
")" << std::endl;
174 BESIndent::UnIndent();
178SiteMapResponseHandler::SiteMapResponseBuilder(
const string &name)
List of all registered catalogs.
virtual std::string default_catalog_name() const
The name of the default catalog.
static BESCatalogList * TheCatalogList()
Get the singleton BESCatalogList instance.
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.
static bool IsSet(const std::string &flagName)
see if the debug context flagName is set to true
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
virtual void dump(std::ostream &strm) const
dumps information about this object
virtual bool start(std::string name)
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