bes  Updated for version 3.20.6
FoCovJsonRequestHandler.cc
1 // -*- mode: c++; c-basic-offset:4 -*-
2 //
3 // FoCovJsonRequestHandler.cc
4 //
5 // This file is part of BES CovJSON File Out Module
6 //
7 // Copyright (c) 2018 OPeNDAP, Inc.
8 // Author: Corey Hemphill <hemphilc@oregonstate.edu>
9 // Author: River Hendriksen <hendriri@oregonstate.edu>
10 // Author: Riley Rimer <rrimer@oregonstate.edu>
11 //
12 // Adapted from the File Out JSON module implemented by Nathan Potter
13 //
14 // This library is free software; you can redistribute it and/or
15 // modify it under the terms of the GNU Lesser General Public
16 // License as published by the Free Software Foundation; either
17 // version 2.1 of the License, or (at your option) any later version.
18 //
19 // This library is distributed in the hope that it will be useful,
20 // but WITHOUT ANY WARRANTY; without even the implied warranty of
21 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 // Lesser General Public License for more details.
23 //
24 // You should have received a copy of the GNU Lesser General Public
25 // License along with this library; if not, write to the Free Software
26 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
27 //
28 
29 #include "FoCovJsonRequestHandler.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 
38 using std::endl;
39 using std::ostream;
40 using std::string;
41 using std::map;
42 
52  BESRequestHandler(name)
53 {
56 }
57 
61 {
62 }
63 
76 {
77  BESResponseObject *response = dhi.response_handler->get_response_object();
78  BESInfo *info = dynamic_cast<BESInfo *>(response);
79  if (!info) throw BESInternalError("cast error", __FILE__, __LINE__);
80 
81  bool found = false;
82  string key = "FoCovJson.Reference";
83  string ref;
84  TheBESKeys::TheKeys()->get_value(key, ref, found);
85  if (ref.empty()) ref = "http://docs.opendap.org/index.php/BES_-_Modules_-_FileOut_COVJSON";
86  map<string, string> attrs;
87  attrs["name"] = MODULE_NAME;
88  attrs["version"] = MODULE_VERSION;
89 
90  attrs["reference"] = ref;
91  info->begin_tag("module", &attrs);
92  info->end_tag("module");
93 
94  return true;
95 }
96 
105 {
106  BESResponseObject *response = dhi.response_handler->get_response_object();
107  BESVersionInfo *info = dynamic_cast<BESVersionInfo *>(response);
108  if (!info) throw BESInternalError("cast error", __FILE__, __LINE__);
109 
110  info->add_module(MODULE_NAME, MODULE_VERSION);
111 
112  return true;
113 }
114 
121 void FoCovJsonRequestHandler::dump(ostream &strm) const
122 {
123  strm << BESIndent::LMarg << "FoCovJsonRequestHandler::dump - (" << (void *) this << ")" << endl;
124  BESIndent::Indent();
126  BESIndent::UnIndent();
127 }
128 
BESRequestHandler
Represents a specific data type request handler.
Definition: BESRequestHandler.h:74
FoCovJsonRequestHandler::build_help
static bool build_help(BESDataHandlerInterface &dhi)
adds help information for FileOut NetCDF to a help request
Definition: FoCovJsonRequestHandler.cc:75
FoCovJsonRequestHandler::~FoCovJsonRequestHandler
virtual ~FoCovJsonRequestHandler(void)
Any cleanup that needs to take place.
Definition: FoCovJsonRequestHandler.cc:60
FoCovJsonRequestHandler::build_version
static bool build_version(BESDataHandlerInterface &dhi)
add version information to a version response
Definition: FoCovJsonRequestHandler.cc:104
BESInfo
informational response object
Definition: BESInfo.h:63
TheBESKeys::TheKeys
static TheBESKeys * TheKeys()
Definition: TheBESKeys.cc:62
BESResponseHandler::get_response_object
virtual BESResponseObject * get_response_object()
return the current response object
Definition: BESResponseHandler.cc:82
BESVersionInfo
Definition: BESVersionInfo.h:47
BESRequestHandler::add_handler
virtual bool add_handler(const std::string &name, p_request_handler_method method)
Backward compatibility with the older version of this class.
Definition: BESRequestHandler.h:101
FoCovJsonRequestHandler::dump
virtual void dump(std::ostream &strm) const
dumps information about this object
Definition: FoCovJsonRequestHandler.cc:121
BESInternalError
exception thrown if internal error encountered
Definition: BESInternalError.h:43
TheBESKeys::get_value
void get_value(const std::string &s, std::string &val, bool &found)
Retrieve the value of a given key, if set.
Definition: TheBESKeys.cc:272
BESRequestHandler::dump
virtual void dump(std::ostream &strm) const
dumps information about this object
Definition: BESRequestHandler.cc:163
BESDataHandlerInterface
Structure storing information used by the BES to handle the request.
Definition: BESDataHandlerInterface.h:56
FoCovJsonRequestHandler::FoCovJsonRequestHandler
FoCovJsonRequestHandler(const std::string &name)
Constructor for FileOut NetCDF module.
Definition: FoCovJsonRequestHandler.cc:51
BESResponseObject
Abstract base class representing a specific set of information in response to a request to the BES.
Definition: BESResponseObject.h:45