bes  Updated for version 3.20.10
BESXMLDefaultCommands.cc
1 // BESXMLDefaultCommands.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 "BESXMLDefaultCommands.h"
38 
39 #include "BESResponseNames.h"
40 #include "BESResponseHandlerList.h"
41 
42 #include "BESXMLShowCommand.h"
43 #include "BESXMLShowErrorCommand.h"
44 #include "BESXMLSetContextCommand.h"
45 #include "BESXMLSetContainerCommand.h"
46 #include "BESXMLDefineCommand.h"
47 #include "BESXMLGetCommand.h"
48 #include "BESXMLDeleteContainerCommand.h"
49 #include "BESXMLDeleteContainersCommand.h"
50 #include "BESXMLDeleteDefinitionCommand.h"
51 #include "BESXMLDeleteDefinitionsCommand.h"
52 
53 #include "ShowPathInfoCommand.h"
54 #include "ShowBesKeyCommand.h"
55 #include "ShowBesKeyResponseHandler.h"
56 
57 #include "SetContextsNames.h"
58 #include "XMLSetContextsCommand.h"
59 
60 #if USE_CONTEXTS_RESPONSE_HANDLER
61 #include "SetContextsResponseHandler.h"
62 #else
63 #include "NullResponseHandler.h"
64 #endif
65 
66 #include "BESDebug.h"
67 
68 using std::endl;
69 using namespace bes;
70 
74 {
75  BESDEBUG("besxml", "Initializing default commands:" << endl);
76 
77  BESXMLCommand::add_command( SHOW_CONTEXT_STR, BESXMLShowCommand::CommandBuilder);
78  BESXMLCommand::add_command( SHOWDEFS_RESPONSE_STR, BESXMLShowCommand::CommandBuilder);
79  BESXMLCommand::add_command( SHOWCONTAINERS_RESPONSE_STR, BESXMLShowCommand::CommandBuilder);
80  BESXMLCommand::add_command( SHOW_ERROR_STR, BESXMLShowErrorCommand::CommandBuilder);
81  BESXMLCommand::add_command( HELP_RESPONSE_STR, BESXMLShowCommand::CommandBuilder);
82 #ifdef BES_DEVELOPER
83  BESXMLCommand::add_command( PROCESS_RESPONSE_STR, BESXMLShowCommand::CommandBuilder );
84  BESXMLCommand::add_command( CONFIG_RESPONSE_STR, BESXMLShowCommand::CommandBuilder );
85 #endif
86  BESXMLCommand::add_command( VERS_RESPONSE_STR, BESXMLShowCommand::CommandBuilder);
87  BESXMLCommand::add_command( STATUS_RESPONSE_STR, BESXMLShowCommand::CommandBuilder);
88  BESXMLCommand::add_command( SERVICE_RESPONSE_STR, BESXMLShowCommand::CommandBuilder);
89 
90  BESXMLCommand::add_command( SET_CONTEXT_STR, BESXMLSetContextCommand::CommandBuilder);
91 
92  // A new command, added both for utility and to learn. jhrg 2/8/18
93  BESXMLCommand::add_command( SET_CONTEXTS_STR, XMLSetContextsCommand::CommandBuilder);
94 
95 #if USE_CONTEXTS_RESPONSE_HANDLER
96  // And we can add the ResponseHandler here too, so it can all be in the same dir. jhrg 2/9/18
97  BESResponseHandlerList::TheList()->add_handler(SET_CONTEXTS_ACTION, SetContextsResponseHandler::SetContextsResponseBuilder);
98 #else
99  BESResponseHandlerList::TheList()->add_handler(NULL_ACTION, NullResponseHandler::NullResponseBuilder);
100 #endif
101 
102  BESXMLCommand::add_command( SETCONTAINER_STR, BESXMLSetContainerCommand::CommandBuilder);
103 
104  BESXMLCommand::add_command( DEFINE_RESPONSE_STR, BESXMLDefineCommand::CommandBuilder);
105 
106  BESXMLCommand::add_command( GET_RESPONSE, BESXMLGetCommand::CommandBuilder);
107 
108  BESXMLCommand::add_command( DELETE_CONTAINER_STR, BESXMLDeleteContainerCommand::CommandBuilder);
109  BESXMLCommand::add_command( DELETE_CONTAINERS_STR, BESXMLDeleteContainersCommand::CommandBuilder);
110 
111  BESXMLCommand::add_command( DELETE_DEFINITION_STR, BESXMLDeleteDefinitionCommand::CommandBuilder);
112  BESXMLCommand::add_command( DELETE_DEFINITIONS_STR, BESXMLDeleteDefinitionsCommand::CommandBuilder);
113 
114  BESDEBUG( "besxml", " adding " << SHOW_PATH_INFO_RESPONSE_STR << " command" << endl ) ;
115  BESXMLCommand::add_command( SHOW_PATH_INFO_RESPONSE_STR, ShowPathInfoCommand::CommandBuilder ) ;
116 
117  BESXMLCommand::add_command( SHOW_BES_KEY_RESPONSE_STR, ShowBesKeyCommand::CommandBuilder ) ;
118 
119  BESDEBUG("besxml", " adding " << SHOW_BES_KEY_RESPONSE << " response handler" << endl ) ;
120  BESResponseHandlerList::TheList()->add_handler( SHOW_BES_KEY_RESPONSE, ShowBesKeyResponseHandler::ShowBesKeyResponseBuilder ) ;
121 
122  BESDEBUG("besxml", "Done Initializing default commands:" << endl);
123 
124  return 0;
125 }
126 
131 {
132  BESDEBUG("besxml", "Removing default commands:" << endl);
133 
134  BESXMLCommand::del_command( GET_RESPONSE);
135  BESXMLCommand::del_command( SHOW_CONTEXT_STR);
136  BESXMLCommand::del_command( SHOWDEFS_RESPONSE_STR);
137  BESXMLCommand::del_command( SHOWCONTAINERS_RESPONSE_STR);
138  BESXMLCommand::del_command( HELP_RESPONSE_STR);
139 #ifdef BES_DEVELOPER
140  BESXMLCommand::del_command( PROCESS_RESPONSE_STR );
141  BESXMLCommand::del_command( CONFIG_RESPONSE_STR );
142 #endif
143  BESXMLCommand::del_command( VERS_RESPONSE_STR);
144  BESXMLCommand::del_command( STATUS_RESPONSE_STR);
145 
146  BESXMLCommand::del_command( SET_CONTEXT_STR);
147  BESXMLCommand::del_command( SET_CONTEXTS_STR);
148 #if USE_CONTEXTS_RESPONSE_HANDLER
149  BESResponseHandlerList::TheList()->remove_handler(SET_CONTEXTS_ACTION);
150 #else
151  BESResponseHandlerList::TheList()->remove_handler(NULL_ACTION);
152 #endif
153  BESXMLCommand::del_command( SETCONTAINER_STR);
154  BESXMLCommand::del_command( DEFINE_RESPONSE_STR);
155  BESXMLCommand::del_command( DELETE_CONTAINER_STR);
156  BESXMLCommand::del_command( DELETE_CONTAINERS_STR);
157  BESXMLCommand::del_command( DELETE_DEFINITION_STR);
158 
159  BESDEBUG("besxml", "Done Removing default commands:" << endl);
160 
161  return true;
162 }
163 
virtual bool remove_handler(const std::string &handler)
removes a response handler from the list
virtual bool add_handler(const std::string &handler, p_response_handler handler_method)
add a response handler to the list
static void del_command(const std::string &cmd_str)
Deletes the command called cmd_str from the list of possible commands.
static void add_command(const std::string &cmd_str, p_xmlcmd_builder cmd)
Add a command to the possible commands allowed by this BES.
static int terminate(void)
Removes the default set of BES XML commands from the list of possible commands.
static int initialize(int argc, char **argv)
Loads the default set of BES XML commands.