28 #include "W10nShowPathInfoResponseHandler.h" 29 #include "W10nShowPathInfoCommand.h" 30 #include "W10NNames.h" 31 #include "w10n_utils.h" 34 #include "BESInfoList.h" 36 #include "BESRequestHandlerList.h" 37 #include "BESRequestHandler.h" 39 #include "BESDapNames.h" 40 #include "BESDataNames.h" 41 #include "BESCatalogList.h" 42 #include "BESCatalog.h" 43 #include "BESCatalogEntry.h" 44 #include "BESCatalogUtils.h" 45 #include "BESSyntaxUserError.h" 46 #include "BESNotFoundError.h" 47 #include "BESStopWatch.h" 49 #define W10N_PATH_INFO_RESPONSE "W10nPathInfo" 52 #define VALID_PATH "validPath" 53 #define REMAINDER "remainder" 54 #define IS_DATA "isData" 55 #define IS_FILE "isFile" 56 #define IS_DIR "isDir" 58 W10nShowPathInfoResponseHandler::W10nShowPathInfoResponseHandler(
const string &name) :
63 W10nShowPathInfoResponseHandler::~W10nShowPathInfoResponseHandler()
81 if (BESISDEBUG(TIMING_LOG)) sw.
start(
"W10NShowPathInfoResponseHandler::execute", dhi.
data[REQUEST_ID]);
83 BESDEBUG(W10N_DEBUG_KEY,
"W10NShowPathInfoResponseHandler::execute() - BEGIN" << endl );
85 BESInfo *info = BESInfoList::TheList()->build_info();
86 d_response_object = info;
88 string container = dhi.
data[CONTAINER];
96 throw BESInternalError(
"Not able to find the default catalog.", __FILE__, __LINE__);
99 string::size_type notslash = container.find_first_not_of(
"/", 0);
100 if (notslash != string::npos) {
101 container = container.substr(notslash);
106 string::size_type slash = container.find_first_of(
"/", 0);
107 if (slash != string::npos) {
108 catname = container.substr(0, slash);
118 if (slash != string::npos) {
119 container = container.substr(slash + 1);
122 notslash = container.find_first_not_of(
"/", 0);
123 if (notslash != string::npos) {
124 container = container.substr(notslash);
132 if (container.empty()) container =
"/";
134 BESDEBUG(W10N_DEBUG_KEY,
"W10NShowPathInfoResponseHandler::execute() - w10n_id: " << container << endl );
139 map<string, string> pathInfoAttrs;
140 pathInfoAttrs[PATH] = container;
142 info->begin_tag(W10N_PATH_INFO_RESPONSE, &pathInfoAttrs);
144 string validPath, remainder;
148 w10n::eval_resource_path(container, utils->
get_root_dir(), utils->follow_sym_links(), validPath, isFile, isDir,
156 if (validPath.length() != 0) {
163 string err = (string)
"Failed to find the validPath node " + validPath
164 +
" this should not be possible. Some thing BAD is happening.";
169 list<string> services = entry->get_service_list();
172 if (services.size()) {
173 list<string>::const_iterator si = services.begin();
174 list<string>::const_iterator se = services.end();
175 for (; si != se; si++) {
176 if ((*si) == OPENDAP_SERVICE) isData =
true;
181 map<string, string> validPathAttrs;
182 validPathAttrs[IS_DATA] = isData ?
"true" :
"false";
183 validPathAttrs[IS_FILE] = isFile ?
"true" :
"false";
184 validPathAttrs[IS_DIR] = isDir ?
"true" :
"false";
186 info->add_tag(VALID_PATH, validPath, &validPathAttrs);
187 info->add_tag(REMAINDER, remainder);
189 info->end_tag(W10N_PATH_INFO_RESPONSE);
192 info->end_response();
194 BESDEBUG(W10N_DEBUG_KEY,
"W10nShowPathInfoResponseHandler::execute() - END" << endl );
210 if (d_response_object) {
211 BESInfo *info = dynamic_cast<BESInfo *>(d_response_object);
225 strm << BESIndent::LMarg <<
"W10nShowPathInfoResponseHandler::dump - (" << (
void *)
this <<
")" << std::endl;
228 BESIndent::UnIndent();
232 W10nShowPathInfoResponseHandler::W10nShowPathInfoResponseBuilder(
const string &name)
exception thrown if inernal error encountered
virtual void execute(BESDataHandlerInterface &dhi)
executes the command 'show catalog|leaves [for <node>];' by returning nodes or leaves at the top leve...
virtual void dump(ostream &strm) const
dumps information about this object
virtual void transmit(BESTransmitter *transmitter, BESDataHandlerInterface &dhi)=0
transmit the informational object
virtual BESCatalogEntry * show_catalog(const std::string &container, BESCatalogEntry *entry)=0
virtual bool start(string name)
virtual void transmit(BESTransmitter *transmitter, BESDataHandlerInterface &dhi)
transmit the response object built by the execute command using the specified transmitter object
handler object that knows how to create a specific response object
informational response object
virtual std::string default_catalog_name() const
The name of the default catalog.
const std::string & get_root_dir() const
Get the root directory of the catalog.
Catalogs provide a hierarchical organization for data.
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 begin_response(const string &response_name, BESDataHandlerInterface &dhi)
begin the informational response
virtual void dump(std::ostream &strm) const
dumps information about this object
virtual BESCatalog * default_catalog() const
The the default catalog.
virtual BESCatalogUtils * get_catalog_utils() const
Get a pointer to the utilities, customized for this catalog.
response handler that returns nodes or leaves within the catalog either at the root or at a specified...
static BESCatalogList * TheCatalogList()
Get the singleton BESCatalogList instance.