00001
00002
00003
00004
00005 #include "eirods_collection_object.h"
00006 #include "eirods_resource_manager.h"
00007 #include "eirods_hierarchy_parser.h"
00008 #include "eirods_stacktrace.h"
00009
00010 extern eirods::resource_manager resc_mgr;
00011
00012 namespace eirods {
00013
00014
00015
00016 collection_object::collection_object() :
00017 data_object(),
00018 directory_pointer_(0) {
00019 }
00020
00021
00022
00023 collection_object::collection_object(
00024 const collection_object& _rhs ) :
00025 data_object( _rhs ) {
00026 directory_pointer_ = _rhs.directory_pointer_;
00027
00028 }
00029
00030
00031
00032 collection_object::collection_object(
00033 const std::string& _fn,
00034 const std::string& _resc_hier,
00035 int _m,
00036 int _f ) :
00037 data_object(
00038 _fn,
00039 _resc_hier,
00040 _m,
00041 _f ),
00042 directory_pointer_(0) {
00043
00044 }
00045
00046
00047
00048 collection_object::~collection_object() {
00049
00050 }
00051
00052
00053
00054 collection_object& collection_object::operator=( const collection_object& _rhs ) {
00055
00056
00057 data_object::operator=( _rhs );
00058
00059 directory_pointer_ = _rhs.directory_pointer_;
00060
00061 return *this;
00062
00063 }
00064
00065
00066
00067 error collection_object::resolve(
00068 const std::string& _interface,
00069 plugin_ptr& _ptr ) {
00070
00071
00072
00073 if( RESOURCE_INTERFACE != _interface ) {
00074 std::stringstream msg;
00075 msg << "collection_object does not support a [";
00076 msg << _interface;
00077 msg << "] for plugin resolution";
00078 return ERROR( SYS_INVALID_INPUT_PARAM, msg.str() );
00079 }
00080
00081 error result = SUCCESS();
00082 error ret;
00083
00084 hierarchy_parser hparse;
00085 ret = hparse.set_string(resc_hier());
00086
00087 if(!ret.ok()) {
00088 std::stringstream msg;
00089 msg << __FUNCTION__ << " - ";
00090 msg << "error parsing resource hierarchy \"" << resc_hier() << "\"";
00091 result = PASSMSG(msg.str(), ret);
00092 } else {
00093 std::string resc;
00094
00095 ret = hparse.first_resc(resc);
00096 if(!ret.ok()) {
00097 std::stringstream msg;
00098 msg << __FUNCTION__ << " - ERROR getting first resource from hierarchy.";
00099 result = PASSMSG(msg.str(), ret);
00100 } else {
00101
00102 if(resc.empty() && resc_hier().empty()) {
00103 std::stringstream msg;
00104 msg << __FUNCTION__;
00105 msg << " - No resource hierarchy or resource specified.";
00106 return ERROR(EIRODS_HIERARCHY_ERROR, msg.str());
00107 } else if(resc.empty()) {
00108 return ERROR( EIRODS_HIERARCHY_ERROR, "Hierarchy string is not empty but first resource is!");
00109 }
00110
00111 resource_ptr resc_ptr;
00112 ret = resc_mgr.resolve( resc, resc_ptr );
00113 if(!ret.ok()) {
00114 std::stringstream msg;
00115 msg << __FUNCTION__ << " - ERROR resolving resource \"" << resc << "\"";
00116 result = PASSMSG(msg.str(), ret);
00117 }
00118
00119 _ptr = boost::dynamic_pointer_cast< resource >( resc_ptr );
00120 }
00121 }
00122 return result;
00123
00124 }
00125
00126
00127
00128 error collection_object::get_re_vars(
00129 keyValPair_t& _kvp ) {
00130 data_object::get_re_vars( _kvp );
00131 return SUCCESS();
00132
00133 }
00134
00135
00136 };
00137
00138
00139