bes  Updated for version 3.20.10
BESXMLCatalogCommand.cc
1 // BESXMLCatalogCommand.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 "config.h"
34 
35 #include "BESXMLCatalogCommand.h"
36 #include "BESContainerStorageList.h"
37 #include "BESNames.h"
38 #include "BESDataNames.h"
39 #include "BESXMLUtils.h"
40 #include "BESUtil.h"
41 #include "BESSyntaxUserError.h"
42 #include "BESDebug.h"
43 
44 using std::endl;
45 using std::ostream;
46 using std::string;
47 using std::map;
48 
49 BESXMLCatalogCommand::BESXMLCatalogCommand(const BESDataHandlerInterface &base_dhi) :
50  BESXMLCommand(base_dhi)
51 {
52 }
53 
63 {
64  string name;
65  string value;
66  map<string, string> props;
67  BESXMLUtils::GetNodeInfo(node, name, value, props);
68  if (name != CATALOG_RESPONSE_STR /*&& name != SHOW_INFO_RESPONSE_STR*/) {
69  string err = "The specified command " + name + " is not a show catalog or show info command";
70  throw BESSyntaxUserError(err, __FILE__, __LINE__);
71  }
72 
73  // the action is the same for show catalog and show info
74  d_xmlcmd_dhi.action = CATALOG_RESPONSE;
75 
76  d_cmd_log_info = "show catalog";
77 
78  // catalog is an additional property and may be empty.
79  d_xmlcmd_dhi.data[CATALOG] = props[CATALOG];
80 
81  // node is an optional property, so could be empty string
82  d_xmlcmd_dhi.data[CONTAINER] = props["node"];
83 
84  if (!d_xmlcmd_dhi.data[CONTAINER].empty()) {
85  d_cmd_log_info += " for " + d_xmlcmd_dhi.data[CONTAINER];
86  }
87 
88  d_cmd_log_info += ";";
89 
90  // Get the response handler for the action
92 }
93 
100 void BESXMLCatalogCommand::dump(ostream &strm) const
101 {
102  strm << BESIndent::LMarg << "BESXMLCatalogCommand::dump - (" << (void *) this << ")" << endl;
103  BESIndent::Indent();
104  BESXMLCommand::dump(strm);
105  BESIndent::UnIndent();
106 }
107 
109 BESXMLCatalogCommand::CommandBuilder(const BESDataHandlerInterface &base_dhi)
110 {
111  return new BESXMLCatalogCommand(base_dhi);
112 }
113 
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
virtual void dump(std::ostream &strm) const
dumps information about this object
virtual void parse_request(xmlNode *node)
Parse a show catalog command.
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:109