OPeNDAP Hyrax Back End Server (BES)
Updated for version 3.8.3
|
00001 // BESVersionResponseHandler.cc 00002 00003 // This file is part of bes, A C++ back-end server implementation framework 00004 // for the OPeNDAP Data Access Protocol. 00005 00006 // Copyright (c) 2004-2009 University Corporation for Atmospheric Research 00007 // Author: Patrick West <pwest@ucar.edu> and Jose Garcia <jgarcia@ucar.edu> 00008 // 00009 // This library is free software; you can redistribute it and/or 00010 // modify it under the terms of the GNU Lesser General Public 00011 // License as published by the Free Software Foundation; either 00012 // version 2.1 of the License, or (at your option) any later version. 00013 // 00014 // This library is distributed in the hope that it will be useful, 00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00017 // Lesser General Public License for more details. 00018 // 00019 // You should have received a copy of the GNU Lesser General Public 00020 // License along with this library; if not, write to the Free Software 00021 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00022 // 00023 // You can contact University Corporation for Atmospheric Research at 00024 // 3080 Center Green Drive, Boulder, CO 80301 00025 00026 // (c) COPYRIGHT University Corporation for Atmospheric Research 2004-2005 00027 // Please read the full copyright statement in the file COPYRIGHT_UCAR. 00028 // 00029 // Authors: 00030 // pwest Patrick West <pwest@ucar.edu> 00031 // jgarcia Jose Garcia <jgarcia@ucar.edu> 00032 00033 #include "config.h" 00034 00035 #include <vector> 00036 00037 using std::vector ; 00038 00039 #include "BESVersionResponseHandler.h" 00040 #include "BESVersionInfo.h" 00041 #include "BESRequestHandlerList.h" 00042 #include "BESResponseNames.h" 00043 #include "TheBESKeys.h" 00044 00045 #define DEFAULT_ADMINISTRATOR "support@opendap.org" 00046 00047 BESVersionResponseHandler::BESVersionResponseHandler( const string &name ) 00048 : BESResponseHandler( name ) 00049 { 00050 } 00051 00052 BESVersionResponseHandler::~BESVersionResponseHandler( ) 00053 { 00054 } 00055 00070 void 00071 BESVersionResponseHandler::execute( BESDataHandlerInterface &dhi ) 00072 { 00073 BESVersionInfo *info = new BESVersionInfo() ; 00074 _response = info ; 00075 dhi.action_name = VERS_RESPONSE_STR ; 00076 info->begin_response( VERS_RESPONSE_STR, dhi ) ; 00077 00078 string administrator = "" ; 00079 try 00080 { 00081 bool found = false ; 00082 vector<string> vals ; 00083 string key = "BES.ServerAdministrator" ; 00084 TheBESKeys::TheKeys()->get_value( key, administrator, found ) ; 00085 } 00086 catch( ... ) 00087 { 00088 administrator = DEFAULT_ADMINISTRATOR ; 00089 } 00090 if( administrator.empty() ) 00091 { 00092 administrator = DEFAULT_ADMINISTRATOR ; 00093 } 00094 info->add_tag( "Administrator", administrator ) ; 00095 00096 info->add_library( PACKAGE_NAME, PACKAGE_VERSION ) ; 00097 00098 BESRequestHandlerList::TheList()->execute_all( dhi ) ; 00099 00100 info->end_response() ; 00101 } 00102 00115 void 00116 BESVersionResponseHandler::transmit( BESTransmitter *transmitter, 00117 BESDataHandlerInterface &dhi ) 00118 { 00119 if( _response ) 00120 { 00121 BESVersionInfo *info = dynamic_cast<BESVersionInfo *>(_response) ; 00122 if( !info ) 00123 throw BESInternalError( "cast error", __FILE__, __LINE__ ) ; 00124 info->transmit( transmitter, dhi ) ; 00125 } 00126 } 00127 00134 void 00135 BESVersionResponseHandler::dump( ostream &strm ) const 00136 { 00137 strm << BESIndent::LMarg << "BESVersionResponseHandler::dump - (" 00138 << (void *)this << ")" << endl ; 00139 BESIndent::Indent() ; 00140 BESResponseHandler::dump( strm ) ; 00141 BESIndent::UnIndent() ; 00142 } 00143 00144 BESResponseHandler * 00145 BESVersionResponseHandler::VersionResponseBuilder( const string &name ) 00146 { 00147 return new BESVersionResponseHandler( name ) ; 00148 } 00149