bes  Updated for version 3.20.10
BESSetContainerResponseHandler.cc
1 // BESSetContainerResponseHandler.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 "BESSetContainerResponseHandler.h"
36 
37 #include "BESCatalogList.h"
38 #include "BESContainerStorageList.h"
39 #include "BESContainerStorage.h"
40 #include "BESDataNames.h"
41 #include "BESSyntaxUserError.h"
42 #include "BESResponseNames.h"
43 #include "BESDataHandlerInterface.h"
44 #include "BESDebug.h"
45 #include "BESUtil.h"
46 
47 using std::endl;
48 using std::string;
49 using std::ostream;
50 
51 #define MODULE "bes"
52 #define prolog std::string("BESSetContainerResponseHandler::").append(__func__).append("() - ")
53 
54 BESSetContainerResponseHandler::BESSetContainerResponseHandler(const string &name) :
55  BESResponseHandler(name)
56 {
57 }
58 
59 BESSetContainerResponseHandler::~BESSetContainerResponseHandler()
60 {
61 }
62 
83 {
84  BESDEBUG(MODULE, prolog << "store = " << dhi.data[STORE_NAME] << endl);
85  BESDEBUG(MODULE, prolog << "symbolic = " << dhi.data[SYMBOLIC_NAME] << endl);
86  BESDEBUG(MODULE, prolog << "real = " << dhi.data[REAL_NAME] << endl);
87  BESDEBUG(MODULE, prolog << "type = " << dhi.data[CONTAINER_TYPE] << endl);
88 
89  BESContainerStorageList::TheList()->delete_container(dhi.data[SYMBOLIC_NAME]);
90 
91  BESContainerStorage *cp = BESContainerStorageList::TheList()->find_persistence(dhi.data[STORE_NAME]);
92  if (cp) {
93  cp->del_container(dhi.data[SYMBOLIC_NAME]);
94  // FIXME Change this so that we make a container and then add it. Do not depend on the store
95  // to make the container. This will require re-design of the Catalog/Container/ContainerStorage
96  // classes and maybe the handlers. jhrg 1/7/19
97  cp->add_container(dhi.data[SYMBOLIC_NAME], dhi.data[REAL_NAME], dhi.data[CONTAINER_TYPE]);
98  }
99  else {
100  string ret = (string) "Unable to add container '" + dhi.data[SYMBOLIC_NAME] + "' to container storage '" + dhi.data[STORE_NAME] + "'. Store does not exist.";
101  throw BESSyntaxUserError(ret, __FILE__, __LINE__);
102  }
103 }
104 
115 {
116 }
117 
124 void BESSetContainerResponseHandler::dump(ostream &strm) const
125 {
126  strm << BESIndent::LMarg << "BESSetContainerResponseHandler::dump - (" << (void *) this << ")" << endl;
127  BESIndent::Indent();
129  BESIndent::UnIndent();
130 }
131 
133 BESSetContainerResponseHandler::SetContainerResponseBuilder(const string &name)
134 {
135  return new BESSetContainerResponseHandler(name);
136 }
137 
virtual void delete_container(const std::string &sym_name)
scan all of the container stores and remove any containers called
virtual BESContainerStorage * find_persistence(const std::string &persist_name)
find the persistence store with the given name
provides persistent storage for data storage information represented by a container.
virtual bool del_container(const std::string &s_name)=0
removes a container with the given symbolic name
virtual void add_container(const std::string &sym_name, const std::string &real_name, const std::string &type)=0
adds a container with the provided information
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.
handler object that knows how to create a specific response object
virtual void dump(std::ostream &strm) const
dumps information about this object
response handler that creates a container given the symbolic name, real name, and data type.
virtual void execute(BESDataHandlerInterface &dhi)
executes the command to create a new container or replaces an already existing container based on the...
virtual void dump(std::ostream &strm) const
dumps information about this object
virtual void transmit(BESTransmitter *transmitter, BESDataHandlerInterface &dhi)
The setContainer command does not return a response.
error thrown if there is a user syntax error in the request or any other user error