bes  Updated for version 3.20.5
BESDapResponse.cc
1 // BESDapResponse.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 "BESDapResponse.h"
34 #include "BESContextManager.h"
35 #include "BESConstraintFuncs.h"
36 #include "BESDataNames.h"
37 #include "BESError.h"
38 
56 {
57  bool found = false;
58 
59  // d_explicit_containers is false by default
60  string context = BESContextManager::TheManager()->get_context("dap_explicit_containers", found);
61  if (found) {
62  if (context == "yes")
63  d_explicit_containers = true;
64  else if (context == "no")
65  d_explicit_containers = false;
66  else
67  throw BESError("dap_explicit_containers must be yes or no",
68  BES_SYNTAX_USER_ERROR, __FILE__, __LINE__);
69  }
70 
71  if (!found) {
72  context = BESContextManager::TheManager()->get_context("dap_format", found);
73  if (found) {
74  if (context == "dap2")
75  d_explicit_containers = false;
76  else
77  d_explicit_containers = true;
78  }
79  }
80 
81  context = BESContextManager::TheManager()->get_context("xdap_accept", found);
82  if (found) d_dap_client_protocol = context;
83 
84  context = BESContextManager::TheManager()->get_context("xml:base", found);
85  if (found) d_request_xml_base = context;
86 
87 }
88 
97 {
98  return !d_explicit_containers;
99 }
100 
112 {
113  if (dhi.container) {
114  if (is_dap2()) {
115  dhi.data[POST_CONSTRAINT] = dhi.container->get_constraint();
116  }
117  else {
118  BESConstraintFuncs::post_append(dhi);
119  }
120  }
121 }
122 
134 {
135  if (dhi.container) {
136  dhi.data[DAP4_CONSTRAINT] = dhi.container->get_dap4_constraint();
137  }
138 }
139 
151 {
152  if (dhi.container) {
153  dhi.data[DAP4_FUNCTION] = dhi.container->get_dap4_function();
154  }
155 }
156 
164 void BESDapResponse::dump(ostream &strm) const
165 {
166  strm << BESIndent::LMarg << "BESDapResponse::dump - (" << (void *) this << ")" << endl;
167  BESIndent::Indent();
168  strm << BESIndent::LMarg << "d_explicit_containers: " << d_explicit_containers << endl;
169  strm << BESIndent::LMarg << "d_dap_client_protocol: " << d_dap_client_protocol << endl;
170  BESIndent::UnIndent();
171 
172  BESIndent::UnIndent();
173 }
174 
virtual void dump(ostream &strm) const
dumps information about this object
string get_dap4_constraint() const
retrieve the constraint expression for this container
Definition: BESContainer.h:206
virtual void set_dap4_constraint(BESDataHandlerInterface &dhi)
set the constraint depending on the context
virtual string get_context(const string &name, bool &found)
retrieve the value of the specified context from the BES
virtual void set_dap4_function(BESDataHandlerInterface &dhi)
set the constraint depending on the context
Abstract exception class for the BES with basic string message.
Definition: BESError.h:58
void read_contexts()
Extract the dap protocol from the setConext information.
virtual void set_constraint(BESDataHandlerInterface &dhi)
set the constraint depending on the context
bool is_dap2()
See get_explicit_containers()
Structure storing information used by the BES to handle the request.
map< string, string > data
the map of string data that will be required for the current request.
string get_constraint() const
retrieve the constraint expression for this container
Definition: BESContainer.h:197
BESContainer * container
pointer to current container in this interface
string get_dap4_function() const
retrieve the constraint expression for this container
Definition: BESContainer.h:215