bes  Updated for version 3.20.5
BESResponseHandler.cc
1 // BESResponseHandler.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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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 "BESResponseHandler.h"
36 #include "BESResponseObject.h"
37 #include "BESDataHandlerInterface.h"
38 #include "BESTransmitter.h"
39 
40 #include "TheBESKeys.h"
41 
42 // Experimental: Annotation service URL. Set this parameter to the URL
43 // of an annotation service. If the value is not null, then a global
44 // attribute will be added to the DAS/DMR response for every dataset
45 // available using this server so that clients can access the annotation
46 // service. The name of the attribute will be 'Annotation'.
47 
48 // BES.AnnotationServerURL = http://localhost:8083/Feedback/form
49 
50 const string annotation_service_url = "BES.AnnotationServiceURL";
51 
52 #if 0
53 // Experimental: Include the current dataset URL in the Query Parameter
54 // of the AnnotationServiceURL. This will make the value of the 'Annotation'
55 // attribute have the form: http://localhost:8083/Feedback/form?url=<url>.
56 // This has no effect if the BES.AnnotationServerURL parameter is null.
57 
58 const string include_dataset_in_annotation_url = "BES.IncludeDatasetInAnnotationURL";
59 #endif
60 
61 BESResponseHandler::BESResponseHandler(const string &name) :
62  d_response_name(name), d_response_object(0)
63 {
64  d_annotation_service_url = TheBESKeys::TheKeys()->read_string_key(annotation_service_url, "");
65 #if 0
66  // see comment in header. jhrg 12/19/18
67  d_include_dataset_in_annotation_url = TheBESKeys::TheKeys()->read_bool_key(include_dataset_in_annotation_url, false);
68 #endif
69 }
70 
71 BESResponseHandler::~BESResponseHandler()
72 {
73  delete d_response_object;
74 }
75 
76 
79 {
80  return d_response_object;
81 }
82 
85 {
86  BESResponseObject *curr_obj = d_response_object;
87  d_response_object = new_response;
88  return curr_obj;
89 }
90 
98 void BESResponseHandler::dump(ostream &strm) const
99 {
100  strm << BESIndent::LMarg << "BESResponseHandler::dump - (" << (void *) this << ")" << endl;
101  BESIndent::Indent();
102  strm << BESIndent::LMarg << "response name: " << d_response_name << endl;
103  if (d_response_object) {
104  strm << BESIndent::LMarg << "response object:" << endl;
105  BESIndent::Indent();
106  d_response_object->dump(strm);
107  BESIndent::UnIndent();
108  }
109  else {
110  strm << BESIndent::LMarg << "response object: not set" << endl;
111  }
112  BESIndent::UnIndent();
113 }
114 
BESResponseObject::dump
virtual void dump(ostream &strm) const =0
dump the contents of this object to the specified ostream
TheBESKeys::read_string_key
std::string read_string_key(const std::string &key, const std::string &default_value)
Read a string-valued key from the bes.conf file.
Definition: TheBESKeys.cc:499
BESResponseHandler::dump
virtual void dump(std::ostream &strm) const
dumps information about this object
Definition: BESResponseHandler.cc:98
TheBESKeys::read_bool_key
bool read_bool_key(const std::string &key, bool default_value)
Read a boolean-valued key from the bes.conf file.
Definition: TheBESKeys.cc:474
BESResponseHandler::set_response_object
virtual BESResponseObject * set_response_object(BESResponseObject *o)
replaces the current response object with the specified one, returning the current response object
Definition: BESResponseHandler.cc:84
TheBESKeys::TheKeys
static TheBESKeys * TheKeys()
Definition: TheBESKeys.cc:61
BESResponseHandler::get_response_object
virtual BESResponseObject * get_response_object()
return the current response object
Definition: BESResponseHandler.cc:78
BESResponseObject
Abstract base class representing a specific set of information in response to a request to the BES.
Definition: BESResponseObject.h:51