bes  Updated for version 3.17.0
BESDDSResponseHandler.cc
1 // BESDDSResponseHandler.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 "BESDDSResponseHandler.h"
34 #include "BESDDSResponse.h"
35 #include "BESRequestHandlerList.h"
36 #include "BESDapNames.h"
37 #include "BESDataNames.h"
38 //#include "BESDapTransmit.h"
39 
40 #include "BESDebug.h"
41 
42 BESDDSResponseHandler::BESDDSResponseHandler(const string &name) :
43  BESResponseHandler(name)
44 {
45 }
46 
47 BESDDSResponseHandler::~BESDDSResponseHandler()
48 {
49 }
50 
65 {
66  // NOTE: It is the responsibility of the specific request handler to set
67  // the BaseTypeFactory. It is set to NULL here
68  dhi.action_name = DDS_RESPONSE_STR;
69  DDS *dds = new DDS(NULL, "virtual");
70  BESDDSResponse *bdds = new BESDDSResponse(dds);
71 
72  // Set the DAP protocol version requested by the client
73 
74  dhi.first_container();
75  BESDEBUG("version", "Initial CE: " << dhi.container->get_constraint() << endl);
76 
77  // Keywords were a hack to the protocol and have been dropped. We can get rid of
78  // this keyword code. jhrg 11/6/13
79  dhi.container->set_constraint(dds->get_keywords().parse_keywords(dhi.container->get_constraint()));
80  BESDEBUG("version", "CE after keyword processing: " << dhi.container->get_constraint() << endl);
81 
82  if (dds->get_keywords().has_keyword("dap")) {
83  dds->set_dap_version(dds->get_keywords().get_keyword_value("dap"));
84  }
85  else if (!bdds->get_dap_client_protocol().empty()) {
86  dds->set_dap_version(bdds->get_dap_client_protocol());
87  }
88 
89  _response = bdds;
90  BESRequestHandlerList::TheList()->execute_each(dhi);
91 }
92 
106 {
107  if (_response) {
108  transmitter->send_response(DDS_SERVICE, _response, dhi);
109  }
110 }
111 
118 void BESDDSResponseHandler::dump(ostream &strm) const
119 {
120  strm << BESIndent::LMarg << "BESDDSResponseHandler::dump - (" << (void *) this << ")" << endl;
121  BESIndent::Indent();
123  BESIndent::UnIndent();
124 }
125 
127 BESDDSResponseHandler::DDSResponseBuilder(const string &name)
128 {
129  return new BESDDSResponseHandler(name);
130 }
131 
string get_dap_client_protocol() const
Return the dap version string sent by the client (e.g., the OLFS)
string get_constraint() const
retrieve the constraint expression for this container
Definition: BESContainer.h:170
Represents an OPeNDAP DDS DAP2 data object within the BES.
virtual void dump(ostream &strm) const
dumps information about this object
handler object that knows how to create a specific response object
virtual void execute_each(BESDataHandlerInterface &dhi)
for each container in the given data handler interface, execute the given request ...
void set_constraint(const string &s)
set the constraint for this container
Definition: BESContainer.h:104
virtual void dump(ostream &strm) const
dumps information about this object
Structure storing information used by the BES to handle the request.
response handler that builds an OPeNDAP DDS response object
void first_container()
set the container pointer to the first container in the containers list
BESContainer * container
pointer to current container in this interface
virtual void execute(BESDataHandlerInterface &dhi)
executes the command &#39;get dds for def_name;&#39; by executing the request for each container in the speci...
virtual void transmit(BESTransmitter *transmitter, BESDataHandlerInterface &dhi)
transmit the response object built by the execute command using the specified transmitter object ...