bes  Updated for version 3.17.0
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 
55 void
57 {
58  bool found = false;
59 
60  // d_explicit_containers is false by default
61  string context = BESContextManager::TheManager()->get_context("dap_explicit_containers", found);
62  if (found) {
63  if (context == "yes")
64  d_explicit_containers = true;
65  else if (context == "no")
66  d_explicit_containers = false;
67  else
68  throw BESError("dap_explicit_containers must be yes or no",
69  BES_SYNTAX_USER_ERROR, __FILE__, __LINE__);
70  }
71 
72  if (!found) {
73  context = BESContextManager::TheManager()->get_context("dap_format", found);
74  if (found) {
75  if (context == "dap2")
76  d_explicit_containers = false;
77  else
78  d_explicit_containers = true;
79  }
80  }
81 
82  context = BESContextManager::TheManager()->get_context("xdap_accept", found);
83  if (found)
84  d_dap_client_protocol = context;
85 
86  context = BESContextManager::TheManager()->get_context("xml:base", found);
87  if (found)
88  d_request_xml_base = context;
89 
90 }
91 
100 {
101  return !d_explicit_containers;
102 #if 0
103  bool found = false;
104  string context = BESContextManager::TheManager()->get_context(
105  "dap_format", found);
106  if (found && (context == "dap2" || context == "2.0")) {
107  return true;
108  }
109  return false;
110 #endif
111 }
112 
123 void
125 {
126  if( dhi.container )
127  {
128  if( is_dap2() )
129  {
130  dhi.data[POST_CONSTRAINT] = dhi.container->get_constraint() ;
131  }
132  else
133  {
134  BESConstraintFuncs::post_append( dhi ) ;
135  }
136  }
137 }
138 
149 void
151 {
152  if( dhi.container )
153  {
154  dhi.data[DAP4_CONSTRAINT] = dhi.container->get_dap4_constraint() ;
155  }
156 }
157 
168 void
170 {
171  if( dhi.container )
172  {
173  dhi.data[DAP4_FUNCTION] = dhi.container->get_dap4_function() ;
174  }
175 }
176 
184 void
185 BESDapResponse::dump( ostream &strm ) const
186 {
187  strm << BESIndent::LMarg << "BESDapResponse::dump - ("
188  << (void *)this << ")" << endl ;
189  BESIndent::Indent();
190  strm << BESIndent::LMarg << "d_explicit_containers: " << d_explicit_containers << endl;
191  strm << BESIndent::LMarg << "d_dap_client_protocol: " << d_dap_client_protocol << endl;
192  BESIndent::UnIndent();
193 
194  BESIndent::UnIndent();
195 }
196 
string get_constraint() const
retrieve the constraint expression for this container
Definition: BESContainer.h:170
virtual void dump(ostream &strm) const
dumps information about this object
string get_dap4_function() const
retrieve the constraint expression for this container
Definition: BESContainer.h:188
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:56
void read_contexts()
Extract the dap protocol from the setConext information.
virtual void set_constraint(BESDataHandlerInterface &dhi)
set the constraint depending on the context
string get_dap4_constraint() const
retrieve the constraint expression for this container
Definition: BESContainer.h:179
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.
BESContainer * container
pointer to current container in this interface