25 #include <BESSyntaxUserError.h>
26 #include <BESInternalError.h>
27 #include <BESNotFoundError.h>
30 #include <TheBESKeys.h>
31 #include <WhiteList.h>
33 #include "HttpdCatalogContainer.h"
34 #include "HttpdCatalogUtils.h"
35 #include "HttpdCatalogNames.h"
36 #include "HttpdCatalog.h"
37 #include "RemoteHttpResource.h"
42 #define prolog std::string("HttpdCatalogContainer::").append(__func__).append("() - ")
44 namespace httpd_catalog {
56 HttpdCatalogContainer::HttpdCatalogContainer(
const string &sym_name,
const string &real_name,
const string &type) :
57 BESContainer(sym_name, real_name, type), d_remoteResource(0)
60 BESDEBUG(MODULE, prolog <<
"BEGIN sym_name: " << sym_name <<
" real_name: " << real_name <<
" type: " << type << endl);
62 string path = real_name;
63 if (path.empty() || path[0] !=
'/') {
70 BESDEBUG(MODULE, prolog <<
"path: '" << path <<
"' path_elements.size(): " << path_elements.size() << endl);
83 BESDEBUG(MODULE, prolog <<
"END" << endl);
91 if (copy_from.d_remoteResource) {
92 throw BESInternalError(
"The Container has already been accessed, cannot create a copy of this container.", __FILE__, __LINE__);
96 void HttpdCatalogContainer::_duplicate(HttpdCatalogContainer ©_to)
98 if (copy_to.d_remoteResource) {
99 throw BESInternalError(
"The Container has already been accessed, cannot duplicate this resource.", __FILE__, __LINE__);
101 copy_to.d_remoteResource = d_remoteResource;
109 _duplicate(*container);
113 HttpdCatalogContainer::~HttpdCatalogContainer()
115 if (d_remoteResource) {
127 BESDEBUG(MODULE, prolog <<
"BEGIN" << endl);
130 BESDEBUG(MODULE, prolog <<
"path: " << path << endl);
135 if (!d_remoteResource) {
136 BESDEBUG(MODULE, prolog <<
"Building new RemoteResource." << endl);
141 BESDEBUG(MODULE, prolog <<
"Located remote resource." << endl);
144 BESDEBUG(MODULE, prolog <<
"Using local cache file: " << cachedResource << endl);
146 string type = d_remoteResource->
getType();
149 BESDEBUG(MODULE, prolog <<
"Type: " << type << endl);
151 BESDEBUG(MODULE, prolog <<
"Done accessing " <<
get_real_name() <<
" returning cached file " << cachedResource << endl);
152 BESDEBUG(MODULE, prolog <<
"Done accessing " << *
this << endl);
153 BESDEBUG(MODULE, prolog <<
"END" << endl);
155 return cachedResource;
166 BESDEBUG(MODULE, prolog <<
"BEGIN" << endl);
167 if (d_remoteResource) {
168 BESDEBUG(MODULE, prolog <<
"Releasing RemoteResource" << endl);
169 delete d_remoteResource;
170 d_remoteResource = 0;
172 BESDEBUG(MODULE, prolog <<
"END" << endl);
185 strm << BESIndent::LMarg << prolog<<
"(" << (
void *)
this
189 if (d_remoteResource) {
190 strm << BESIndent::LMarg <<
"RemoteResource.getCacheFileName(): " <<d_remoteResource->
getCacheFileName()
192 strm << BESIndent::LMarg <<
"response headers: ";
199 vector<string>::const_iterator i = hdrs.begin();
200 vector<string>::const_iterator e = hdrs.end();
201 for (; i != e; i++) {
202 string hdr_line = (*i);
203 strm << BESIndent::LMarg << hdr_line << endl;
205 BESIndent::UnIndent();
208 strm <<
"none" << endl;
212 strm << BESIndent::LMarg <<
"response not yet obtained" << endl;
215 BESIndent::UnIndent();