35#include "BESContainerStorageVolatile.h"
36#include "BESFileContainer.h"
37#include "BESInternalError.h"
38#include "BESSyntaxUserError.h"
40#include "TheBESKeys.h"
42#include "BESServiceRegistry.h"
48#define prolog std::string("BESContainerStorageVolatile::").append(__func__).append("() - ")
72 string key =
"BES.Data.RootDirectory";
75 if (_root_dir ==
"") {
76 string s = key +
" not defined in BES configuration file";
81 key = (string)
"BES.FollowSymLinks";
85 if (found && (s_str ==
"yes" || s_str ==
"on" || s_str ==
"true")) {
86 _follow_sym_links =
true;
90BESContainerStorageVolatile::~BESContainerStorageVolatile()
109 BESContainerStorageVolatile::Container_citer i;
110 i = _container_list.find(sym_name);
111 if (i != _container_list.end()) {
116 ret_container = (*i).second;
120 return ret_container;
145 throw BESInternalError(
string(
"Unable to add container '").append(real_name).append(
"', type of data must be specified"), __FILE__, __LINE__);
148 BESContainerStorageVolatile::Container_citer i = _container_list.find(sym_name);
149 if (i != _container_list.end()) {
150 throw BESInternalError(
string(
"A container with the name '").append(sym_name).append(
"' already exists"), __FILE__, __LINE__);
161 BESDEBUG(
"container",
"BESContainerStorageVolatile::add_container() - "
162 <<
" _root_dir: " << _root_dir
163 <<
" real_name: " << real_name
164 <<
" symbolic name: " << sym_name
165 <<
" fully_qualified_real_name: " << fully_qualified_real_name
174 _container_list[sym_name] = c;
197 throw BESInternalError(
"Unable to add container, container passed is null", __FILE__, __LINE__);
200 throw BESInternalError(
"Unable to add container, type of data must be specified", __FILE__, __LINE__);
205 BESContainerStorageVolatile::Container_citer i = _container_list.find(sym_name);
206 if (i != _container_list.end()) {
207 throw BESInternalError(
string(
"A container with the name '").append(sym_name).append(
"' already exists"), __FILE__, __LINE__);
210 _container_list[sym_name] = c;
221 BESDEBUG(MODULE, prolog <<
"BEGIN: " << s_name << endl);
223 BESContainerStorageVolatile::Container_iter i = _container_list.find(s_name);
224 if (i != _container_list.end()) {
226 _container_list.erase(i);
228 BESDEBUG(MODULE, prolog <<
"delete the container: "<< (
void *) c << endl);
233 BESDEBUG(MODULE, prolog <<
"END" << endl);
246 BESDEBUG(MODULE, prolog <<
"BEGIN" << endl);
247 while (_container_list.size() != 0) {
248 Container_iter ci = _container_list.begin();
250 _container_list.erase(ci);
252 BESDEBUG(MODULE, prolog <<
"delete the container: "<< (
void *) c << endl);
256 BESDEBUG(MODULE, prolog <<
"END" << endl);
296 string::size_type root_len = _root_dir.length();
297 BESContainerStorageVolatile::Container_iter i = _container_list.begin();
298 BESContainerStorageVolatile::Container_iter e = _container_list.end();
299 for (; i != e; i++) {
303 if (real.length() > root_len) {
304 if (real.compare(0, root_len, _root_dir) == 0) {
305 real = real.substr(root_len, real.length() - root_len);
322 strm << BESIndent::LMarg <<
"BESContainerStorageVolatile::dump - (" << (
void *)
this <<
")" << endl;
324 strm << BESIndent::LMarg <<
"name: " <<
get_name() << endl;
325 if (_container_list.size()) {
326 strm << BESIndent::LMarg <<
"containers:" << endl;
328 BESContainerStorageVolatile::Container_citer i = _container_list.begin();
329 BESContainerStorageVolatile::Container_citer ie = _container_list.end();
330 for (; i != ie; i++) {
334 BESIndent::UnIndent();
337 strm << BESIndent::LMarg <<
"containers: none" << endl;
339 BESIndent::UnIndent();
virtual BESContainer * look_for(const std::string &sym_name)
looks for the specified container using the symbolic name passed
virtual void show_containers(BESInfo &info)
show information for each container in this persistent store
virtual bool del_container(const std::string &s_name)
removes a container with the given symbolic name from the list and deletes it.
virtual bool isData(const std::string &inQuestion, std::list< std::string > &provides)
determine if the given container is data and what servies are available for it
BESContainerStorageVolatile(const std::string &n)
create an instance of this persistent store with the given name.
virtual bool del_containers()
removes all container
virtual void dump(std::ostream &strm) const
dumps information about this object
virtual void add_container(BESContainer *c)
add the passed container to the list of containers in volatile storage
provides persistent storage for data storage information represented by a container.
virtual void show_container(const std::string &sym_name, const std::string &real_name, const std::string &type, BESInfo &info)
add information for a container to the informational response object
virtual const std::string & get_name() const
retrieve the name of this persistent store
A container is something that holds data. E.G., a netcdf file or a database entry.
std::string get_symbolic_name() const
retrieve the symbolic name for this container
virtual BESContainer * ptr_duplicate()=0
pure abstract method to duplicate this instances of BESContainer
virtual void dump(std::ostream &strm) const
dumps information about this object
std::string get_container_type() const
retrieve the type of data this container holds, such as cedar or netcdf.
void set_relative_name(const std::string &relative)
Set the relative name of the object in this container.
std::string get_real_name() const
retrieve the real name for this container, such as a file name.
Holds real data, container type and constraint for symbolic name read from persistence.
informational response object
exception thrown if internal error encountered
virtual void services_handled(const std::string &handler, std::list< std::string > &services)
returns the list of servies provided by the handler in question
error thrown if there is a user syntax error in the request or any other user error
static void check_path(const std::string &path, const std::string &root, bool follow_sym_links)
Is the combination of root + path a pathname the BES can/should access?
static std::string lowercase(const std::string &s)
static std::string assemblePath(const std::string &firstPart, const std::string &secondPart, bool leadingSlash=false, bool trailingSlash=false)
Assemble path fragments making sure that they are separated by a single '/' character.
void get_value(const std::string &s, std::string &val, bool &found)
Retrieve the value of a given key, if set.
static TheBESKeys * TheKeys()