bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
ShowNodeCommand.cc
1// ShowNodeCommand.cc
2
3// This file is part of bes, A C++ back-end server implementation framework
4// for the OPeNDAP Data Access Protocol.
5
6// Copyright (c) 2018 OPeNDAP, Inc
7// Author: James Gallagher <jgallagher@opendap.org>
8//
9// This library is free software; you can redistribute it and/or
10// modify it under the terms of the GNU Lesser General Public
11// License as published by the Free Software Foundation; either
12// version 2.1 of the License, or (at your option) any later version.
13//
14// This library is distributed in the hope that it will be useful,
15// but WITHOUT ANY WARRANTY; without even the implied warranty of
16// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17// Lesser General Public License for more details.
18//
19// You should have received a copy of the GNU Lesser General Public
20// License along with this library; if not, write to the Free Software
21// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22//
23// You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
24
25#include "config.h"
26
27#include "BESContainerStorageList.h"
28
29#include "BESNames.h"
30#include "BESDataNames.h"
31#include "BESXMLUtils.h"
32#include "BESUtil.h"
33#include "BESSyntaxUserError.h"
34#include "BESDebug.h"
35
36#include "ShowNodeCommand.h"
37
38using std::endl;
39using std::ostream;
40using std::string;
41using std::map;
42
43using namespace bes;
44
45ShowNodeCommand::ShowNodeCommand(const BESDataHandlerInterface &base_dhi) :
46 BESXMLCommand(base_dhi)
47{
48}
49
72{
73 string name;
74 string value;
75 map<string, string> props;
76 BESXMLUtils::GetNodeInfo(node, name, value, props);
77 if (name != NODE_RESPONSE_STR) {
78 string err = "The specified command " + name + " is not a showNode command";
79 throw BESSyntaxUserError(err, __FILE__, __LINE__);
80 }
81
82 // the action is the same for show catalog and show info
83 d_xmlcmd_dhi.action = NODE_RESPONSE;
84
85 d_cmd_log_info = "show node";
86
87 // node is an optional property, so could be empty string
88 d_xmlcmd_dhi.data[CONTAINER] = props["node"];
89
90 if (!d_xmlcmd_dhi.data[CONTAINER].empty()) {
91 d_cmd_log_info.append(" for ").append(d_xmlcmd_dhi.data[CONTAINER]);
92 }
93
94 // catalog is an optional property, so could be empty string
95 // Dropped this because the catalog name is going to be in the path. ndp 8/8/18
96 // d_xmlcmd_dhi.data[CATALOG] = props["catalog"];
97
98 if (!d_xmlcmd_dhi.data[CATALOG].empty()) {
99 d_cmd_log_info.append(" in catalog ").append(d_xmlcmd_dhi.data[CATALOG]);
100 }
101
102 d_cmd_log_info += ";";
103
104 // Get the response handler for the action (dhi.action == show.node)
105 set_response();
106}
107
114void ShowNodeCommand::dump(ostream &strm) const
115{
116 strm << BESIndent::LMarg << "ShowNodeCommand::dump - (" << (void *) this << ")" << endl;
117 BESIndent::Indent();
119 BESIndent::UnIndent();
120}
121
131{
132 return new ShowNodeCommand(base_dhi);
133}
134
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 node command.
virtual void dump(std::ostream &strm) const
dumps information about this object
static BESXMLCommand * CommandBuilder(const BESDataHandlerInterface &base_dhi)
A command builder suitable for BESXMLCommand::add_command()