bes  Updated for version 3.20.6
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 using std::endl;
43 using std::string;
44 using std::ostream;
45 
46 // Experimental: Annotation service URL. Set this parameter to the URL
47 // of an annotation service. If the value is not null, then a global
48 // attribute will be added to the DAS/DMR response for every dataset
49 // available using this server so that clients can access the annotation
50 // service. The name of the attribute will be 'Annotation'.
51 
52 // BES.AnnotationServerURL = http://localhost:8083/Feedback/form
53 
54 const string annotation_service_url = "BES.AnnotationServiceURL";
55 
56 #if 0
57 // Experimental: Include the current dataset URL in the Query Parameter
58 // of the AnnotationServiceURL. This will make the value of the 'Annotation'
59 // attribute have the form: http://localhost:8083/Feedback/form?url=<url>.
60 // This has no effect if the BES.AnnotationServerURL parameter is null.
61 
62 const string include_dataset_in_annotation_url = "BES.IncludeDatasetInAnnotationURL";
63 #endif
64 
65 BESResponseHandler::BESResponseHandler(const string &name) :
66  d_response_name(name), d_response_object(0)
67 {
68  d_annotation_service_url = TheBESKeys::TheKeys()->read_string_key(annotation_service_url, "");
69 #if 0
70  // see comment in header. jhrg 12/19/18
71  d_include_dataset_in_annotation_url = TheBESKeys::TheKeys()->read_bool_key(include_dataset_in_annotation_url, false);
72 #endif
73 }
74 
75 BESResponseHandler::~BESResponseHandler()
76 {
77  delete d_response_object;
78 }
79 
80 
83 {
84  return d_response_object;
85 }
86 
89 {
90  BESResponseObject *curr_obj = d_response_object;
91  d_response_object = new_response;
92  return curr_obj;
93 }
94 
102 void BESResponseHandler::dump(ostream &strm) const
103 {
104  strm << BESIndent::LMarg << "BESResponseHandler::dump - (" << (void *) this << ")" << endl;
105  BESIndent::Indent();
106  strm << BESIndent::LMarg << "response name: " << d_response_name << endl;
107  if (d_response_object) {
108  strm << BESIndent::LMarg << "response object:" << endl;
109  BESIndent::Indent();
110  d_response_object->dump(strm);
111  BESIndent::UnIndent();
112  }
113  else {
114  strm << BESIndent::LMarg << "response object: not set" << endl;
115  }
116  BESIndent::UnIndent();
117 }
118 
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:351
BESResponseHandler::dump
virtual void dump(std::ostream &strm) const
dumps information about this object
Definition: BESResponseHandler.cc:102
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:326
BESResponseObject::dump
virtual void dump(std::ostream &strm) const =0
dump the contents of this object to the specified ostream
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:88
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
BESResponseObject
Abstract base class representing a specific set of information in response to a request to the BES.
Definition: BESResponseObject.h:45