bes
Updated for version 3.20.6
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
39
using
std::endl;
40
using
std::string;
41
using
std::ostream;
42
59
void
BESDapResponse::read_contexts
()
60
{
61
bool
found =
false
;
62
63
// d_explicit_containers is false by default
64
string
context = BESContextManager::TheManager()->
get_context
(
"dap_explicit_containers"
, found);
65
if
(found) {
66
if
(context ==
"yes"
)
67
d_explicit_containers =
true
;
68
else
if
(context ==
"no"
)
69
d_explicit_containers =
false
;
70
else
71
throw
BESError
(
"dap_explicit_containers must be yes or no"
,
72
BES_SYNTAX_USER_ERROR, __FILE__, __LINE__);
73
}
74
75
if
(!found) {
76
context = BESContextManager::TheManager()->
get_context
(
"dap_format"
, found);
77
if
(found) {
78
if
(context ==
"dap2"
)
79
d_explicit_containers =
false
;
80
else
81
d_explicit_containers =
true
;
82
}
83
}
84
85
context = BESContextManager::TheManager()->
get_context
(
"xdap_accept"
, found);
86
if
(found) d_dap_client_protocol = context;
87
88
context = BESContextManager::TheManager()->
get_context
(
"xml:base"
, found);
89
if
(found) d_request_xml_base = context;
90
91
}
92
100
bool
BESDapResponse::is_dap2
()
101
{
102
return
!d_explicit_containers;
103
}
104
115
void
BESDapResponse::set_constraint
(
BESDataHandlerInterface
&dhi)
116
{
117
if
(dhi.
container
) {
118
if
(
is_dap2
()) {
119
dhi.
data
[POST_CONSTRAINT] = dhi.
container
->
get_constraint
();
120
}
121
else
{
122
BESConstraintFuncs::post_append(dhi);
123
}
124
}
125
}
126
137
void
BESDapResponse::set_dap4_constraint
(
BESDataHandlerInterface
&dhi)
138
{
139
if
(dhi.
container
) {
140
dhi.
data
[DAP4_CONSTRAINT] = dhi.
container
->
get_dap4_constraint
();
141
}
142
}
143
154
void
BESDapResponse::set_dap4_function
(
BESDataHandlerInterface
&dhi)
155
{
156
if
(dhi.
container
) {
157
dhi.
data
[DAP4_FUNCTION] = dhi.
container
->
get_dap4_function
();
158
}
159
}
160
168
void
BESDapResponse::dump
(ostream &strm)
const
169
{
170
strm << BESIndent::LMarg <<
"BESDapResponse::dump - ("
<< (
void
*)
this
<<
")"
<< endl;
171
BESIndent::Indent();
172
strm << BESIndent::LMarg <<
"d_explicit_containers: "
<< d_explicit_containers << endl;
173
strm << BESIndent::LMarg <<
"d_dap_client_protocol: "
<< d_dap_client_protocol << endl;
174
BESIndent::UnIndent();
175
176
BESIndent::UnIndent();
177
}
178
BESDataHandlerInterface::container
BESContainer * container
pointer to current container in this interface
Definition:
BESDataHandlerInterface.h:75
BESDapResponse::dump
virtual void dump(std::ostream &strm) const
dumps information about this object
Definition:
BESDapResponse.cc:168
BESDapResponse::set_dap4_constraint
virtual void set_dap4_constraint(BESDataHandlerInterface &dhi)
set the constraint depending on the context
Definition:
BESDapResponse.cc:137
BESContainer::get_dap4_function
std::string get_dap4_function() const
retrieve the constraint expression for this container
Definition:
BESContainer.h:212
BESDapResponse::set_dap4_function
virtual void set_dap4_function(BESDataHandlerInterface &dhi)
set the constraint depending on the context
Definition:
BESDapResponse.cc:154
BESContainer::get_constraint
std::string get_constraint() const
retrieve the constraint expression for this container
Definition:
BESContainer.h:194
BESDapResponse::read_contexts
void read_contexts()
Extract the dap protocol from the setConext information.
Definition:
BESDapResponse.cc:59
BESDataHandlerInterface::data
std::map< std::string, std::string > data
the map of string data that will be required for the current request.
Definition:
BESDataHandlerInterface.h:90
BESDapResponse::is_dap2
bool is_dap2()
See get_explicit_containers()
Definition:
BESDapResponse.cc:100
BESDapResponse::set_constraint
virtual void set_constraint(BESDataHandlerInterface &dhi)
set the constraint depending on the context
Definition:
BESDapResponse.cc:115
BESContextManager::get_context
virtual std::string get_context(const std::string &name, bool &found)
retrieve the value of the specified context from the BES
Definition:
BESContextManager.cc:77
BESDataHandlerInterface
Structure storing information used by the BES to handle the request.
Definition:
BESDataHandlerInterface.h:56
BESError
Abstract exception class for the BES with basic string message.
Definition:
BESError.h:58
BESContainer::get_dap4_constraint
std::string get_dap4_constraint() const
retrieve the constraint expression for this container
Definition:
BESContainer.h:203
dap
BESDapResponse.cc
Generated by
1.8.17