bes  Updated for version 3.20.6
BESXMLDeleteContainersCommand.cc
1 // BESXMLDeleteContainersCommand.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 "BESXMLDeleteContainersCommand.h"
34 #include "BESContainerStorageList.h"
35 #include "BESDataNames.h"
36 #include "BESResponseNames.h"
37 #include "BESXMLUtils.h"
38 #include "BESUtil.h"
39 #include "BESSyntaxUserError.h"
40 #include "BESDebug.h"
41 
42 using std::endl;
43 using std::ostream;
44 using std::string;
45 using std::map;
46 
47 BESXMLDeleteContainersCommand::BESXMLDeleteContainersCommand(const BESDataHandlerInterface &base_dhi) :
48  BESXMLCommand(base_dhi)
49 {
50 }
51 
59 {
60  string name;
61  string value;
62  map<string, string> props;
63  BESXMLUtils::GetNodeInfo(node, name, value, props);
64  if (name != DELETE_CONTAINERS_STR) {
65  string err = "The specified command " + name + " is not a delete container command";
66  throw BESSyntaxUserError(err, __FILE__, __LINE__);
67  }
68 
69  // optional property, defaults to default
70  string storage = props["space"];
71  d_xmlcmd_dhi.data[STORE_NAME] = storage;
72  if (d_xmlcmd_dhi.data[STORE_NAME].empty()) {
73  d_xmlcmd_dhi.data[STORE_NAME] = CATALOG /* DEFAULT jhrg 12/27/18 */;
74  storage = CATALOG /* DEFAULT jhrg 12/27/18 */;
75  }
76 
77  d_xmlcmd_dhi.action = DELETE_CONTAINERS;
78 
79  d_cmd_log_info = (string) "delete containers from " + storage + ";";
80 
81  // now that we've set the action, go get the response handler for the
82  // action
84 }
85 
92 void BESXMLDeleteContainersCommand::dump(ostream &strm) const
93 {
94  strm << BESIndent::LMarg << "BESXMLDeleteContainersCommand::dump - (" << (void *) this << ")" << endl;
95  BESIndent::Indent();
96  BESXMLCommand::dump(strm);
97  BESIndent::UnIndent();
98 }
99 
101 BESXMLDeleteContainersCommand::CommandBuilder(const BESDataHandlerInterface &base_dhi)
102 {
103  return new BESXMLDeleteContainersCommand(base_dhi);
104 }
105 
BESXMLCommand::d_cmd_log_info
std::string d_cmd_log_info
Used only for the log.
Definition: BESXMLCommand.h:74
BESDataHandlerInterface::action
std::string action
the response object requested, e.g. das, dds
Definition: BESDataHandlerInterface.h:79
BESXMLCommand::set_response
virtual void set_response()
The request has been parsed, use the command action name to set the response handler.
Definition: BESXMLCommand.cc:63
BESXMLUtils::GetNodeInfo
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
BESXMLDeleteContainersCommand
Definition: BESXMLDeleteContainersCommand.h:39
BESXMLDeleteContainersCommand::dump
virtual void dump(std::ostream &strm) const
dumps information about this object
Definition: BESXMLDeleteContainersCommand.cc:92
BESXMLCommand::dump
virtual void dump(std::ostream &strm) const
dumps information about this object
Definition: BESXMLCommand.cc:119
BESXMLDeleteContainersCommand::parse_request
virtual void parse_request(xmlNode *node)
parse a delete containers command.
Definition: BESXMLDeleteContainersCommand.cc:58
BESSyntaxUserError
error thrown if there is a user syntax error in the request or any other user error
Definition: BESSyntaxUserError.h:41
BESDataHandlerInterface::data
std::map< std::string, std::string > data
the map of string data that will be required for the current request.
Definition: BESDataHandlerInterface.h:90
BESXMLCommand
Base class for the BES's commands.
Definition: BESXMLCommand.h:63
BESDataHandlerInterface
Structure storing information used by the BES to handle the request.
Definition: BESDataHandlerInterface.h:56