OPeNDAP Hyrax Back End Server (BES)  Updated for version 3.8.3
BESVersionResponseHandler.cc
Go to the documentation of this file.
1 // BESVersionResponseHandler.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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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 <vector>
36 
37 using std::vector ;
38 
40 #include "BESVersionInfo.h"
41 #include "BESRequestHandlerList.h"
42 #include "BESResponseNames.h"
43 #include "TheBESKeys.h"
44 
45 #define DEFAULT_ADMINISTRATOR "support@opendap.org"
46 
48  : BESResponseHandler( name )
49 {
50 }
51 
53 {
54 }
55 
70 void
72 {
73  BESVersionInfo *info = new BESVersionInfo() ;
74  _response = info ;
76  info->begin_response( VERS_RESPONSE_STR, dhi ) ;
77 
78  string administrator = "" ;
79  try
80  {
81  bool found = false ;
82  vector<string> vals ;
83  string key = "BES.ServerAdministrator" ;
84  TheBESKeys::TheKeys()->get_value( key, administrator, found ) ;
85  }
86  catch( ... )
87  {
88  administrator = DEFAULT_ADMINISTRATOR ;
89  }
90  if( administrator.empty() )
91  {
92  administrator = DEFAULT_ADMINISTRATOR ;
93  }
94  info->add_tag( "Administrator", administrator ) ;
95 
97 
99 
100  info->end_response() ;
101 }
102 
115 void
118 {
119  if( _response )
120  {
121  BESVersionInfo *info = dynamic_cast<BESVersionInfo *>(_response) ;
122  if( !info )
123  throw BESInternalError( "cast error", __FILE__, __LINE__ ) ;
124  info->transmit( transmitter, dhi ) ;
125  }
126 }
127 
134 void
135 BESVersionResponseHandler::dump( ostream &strm ) const
136 {
137  strm << BESIndent::LMarg << "BESVersionResponseHandler::dump - ("
138  << (void *)this << ")" << endl ;
140  BESResponseHandler::dump( strm ) ;
142 }
143 
146 {
147  return new BESVersionResponseHandler( name ) ;
148 }
149