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