BESDelContainersResponseHandler.cc
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #include "BESDelContainersResponseHandler.h"
00034 #include "BESSilentInfo.h"
00035 #include "BESDefinitionStorageList.h"
00036 #include "BESDefinitionStorage.h"
00037 #include "BESDefine.h"
00038 #include "BESContainerStorageList.h"
00039 #include "BESContainerStorage.h"
00040 #include "BESContainer.h"
00041 #include "BESDataNames.h"
00042 #include "BESSyntaxUserError.h"
00043 #include "BESResponseNames.h"
00044
00045 BESDelContainersResponseHandler::BESDelContainersResponseHandler( const string &name )
00046 : BESResponseHandler( name )
00047 {
00048 }
00049
00050 BESDelContainersResponseHandler::~BESDelContainersResponseHandler( )
00051 {
00052 }
00053
00074 void
00075 BESDelContainersResponseHandler::execute( BESDataHandlerInterface &dhi )
00076 {
00077 dhi.action_name = DELETE_CONTAINERS_STR ;
00078 BESInfo *info = new BESSilentInfo() ;
00079 _response = info ;
00080
00081 string store_name = dhi.data[STORE_NAME] ;
00082 if( store_name == "" )
00083 {
00084 store_name = PERSISTENCE_VOLATILE ;
00085 }
00086 BESContainerStorage *cp =
00087 BESContainerStorageList::TheList()->find_persistence( store_name ) ;
00088 if( cp )
00089 {
00090 bool deleted = cp->del_containers( ) ;
00091 if( !deleted )
00092 {
00093 string line = (string)"Unable to delete containers from \""
00094 + dhi.data[STORE_NAME]
00095 + "\" container store" ;
00096 throw BESSyntaxUserError( line, __FILE__, __LINE__ ) ;
00097 }
00098 }
00099 else
00100 {
00101 string line = (string)"Container storage \""
00102 + dhi.data[STORE_NAME]
00103 + "\" does not exist. "
00104 + "Unable to delete containers" ;
00105 throw BESSyntaxUserError( line, __FILE__, __LINE__ ) ;
00106 }
00107 }
00108
00121 void
00122 BESDelContainersResponseHandler::transmit( BESTransmitter *transmitter,
00123 BESDataHandlerInterface &dhi )
00124 {
00125 if( _response )
00126 {
00127 BESInfo *info = dynamic_cast<BESInfo *>(_response) ;
00128 if( !info )
00129 throw BESInternalError( "cast error", __FILE__, __LINE__ ) ;
00130 info->transmit( transmitter, dhi ) ;
00131 }
00132 }
00133
00140 void
00141 BESDelContainersResponseHandler::dump( ostream &strm ) const
00142 {
00143 strm << BESIndent::LMarg << "BESDelContainersResponseHandler::dump - ("
00144 << (void *)this << ")" << endl ;
00145 BESIndent::Indent() ;
00146 BESResponseHandler::dump( strm ) ;
00147 BESIndent::UnIndent() ;
00148 }
00149
00150 BESResponseHandler *
00151 BESDelContainersResponseHandler::DelContainersResponseBuilder( const string &name )
00152 {
00153 return new BESDelContainersResponseHandler( name ) ;
00154 }