34#include <BESCatalogDirectory.h>
35#include <BESCatalogList.h>
36#include <BESContainerStorageList.h>
37#include <BESFileContainerStorage.h>
38#include <BESDapService.h>
40#include <BESRequestHandlerList.h>
41#include <BESResponseHandlerList.h>
42#include <BESResponseNames.h>
43#include <BESXMLCommand.h>
44#include <BESContainerStorageList.h>
45#include <TheBESKeys.h>
46#include <BESInternalError.h>
48#include "NCMLModule.h"
49#include "NCMLRequestHandler.h"
50#include "NCMLResponseNames.h"
54#include "NCMLCacheAggXMLCommand.h"
55#include "NCMLContainerStorage.h"
63static const char*
const NCML_CATALOG =
"catalog";
65void NCMLModule::initialize(
const string &modname)
67 BESDEBUG(modname,
"Initializing NCML Module " << modname << endl);
69 BESRequestHandlerList::TheList()->add_handler(modname,
new NCMLRequestHandler(modname));
75 addCommandAndResponseHandlers(modname);
80 if (!BESCatalogList::TheCatalogList()->ref_catalog(NCML_CATALOG)) {
81 BESCatalogList::TheCatalogList()->add_catalog(
new BESCatalogDirectory(NCML_CATALOG));
84 if (!BESContainerStorageList::TheList()->ref_persistence(NCML_CATALOG)) {
85 BESFileContainerStorage *csc =
new BESFileContainerStorage(NCML_CATALOG);
86 BESContainerStorageList::TheList()->add_persistence(csc);
91 BESContainerStorageList::TheList()->add_persistence(
new NCMLContainerStorage(modname));
93 const string key =
"NCML.TempDirectory";
97 if (!found || val.empty() || val ==
"/") {
98 string err = (string)
"The parameter " + key +
" must be set to use the NCML module";
99 throw BESInternalError(err, __FILE__, __LINE__);
102 NCMLContainerStorage::NCML_TempDir = val;
107 BESDEBUG(modname,
"Done Initializing NCML Module " << modname << endl);
110void NCMLModule::terminate(
const string &modname)
112 BESDEBUG(modname,
"Cleaning NCML module " << modname << endl);
114 BESRequestHandler *rh = BESRequestHandlerList::TheList()->remove_handler(modname);
120 removeCommandAndResponseHandlers();
123 BESContainerStorageList::TheList()->deref_persistence(NCML_CATALOG);
125 BESContainerStorageList::TheList()->deref_persistence(modname);
127 BESCatalogList::TheCatalogList()->deref_catalog(NCML_CATALOG);
132 BESDEBUG(modname,
"Done Cleaning NCML module " << modname << endl);
136BESAbstractModule *maker()
144 strm << BESIndent::LMarg <<
"NCMLModule::dump - (" << (
void *)
this <<
")" << endl;
149void NCMLModule::addCommandAndResponseHandlers(
const string& modname)
151 BESDEBUG(modname,
"Adding module extensions..." << endl);
152 addCacheAggCommandAndResponseHandlers(modname);
153 BESDEBUG(modname,
"... done adding module extensions." << endl);
156void NCMLModule::addCacheAggCommandAndResponseHandlers(
const string& modname)
160 BESDEBUG( modname,
" adding "
162 <<
" response handler" << endl );
163 BESResponseHandlerList::TheList()->add_handler(cmdName, NCMLCacheAggResponseHandler::makeInstance);
165 BESDEBUG(modname,
" adding " << cmdName <<
" command" << endl );
169void NCMLModule::removeCommandAndResponseHandlers()
172 removeCacheAggCommandAndResponseHandlers();
176void NCMLModule::removeCacheAggCommandAndResponseHandlers()
181 <<
" response handler" << endl );
182 BESResponseHandlerList::TheList()->remove_handler(cmdName);
static void handle_dap_service(const std::string &handler)
static function to register a handler to handle the dap services
static void Register(const std::string &flagName)
register the specified debug flag
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.
void get_value(const std::string &s, std::string &val, bool &found)
Retrieve the value of a given key, if set.
static TheBESKeys * TheKeys()
Access to the singleton.
virtual void dump(std::ostream &strm) const
dump the contents of this object to the specified ostream
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 NCML_NAME