OPeNDAP Hyrax Back End Server (BES)  Updated for version 3.8.3
FoJsonRequestHandler.cc
Go to the documentation of this file.
1 // -*- mode: c++; c-basic-offset:4 -*-
2 //
3 // FoJsonRequestHandler.cc
4 //
5 // This file is part of BES JSON File Out Module
6 //
7 // Copyright (c) 2014 OPeNDAP, Inc.
8 // Author: Nathan Potter <ndp@opendap.org>
9 //
10 // This library is free software; you can redistribute it and/or
11 // modify it under the terms of the GNU Lesser General Public
12 // License as published by the Free Software Foundation; either
13 // version 2.1 of the License, or (at your option) any later version.
14 //
15 // This library is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public
21 // License along with this library; if not, write to the Free Software
22 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 //
24 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
25 // (c) COPYRIGHT URI/MIT 1995-1999
26 // Please read the full copyright statement in the file COPYRIGHT_URI.
27 //
28 
29 #include "FoJsonRequestHandler.h"
30 #include <BESResponseHandler.h>
31 #include <BESResponseNames.h>
32 #include <BESVersionInfo.h>
33 #include <BESDataNames.h>
34 #include <BESDataNames.h>
35 #include <TheBESKeys.h>
36 #include "config.h"
37 
47  : BESRequestHandler( name )
48 {
51 }
52 
56 {
57 }
58 
70 bool
72 {
74  BESInfo *info = dynamic_cast < BESInfo * >(response) ;
75  if( !info )
76  throw BESInternalError( "cast error", __FILE__, __LINE__ ) ;
77 
78  bool found = false ;
79  string key = "FoJson.Reference" ;
80  string ref ;
81  TheBESKeys::TheKeys()->get_value( key, ref, found ) ;
82  if( ref.empty() )
83  ref = "http://docs.opendap.org/index.php/BES_-_Modules_-_FileOut_JSON" ;
84  map<string,string> attrs ;
85  attrs["name"] = MODULE_NAME ;
86  attrs["version"] = MODULE_VERSION ;
87 #if 0
88  attrs["name"] = PACKAGE_NAME;
89  attrs["version"] = PACKAGE_VERSION;
90 #endif
91  attrs["reference"] = ref ;
92  info->begin_tag( "module", &attrs ) ;
93  info->end_tag( "module" ) ;
94 
95  return true ;
96 }
97 
105 bool
107 {
109  BESVersionInfo *info = dynamic_cast < BESVersionInfo * >(response) ;
110  if( !info )
111  throw BESInternalError( "cast error", __FILE__, __LINE__ ) ;
112 
113 #if 0
115 #endif
116  info->add_module(MODULE_NAME, MODULE_VERSION);
117 
118  return true ;
119 }
120 
127 void
128 FoJsonRequestHandler::dump( ostream &strm ) const
129 {
130  strm << BESIndent::LMarg << "FoJsonRequestHandler::dump - ("
131  << (void *)this << ")" << endl ;
133  BESRequestHandler::dump( strm ) ;
135 }
136 
brief represents simple text information in a response object, such as version and help inforamtion...
exception thrown if inernal error encountered
static bool build_help(BESDataHandlerInterface &dhi)
adds help information for FileOut NetCDF to a help request
FoJsonRequestHandler(const string &name)
Constructor for FileOut NetCDF module.
static void Indent()
Definition: BESIndent.cc:38
static bool build_version(BESDataHandlerInterface &dhi)
add version information to a version response
#define HELP_RESPONSE
informational response object
Definition: BESInfo.h:68
virtual BESResponseObject * get_response_object()
return the current response object
#define PACKAGE_NAME
Definition: config.h:244
virtual void dump(ostream &strm) const
dumps information about this object
BESResponseHandler * response_handler
virtual void begin_tag(const string &tag_name, map< string, string > *attrs=0)
Definition: BESInfo.cc:127
static ostream & LMarg(ostream &strm)
Definition: BESIndent.cc:73
virtual ~FoJsonRequestHandler(void)
Any cleanup that needs to take place.
Represents a specific data type request handler.
void get_value(const string &s, string &val, bool &found)
Retrieve the value of a given key, if set.
Definition: BESKeys.cc:453
Structure storing information used by the BES to handle the request.
#define VERS_RESPONSE
virtual bool add_handler(const string &handler_name, p_request_handler handler_method)
add a handler method to the request handler that knows how to fill in a specific response object ...
#define PACKAGE_VERSION
Definition: config.h:256
static void UnIndent()
Definition: BESIndent.cc:44
static BESKeys * TheKeys()
Definition: TheBESKeys.cc:48
virtual void dump(ostream &strm) const
dumps information about this object
virtual void add_module(const string &n, const string &v)
Abstract base class representing a specific set of information in response to a request to the BES...
virtual void end_tag(const string &tag_name)
Definition: BESInfo.cc:132