bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
BESXMLGetDataDDXCommand.cc
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
33#include "BESXMLGetDataDDXCommand.h"
34#include "BESDefinitionStorageList.h"
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
44BESXMLGetDataDDXCommand::BESXMLGetDataDDXCommand(const BESDataHandlerInterface &base_dhi) :
45 BESXMLGetCommand(base_dhi)
46{
47}
48
56{
57 string name; // element name
58 string value; // node context
59 map<string, string> props; // attributes
60 BESXMLUtils::GetNodeInfo(node, name, value, props);
61
62 if (name != GET_RESPONSE) {
63 string err = "The specified command " + name + " is not a get command";
64 throw BESSyntaxUserError(err, __FILE__, __LINE__);
65 }
66
67 string type = props["type"];
68 if (type.empty() || type != DATADDX_SERVICE) {
69 string err = name + " command: data product must be " + DATADDX_SERVICE;
70 throw BESSyntaxUserError(err, __FILE__, __LINE__);
71 }
72
73 parse_basic_get(type, props);
74
75 // Get the elements for contentStartId and mimeBoundary
77 string cname;
78 string cval;
79 int elems = 0;
80 xmlNode *cnode = BESXMLUtils::GetFirstChild(node, cname, cval, cprops);
81 while (cnode && (elems < 2)) {
82 if (cname == "contentStartId") {
83 if (!_contentStartId.empty()) {
84 string err = name + " command: contentStartId has multiple values";
85 throw BESSyntaxUserError(err, __FILE__, __LINE__);
86 }
87 _contentStartId = cval;
88 d_cmd_log_info += " contentStartId " + _contentStartId;
89 elems++;
90 }
91 if (cname == "mimeBoundary") {
92 if (!_mimeBoundary.empty()) {
93 string err = name + " command: mimeBoundary has multiple values";
94 throw BESSyntaxUserError(err, __FILE__, __LINE__);
95 }
96 _mimeBoundary = cval;
97 d_cmd_log_info += " mimeBoundary " + _mimeBoundary;
98 elems++;
99 }
100 cprops.clear();
101 cnode = BESXMLUtils::GetNextChild(cnode, cname, cval, cprops);
102 }
103 if (_contentStartId.empty()) {
104 string err = name + " command: contentStartId not specified";
105 throw BESSyntaxUserError(err, __FILE__, __LINE__);
106 }
107 if (_mimeBoundary.empty()) {
108 string err = name + " command: mimeBoundary not specified";
109 throw BESSyntaxUserError(err, __FILE__, __LINE__);
110 }
111 d_cmd_log_info += ";";
112
113 // now that we've set the action, go get the response handler for the
114 // action
116}
117
124{
126 d_xmlcmd_dhi.data[DATADDX_STARTID] = _contentStartId;
127 d_xmlcmd_dhi.data[DATADDX_BOUNDARY] = _mimeBoundary;
128}
129
137{
138 strm << BESIndent::LMarg << "BESXMLGetDataDDXCommand::dump - (" << (void *) this << ")" << endl;
139 BESIndent::Indent();
141 BESIndent::UnIndent();
142}
143
145BESXMLGetDataDDXCommand::CommandBuilder(const BESDataHandlerInterface &base_dhi)
146{
147 return new BESXMLGetDataDDXCommand(base_dhi);
148}
149
Structure storing information used by the BES to handle the request.
error thrown if there is a user syntax error in the request or any other user error
Base class for the BES's commands.
virtual void dump(std::ostream &strm) const
dumps information about this object
virtual void set_response()
The request has been parsed, use the command action name to set the response handler.
std::string d_cmd_log_info
Used only for the log.
virtual void prep_request()
Prepare any information needed to execute the request of this get command.
virtual void parse_basic_get(const std::string &type, std::map< std::string, std::string > &props)
Extract information from the 'props' map.
virtual void prep_request()
prepare the get dataddx command
virtual void dump(ostream &strm) const
dumps information about this object
virtual void parse_request(xmlNode *node)
parse a get dataddx command.
static void GetNodeInfo(xmlNode *node, std::string &name, std::string &value, std::map< std::string, std::string > &props)
get the name, value if any, and any properties for the specified node
static xmlNode * GetFirstChild(xmlNode *node, std::string &child_name, std::string &child_value, std::map< std::string, std::string > &child_props)
get the first element child node for the given node
static xmlNode * GetNextChild(xmlNode *child_node, std::string &next_name, std::string &next_value, std::map< std::string, std::string > &next_props)
get the next element child node after the given child node
STL class.
STL class.