bes  Updated for version 3.20.5
BESXMLShowCommand.cc
1 // BESXMLShowCommand.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) 2004-2009 University Corporation for Atmospheric Research
7 // Author: Patrick West <pwest@ucar.edu> and Jose Garcia <jgarcia@ucar.edu>
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 University Corporation for Atmospheric Research at
24 // 3080 Center Green Drive, Boulder, CO 80301
25 
26 // (c) COPYRIGHT University Corporation for Atmospheric Research 2004-2005
27 // Please read the full copyright statement in the file COPYRIGHT_UCAR.
28 //
29 // Authors:
30 // pwest Patrick West <pwest@ucar.edu>
31 // jgarcia Jose Garcia <jgarcia@ucar.edu>
32 
33 #include "BESXMLShowCommand.h"
34 #include "BESXMLUtils.h"
35 #include "BESUtil.h"
36 #include "BESSyntaxUserError.h"
37 #include "BESDebug.h"
38 
39 BESXMLShowCommand::BESXMLShowCommand(const BESDataHandlerInterface &base_dhi) :
40  BESXMLCommand(base_dhi)
41 {
42 }
43 
55 {
56  string name;
57  string value;
58  map<string, string> props;
59  BESXMLUtils::GetNodeInfo(node, name, value, props);
60  if (BESUtil::lowercase(name.substr(0, 4)) != "show") {
61  string err = "The specified command " + name + " is not a show command";
62  throw BESSyntaxUserError(err, __FILE__, __LINE__);
63  }
64  if (name.length() <= 4) {
65  string err = "The specified command " + name + " is not an allowed show command";
66  throw BESSyntaxUserError(err, __FILE__, __LINE__);
67  }
68 
69  d_xmlcmd_dhi.action = "show.";
70  string toadd = BESUtil::lowercase(name.substr(4, name.length() - 4));
71  d_xmlcmd_dhi.action += toadd;
72  d_cmd_log_info = (string) "show " + toadd + ";";
73  BESDEBUG("besxml", "Converted xml element name to command " << d_xmlcmd_dhi.action << endl);
74 
75  // now that we've set the action, go get the response handler for the
76  // action
78 }
79 
86 void BESXMLShowCommand::dump(ostream &strm) const
87 {
88  strm << BESIndent::LMarg << "BESXMLShowCommand::dump - (" << (void *) this << ")" << endl;
89  BESIndent::Indent();
90  BESXMLCommand::dump(strm);
91  BESIndent::UnIndent();
92 }
93 
95 BESXMLShowCommand::CommandBuilder(const BESDataHandlerInterface &base_dhi)
96 {
97  return new BESXMLShowCommand(base_dhi);
98 }
99 
virtual void parse_request(xmlNode *node)
parse any show command. No sub-elements or properties are defined
virtual void dump(ostream &strm) const
dumps information about this object
static string lowercase(const string &s)
Definition: BESUtil.cc:197
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 set_response()
The request has been parsed, use the command action name to set the response handler.
Structure storing information used by the BES to handle the request.
Base class for the BES's commands.
Definition: BESXMLCommand.h:63
virtual void dump(ostream &strm) const
dumps information about this object
string action
the response object requested, e.g. das, dds
std::string d_cmd_log_info
Used only for the log.
Definition: BESXMLCommand.h:74