bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
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
33using std::endl;
34using std::ostream;
35using std::string;
36using std::map;
37
38#define SPI_DEBUG_KEY "show-path-info"
39
40#define SHOW_PATH_INFO_RESPONSE "show.pathInfo"
41
42
43ShowPathInfoCommand::ShowPathInfoCommand(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_PATH_INFO_RESPONSE_STR) {
62 string err = "The specified command " + name + " is not a " + SHOW_PATH_INFO_RESPONSE_STR + " command";
63 throw BESSyntaxUserError(err, __FILE__, __LINE__);
64 }
65
66 // the the action is to return the showPathInfo response
67 d_xmlcmd_dhi.action = SHOW_PATH_INFO_RESPONSE;
68 d_xmlcmd_dhi.data[SHOW_PATH_INFO_RESPONSE] = SHOW_PATH_INFO_RESPONSE;
69 d_cmd_log_info = "show pathInfo";
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
91void ShowPathInfoCommand::dump(ostream &strm) const
92{
93 strm << BESIndent::LMarg << "ShowPathInfoCommand::dump - (" << (void *) this << ")" << endl;
94 BESIndent::Indent();
96 BESIndent::UnIndent();
97}
98
100ShowPathInfoCommand::CommandBuilder(const BESDataHandlerInterface &base_dhi)
101{
102 return new ShowPathInfoCommand(base_dhi);
103}
104
Structure storing information used by the BES to handle the request.
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 show command. No properties or children elements
virtual void dump(std::ostream &strm) const
dumps information about this object