38 using std::stringstream ;
89 BESDEBUG(
"besxml",
"building request plan for xml document: " 90 << endl <<
_dhi->
data[
"XMLDoc"] << endl ) ;
95 <<
"] building" << endl ;
101 xmlNode *root_element = NULL ;
102 xmlNode *current_node = NULL ;
107 vector<string> parseerrors ;
110 doc = xmlParseDoc( (
unsigned char *)
_dhi->
data[
"XMLDoc"].c_str() ) ;
113 string err =
"Problem parsing the request xml document:\n" ;
114 bool isfirst = true ;
115 vector<string>::const_iterator i = parseerrors.begin() ;
116 vector<string>::const_iterator e = parseerrors.end() ;
119 if( !isfirst && (*i).compare( 0, 6,
"Entity" ) == 0 )
130 root_element = xmlDocGetRootElement( doc ) ;
133 string err =
"There is no root element in the xml document" ;
139 map< string, string> props ;
141 if( root_name !=
"request" )
143 string err = (string)
"The root element should be a request element, " 144 +
"name is " + (
char *)root_element->name ;
149 string err = (string)
"The request element must not contain a value, " 158 string err = (string)
"request id value empty" ;
167 bool has_response = false ;
168 current_node = root_element->children ;
170 while( current_node )
172 if( current_node->type == XML_ELEMENT_NODE )
176 string node_name = (
char *)current_node->name ;
177 BESDEBUG(
"besxml",
"looking for command " << node_name
185 string err = (string)
"Failed to build command object for " 191 _cmd_list.push_back( current_cmd ) ;
196 if( has_response && cmd_has_response )
198 string err =
"Multiple responses not allowed" ;
201 has_response = cmd_has_response ;
204 BESDEBUG(
"besxml",
"parse request using " << node_name
209 BESDEBUG(
"besxml", node_name <<
" parsed request, dhi = " 210 << current_dhi << endl ) ;
214 BESDEBUG(
"xml",
"Finding transmitter: " << returnAs
215 <<
" ... " << endl ) ;
220 string s = (string)
"Unable to find transmitter " 229 string err = (string)
"Unable to find command for " 234 current_node = current_node->next ;
249 BESDEBUG(
"besxml",
"Done building request plan" << endl ) ;
259 vector<BESXMLCommand *>::iterator i = _cmd_list.begin() ;
260 vector<BESXMLCommand *>::iterator e = _cmd_list.end() ;
263 (*i)->prep_request() ;
264 _dhi = &(*i)->get_dhi() ;
285 BESDEBUG(
"xml",
"Setting transmitter: " << returnAs
286 <<
" ... " << endl ) ;
291 string s = (string)
"Unable to find transmitter " 308 vector<BESXMLCommand *>::iterator i = _cmd_list.begin() ;
309 vector<BESXMLCommand *>::iterator e = _cmd_list.end() ;
312 _dhi = &(*i)->get_dhi() ;
335 vector<BESXMLCommand *>::iterator i = _cmd_list.begin() ;
336 vector<BESXMLCommand *>::iterator e = _cmd_list.end() ;
339 _dhi = &(*i)->get_dhi() ;
349 vector<BESXMLCommand *>::iterator i = _cmd_list.begin() ;
350 vector<BESXMLCommand *>::iterator e = _cmd_list.end() ;
371 << (
void *)
this <<
")" << endl ;
374 vector<BESXMLCommand *>::const_iterator i = _cmd_list.begin() ;
375 vector<BESXMLCommand *>::const_iterator e = _cmd_list.end() ;
virtual BESTransmitter * find_transmitter(const string &name)
virtual int execute_request(const string &from)
Override execute_request in order to register memory pool.
exception thrown if inernal error encountered
virtual void dump(ostream &strm) const
dumps information about this object
BESXMLCommand *(* p_xmlcmd_builder)(const BESDataHandlerInterface &dhi)
Entry point into BES using string command requests.
virtual void invoke_aggregation()
Invoke the aggregation server, if there is one.
static void GetNodeInfo(xmlNode *node, string &name, string &value, map< string, string > &props)
get the name, value if any, and any properties for the specified node
virtual void initialize()
Initialize the BES.
virtual void parse_request(xmlNode *node)=0
Parse the XML request document begining at the given node.
virtual void log_status()
Log the status of the request to the BESLog file.
virtual BESDataHandlerInterface & get_dhi()
Return the current BESDataHandlerInterface.
BESTransmitter * _transmitter
virtual void transmit_data()
Transmit the response object.
virtual void build_data_request_plan()
Build the data request plan using the BESCmdParser.
error thrown if there is a user syntax error in the request or any other user error ...
virtual void build_data_request_plan()
Build the data request plan using the BESCmdParser.
static BESReturnManager * TheManager()
virtual void execute_data_request_plan()
Execute the data request plan.
virtual ~BESXMLInterface()
static void XMLErrorFunc(void *context, const char *msg,...)
error function used by libxml2 to report errors
Abstract exception class for the BES with basic string message.
virtual void log_status()
Log the status of the request to the BESLog file.
virtual void clean()
Clean up after the request is completed.
virtual void report_request()
Report the request and status of the request to BESReporterList::TheList()
static ostream & LMarg(ostream &strm)
virtual void invoke_aggregation()
Invoke the aggregation server, if there is one.
virtual void dump(ostream &strm) const
dumps information about this object
virtual void report_request()
Report the request and status of the request.
BESXMLInterface(const string &cmd, ostream *strm)
virtual void validate_data_request()
Validate the incoming request information.
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 transmit_data()
Transmit the response object.
virtual void validate_data_request()
Validate the incoming request information.
#define BESDEBUG(x, y)
macro used to send debug information to the debug stream
virtual void execute_data_request_plan()
Execute the data request plan.
BESDataHandlerInterface * _dhi
virtual void initialize()
Initialize the BES.
virtual void clean()
Clean up after the request is completed.
virtual bool has_response()=0
Has a response handler been created given the request document?
virtual int execute_request(const string &from)
Override execute_request in order to register memory pool.
static p_xmlcmd_builder find_command(const string &cmd_str)
Find the BESXMLCommand creation function with the given name.
virtual void dump(ostream &strm) const
dumps information about this object