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