/// =-=-=-=-=-=-=- /// @brief function to handle resolving the hier given the fco and /// resource keyword for create or open depending on the keyword static error resolve_hier_for_create_or_open( rsComm_t* _comm, irods::file_object_ptr _file_obj, const char* _key_word, dataObjInp_t* _data_obj_inp, std::string& _out_hier ) { // =-=-=-=-=-=-=- // regardless we need to resolve the appropriate resource // to do the voting so search the repls for the proper resc std::vector< physical_object > repls = _file_obj->replicas(); bool kw_match_found = false; if ( _key_word ) { // =-=-=-=-=-=-=- // we have a kw present, compare against all the repls for a match for ( size_t i = 0; i < repls.size(); ++i ) { // =-=-=-=-=-=-=- // extract the root resource from the hierarchy std::string root_resc; hierarchy_parser parser; parser.set_string( repls[ i ].resc_hier() ); parser.first_resc( root_resc ); // =-=-=-=-=-=-=- // if we have a match then set open & break, otherwise continue if ( root_resc == _key_word ) { _file_obj->resc_hier( repls[ i ].resc_hier() ); kw_match_found = true; break; } } // for i // =-=-=-=-=-=-=- // if a match is found, resolve it and get the hier string if ( kw_match_found ) { float vote = 0.0; error ret = request_vote_for_file_object( _comm, WRITE_OPERATION, _key_word, _file_obj, _out_hier, vote ); if ( 0.0 == vote ) { if ( ret.code() == 0 ) { ret.code( -1 ); } ret.status( false ); } return PASS( ret ); } // if kw_match_found // =-=-=-=-=-=-=- // NOTE:: if a kw match is not found is this an // error or is falling through acceptable } // =-=-=-=-=-=-=- // either no kw match or no kw, so pick one... return resolve_hier_for_create( _comm, _file_obj, _key_word, _data_obj_inp, _out_hier ); } // resolve_hier_for_create_or_open
/// =-=-=-=-=-=-=- /// @brief function to handle resolving the hier given the fco and /// resource keyword static error resolve_hier_for_create( rsComm_t* _comm, irods::file_object_ptr _file_obj, const char* _key_word, dataObjInp_t* _data_obj_inp, std::string& _out_hier ) { // =-=-=-=-=-=-=- // handle the create operation // check for incoming requested destination resource first std::string resc_name; if ( !_key_word ) { // =-=-=-=-=-=-=- // this is a 'create' operation and no resource is specified, // query the server for the default or other resource to use rescGrpInfo_t* grp_info = 0; int status = getRescGrpForCreate( _comm, _data_obj_inp, &grp_info ); if ( status < 0 || !grp_info || !grp_info->rescInfo ) { // =-=-=-=-=-=-=- // clean up memory delete grp_info->rescInfo; delete grp_info; return ERROR( status, "failed in getRescGrpForCreate" ); } resc_name = grp_info->rescInfo->rescName; // =-=-=-=-=-=-=- // clean up memory delete grp_info->rescInfo; delete grp_info; } else { resc_name = _key_word; } // =-=-=-=-=-=-=- // set the resc hier given the root resc name _file_obj->resc_hier( resc_name ); // =-=-=-=-=-=-=- // get a vote and hier for the create float vote = 0.0; error ret = request_vote_for_file_object( _comm, CREATE_OPERATION, resc_name, _file_obj, _out_hier, vote ); if ( 0.0 == vote ) { if ( ret.code() == 0 ) { ret.code( -1 ); } ret.status( false ); } return PASS( ret ); } // resolve_hier_for_create