bes  Updated for version 3.17.0
BESDMRResponseHandler.cc
1 // BESDMRResponseHandler.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) 2013 OPeNDAP, Inc.
7 // Author: Patrick West <pwest@rpi.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 OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
24 
25 #include <DMR.h>
26 
27 #include "BESDMRResponseHandler.h"
28 #include "BESDMRResponse.h"
29 #include "BESRequestHandlerList.h"
30 #include "BESDapNames.h"
31 #include "BESDapTransmit.h"
32 #include "BESContextManager.h"
33 
34 BESDMRResponseHandler::BESDMRResponseHandler(const string &name) :
35  BESResponseHandler(name)
36 {
37 }
38 
39 BESDMRResponseHandler::~BESDMRResponseHandler()
40 {
41 }
42 
57 {
58  dhi.action_name = DMR_RESPONSE_STR;
59  DMR *dmr = new DMR();
60 
61  // Here we might set the dap and dmr version if they should be different from
62  // 4.0 and 1.0. jhrg 11/6/13
63 
64  bool found = false;
65  string xml_base = BESContextManager::TheManager()->get_context("xml:base", found);
66  if (found && !xml_base.empty()) {
67  dmr->set_request_xml_base(xml_base);
68  }
69 
70  _response = new BESDMRResponse(dmr);
71  BESRequestHandlerList::TheList()->execute_each(dhi);
72 }
73 
87 {
88  if (_response) {
89  transmitter->send_response(DMR_SERVICE, _response, dhi);
90  }
91 }
92 
99 void BESDMRResponseHandler::dump(ostream &strm) const
100 {
101  strm << BESIndent::LMarg << "BESDMRResponseHandler::dump - (" << (void *) this << ")" << endl;
102  BESIndent::Indent();
104  BESIndent::UnIndent();
105 }
106 
108 BESDMRResponseHandler::DMRResponseBuilder(const string &name)
109 {
110  return new BESDMRResponseHandler(name);
111 }
112 
virtual void transmit(BESTransmitter *transmitter, BESDataHandlerInterface &dhi)
transmit the response object built by the execute command using the specified transmitter object ...
virtual void dump(ostream &strm) const
dumps information about this object
virtual void execute(BESDataHandlerInterface &dhi)
executes the command &#39;get dmr for def_name;&#39; by executing the request for each container in the speci...
response handler that builds an OPeNDAP DMR response object
virtual string get_context(const string &name, bool &found)
retrieve the value of the specified context from the BES
handler object that knows how to create a specific response object
Represents an OPeNDAP DMR DAP4 data object within the BES.
virtual void execute_each(BESDataHandlerInterface &dhi)
for each container in the given data handler interface, execute the given request ...
virtual void dump(ostream &strm) const
dumps information about this object
Structure storing information used by the BES to handle the request.