bes  Updated for version 3.20.5
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 "BESSetContainerResponseHandler.h"
34 
35 #include "BESCatalogList.h"
36 #include "BESContainerStorageList.h"
37 #include "BESContainerStorage.h"
38 #include "BESDataNames.h"
39 #include "BESSyntaxUserError.h"
40 #include "BESResponseNames.h"
41 #include "BESDataHandlerInterface.h"
42 #include "BESDebug.h"
43 #include "BESUtil.h"
44 
45 #define MODULE "bes"
46 #define prolog std::string("BESSetContainerResponseHandler::").append(__func__).append("() - ")
47 
48 BESSetContainerResponseHandler::BESSetContainerResponseHandler(const string &name) :
49  BESResponseHandler(name)
50 {
51 }
52 
53 BESSetContainerResponseHandler::~BESSetContainerResponseHandler()
54 {
55 }
56 
77 {
78  BESDEBUG(MODULE, prolog << "store = " << dhi.data[STORE_NAME] << endl);
79  BESDEBUG(MODULE, prolog << "symbolic = " << dhi.data[SYMBOLIC_NAME] << endl);
80  BESDEBUG(MODULE, prolog << "real = " << dhi.data[REAL_NAME] << endl);
81  BESDEBUG(MODULE, prolog << "type = " << dhi.data[CONTAINER_TYPE] << endl);
82 
83  BESContainerStorageList::TheList()->delete_container(dhi.data[SYMBOLIC_NAME]);
84 
85  BESContainerStorage *cp = BESContainerStorageList::TheList()->find_persistence(dhi.data[STORE_NAME]);
86  if (cp) {
87  cp->del_container(dhi.data[SYMBOLIC_NAME]);
88  // FIXME Change this so that we make a container and then add it. Do not depend on the store
89  // to make the container. This will require re-design of the Catalog/Container/ContainerStorage
90  // classes and maybe the handlers. jhrg 1/7/19
91  cp->add_container(dhi.data[SYMBOLIC_NAME], dhi.data[REAL_NAME], dhi.data[CONTAINER_TYPE]);
92  }
93  else {
94  string ret = (string) "Unable to add container '" + dhi.data[SYMBOLIC_NAME] + "' to container storage '" + dhi.data[STORE_NAME] + "'. Store does not exist.";
95  throw BESSyntaxUserError(ret, __FILE__, __LINE__);
96  }
97 }
98 
109 {
110 }
111 
118 void BESSetContainerResponseHandler::dump(ostream &strm) const
119 {
120  strm << BESIndent::LMarg << "BESSetContainerResponseHandler::dump - (" << (void *) this << ")" << endl;
121  BESIndent::Indent();
123  BESIndent::UnIndent();
124 }
125 
127 BESSetContainerResponseHandler::SetContainerResponseBuilder(const string &name)
128 {
129  return new BESSetContainerResponseHandler(name);
130 }
131 
provides persistent storage for data storage information represented by a container.
virtual void dump(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
virtual BESContainerStorage * find_persistence(const std::string &persist_name)
find the persistence store with the given name
response handler that creates a container given the symbolic name, real name, and data type.
handler object that knows how to create a specific response object
virtual bool del_container(const std::string &s_name)=0
removes a container with the given symbolic name
virtual void delete_container(const std::string &sym_name)
scan all of the container stores and remove any containers called
virtual void execute(BESDataHandlerInterface &dhi)
executes the command to create a new container or replaces an already existing container based on the...
Structure storing information used by the BES to handle the request.
map< string, string > data
the map of string data that will be required for the current request.
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
virtual void dump(std::ostream &strm) const
dumps information about this object