OPeNDAP Hyrax Back End Server (BES)  Updated for version 3.8.3
BESXMLGetDataDDXCommand.cc
Go to the documentation of this file.
1 // BESXMLGetDataDDXCommand.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 
35 #include "BESDefinitionStorage.h"
36 #include "BESDefine.h"
37 #include "BESDapNames.h"
38 #include "BESResponseNames.h"
39 #include "BESXMLUtils.h"
40 #include "BESUtil.h"
41 #include "BESSyntaxUserError.h"
42 #include "BESDebug.h"
43 
45  : BESXMLGetCommand( base_dhi )
46 {
47 }
48 
55 void
57 {
58  string name ;
59  string value ;
60  map<string, string> props ;
61  BESXMLUtils::GetNodeInfo( node, name, value, props ) ;
62 
63  if( name != GET_RESPONSE )
64  {
65  string err = "The specified command " + name
66  + " is not a get command" ;
67  throw BESSyntaxUserError( err, __FILE__, __LINE__ ) ;
68  }
69 
70  string type = props["type"] ;
71  if( type.empty() || type != DATADDX_SERVICE )
72  {
73  string err = name + " command: data product must be "
74  + DATADDX_SERVICE ;
75  throw BESSyntaxUserError( err, __FILE__, __LINE__ ) ;
76  }
77 
78  parse_basic_get( node, name, type, value, props ) ;
79 
80  // Get the elements for contentStartId and mimeBoundary
81  map<string,string> cprops ;
82  string cname ;
83  string cval ;
84  int elems = 0 ;
85  xmlNode *cnode = BESXMLUtils::GetFirstChild( node, cname, cval, cprops ) ;
86  while( cnode && (elems < 2) )
87  {
88  if( cname == "contentStartId" )
89  {
90  if( !_contentStartId.empty() )
91  {
92  string err = name
93  + " command: contentStartId has multiple values" ;
94  throw BESSyntaxUserError( err, __FILE__, __LINE__ ) ;
95  }
96  _contentStartId = cval ;
97  _str_cmd += " contentStartId " + _contentStartId ;
98  elems++ ;
99  }
100  if( cname == "mimeBoundary" )
101  {
102  if( !_mimeBoundary.empty() )
103  {
104  string err = name
105  + " command: mimeBoundary has multiple values" ;
106  throw BESSyntaxUserError( err, __FILE__, __LINE__ ) ;
107  }
108  _mimeBoundary = cval ;
109  _str_cmd += " mimeBoundary " + _mimeBoundary ;
110  elems++ ;
111  }
112  cprops.clear() ;
113  cnode = BESXMLUtils::GetNextChild( cnode, cname, cval, cprops ) ;
114  }
115  if( _contentStartId.empty() )
116  {
117  string err = name + " command: contentStartId not specified" ;
118  throw BESSyntaxUserError( err, __FILE__, __LINE__ ) ;
119  }
120  if( _mimeBoundary.empty() )
121  {
122  string err = name + " command: mimeBoundary not specified" ;
123  throw BESSyntaxUserError( err, __FILE__, __LINE__ ) ;
124  }
125  _str_cmd += ";" ;
126 
127  // now that we've set the action, go get the response handler for the
128  // action
130 }
131 
137 void
139 {
141  _dhi.data[DATADDX_STARTID] = _contentStartId ;
142  _dhi.data[DATADDX_BOUNDARY] = _mimeBoundary ;
143 }
144 
151 void
152 BESXMLGetDataDDXCommand::dump( ostream &strm ) const
153 {
154  strm << BESIndent::LMarg << "BESXMLGetDataDDXCommand::dump - ("
155  << (void *)this << ")" << endl ;
157  BESXMLCommand::dump( strm ) ;
159 }
160 
163 {
164  return new BESXMLGetDataDDXCommand( base_dhi ) ;
165 }
166 
#define DATADDX_BOUNDARY
Definition: BESDapNames.h:94
static xmlNode * GetFirstChild(xmlNode *node, string &child_name, string &child_value, map< string, string > &child_props)
get the first element child node for the given node
Definition: BESXMLUtils.cc:145
static xmlNode * GetNextChild(xmlNode *child_node, string &next_name, string &next_value, map< string, string > &next_props)
get the next element child node after the given child node
Definition: BESXMLUtils.cc:180
virtual void prep_request()
prepare the get dataddx command
static void GetNodeInfo(xmlNode *node, string &name, string &value, map< string, string > &props)
get the name, value if any, and any properties for the specified node
Definition: BESXMLUtils.cc:105
BESDataHandlerInterface _dhi
Definition: BESXMLCommand.h:57
static void Indent()
Definition: BESIndent.cc:38
error thrown if there is a user syntax error in the request or any other user error ...
BESXMLGetDataDDXCommand(const BESDataHandlerInterface &base_dhi)
virtual void set_response()
The request has been parsed, use the command action name to set the response handler.
virtual void parse_basic_get(xmlNode *node, const string &name, const string &type, const string &value, map< string, string > &props)
static BESXMLCommand * CommandBuilder(const BESDataHandlerInterface &base_dhi)
static ostream & LMarg(ostream &strm)
Definition: BESIndent.cc:73
#define GET_RESPONSE
virtual void prep_request()
Prepare any information needed to execute the request of this get command.
#define DATADDX_SERVICE
Definition: BESDapNames.h:75
Structure storing information used by the BES to handle the request.
virtual void parse_request(xmlNode *node)
parse a get dataddx command.
#define DATADDX_STARTID
Definition: BESDapNames.h:93
map< string, string > data
the map of string data that will be required for the current request.
virtual void dump(ostream &strm) const
dumps information about this object
static void UnIndent()
Definition: BESIndent.cc:44
virtual void dump(ostream &strm) const
dumps information about this object