예제 #1
0
int
_rsDataObjUnlink (rsComm_t *rsComm, dataObjInp_t *dataObjUnlinkInp,
dataObjInfo_t **dataObjInfoHead)
{
    int status;
    int retVal = 0;
    dataObjInfo_t *tmpDataObjInfo, *myDataObjInfoHead;

    status = chkPreProcDeleteRule (rsComm, dataObjUnlinkInp, *dataObjInfoHead);
    if (status < 0) return status;

#if 0	/* done in chkPreProcDeleteRule */
    ruleExecInfo_t rei;
    initReiWithDataObjInp (&rei, rsComm, dataObjUnlinkInp);
    rei.doi = *dataObjInfoHead;

    status = applyRule ("acDataDeletePolicy", NULL, &rei, NO_SAVE_REI);

    if (status < 0 && status != NO_MORE_RULES_ERR &&
      status != SYS_DELETE_DISALLOWED) {
        rodsLog (LOG_NOTICE,
          "_rsDataObjUnlink: acDataDeletePolicy error for %s. status = %d",
          dataObjUnlinkInp->objPath, status);
        return (status);
    }

    if (rei.status == SYS_DELETE_DISALLOWED) {
        rodsLog (LOG_NOTICE,
        "_rsDataObjUnlink:disallowed for %s via acDataDeletePolicy,stat=%d",
          dataObjUnlinkInp->objPath, rei.status);
        return (rei.status);
    }
#endif

    myDataObjInfoHead = *dataObjInfoHead;
    if (strstr (myDataObjInfoHead->dataType, BUNDLE_STR) != NULL) {
	int numSubfiles;
        if (rsComm->proxyUser.authInfo.authFlag < LOCAL_PRIV_USER_AUTH) {
            return CAT_INSUFFICIENT_PRIVILEGE_LEVEL;
	}
	if (getValByKey (&dataObjUnlinkInp->condInput, REPL_NUM_KW) != NULL) {
	    return SYS_CANT_MV_BUNDLE_DATA_BY_COPY;
	}
	numSubfiles = getNumSubfilesInBunfileObj (rsComm, 
	  myDataObjInfoHead->objPath);
	if (numSubfiles > 0) {
	    if (getValByKey (&dataObjUnlinkInp->condInput, 
	      EMPTY_BUNDLE_ONLY_KW) != NULL) {
		/* not empty. Nothing yo do */
		return 0;
	    } else {
	        status = _unbunAndStageBunfileObj (rsComm, dataObjInfoHead, 
		  NULL, 1);
	        if (status < 0) {
	            /* go ahead and unlink the obj if the phy file does not 
		     * exist or have problem untaring it */
	            if (getErrno (status) != EEXIST && 
	                getIrodsErrno (status) != 
			  SYS_TAR_STRUCT_FILE_EXTRACT_ERR) {
                        rodsLogError (LOG_ERROR, status,
                        "_rsDataObjUnlink:_unbunAndStageBunfileObj err for %s",
                          myDataObjInfoHead->objPath);
                        return (status);
	            }
                }
	        /* dataObjInfoHead may be outdated */
	        *dataObjInfoHead = NULL;
                status = getDataObjInfoIncSpecColl (rsComm, dataObjUnlinkInp,
                  dataObjInfoHead);

                if (status < 0) return (status);
            }
	}
    }
    tmpDataObjInfo = *dataObjInfoHead;
    while (tmpDataObjInfo != NULL) {
	status = dataObjUnlinkS (rsComm, dataObjUnlinkInp, tmpDataObjInfo);
	if (status < 0) {
	    if (retVal == 0) {
	        retVal = status;
	    }
	}
        if (dataObjUnlinkInp->specColl != NULL) 	/* do only one */
	    break;
	tmpDataObjInfo = tmpDataObjInfo->next;
    }

    if ((*dataObjInfoHead)->specColl == NULL)
        resolveDataObjReplStatus (rsComm, dataObjUnlinkInp);

    return (retVal);
}
예제 #2
0
int
_rsDataObjUnlink( rsComm_t *rsComm, dataObjInp_t *dataObjUnlinkInp,
                  dataObjInfo_t **dataObjInfoHead ) {
    int status;
    int retVal = 0;
    dataObjInfo_t *tmpDataObjInfo, *myDataObjInfoHead;

    status = chkPreProcDeleteRule( rsComm, dataObjUnlinkInp, *dataObjInfoHead );
    if ( status < 0 ) {
        return status;
    }


    myDataObjInfoHead = *dataObjInfoHead;
    if ( strstr( myDataObjInfoHead->dataType, BUNDLE_STR ) != NULL ) { // JMC - backport 4658
        int numSubfiles; // JMC - backport 4552
        if ( rsComm->proxyUser.authInfo.authFlag < LOCAL_PRIV_USER_AUTH ) {
            return CAT_INSUFFICIENT_PRIVILEGE_LEVEL;
        }
        if ( getValByKey( &dataObjUnlinkInp->condInput, REPL_NUM_KW ) != NULL ) {
            return SYS_CANT_MV_BUNDLE_DATA_BY_COPY;
        }

        // =-=-=-=-=-=-=-
        // JMC - backport 4552
        numSubfiles = getNumSubfilesInBunfileObj( rsComm, myDataObjInfoHead->objPath );
        if ( numSubfiles > 0 ) {
            if ( getValByKey( &dataObjUnlinkInp->condInput, EMPTY_BUNDLE_ONLY_KW ) != NULL ) {
                /* not empty. Nothing to do */
                return 0;
            }
            else {
                status = _unbunAndStageBunfileObj( rsComm, dataObjInfoHead, &dataObjUnlinkInp->condInput, NULL, 1 );
                if ( status < 0 ) {
                    /* go ahead and unlink the obj if the phy file does not
                     * exist or have problem untaring it */
                    if ( getErrno( status ) != EEXIST && getIrodsErrno( status ) != SYS_TAR_STRUCT_FILE_EXTRACT_ERR ) {
                        rodsLogError( LOG_ERROR, status, "_rsDataObjUnlink:_unbunAndStageBunfileObj err for %s",
                                      myDataObjInfoHead->objPath );
                        return status;
                    }
                } // status < 0
                /* dataObjInfoHead may be outdated */
                *dataObjInfoHead = NULL;
                status = getDataObjInfoIncSpecColl( rsComm, dataObjUnlinkInp, dataObjInfoHead );

                if ( status < 0 ) {
                    return status;
                }
            } // else
        } // if numSubfiles
    } // if strcmp
    // =-=-=-=-=-=-=-

    tmpDataObjInfo = *dataObjInfoHead;
    while ( tmpDataObjInfo != NULL ) {
        status = dataObjUnlinkS( rsComm, dataObjUnlinkInp, tmpDataObjInfo );
        if ( status < 0 ) {
            if ( retVal == 0 ) {
                retVal = status;
            }
        }
        if ( dataObjUnlinkInp->specColl != NULL ) {     /* do only one */
            break;
        }
        tmpDataObjInfo = tmpDataObjInfo->next;
    }

    if ( ( *dataObjInfoHead )->specColl == NULL ) {
        resolveDataObjReplStatus( rsComm, dataObjUnlinkInp );
    }

    return retVal;
}