OPeNDAP Hyrax Back End Server (BES)  Updated for version 3.8.3
BESDataDDXResponseHandler.cc
Go to the documentation of this file.
1 // BESDataDDXResponseHandler.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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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 
34 #include "BESDataDDSResponse.h"
35 #include "BESRequestHandlerList.h"
36 #include "BESDapNames.h"
37 #include "BESDataNames.h"
38 #include "BESDapTransmit.h"
39 
40 #include "BESDebug.h"
41 
43  : BESResponseHandler( name )
44 {
45 }
46 
48 {
49 }
50 
65 void
67 {
68  BESDEBUG( "dap", "Entering BESDataDDXResponseHandler::execute" << endl ) ;
69 
71  // Create the DDS.
72  // NOTE: It is the responsibility of the specific request handler to set
73  // the BaseTypeFactory. It is set to NULL here
74  DataDDS *dds = new DataDDS( NULL, "virtual" ) ;
75  BESDataDDSResponse *bdds = new BESDataDDSResponse( dds ) ;
76  _response = bdds ;
77 
78  // we're actually going to get the data response, it just gets
79  // displayed as a DataDDX
81  dhi.action = DATA_RESPONSE ;
82 
83  // Read keywords from the CE and use those to set the DAP version; maybe
84  // other things. If the dap version(s) are not included in the CE using
85  // keywords, then see if anything was sent in the Request headers (which
86  // the OLFS will parse); the BES includes that info in the BESDapResponse
87  // object.
88 
89  // Set the DAP protocol version requested by the client. 2/25/11 jhrg
90 
91  dhi.first_container();
92  BESDEBUG("version", "Initial CE: " << dhi.container->get_constraint() << endl);
93  dhi.container->set_constraint(dds->get_keywords().parse_keywords(dhi.container->get_constraint()));
94  BESDEBUG("version", "CE after keyword processing: " << dhi.container->get_constraint() << endl);
95 
96  dhi.data[POST_CONSTRAINT] = dds->get_keywords().parse_keywords(dhi.data[POST_CONSTRAINT]);
97  if (dds->get_keywords().has_keyword("dap")) {
98  dds->set_dap_version(dds->get_keywords().get_keyword_value("dap"));
99  }
100  else if (!bdds->get_dap_client_protocol().empty()) {
101  dds->set_dap_version( bdds->get_dap_client_protocol() ) ;
102  }
103 
104  dds->set_request_xml_base( bdds->get_request_xml_base() );
105 
107 
108  // we've got what we want, now set the action back to data ddx
109  dhi.action = DATADDX_RESPONSE ;
110  _response = bdds ;
111 
112  BESDEBUG( "dap", "Leaving BESDataDDXResponseHandler::execute" << endl ) ;
113 }
114 
127 void
130 {
131  if( _response )
132  {
133  transmitter->send_response( DATADDX_SERVICE, _response, dhi ) ;
134  }
135 }
136 
143 void
144 BESDataDDXResponseHandler::dump( ostream &strm ) const
145 {
146  strm << BESIndent::LMarg << "BESDataDDXResponseHandler::dump - ("
147  << (void *)this << ")" << endl ;
149  BESResponseHandler::dump( strm ) ;
151 }
152 
155 {
156  return new BESDataDDXResponseHandler( name ) ;
157 }
158