Search in sources :

Example 1 with SRMFileUnvailableException

use of org.dcache.srm.SRMFileUnvailableException in project dcache by dCache.

the class PinCompanion method fail.

private void fail(int rc, String error) {
    switch(rc) {
        case FILE_NOT_FOUND:
            setException(new SRMInvalidPathException("No such file."));
            break;
        case FILE_NOT_IN_REPOSITORY:
            _log.warn("Pinning failed for {} ({})", _path, error);
            setException(new SRMFileUnvailableException(error));
            break;
        case PERMISSION_DENIED:
            _log.warn("Pinning failed for {} ({})", _path, error);
            setException(new SRMAuthorizationException(error));
            break;
        case TIMEOUT:
            _log.info("Pinning failed: {}", error);
            setException(new SRMInternalErrorException("Pin operation timed out"));
            break;
        default:
            _log.error("Pinning failed for {} [rc={},msg={}].", _path, rc, error);
            String reason = String.format("Failed to pin file [rc=%d,msg=%s].", rc, error);
            setException(new SRMException(reason));
            break;
    }
    _state = new FailedState();
}
Also used : SRMInternalErrorException(org.dcache.srm.SRMInternalErrorException) SRMAuthorizationException(org.dcache.srm.SRMAuthorizationException) SRMException(org.dcache.srm.SRMException) SRMFileUnvailableException(org.dcache.srm.SRMFileUnvailableException) SRMInvalidPathException(org.dcache.srm.SRMInvalidPathException)

Example 2 with SRMFileUnvailableException

use of org.dcache.srm.SRMFileUnvailableException in project dcache by dCache.

the class TStatusCodes method checkSuccess.

public static void checkSuccess(TReturnStatus returnStatus, TStatusCode... success) throws SRMException {
    TStatusCode statusCode = returnStatus.getStatusCode();
    String explanation = returnStatus.getExplanation();
    if (asList(success).contains(statusCode)) {
        return;
    }
    if (explanation == null) {
        explanation = "Operation failed with " + returnStatus.getStatusCode();
    }
    if (statusCode == TStatusCode.SRM_FAILURE) {
        throw new SRMException(explanation);
    } else if (statusCode == TStatusCode.SRM_PARTIAL_SUCCESS) {
        throw new SRMOtherException(statusCode, explanation);
    } else if (statusCode == TStatusCode.SRM_AUTHENTICATION_FAILURE) {
        throw new SRMOtherException(statusCode, explanation);
    } else if (statusCode == TStatusCode.SRM_AUTHORIZATION_FAILURE) {
        throw new SRMAuthorizationException(explanation);
    } else if (statusCode == TStatusCode.SRM_INVALID_REQUEST) {
        throw new SRMInvalidRequestException(explanation);
    } else if (statusCode == TStatusCode.SRM_INVALID_PATH) {
        throw new SRMInvalidPathException(explanation);
    } else if (statusCode == TStatusCode.SRM_FILE_LIFETIME_EXPIRED) {
        throw new SRMOtherException(statusCode, explanation);
    } else if (statusCode == TStatusCode.SRM_SPACE_LIFETIME_EXPIRED) {
        throw new SRMSpaceLifetimeExpiredException(explanation);
    } else if (statusCode == TStatusCode.SRM_EXCEED_ALLOCATION) {
        throw new SRMExceedAllocationException(explanation);
    } else if (statusCode == TStatusCode.SRM_NO_USER_SPACE) {
        throw new SRMOtherException(statusCode, explanation);
    } else if (statusCode == TStatusCode.SRM_NO_FREE_SPACE) {
        throw new SRMNoFreeSpaceException(explanation);
    } else if (statusCode == TStatusCode.SRM_DUPLICATION_ERROR) {
        throw new SRMDuplicationException(explanation);
    } else if (statusCode == TStatusCode.SRM_NON_EMPTY_DIRECTORY) {
        throw new SRMNonEmptyDirectoryException(explanation);
    } else if (statusCode == TStatusCode.SRM_TOO_MANY_RESULTS) {
        throw new SRMTooManyResultsException(explanation);
    } else if (statusCode == TStatusCode.SRM_INTERNAL_ERROR) {
        throw new SRMInternalErrorException(explanation);
    } else if (statusCode == TStatusCode.SRM_FATAL_INTERNAL_ERROR) {
        throw new SRMInternalErrorException(explanation);
    } else if (statusCode == TStatusCode.SRM_NOT_SUPPORTED) {
        throw new SRMNotSupportedException(explanation);
    } else if (statusCode == TStatusCode.SRM_REQUEST_QUEUED) {
        throw new SRMOtherException(statusCode, explanation);
    } else if (statusCode == TStatusCode.SRM_REQUEST_INPROGRESS) {
        throw new SRMOtherException(statusCode, explanation);
    } else if (statusCode == TStatusCode.SRM_ABORTED) {
        throw new SRMAbortedException(explanation);
    } else if (statusCode == TStatusCode.SRM_RELEASED) {
        throw new SRMReleasedException(explanation);
    } else if (statusCode == TStatusCode.SRM_FILE_PINNED) {
        throw new SRMOtherException(statusCode, explanation);
    } else if (statusCode == TStatusCode.SRM_FILE_IN_CACHE) {
        throw new SRMOtherException(statusCode, explanation);
    } else if (statusCode == TStatusCode.SRM_SPACE_AVAILABLE) {
        throw new SRMOtherException(statusCode, explanation);
    } else if (statusCode == TStatusCode.SRM_LOWER_SPACE_GRANTED) {
        throw new SRMOtherException(statusCode, explanation);
    } else if (statusCode == TStatusCode.SRM_REQUEST_TIMED_OUT) {
        throw new SRMRequestTimedOutException(explanation);
    } else if (statusCode == TStatusCode.SRM_LAST_COPY) {
        throw new SRMOtherException(statusCode, explanation);
    } else if (statusCode == TStatusCode.SRM_FILE_BUSY) {
        throw new SRMOtherException(statusCode, explanation);
    } else if (statusCode == TStatusCode.SRM_FILE_LOST) {
        throw new SRMOtherException(statusCode, explanation);
    } else if (statusCode == TStatusCode.SRM_FILE_UNAVAILABLE) {
        throw new SRMFileUnvailableException(explanation);
    } else if (statusCode == TStatusCode.SRM_CUSTOM_STATUS) {
        throw new SRMOtherException(statusCode, explanation);
    } else {
        throw new SRMOtherException(statusCode, explanation);
    }
}
Also used : SRMExceedAllocationException(org.dcache.srm.SRMExceedAllocationException) SRMAuthorizationException(org.dcache.srm.SRMAuthorizationException) SRMNotSupportedException(org.dcache.srm.SRMNotSupportedException) SRMNonEmptyDirectoryException(org.dcache.srm.SRMNonEmptyDirectoryException) SRMInvalidPathException(org.dcache.srm.SRMInvalidPathException) SRMAbortedException(org.dcache.srm.SRMAbortedException) TStatusCode(org.dcache.srm.v2_2.TStatusCode) SRMTooManyResultsException(org.dcache.srm.SRMTooManyResultsException) SRMRequestTimedOutException(org.dcache.srm.SRMRequestTimedOutException) SRMInternalErrorException(org.dcache.srm.SRMInternalErrorException) SRMException(org.dcache.srm.SRMException) SRMFileUnvailableException(org.dcache.srm.SRMFileUnvailableException) SRMReleasedException(org.dcache.srm.SRMReleasedException) SRMOtherException(org.dcache.srm.SRMOtherException) SRMSpaceLifetimeExpiredException(org.dcache.srm.SRMSpaceLifetimeExpiredException) SRMInvalidRequestException(org.dcache.srm.SRMInvalidRequestException) SRMNoFreeSpaceException(org.dcache.srm.SRMNoFreeSpaceException) SRMDuplicationException(org.dcache.srm.SRMDuplicationException)

Aggregations

SRMAuthorizationException (org.dcache.srm.SRMAuthorizationException)2 SRMException (org.dcache.srm.SRMException)2 SRMFileUnvailableException (org.dcache.srm.SRMFileUnvailableException)2 SRMInternalErrorException (org.dcache.srm.SRMInternalErrorException)2 SRMInvalidPathException (org.dcache.srm.SRMInvalidPathException)2 SRMAbortedException (org.dcache.srm.SRMAbortedException)1 SRMDuplicationException (org.dcache.srm.SRMDuplicationException)1 SRMExceedAllocationException (org.dcache.srm.SRMExceedAllocationException)1 SRMInvalidRequestException (org.dcache.srm.SRMInvalidRequestException)1 SRMNoFreeSpaceException (org.dcache.srm.SRMNoFreeSpaceException)1 SRMNonEmptyDirectoryException (org.dcache.srm.SRMNonEmptyDirectoryException)1 SRMNotSupportedException (org.dcache.srm.SRMNotSupportedException)1 SRMOtherException (org.dcache.srm.SRMOtherException)1 SRMReleasedException (org.dcache.srm.SRMReleasedException)1 SRMRequestTimedOutException (org.dcache.srm.SRMRequestTimedOutException)1 SRMSpaceLifetimeExpiredException (org.dcache.srm.SRMSpaceLifetimeExpiredException)1 SRMTooManyResultsException (org.dcache.srm.SRMTooManyResultsException)1 TStatusCode (org.dcache.srm.v2_2.TStatusCode)1