bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
BESXMLCommand.cc
1// BESXMLCommand.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., 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 <iostream>
36
37#include "BESXMLCommand.h"
38#include "BESResponseHandlerList.h"
39#include "BESSyntaxUserError.h"
40#include "BESDataNames.h"
41#include "BESLog.h"
42
43using std::endl;
44using std::ostream;
45using std::map;
46using std::string;
47
48map<string, p_xmlcmd_builder> BESXMLCommand::factory;
49
58{
59 d_xmlcmd_dhi.make_copy(base_dhi);
60}
61
66{
67 d_xmlcmd_dhi.response_handler = BESResponseHandlerList::TheList()->find_handler(d_xmlcmd_dhi.action);
68 if (!d_xmlcmd_dhi.response_handler) {
69 throw BESSyntaxUserError(string("Command '") + d_xmlcmd_dhi.action
70 + "' does not have a registered response handler", __FILE__, __LINE__);
71 }
72
73 d_xmlcmd_dhi.data[LOG_INFO] = d_cmd_log_info;
74
75 VERBOSE(d_xmlcmd_dhi.data[REQUEST_FROM] + " [" + d_xmlcmd_dhi.data[LOG_INFO] + "] parsed" );
76}
77
88void BESXMLCommand::add_command(const string &cmd_str, p_xmlcmd_builder cmd)
89{
90 BESXMLCommand::factory[cmd_str] = cmd;
91}
92
98void BESXMLCommand::del_command(const string &cmd_str)
99{
100 BESXMLCommand::cmd_iter iter = BESXMLCommand::factory.find(cmd_str);
101 if (iter != BESXMLCommand::factory.end()) {
102 BESXMLCommand::factory.erase(iter);
103 }
104}
105
110p_xmlcmd_builder BESXMLCommand::find_command(const string &cmd_str)
111{
112 return BESXMLCommand::factory[cmd_str];
113}
114
121void BESXMLCommand::dump(ostream &strm) const
122{
123 strm << BESIndent::LMarg << "BESXMLCommand::dump - (" << (void *) this << ")" << endl;
124 BESIndent::Indent();
125 BESIndent::UnIndent();
126}
127
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
static void del_command(const std::string &cmd_str)
Deletes the command called cmd_str from the list of possible commands.
BESXMLCommand(const BESDataHandlerInterface &base_dhi)
Creates a BESXMLCommand document given a base data handler interface object.
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.
static void add_command(const std::string &cmd_str, p_xmlcmd_builder cmd)
Add a command to the possible commands allowed by this BES.
std::string d_cmd_log_info
Used only for the log.
static p_xmlcmd_builder find_command(const std::string &cmd_str)
Find the BESXMLCommand creation function with the given name.