80 BESDEBUG(BES_XML, prolog <<
"BEGIN #####################################################" << endl);
81 BESDEBUG(BES_XML, prolog <<
"Building request plan for xml document: " << endl << d_xml_document << endl);
90 xmlDoc *doc =
nullptr;
91 xmlNode *root_element =
nullptr;
92 xmlNode *current_node =
nullptr;
96 vector<string> parseerrors;
100 doc = xmlReadMemory(d_xml_document.c_str(), (
int) d_xml_document.size(),
"" ,
101 nullptr , XML_PARSE_NONET );
103 if (doc ==
nullptr) {
104 string err =
"Problem parsing the request xml document:\n";
106 for (
const auto &parseerror: parseerrors) {
107 if (!isfirst && parseerror.compare(0, 6,
"Entity") == 0) {
116 root_element = xmlDocGetRootElement(doc);
117 if (!root_element)
throw BESSyntaxUserError(
"There is no root element in the xml document", __FILE__, __LINE__);
121 map<string, string> attributes;
123 if (root_name !=
"request")
125 string(
"The root element should be a request element, name is ").append(
126 (
const char *)root_element->name),
129 if (!root_val.empty())
130 throw BESSyntaxUserError(
string(
"The request element must not contain a value, ").append(root_val),
140 auto reqID = attributes[REQUEST_ID_KEY];
141 BESDEBUG(BES_XML, prolog <<
"attributes[" << REQUEST_ID_KEY <<
"]: '" << reqID <<
"'\n");
144 reqID = prolog +
"NoRequestIdDetected";
146 BESDEBUG(BES_XML, prolog <<
"Using reqId: " << reqID << endl);
149 BESDEBUG(BES_XML, prolog <<
"d_dhi_ptr->data[\"" << REQUEST_ID_KEY <<
"\"]: '" <<
d_dhi_ptr->data[REQUEST_ID_KEY] <<
"'\n");
152 auto reqUUID = attributes[REQUEST_UUID_KEY];
153 BESDEBUG(BES_XML, prolog <<
"attributes[" << REQUEST_UUID_KEY <<
"]: '" << reqUUID <<
"'\n");
154 if (reqUUID.empty()) {
156 reqUUID =
"BesXmlInterface-" + BESUtil::uuid();
158 BESDEBUG(BES_XML, prolog <<
"Using reqUUID: " << reqUUID << endl);
160 d_dhi_ptr->data[REQUEST_UUID_KEY] = reqUUID;
161 BESDEBUG(BES_XML, prolog <<
"d_dhi_ptr->data[\"" << REQUEST_UUID_KEY <<
"\"]: '" <<
d_dhi_ptr->data[REQUEST_UUID_KEY] <<
"'\n");
164 auto request_id_for_log = reqID +
"-" + reqUUID;
165 BESDEBUG(BES_XML, prolog <<
"request_id_for_log: '" << request_id_for_log <<
"'\n");
167 BESLog::TheLog()->set_request_id(request_id_for_log);
168 BESDEBUG(BES_XML, prolog <<
"BESLog::TheLog()->get_request_id(): '" << BESLog::TheLog()->get_request_id() <<
"'\n");
172 auto bes_client_id = attributes[BES_CLIENT_ID_KEY];
173 BESDEBUG(BES_XML, prolog << BES_CLIENT_ID_KEY <<
": " << bes_client_id << endl);
177 bool has_response =
false;
178 current_node = root_element->children;
180 while (current_node) {
181 if (current_node->type == XML_ELEMENT_NODE) {
184 string node_name = (
char *) current_node->name;
186 if (node_name == SETCONTAINER_STR) {
189 map<string, string> props;
191 BESDEBUG(MODULE, prolog <<
"In " << SETCONTAINER_STR <<
" element. Value: " << value << endl);
202 throw BESSyntaxUserError(
string(
"Unable to find command for ").append(node_name), __FILE__,
207 throw BESInternalError(
string(
"Failed to build command object for ").append(node_name), __FILE__,
211 if (node_name == SET_CONTEXT_STR) {
224 setContext_xml_dhi.response_handler->
execute(setContext_xml_dhi);
233 d_xml_cmd_list.push_back(current_cmd);
237 if (has_response && cmd_has_response)
238 throw BESSyntaxUserError(
"Commands with multiple responses not supported.", __FILE__, __LINE__);
240 has_response = cmd_has_response;
252 string return_as = current_dhi.
data[RETURN_CMD];
253 if (!return_as.empty() && !BESReturnManager::TheManager()->find_transmitter(return_as))
254 throw BESSyntaxUserError(
string(
"Unable to find transmitter ").append(return_as), __FILE__,
259 current_node = current_node->next;
282 BESDEBUG(
"bes",
"Done building request plan" << endl);
291 VERBOSE(
d_dhi_ptr->data[REQUEST_FROM] +
" [" +
d_dhi_ptr->data[LOG_INFO] +
"] executing");
297#ifdef LOG_ONLY_GET_COMMANDS
300 if (
d_dhi_ptr->action.find(
"get.") != string::npos) {
302 string log_delim=
"|&|";
308 string olfs_log_line = BESContextManager::TheManager()->get_context(
"olfsLog", found);
310 new_log_info.append(
"OLFS").append(log_delim).append(olfs_log_line).append(log_delim);
311 new_log_info.append(
"BES").append(log_delim);
316 if (!
d_dhi_ptr->data[RETURN_CMD].empty())
317 new_log_info.append(log_delim).append(
d_dhi_ptr->data[RETURN_CMD]);
321 auto const *c = *(
d_dhi_ptr->containers.begin());
323 if (!c->get_real_name().empty()) new_log_info.append(log_delim).append(c->get_real_name());
325 if (!c->get_constraint().empty()) {
326 new_log_info.append(log_delim).append(c->get_constraint());
329 if (!c->get_dap4_constraint().empty()) new_log_info.append(log_delim).append(c->get_dap4_constraint());
330 if (!c->get_dap4_function().empty()) new_log_info.append(log_delim).append(c->get_dap4_function());
334 REQUEST_LOG(new_log_info);
337 ERROR_LOG(
"The previous command had multiple containers defined, but only the first was logged.");
340 if (!BESLog::TheLog()->is_verbose()) {
341 if (
d_dhi_ptr->action.find(
"set.context") == string::npos
342 &&
d_dhi_ptr->action.find(
"show.catalog") == string::npos) {