bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
BESWWWResponseHandler.cc
1// BESWWWResponseHandler.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,2005 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 "config.h"
34
35#include <libdap/DDS.h>
36
37#include "GlobalMetadataStore.h"
38#include "BESWWWResponseHandler.h"
39#include "BESRequestHandlerList.h"
40#include "BESDapNames.h"
41#include "BESWWWNames.h"
42#include "BESWWW.h"
43#include "BESDDSResponse.h"
44#include "BESTransmitter.h"
45
46#include "BESWWWTransmit.h"
47
48using namespace libdap;
49using namespace bes;
50
51BESWWWResponseHandler::BESWWWResponseHandler( const string &name )
53{
54}
55
56BESWWWResponseHandler::~BESWWWResponseHandler()
57{
58}
59
76void
78{
79 dhi.action_name = WWW_RESPONSE_STR;
80
81 dhi.action_name = DDX_RESPONSE_STR;
82
85
86 dhi.first_container();
87 if (mds) lock = mds->is_dds_available(*(dhi.container));
88
89 if (mds && lock()) {
90 DDS *dds = mds->get_dds_object(dhi.container->get_relative_name());
91 BESDDSResponse *bdds = new BESDDSResponse(dds);
92
93#if FORCE_DAP_VERSION_TO_3_2
94 dds->set_dap_version("3.2");
95#else
96 // These values are read from the BESContextManager by the BESDapResponse ctor
97 if (!bdds->get_dap_client_protocol().empty()) {
98 dds->set_dap_version(bdds->get_dap_client_protocol());
99 }
100#endif
101 dds->set_request_xml_base(bdds->get_request_xml_base());
102
103 d_response_object = new BESWWW(bdds);
104 dhi.action = WWW_RESPONSE;
105 }
106 else {
107 // Make a blank DDS. It is the responsibility of the specific request
108 // handler to set the BaseTypeFactory. It is set to NULL here
109 DDS *dds = new DDS(NULL, "virtual");
110
111 BESDDSResponse *bdds = new BESDDSResponse(dds);
112 d_response_name = DDS_RESPONSE;
113 dhi.action = DDS_RESPONSE;
114
115#if FORCE_DAP_VERSION_TO_3_2
116 dds->set_dap_version("3.2");
117#else
118 if (!bdds->get_dap_client_protocol().empty()) {
119 dds->set_dap_version(bdds->get_dap_client_protocol());
120 }
121#endif
122
123 dds->set_request_xml_base(bdds->get_request_xml_base());
124
125 d_response_object = bdds;
126
127 BESRequestHandlerList::TheList()->execute_each(dhi);
128
129 if (mds) {
130 dhi.first_container(); // must reset container; execute_each() iterates over all of them
131 mds->add_responses(static_cast<BESDDSResponse*>(d_response_object)->get_dds(),
133 }
134
135 d_response_object = new BESWWW(bdds);
136 dhi.action = WWW_RESPONSE;
137 }
138
139 // Original code follows
140#if 0
141 // Create the DDS.
142 // NOTE: It is the responsibility of the specific request handler to set
143 // the BaseTypeFactory. It is set to NULL here
144 DDS *dds = new DDS(NULL, "virtual");
145 BESDDSResponse *bdds = new BESDDSResponse(dds);
146 d_response_object = bdds;
147 d_response_name = DDS_RESPONSE;
148 dhi.action = DDS_RESPONSE;
149 BESRequestHandlerList::TheList()->execute_each(dhi);
150#if 0
151 // Fill the DAS
152 DAS *das = new DAS;
153 BESDASResponse *bdas = new BESDASResponse(das);
154 d_response_object = bdas;
155 d_response_name = DAS_RESPONSE;
156 dhi.action = DAS_RESPONSE;
157 BESRequestHandlerList::TheList()->execute_each(dhi);
158#endif
159 BESWWW *www = new BESWWW(/*bdas,*/bdds);
160 d_response_object = www;
161 dhi.action = WWW_RESPONSE;
162#endif
163
164}
165
180{
181 if (d_response_object) {
182 transmitter->send_response(WWW_TRANSMITTER, d_response_object, dhi);
183 }
184}
185
186BESResponseHandler *BESWWWResponseHandler::
187WWWResponseBuilder( const string &handler_name )
188{
189 return new BESWWWResponseHandler( handler_name ) ;
190}
std::string get_relative_name() const
Get the relative name of the object in this container.
Represents an OPeNDAP DAS DAP2 data object within the BES.
Holds a DDS object within the BES.
std::string get_dap_client_protocol() const
Return the dap version string sent by the client (e.g., the OLFS)
std::string get_request_xml_base() const
Return the xml:base URL for this request.
Structure storing information used by the BES to handle the request.
std::string action
the response object requested, e.g. das, dds
void first_container()
set the container pointer to the first container in the containers list
BESContainer * container
pointer to current container in this interface
handler object that knows how to create a specific response object
response handler that builds an OPeNDAP WWW response object
virtual void execute(BESDataHandlerInterface &dhi)
executes the command 'get html_form for <def_name>;' by executing the request for each container in t...
virtual void transmit(BESTransmitter *transmitter, BESDataHandlerInterface &dhi)
transmit the response object built by the execute command using the specified transmitter object
container for a DAS and DDS needed to write out the usage information for a dataset.
Definition BESWWW.h:52
Store the DAP metadata responses.
virtual libdap::DDS * get_dds_object(const std::string &name)
Build a DDS object from the cached Response.
static GlobalMetadataStore * get_instance()
virtual MDSReadLock is_dds_available(const std::string &name)
Is the DDS response for.
virtual bool add_responses(libdap::DDS *dds, const std::string &name)
Add the DAP2 metadata responses using a DDS.
Unlock and close the MDS item when the ReadLock goes out of scope.