30#include "W10nShowPathInfoResponseHandler.h"
31#include "W10nShowPathInfoCommand.h"
33#include "w10n_utils.h"
36#include "BESInfoList.h"
38#include "BESRequestHandlerList.h"
39#include "BESRequestHandler.h"
41#include "BESDapNames.h"
42#include "BESDataNames.h"
43#include "BESCatalogList.h"
44#include "BESCatalog.h"
45#include "BESCatalogEntry.h"
46#include "BESCatalogUtils.h"
47#include "BESSyntaxUserError.h"
48#include "BESNotFoundError.h"
49#include "BESStopWatch.h"
51#define W10N_PATH_INFO_RESPONSE "W10nPathInfo"
54#define VALID_PATH "validPath"
55#define REMAINDER "remainder"
56#define IS_DATA "isData"
57#define IS_FILE "isFile"
60W10nShowPathInfoResponseHandler::W10nShowPathInfoResponseHandler(
const string &name) :
65W10nShowPathInfoResponseHandler::~W10nShowPathInfoResponseHandler()
85 BESDEBUG(W10N_DEBUG_KEY,
"W10NShowPathInfoResponseHandler::execute() - BEGIN" << endl );
87 BESInfo *info = BESInfoList::TheList()->build_info();
88 d_response_object = info;
90 string container = dhi.
data[CONTAINER];
98 throw BESInternalError(
"Not able to find the default catalog.", __FILE__, __LINE__);
101 string::size_type notslash = container.find_first_not_of(
"/", 0);
102 if (notslash != string::npos) {
103 container = container.substr(notslash);
108 string::size_type slash = container.find_first_of(
"/", 0);
109 if (slash != string::npos) {
110 catname = container.substr(0, slash);
120 if (slash != string::npos) {
121 container = container.substr(slash + 1);
124 notslash = container.find_first_not_of(
"/", 0);
125 if (notslash != string::npos) {
126 container = container.substr(notslash);
134 if (container.empty()) container =
"/";
136 BESDEBUG(W10N_DEBUG_KEY,
"W10NShowPathInfoResponseHandler::execute() - w10n_id: " << container << endl );
141 map<string, string> pathInfoAttrs;
142 pathInfoAttrs[PATH] = container;
144 info->begin_tag(W10N_PATH_INFO_RESPONSE, &pathInfoAttrs);
146 string validPath, remainder;
150 w10n::eval_resource_path(container, utils->
get_root_dir(), utils->follow_sym_links(), validPath, isFile, isDir,
158 if (validPath.length() != 0) {
165 string err = (string)
"Failed to find the validPath node " + validPath
166 +
" this should not be possible. Some thing BAD is happening.";
171 list<string> services = entry->get_service_list();
174 if (services.size()) {
175 list<string>::const_iterator si = services.begin();
176 list<string>::const_iterator se = services.end();
177 for (; si != se; si++) {
178 if ((*si) == OPENDAP_SERVICE) isData =
true;
183 map<string, string> validPathAttrs;
184 validPathAttrs[IS_DATA] = isData ?
"true" :
"false";
185 validPathAttrs[IS_FILE] = isFile ?
"true" :
"false";
186 validPathAttrs[IS_DIR] = isDir ?
"true" :
"false";
188 info->add_tag(VALID_PATH, validPath, &validPathAttrs);
189 info->add_tag(REMAINDER, remainder);
191 info->end_tag(W10N_PATH_INFO_RESPONSE);
194 info->end_response();
196 BESDEBUG(W10N_DEBUG_KEY,
"W10nShowPathInfoResponseHandler::execute() - END" << endl );
212 if (d_response_object) {
227 strm << BESIndent::LMarg <<
"W10nShowPathInfoResponseHandler::dump - (" << (
void *)
this <<
")" << std::endl;
230 BESIndent::UnIndent();
234W10nShowPathInfoResponseHandler::W10nShowPathInfoResponseBuilder(
const string &name)
virtual BESCatalog * default_catalog() const
The the default catalog.
virtual std::string default_catalog_name() const
The name of the default catalog.
static BESCatalogList * TheCatalogList()
Get the singleton BESCatalogList instance.
const std::string & get_root_dir() const
Get the root directory of the catalog.
Catalogs provide a hierarchical organization for data.
virtual BESCatalogEntry * show_catalog(const std::string &container, BESCatalogEntry *entry)=0
virtual BESCatalogUtils * get_catalog_utils() const
Get a pointer to the utilities, customized for this catalog.
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.
static bool IsSet(const std::string &flagName)
see if the debug context flagName is set to true
informational response object
virtual void transmit(BESTransmitter *transmitter, BESDataHandlerInterface &dhi)=0
transmit the informational object
virtual void begin_response(const std::string &response_name, BESDataHandlerInterface &dhi)
begin the informational response
exception thrown if internal error encountered
handler object that knows how to create a specific response object
virtual void dump(std::ostream &strm) const
dumps information about this object
virtual bool start(std::string name)
response handler that returns nodes or leaves within the catalog either at the root or at a specified...
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(std::ostream &strm) const
dumps information about this object
virtual void transmit(BESTransmitter *transmitter, BESDataHandlerInterface &dhi)
transmit the response object built by the execute command using the specified transmitter object