Example #1
0
int
rcDataObjPhymv( rcComm_t *conn, dataObjInp_t *dataObjInp ) {
    int status;
    transferStat_t *transferStat = NULL;

    memset( &conn->transStat, 0, sizeof( transferStat_t ) );

    dataObjInp->oprType = PHYMV_OPR;

    status = _rcDataObjPhymv( conn, dataObjInp, &transferStat );

    if ( status >= 0 && transferStat != NULL ) {
        conn->transStat = *( transferStat );
    }
    else if ( status == SYS_UNMATCHED_API_NUM ) {
        /* try older version */
        transStat_t *transStat = NULL;
        status = _rcDataObjPhymv250( conn, dataObjInp, &transStat );
        if ( status >= 0 && transStat != NULL ) {
            conn->transStat.numThreads = transStat->numThreads;
            conn->transStat.bytesWritten = transStat->bytesWritten;
            conn->transStat.flags = 0;
        }
        if ( transStat != NULL ) {
            free( transStat );
        }
        return status;
    }
    if ( transferStat != NULL ) {
        free( transferStat );
    }
    return status;
}
Example #2
0
int
rsDataObjPhymv( rsComm_t *rsComm, dataObjInp_t *dataObjInp,
                transferStat_t **transStat ) {
    int status = 0;
    dataObjInfo_t *dataObjInfoHead = NULL;
    dataObjInfo_t *oldDataObjInfoHead = NULL;
    rescGrpInfo_t *myRescGrpInfo = NULL;
    ruleExecInfo_t rei;
    int multiCopyFlag = 0;
    char *accessPerm = NULL;
    int remoteFlag = 0;
    rodsServerHost_t *rodsServerHost = NULL;
    specCollCache_t *specCollCache = NULL;

    resolveLinkedPath( rsComm, dataObjInp->objPath, &specCollCache,
                       &dataObjInp->condInput );
    remoteFlag = getAndConnRemoteZone( rsComm, dataObjInp, &rodsServerHost,
                                       REMOTE_OPEN );

    if ( remoteFlag < 0 ) {
        return remoteFlag;
    }
    else if ( remoteFlag == REMOTE_HOST ) {
        status = _rcDataObjPhymv( rodsServerHost->conn, dataObjInp,
                                  transStat );
        return status;
    }

    // =-=-=-=-=-=-=-
    // determine hierarchy string
    if ( getValByKey( &dataObjInp->condInput, RESC_HIER_STR_KW ) == NULL ) {
        std::string       hier;
        irods::error ret = irods::resolve_resource_hierarchy( irods::OPEN_OPERATION, rsComm,
                           dataObjInp, hier );
        if ( !ret.ok() ) {
            std::stringstream msg;
            msg << __FUNCTION__;
            msg << " :: failed in irods::resolve_resource_hierarchy for [";
            msg << dataObjInp->objPath << "]";
            irods::log( PASSMSG( msg.str(), ret ) );
            return ret.code();
        }

        // =-=-=-=-=-=-=-
        // we resolved the redirect and have a host, set the hier str for subsequent
        // api calls, etc.
        addKeyVal( &dataObjInp->condInput, RESC_HIER_STR_KW, hier.c_str() );

    } // if keyword

    *transStat = ( transferStat_t* )malloc( sizeof( transferStat_t ) );
    memset( *transStat, 0, sizeof( transferStat_t ) );

    if ( getValByKey( &dataObjInp->condInput, ADMIN_KW ) != NULL ) {
        if ( rsComm->clientUser.authInfo.authFlag < LOCAL_PRIV_USER_AUTH ) {
            return CAT_INSUFFICIENT_PRIVILEGE_LEVEL;
        }
        accessPerm = NULL;
    }
    else {
        accessPerm = ACCESS_DELETE_OBJECT;
    }

    /* query rcat for resource info and sort it */
    status = getRescGrpForCreate( rsComm, dataObjInp, &myRescGrpInfo );
    if ( status < 0 ) {
        delete myRescGrpInfo->rescInfo;
        delete myRescGrpInfo;
        return status;
    }

    initReiWithDataObjInp( &rei, rsComm, dataObjInp );
    status = applyRule( "acSetMultiReplPerResc", NULL, &rei, NO_SAVE_REI );
    if ( strcmp( rei.statusStr, MULTI_COPIES_PER_RESC ) == 0 ) {
        multiCopyFlag = 1;
    }
    else {
        multiCopyFlag = 0;
    }

    /* query rcat for dataObjInfo and sort it */
    status = getDataObjInfo( rsComm, dataObjInp, &dataObjInfoHead,
                             accessPerm, 1 );

    if ( status < 0 ) {
        rodsLog( LOG_NOTICE,
                 "rsDataObjPhymv: getDataObjInfo for %s", dataObjInp->objPath );
        delete myRescGrpInfo->rescInfo;
        delete myRescGrpInfo;
        return status;
    }

    status = resolveInfoForPhymv( &dataObjInfoHead, &oldDataObjInfoHead, &myRescGrpInfo, &dataObjInp->condInput, multiCopyFlag );

    if ( status < 0 ) {
        freeAllDataObjInfo( dataObjInfoHead );
        freeAllDataObjInfo( oldDataObjInfoHead );
        if ( myRescGrpInfo ) {
            delete myRescGrpInfo->rescInfo;
            delete myRescGrpInfo;
        }
        if ( status == CAT_NO_ROWS_FOUND ) {
            return 0;
        }
        else {
            return status;
        }
    }

    status = _rsDataObjPhymv( rsComm, dataObjInp, dataObjInfoHead,
                              myRescGrpInfo, *transStat, multiCopyFlag );

    freeAllDataObjInfo( dataObjInfoHead );
    freeAllDataObjInfo( oldDataObjInfoHead );
    if ( myRescGrpInfo ) {
        delete myRescGrpInfo->rescInfo;
        delete myRescGrpInfo;
    }

    return status;
}
Example #3
0
int
rsDataObjPhymv (rsComm_t *rsComm, dataObjInp_t *dataObjInp,
transferStat_t **transStat)
{
    int status;
    dataObjInfo_t *dataObjInfoHead = NULL;
    dataObjInfo_t *oldDataObjInfoHead = NULL;
    rescGrpInfo_t *myRescGrpInfo = NULL;
    ruleExecInfo_t rei;
    int multiCopyFlag;
    char *accessPerm;
    int remoteFlag;
    rodsServerHost_t *rodsServerHost;
    specCollCache_t *specCollCache = NULL;

    resolveLinkedPath (rsComm, dataObjInp->objPath, &specCollCache,
      &dataObjInp->condInput);
    remoteFlag = getAndConnRemoteZone (rsComm, dataObjInp, &rodsServerHost,
      REMOTE_OPEN);

    if (remoteFlag < 0) {
        return (remoteFlag);
    } else if (remoteFlag == REMOTE_HOST) {
        status = _rcDataObjPhymv (rodsServerHost->conn, dataObjInp,
          transStat);
        return status;
    }

    *transStat = (transferStat_t*)malloc (sizeof (transferStat_t));
    memset (*transStat, 0, sizeof (transferStat_t));

    if (getValByKey (&dataObjInp->condInput, IRODS_ADMIN_KW) != NULL) {
	if (rsComm->clientUser.authInfo.authFlag < LOCAL_PRIV_USER_AUTH) {
	    return (CAT_INSUFFICIENT_PRIVILEGE_LEVEL);
	}
	accessPerm = NULL;
    } else {
	accessPerm = ACCESS_DELETE_OBJECT;
    }

    /* query rcat for resource info and sort it */
    status = getRescGrpForCreate (rsComm, dataObjInp, &myRescGrpInfo);
    if (status < 0) return status;

    initReiWithDataObjInp (&rei, rsComm, dataObjInp);
    status = applyRule ("acSetMultiReplPerResc", NULL, &rei, NO_SAVE_REI);
    if (strcmp (rei.statusStr, MULTI_COPIES_PER_RESC) == 0) {
        multiCopyFlag = 1;
    } else {
        multiCopyFlag = 0;
    }

    /* query rcat for dataObjInfo and sort it */
    status = getDataObjInfo (rsComm, dataObjInp, &dataObjInfoHead,
      accessPerm, 1);

    if (status < 0) {
      rodsLog (LOG_NOTICE,
          "rsDataObjPhymv: getDataObjInfo for %s", dataObjInp->objPath);
        return (status);
    }

	
    status = resolveInfoForPhymv (&dataObjInfoHead, &oldDataObjInfoHead,
      &myRescGrpInfo, &dataObjInp->condInput, multiCopyFlag);
    if (status < 0) {
        freeAllDataObjInfo (dataObjInfoHead);
        freeAllDataObjInfo (oldDataObjInfoHead);
        freeAllRescGrpInfo (myRescGrpInfo);
        if (status == CAT_NO_ROWS_FOUND) {
	    return (0);
	} else {
            return (status);
	}
    }

    status = _rsDataObjPhymv (rsComm, dataObjInp, dataObjInfoHead, 
      myRescGrpInfo, *transStat, multiCopyFlag);

    freeAllDataObjInfo (dataObjInfoHead);
    freeAllDataObjInfo (oldDataObjInfoHead);
    freeAllRescGrpInfo (myRescGrpInfo);

    return (status);
}