OPeNDAP Hyrax Back End Server (BES)  Updated for version 3.8.3
NCMLCacheAggXMLCommand.cc
Go to the documentation of this file.
1 // 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 
39 using std::string;
40 
41 namespace ncml_module {
42 
44  BESXMLCommand(baseDHI)
45 {
46 }
47 
48 /* virtual */
50 {
51 }
52 
53 /* virtual */
55 {
56  BESDEBUG(ModuleConstants::NCML_NAME, "NCMLCacheAggXMLCommand::parse_request() called...." << endl);
57 
58  string cmdName;
59  string contentValue;
60  map<string, string> attrs;
61  BESXMLUtils::GetNodeInfo(pNode, cmdName, contentValue, attrs);
62  if (cmdName != ModuleConstants::CACHE_AGG_RESPONSE) {
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.
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
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 */
110 void NCMLCacheAggXMLCommand::dump(ostream& strm) const
111 {
112  strm << BESIndent::LMarg << "NCMLCacheAggXMLCommand::dump - (" << (void *) this << ")" << endl;
114  BESXMLCommand::dump(strm);
116 }
117 
118 /* static */
121 {
122  return new NCMLCacheAggXMLCommand(baseDHI);
123 }
124 
126 
128  BESResponseHandler(name)
129 {
130  BESDEBUG("ncml", "NCMLCacheAggResponseHandler::NCMLCacheAggResponseHandler() called..." << endl);
131 }
132 
133 /* virtual */
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 */
156 void NCMLCacheAggResponseHandler::dump(ostream & /* strm */) const
157 {
158  BESDEBUG("ncml",
159  "NCMLCacheAggResponseHandler::dump() called for command: " << ModuleConstants::CACHE_AGG_RESPONSE << endl);
160 }
161 
162 /* static */
165 {
166  return new NCMLCacheAggResponseHandler(name);
167 }
168 
169 }
170 ;
171 // namespace ncml_module
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
NCMLCacheAggXMLCommand(const BESDataHandlerInterface &baseDHI)
virtual void parse_request(xmlNode *pNode)
Parse the XML request document begining at the given node.
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
An abstract superclass for NCMLArray that handles the non-parameterized functionality and allows u...
static BESXMLCommand * makeInstance(const BESDataHandlerInterface &baseDHI)
virtual bool has_response()
Has a response handler been created given the request document?
static const std::string CACHE_AGG_RESPONSE
Response name in the DHI for the cache of aggregations command.
static const std::string CACHE_AGG_LOCATION_DATA_KEY
Key in the dhi.data[] map where the location is stored.
static void Indent()
Definition: BESIndent.cc:38
virtual void set_response()
The request has been parsed, use the command action name to set the response handler.
handler object that knows how to create a specific response object
#define THROW_NCML_PARSE_ERROR(parseLine, msg)
Definition: NCMLDebug.h:69
static ostream & LMarg(ostream &strm)
Definition: BESIndent.cc:73
static const std::string CACHE_AGG_LOCATION_XML_ATTR
Name of the attribute in the cacheAgg XML command where the filename to do the caching on is located...
Structure storing information used by the BES to handle the request.
map< string, string > data
the map of string data that will be required for the current request.
virtual void execute(BESDataHandlerInterface &dhi)
knows how to build a requested response object
#define BESDEBUG(x, y)
macro used to send debug information to the debug stream
Definition: BESDebug.h:64
static void UnIndent()
Definition: BESIndent.cc:44
static const std::string NCML_NAME
The name used to specify an ncml file.
string action
the response object requested, e.g.
static BESResponseHandler * makeInstance(const string &name)
virtual void dump(ostream &strm) const
dumps information about this object
virtual void dump(ostream &strm) const
dumps information about this 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 dump(ostream &strm) const
dumps information about this object