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
55
void
BESDapResponse::read_contexts
()
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
96
bool
BESDapResponse::is_dap2
()
97
{
98
return
!d_explicit_containers;
99
}
100
111
void
BESDapResponse::set_constraint
(
BESDataHandlerInterface
&dhi)
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
133
void
BESDapResponse::set_dap4_constraint
(
BESDataHandlerInterface
&dhi)
134
{
135
if
(dhi.
container
) {
136
dhi.
data
[DAP4_CONSTRAINT] = dhi.
container
->
get_dap4_constraint
();
137
}
138
}
139
150
void
BESDapResponse::set_dap4_function
(
BESDataHandlerInterface
&dhi)
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
BESDataHandlerInterface::container
BESContainer * container
pointer to current container in this interface
Definition:
BESDataHandlerInterface.h:79
BESDapResponse::set_dap4_constraint
virtual void set_dap4_constraint(BESDataHandlerInterface &dhi)
set the constraint depending on the context
Definition:
BESDapResponse.cc:133
BESContainer::get_dap4_function
string get_dap4_function() const
retrieve the constraint expression for this container
Definition:
BESContainer.h:215
BESDapResponse::dump
virtual void dump(ostream &strm) const
dumps information about this object
Definition:
BESDapResponse.cc:164
BESDapResponse::set_dap4_function
virtual void set_dap4_function(BESDataHandlerInterface &dhi)
set the constraint depending on the context
Definition:
BESDapResponse.cc:150
BESContextManager::get_context
virtual string get_context(const string &name, bool &found)
retrieve the value of the specified context from the BES
Definition:
BESContextManager.cc:73
BESDapResponse::read_contexts
void read_contexts()
Extract the dap protocol from the setConext information.
Definition:
BESDapResponse.cc:55
BESContainer::get_dap4_constraint
string get_dap4_constraint() const
retrieve the constraint expression for this container
Definition:
BESContainer.h:206
BESContainer::get_constraint
string get_constraint() const
retrieve the constraint expression for this container
Definition:
BESContainer.h:197
BESDapResponse::is_dap2
bool is_dap2()
See get_explicit_containers()
Definition:
BESDapResponse.cc:96
BESDapResponse::set_constraint
virtual void set_constraint(BESDataHandlerInterface &dhi)
set the constraint depending on the context
Definition:
BESDapResponse.cc:111
BESDataHandlerInterface::data
map< string, string > data
the map of string data that will be required for the current request.
Definition:
BESDataHandlerInterface.h:94
BESDataHandlerInterface
Structure storing information used by the BES to handle the request.
Definition:
BESDataHandlerInterface.h:60
BESError
Abstract exception class for the BES with basic string message.
Definition:
BESError.h:58
dap
BESDapResponse.cc
Generated by
1.8.16