bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
BESXMLWWWGetCommand.cc
1// BESXMLWWWGetCommand.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 "config.h"
34
35#include "BESXMLWWWGetCommand.h"
36#include "BESDefinitionStorageList.h"
37#include "BESDefinitionStorage.h"
38#include "BESDefine.h"
39#include "BESDataNames.h"
40#include "BESWWWNames.h"
41#include "BESResponseNames.h"
42#include "BESXMLUtils.h"
43#include "BESUtil.h"
44#include "BESSyntaxUserError.h"
45#include "BESDebug.h"
46
47using std::endl;
48using std::ostream;
49using std::string;
50using std::map;
51
52BESXMLWWWGetCommand::BESXMLWWWGetCommand(const BESDataHandlerInterface &base_dhi) :
53 BESXMLGetCommand(base_dhi)
54{
55}
56
64{
65 string name; // element name
66 string value; // node context
67 map<string, string> props; // attributes
68 BESXMLUtils::GetNodeInfo(node, name, value, props);
69
70 if (name != GET_RESPONSE) {
71 string err = "The specified command " + name + " is not a get command";
72 throw BESSyntaxUserError(err, __FILE__, __LINE__);
73 }
74
75 string type = props["type"];
76 if (type.empty() || type != "html_form") {
77 string err = name + " command: data product must be html_form";
78 throw BESSyntaxUserError(err, __FILE__, __LINE__);
79 }
80
81 parse_basic_get(type, props);
82
83 d_xmlcmd_dhi.data[WWW_URL] = props["url"];
84 if (d_xmlcmd_dhi.data[WWW_URL].empty()) {
85 string err = name + " html_form command: missing url property";
86 throw BESSyntaxUserError(err, __FILE__, __LINE__);
87 }
88
89 d_cmd_log_info += " using " + d_xmlcmd_dhi.data[WWW_URL];
90
91 // now that we've set the action, go get the response handler for the
92 // action
94}
95
102void BESXMLWWWGetCommand::dump(ostream &strm) const
103{
104 strm << BESIndent::LMarg << "BESXMLWWWGetCommand::dump - (" << (void *) this << ")" << endl;
105 BESIndent::Indent();
107 BESIndent::UnIndent();
108}
109
111BESXMLWWWGetCommand::CommandBuilder(const BESDataHandlerInterface &base_dhi)
112{
113 return new BESXMLWWWGetCommand(base_dhi);
114}
115
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 parse_basic_get(const std::string &type, std::map< std::string, std::string > &props)
Extract information from the 'props' map.
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
virtual void parse_request(xmlNode *node)
parse a get html_form command.
virtual void dump(std::ostream &strm) const
dumps information about this object