OPeNDAP Hyrax Back End Server (BES)  Updated for version 3.8.3
BESDapResponse.cc
Go to the documentation of this file.
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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  {
131  }
132  else
133  {
135  }
136  }
137 }
138 
146 void
147 BESDapResponse::dump( ostream &strm ) const
148 {
149  strm << BESIndent::LMarg << "BESDapResponse::dump - ("
150  << (void *)this << ")" << endl ;
152  strm << BESIndent::LMarg << "d_explicit_containers: " << d_explicit_containers << endl;
153  strm << BESIndent::LMarg << "d_dap_client_protocol: " << d_dap_client_protocol << endl;
155 
157 }
158 
#define BES_SYNTAX_USER_ERROR
Definition: BESError.h:44
virtual void dump(ostream &strm) const
dumps information about this object
virtual string get_context(const string &name, bool &found)
retrieve the value of the specified context from the BES
static void Indent()
Definition: BESIndent.cc:38
Abstract exception class for the BES with basic string message.
Definition: BESError.h:51
void read_contexts()
Extract the dap protocol from the setConext information.
virtual void set_constraint(BESDataHandlerInterface &dhi)
set the constraint depending on the context
static ostream & LMarg(ostream &strm)
Definition: BESIndent.cc:73
static BESContextManager * TheManager()
#define POST_CONSTRAINT
Definition: BESDataNames.h:43
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:150
void post_append(BESDataHandlerInterface &dhi)
static void UnIndent()
Definition: BESIndent.cc:44
BESContainer * container
pointer to current container in this interface