bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
NCMLCacheAggXMLCommand.cc
1
2// This file is part of the "NcML Module" project, a BES module designed
3// to allow NcML files to be used to be used as a wrapper to add
4// AIS to existing datasets of any format.
5//
6// Copyright (c) 2010 OPeNDAP, Inc.
7// Author: Michael Johnson <m.johnson@opendap.org>
8//
9// For more information, please also see the main website: http://opendap.org/
10//
11// This library is free software; you can redistribute it and/or
12// modify it under the terms of the GNU Lesser General Public
13// License as published by the Free Software Foundation; either
14// version 2.1 of the License, or (at your option) any later version.
15//
16// This library is distributed in the hope that it will be useful,
17// but WITHOUT ANY WARRANTY; without even the implied warranty of
18// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19// Lesser General Public License for more details.
20//
21// You should have received a copy of the GNU Lesser General Public
22// License along with this library; if not, write to the Free Software
23// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24//
25// Please see the files COPYING and COPYRIGHT for more information on the GLPL.
26//
27// You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
29#include "NCMLCacheAggXMLCommand.h"
30
31#include "BESXMLUtils.h"
32#include "BESUtil.h"
33#include "BESSyntaxUserError.h"
34#include "BESDebug.h"
35
36#include "NCMLDebug.h"
37#include "NCMLResponseNames.h"
38
39using std::string;
40
41namespace ncml_module {
42
43NCMLCacheAggXMLCommand::NCMLCacheAggXMLCommand(const BESDataHandlerInterface& baseDHI) :
44 BESXMLCommand(baseDHI)
45{
46}
47
48/* virtual */
49NCMLCacheAggXMLCommand::~NCMLCacheAggXMLCommand()
50{
51}
52
53/* virtual */
55{
56 BESDEBUG(ModuleConstants::NCML_NAME, "NCMLCacheAggXMLCommand::parse_request() called...." << endl);
57
58 string cmdName;
59 string contentValue;
61 BESXMLUtils::GetNodeInfo(pNode, cmdName, contentValue, attrs);
63 THROW_NCML_PARSE_ERROR(-1, "Got unexpected command name=" + cmdName);
64 }
65
66 if (!contentValue.empty()) {
67 THROW_NCML_PARSE_ERROR(-1, cmdName + ": should not have xml content!");
68 }
69
70 // Grab the filename we are to run on.
72
73 // It had to be there, or it's an error.
74 if (d_xmlcmd_dhi.data[ModuleConstants::CACHE_AGG_LOCATION_DATA_KEY].empty()) {
75 THROW_NCML_PARSE_ERROR(-1,
76 cmdName + ": we did find the required aggregation location specified in the attribute="
77 + ModuleConstants::CACHE_AGG_LOCATION_XML_ATTR + " and cannot continue the caching.");
78 }
79
80 string childCmdName;
81 string childContentValue;
82 map<string, string> childAttrs;
83 xmlNode *pChildNode = BESXMLUtils::GetFirstChild(pNode, childCmdName, childContentValue, childAttrs);
84 if (pChildNode) {
85 THROW_NCML_PARSE_ERROR(-1, cmdName + ": should not have child elements!");
86 }
87
88 if (!childAttrs.empty()) {
89 THROW_NCML_PARSE_ERROR(-1, cmdName + ": should not have attributes!");
90 }
91
92 // Grab the response handler for this action
93 d_xmlcmd_dhi.action = ModuleConstants::CACHE_AGG_RESPONSE;
95}
96
97/* virtual */
99{
100 return true;
101}
102
103/* virtual */
105{
106 BESDEBUG(ModuleConstants::NCML_NAME, "NCMLCacheAggXMLCommand::prep_request() called..." << endl);
107}
108
109/* virtual */
110void NCMLCacheAggXMLCommand::dump(ostream& strm) const
111{
112 strm << BESIndent::LMarg << "NCMLCacheAggXMLCommand::dump - (" << (void *) this << ")" << endl;
113 BESIndent::Indent();
115 BESIndent::UnIndent();
116}
117
118/* static */
120NCMLCacheAggXMLCommand::makeInstance(const BESDataHandlerInterface& baseDHI)
121{
122 return new NCMLCacheAggXMLCommand(baseDHI);
123}
124
126
127NCMLCacheAggResponseHandler::NCMLCacheAggResponseHandler(const string &name) :
129{
130 BESDEBUG("ncml", "NCMLCacheAggResponseHandler::NCMLCacheAggResponseHandler() called..." << endl);
131}
132
133/* virtual */
134NCMLCacheAggResponseHandler::~NCMLCacheAggResponseHandler()
135{
136}
137
138/* virtual */
140{
141 BESDEBUG("ncml",
142 "NCMLCacheAggResponseHandler::execute() called for command:" << ModuleConstants::CACHE_AGG_RESPONSE << endl);
143
144 const std::string& loc = dhi.data[ModuleConstants::CACHE_AGG_LOCATION_DATA_KEY];
145 BESDEBUG("ncml", "We got a cacheAgg request for the aggregation location = " << loc << endl);
146}
147
148/* virtual */
150{
151 BESDEBUG("ncml",
152 "NCMLCacheAggResponseHandler::transmit() called for command: " << ModuleConstants::CACHE_AGG_RESPONSE << endl);
153}
154
155/* virtual */
156void NCMLCacheAggResponseHandler::dump(ostream & /* strm */) const
157{
158 BESDEBUG("ncml",
159 "NCMLCacheAggResponseHandler::dump() called for command: " << ModuleConstants::CACHE_AGG_RESPONSE << endl);
160}
161
162/* static */
164NCMLCacheAggResponseHandler::makeInstance(const string &name)
165{
166 return new NCMLCacheAggResponseHandler(name);
167}
168
169}
170;
171// namespace ncml_module
Structure storing information used by the BES to handle the request.
std::map< std::string, std::string > data
the map of string data that will be required for the current request.
handler object that knows how to create a specific response object
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.
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
STL class.
virtual void execute(BESDataHandlerInterface &dhi)
knows how to build a requested response object
virtual void transmit(BESTransmitter *pTransmitter, BESDataHandlerInterface &dhi)
transmit the response object built by the execute command using the specified transmitter object
virtual void prep_request()
Prepare any information needed to execute the request of this command.
virtual void parse_request(xmlNode *pNode)
Parse the XML request document beginning at the given node.
virtual bool has_response()
Does this command return a response to the client?
STL class.
NcML Parser for adding/modifying/removing metadata (attributes) to existing local datasets using NcML...
static const std::string CACHE_AGG_RESPONSE
static const std::string CACHE_AGG_LOCATION_XML_ATTR
static const std::string NCML_NAME
static const std::string CACHE_AGG_LOCATION_DATA_KEY