28 #include <sys/types.h>
39 #include "ShowBesKeyCommand.h"
40 #include "ShowBesKeyResponseHandler.h"
45 #include "BESInfoList.h"
46 #include "BESDataNames.h"
47 #include "TheBESKeys.h"
49 #include "BESStopWatch.h"
53 ShowBesKeyResponseHandler::ShowBesKeyResponseHandler(
const string &name) :
58 ShowBesKeyResponseHandler::~ShowBesKeyResponseHandler()
76 if (BESISDEBUG(TIMING_LOG)) sw.
start(
"ShowBesKeyResponseHandler::execute", dhi.
data[REQUEST_ID]);
78 BESInfo *info = BESInfoList::TheList()->build_info();
79 d_response_object = info;
81 string requested_bes_key = dhi.
data[BES_KEY];
83 BESDEBUG(SBK_DEBUG_KEY, __func__ <<
"() - requested key: " << requested_bes_key << endl);
85 vector<string> key_values;
86 getBesKeyValue(requested_bes_key, key_values);
88 map<string, string> attrs;
90 attrs[KEY] = requested_bes_key;
96 map<string, string> emptyAttrs;
97 for(
unsigned long i = 0; i < key_values.size(); ++i)
98 info->add_tag(
"value", key_values[i], &emptyAttrs);
101 info->end_response();
118 if (d_response_object) {
133 strm << BESIndent::LMarg <<
"ShowBesKeyResponseHandler::dump - (" << (
void *)
this <<
")" << std::endl;
136 BESIndent::UnIndent();
140 ShowBesKeyResponseHandler::ShowBesKeyResponseBuilder(
const string &name)
145 void ShowBesKeyResponseHandler::getBesKeyValue(
string key, vector<string> &values)
151 BESDEBUG(SBK_DEBUG_KEY, __func__ <<
"() Failed to located BES key '" << key <<
"'" << endl);
152 throw BESError(
"Ouch! The Key name '"+key+
"' was not found in BESKeys",BES_NOT_FOUND_ERROR, __FILE__, __LINE__);
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.
Abstract exception class for the BES with basic string message.
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
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)
Response handler that returns the value(s) of a BES key.
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
virtual void execute(BESDataHandlerInterface &dhi)
executes the command 'show catalog|leaves [for <node>];' by returning nodes or leaves at the top leve...
static TheBESKeys * TheKeys()
void get_values(const std::string &s, std::vector< std::string > &vals, bool &found)
Retrieve the values of a given key, if set.