27#include "XMLSetContextsCommand.h"
29#include "BESXMLUtils.h"
31#include "BESDataNames.h"
32#include "BESSyntaxUserError.h"
35#include "SetContextsNames.h"
37#if !USE_CONTEXTS_RESPONSE_HANDLER
38#include "BESContextManager.h"
65 string value, name, action;
66 map<string, string> props;
68 if (action != SET_CONTEXTS_STR) {
69 string err =
"The specified command " + action +
" is not a set context command";
73 xmlNode *current_node = node->children;
74 while (current_node) {
75 if (current_node->type == XML_ELEMENT_NODE) {
78 map<string, string> attributes;
81 if (name !=
"context")
83 + name +
"'."), __FILE__, __LINE__);
86 throw BESSyntaxUserError(
string(
"The 'context' element must contain a value"), __FILE__,
89 if (attributes.size() != 1 || attributes[
"name"].empty())
90 throw BESSyntaxUserError(
string(
"The 'context' element must contain a 'name' attribute."),
94#if USE_CONTEXTS_RESPONSE_HANDLER
101 string context_key = string(CONTEXT_PREFIX).append(attributes[
"name"]);
102 d_xmlcmd_dhi.
data[CONTEXT_NAMES] = d_xmlcmd_dhi.
data[CONTEXT_NAMES].append(
" ").append(context_key);
103 d_xmlcmd_dhi.
data[context_key] = value;
105 BESDEBUG(
"besxml",
"d_xmlcmd_dhi.data[" << context_key <<
"] = " << value << endl);
107 BESDEBUG(
"besxml",
"In " << __func__ <<
" BESContextManager::TheManager()->set_context("
108 << name <<
", " << value <<
")" << endl);
110 BESContextManager::TheManager()->
set_context(attributes[
"name"], value);
114 current_node = current_node->next;
117 d_cmd_log_info = string(
"set contexts for ").append(d_xmlcmd_dhi.
data[CONTEXT_NAMES]);
120#if USE_CONTEXTS_RESPONSE_HANDLER
122 d_xmlcmd_dhi.
action = SET_CONTEXTS_ACTION;
127 d_xmlcmd_dhi.action_name = SET_CONTEXTS_STR;
128 d_xmlcmd_dhi.
action = NULL_ACTION;
145 strm << BESIndent::LMarg <<
"XMLSetContextsCommand::dump - (" << (
void *)
this <<
")" << endl;
148 BESIndent::UnIndent();
virtual void set_context(const std::string &name, const std::string &value)
set context in the BES
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.
std::string action
the response object requested, e.g. das, dds
error thrown if there is a user syntax error in the request or any other user error
Base class for the BES's commands.
virtual void dump(std::ostream &strm) const
dumps information about this object
virtual void set_response()
The request has been parsed, use the command action name to set the response handler.
std::string d_cmd_log_info
Used only for the log.
static void GetNodeInfo(xmlNode *node, std::string &name, std::string &value, std::map< std::string, std::string > &props)
get the name, value if any, and any properties for the specified node
virtual void parse_request(xmlNode *node)
parse a setContexts command.
virtual void dump(std::ostream &strm) const
dumps information about this object