bes  Updated for version 3.20.5
ShowPathInfoCommand.cc
1 
2 // This file is part of bes, A C++ back-end server implementation framework
3 // for the OPeNDAP Data Access Protocol.
4 
5 // Copyright (c) 2018 OPeNDAP, Inc
6 // Author: James Gallagher <jgallagher@opendap.org>
7 //
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Lesser General Public
10 // License as published by the Free Software Foundation; either
11 // version 2.1 of the License, or (at your option) any later version.
12 //
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
17 //
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 //
22 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
23 
24 #include "config.h"
25 
26 #include "ShowPathInfoCommand.h"
27 #include "BESDataNames.h"
28 #include "BESDebug.h"
29 #include "BESUtil.h"
30 #include "BESXMLUtils.h"
31 #include "BESSyntaxUserError.h"
32 
33 #define SPI_DEBUG_KEY "show-path-info"
34 
35 #define SHOW_PATH_INFO_RESPONSE "show.pathInfo"
36 
37 
38 ShowPathInfoCommand::ShowPathInfoCommand(const BESDataHandlerInterface &base_dhi) :
39  BESXMLCommand(base_dhi)
40 {
41 
42 }
43 
51 {
52  string name;
53  string value;
54  map<string, string> props;
55  BESXMLUtils::GetNodeInfo(node, name, value, props);
56  if (name != SHOW_PATH_INFO_RESPONSE_STR) {
57  string err = "The specified command " + name + " is not a " + SHOW_PATH_INFO_RESPONSE_STR + " command";
58  throw BESSyntaxUserError(err, __FILE__, __LINE__);
59  }
60 
61  // the the action is to return the showPathInfo response
62  d_xmlcmd_dhi.action = SHOW_PATH_INFO_RESPONSE;
63  d_xmlcmd_dhi.data[SHOW_PATH_INFO_RESPONSE] = SHOW_PATH_INFO_RESPONSE;
64  d_cmd_log_info = "show pathInfo";
65 
66  // node is an optional property, so could be empty string
67  d_xmlcmd_dhi.data[CONTAINER] = props["node"];
68  if (!d_xmlcmd_dhi.data[CONTAINER].empty()) {
69  d_cmd_log_info += " for " + d_xmlcmd_dhi.data[CONTAINER];
70  }
71  d_cmd_log_info += ";";
72 
73  BESDEBUG(SPI_DEBUG_KEY, "Built BES Command: '" << d_cmd_log_info << "'"<< endl );
74 
75  // now that we've set the action, go get the response handler for the
76  // action by calling set_response() in our parent class
78 }
79 
86 void ShowPathInfoCommand::dump(ostream &strm) const
87 {
88  strm << BESIndent::LMarg << "ShowPathInfoCommand::dump - (" << (void *) this << ")" << endl;
89  BESIndent::Indent();
90  BESXMLCommand::dump(strm);
91  BESIndent::UnIndent();
92 }
93 
95 ShowPathInfoCommand::CommandBuilder(const BESDataHandlerInterface &base_dhi)
96 {
97  return new ShowPathInfoCommand(base_dhi);
98 }
99 
virtual void dump(ostream &strm) const
dumps information about this object
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
Definition: BESXMLUtils.cc:101
error thrown if there is a user syntax error in the request or any other user error
virtual void parse_request(xmlNode *node)
parse a show command. No properties or children elements
virtual void set_response()
The request has been parsed, use the command action name to set the response handler.
virtual void dump(ostream &strm) const
dumps information about this object
Structure storing information used by the BES to handle the request.
Base class for the BES's commands.
Definition: BESXMLCommand.h:63