bes  Updated for version 3.20.8
W10nShowPathInfoCommand.cc
1 // -*- mode: c++; c-basic-offset:4 -*-
2 //
3 // W10nShowPathInfoCommand.cc
4 //
5 // This file is part of BES w10n handler
6 //
7 // Copyright (c) 2020 OPeNDAP, Inc.
8 // Author: Nathan Potter <ndp@opendap.org>
9 //
10 // This library is free software; you can redistribute it and/or
11 // modify it under the terms of the GNU Lesser General Public
12 // License as published by the Free Software Foundation; either
13 // version 2.1 of the License, or (at your option) any later version.
14 //
15 // This library is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public
21 // License along with this library; if not, write to the Free Software
22 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 //
24 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
25 // Please read the full copyright statement in the file COPYRIGHT_URI.
26 //
27 
28 #include "config.h"
29 
30 #include "W10nShowPathInfoCommand.h"
31 #include "W10NNames.h"
32 #include "BESDataNames.h"
33 #include "BESDebug.h"
34 #include "BESUtil.h"
35 #include "BESXMLUtils.h"
36 #include "BESSyntaxUserError.h"
37 
38 using std::endl;
39 using std::ostream;
40 using std::string;
41 using std::map;
42 
43 #define W10N_SHOW_PATH_INFO_DHI_TAG "show.w10nPathInfo"
44 
45 W10nShowPathInfoCommand::W10nShowPathInfoCommand(const BESDataHandlerInterface &base_dhi) :
46  BESXMLCommand(base_dhi)
47 {
48 }
49 
57 {
58  string name;
59  string value;
60  map<string, string> props;
61  BESXMLUtils::GetNodeInfo(node, name, value, props);
62  if (name != W10N_SHOW_PATH_INFO_REQUEST) {
63  string err = "The specified command " + name + " is not a show w10n command";
64  throw BESSyntaxUserError(err, __FILE__, __LINE__);
65  }
66 
67  // the the action is to show the w10n info response
68  d_xmlcmd_dhi.action = W10N_SHOW_PATH_INFO_DHI_TAG;
69  d_xmlcmd_dhi.data[W10N_SHOW_PATH_INFO_DHI_TAG] = W10N_SHOW_PATH_INFO_DHI_TAG;
70  d_cmd_log_info = "show w10nPathInfo";
71 
72  // node is an optional property, so could be empty string
73  d_xmlcmd_dhi.data[CONTAINER] = props["node"];
74  if (!d_xmlcmd_dhi.data[CONTAINER].empty()) {
75  d_cmd_log_info += " for " + d_xmlcmd_dhi.data[CONTAINER];
76  }
77  d_cmd_log_info += ";";
78 
79  BESDEBUG(W10N_DEBUG_KEY, "Built BES Command: '" << d_cmd_log_info << "'"<< endl );
80 
81  // now that we've set the action, go get the response handler for the
82  // action by calling set_response() in our parent class
84 }
85 
92 void W10nShowPathInfoCommand::dump(ostream &strm) const
93 {
94  strm << BESIndent::LMarg << "W10nShowPathInfoCommand::dump - (" << (void *) this << ")" << endl;
95  BESIndent::Indent();
96  BESXMLCommand::dump(strm);
97  BESIndent::UnIndent();
98 }
99 
101 W10nShowPathInfoCommand::CommandBuilder(const BESDataHandlerInterface &base_dhi)
102 {
103  return new W10nShowPathInfoCommand(base_dhi);
104 }
105 
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.
Definition: BESXMLCommand.h:63
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.
Definition: BESXMLCommand.h:74
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
Definition: BESXMLUtils.cc:105
virtual void dump(std::ostream &strm) const
dumps information about this object
virtual void parse_request(xmlNode *node)
parse a show command. No properties or children elements