Search in sources :

Example 21 with SRMInternalErrorException

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

the class SrmMkdir method srmMkdir.

private SrmMkdirResponse srmMkdir() {
    TReturnStatus returnStatus;
    try {
        storage.createDirectory(user, URI.create(request.getSURL().toString()));
        returnStatus = new TReturnStatus(TStatusCode.SRM_SUCCESS, null);
    } catch (SRMInternalErrorException e) {
        LOGGER.error(e.getMessage());
        returnStatus = new TReturnStatus(TStatusCode.SRM_INTERNAL_ERROR, e.getMessage());
    } catch (SRMDuplicationException e) {
        returnStatus = new TReturnStatus(TStatusCode.SRM_DUPLICATION_ERROR, e.getMessage());
    } catch (SRMAuthorizationException e) {
        returnStatus = new TReturnStatus(TStatusCode.SRM_AUTHORIZATION_FAILURE, e.getMessage());
    } catch (SRMInvalidPathException e) {
        returnStatus = new TReturnStatus(TStatusCode.SRM_INVALID_PATH, e.getMessage());
    } catch (SRMException e) {
        returnStatus = new TReturnStatus(TStatusCode.SRM_FAILURE, e.getMessage());
    }
    return new SrmMkdirResponse(returnStatus);
}
Also used : SRMInternalErrorException(org.dcache.srm.SRMInternalErrorException) SRMAuthorizationException(org.dcache.srm.SRMAuthorizationException) SRMException(org.dcache.srm.SRMException) TReturnStatus(org.dcache.srm.v2_2.TReturnStatus) SRMInvalidPathException(org.dcache.srm.SRMInvalidPathException) SrmMkdirResponse(org.dcache.srm.v2_2.SrmMkdirResponse) SRMDuplicationException(org.dcache.srm.SRMDuplicationException)

Example 22 with SRMInternalErrorException

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

the class SrmBringOnline method srmBringOnline.

private SrmBringOnlineResponse srmBringOnline() throws SRMInvalidRequestException, SRMInternalErrorException, SRMNotSupportedException {
    String[] protocols = getProtocols(request);
    String clientHost = getClientNetwork(request).orElse(this.clientHost);
    TGetFileRequest[] fileRequests = getFileRequests(request);
    URI[] surls = getSurls(fileRequests);
    long requestTime = Lifetimes.calculateLifetime(request.getDesiredTotalRequestTime(), configuration.getBringOnlineLifetime());
    long desiredLifetimeInSeconds = getDesiredLifetime(request, requestTime);
    if (protocols != null && protocols.length > 0) {
        String[] supportedProtocols = storage.supportedGetProtocols();
        boolean isAnyProtocolSupported = any(asList(protocols), in(asList(supportedProtocols)));
        if (!isAnyProtocolSupported) {
            throw new SRMNotSupportedException("Protocol(s) not supported: " + Arrays.toString(protocols));
        }
    }
    BringOnlineRequest r = new BringOnlineRequest(srm.getSrmId(), user, surls, protocols, requestTime, desiredLifetimeInSeconds, configuration.getBringOnlineMaxPollPeriod(), request.getUserRequestDescription(), clientHost);
    try (JDC ignored = r.applyJdc()) {
        srm.acceptNewJob(r);
        return r.getSrmBringOnlineResponse(configuration.getBringOnlineSwitchToAsynchronousModeDelay());
    } catch (InterruptedException e) {
        throw new SRMInternalErrorException("Operation interrupted", e);
    } catch (IllegalStateTransition e) {
        throw new SRMInternalErrorException("Scheduling failure", e);
    }
}
Also used : IllegalStateTransition(org.dcache.srm.scheduler.IllegalStateTransition) SRMNotSupportedException(org.dcache.srm.SRMNotSupportedException) TGetFileRequest(org.dcache.srm.v2_2.TGetFileRequest) JDC(org.dcache.srm.util.JDC) URI(java.net.URI) SRMInternalErrorException(org.dcache.srm.SRMInternalErrorException) SrmBringOnlineRequest(org.dcache.srm.v2_2.SrmBringOnlineRequest) BringOnlineRequest(org.dcache.srm.request.BringOnlineRequest)

Example 23 with SRMInternalErrorException

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

the class SrmCheckPermission method srmCheckPermission.

private SrmCheckPermissionResponse srmCheckPermission() throws SRMInternalErrorException, SRMInvalidRequestException {
    org.apache.axis.types.URI[] surls = request.getArrayOfSURLs().getUrlArray();
    if (surls == null || surls.length == 0) {
        throw new SRMInvalidRequestException("arrayOfSURLs is empty");
    }
    int length = surls.length;
    TSURLPermissionReturn[] permissions = new TSURLPermissionReturn[length];
    boolean hasSuccess = false;
    boolean hasFailure = false;
    for (int i = 0; i < length; i++) {
        TReturnStatus returnStatus;
        TPermissionMode pm = null;
        try {
            FileMetaData fmd = storage.getFileMetaData(user, URI.create(surls[i].toString()), false);
            int mode = fmd.permMode;
            if (fmd.isOwner(user)) {
                pm = PermissionMaskToTPermissionMode.maskToTPermissionMode(((mode >> 6) & 0x7));
            } else if (fmd.isGroupMember(user)) {
                pm = PermissionMaskToTPermissionMode.maskToTPermissionMode(((mode >> 3) & 0x7));
            } else {
                pm = PermissionMaskToTPermissionMode.maskToTPermissionMode((mode & 0x7));
            }
            returnStatus = new TReturnStatus(TStatusCode.SRM_SUCCESS, null);
            hasSuccess = true;
        } catch (SRMInternalErrorException e) {
            throw e;
        } catch (SRMInvalidPathException e) {
            returnStatus = new TReturnStatus(TStatusCode.SRM_INVALID_PATH, e.getMessage());
            hasFailure = true;
        } catch (SRMAuthorizationException e) {
            returnStatus = new TReturnStatus(TStatusCode.SRM_AUTHORIZATION_FAILURE, e.getMessage());
            hasFailure = true;
        } catch (SRMException e) {
            LOGGER.warn(e.toString());
            returnStatus = new TReturnStatus(TStatusCode.SRM_FAILURE, e.getMessage());
            hasFailure = true;
        }
        permissions[i] = new TSURLPermissionReturn(surls[i], returnStatus, pm);
    }
    return new SrmCheckPermissionResponse(ReturnStatuses.getSummaryReturnStatus(hasFailure, hasSuccess), new ArrayOfTSURLPermissionReturn(permissions));
}
Also used : SRMAuthorizationException(org.dcache.srm.SRMAuthorizationException) TReturnStatus(org.dcache.srm.v2_2.TReturnStatus) SRMInvalidPathException(org.dcache.srm.SRMInvalidPathException) ArrayOfTSURLPermissionReturn(org.dcache.srm.v2_2.ArrayOfTSURLPermissionReturn) TSURLPermissionReturn(org.dcache.srm.v2_2.TSURLPermissionReturn) ArrayOfTSURLPermissionReturn(org.dcache.srm.v2_2.ArrayOfTSURLPermissionReturn) TPermissionMode(org.dcache.srm.v2_2.TPermissionMode) URI(java.net.URI) SRMInternalErrorException(org.dcache.srm.SRMInternalErrorException) SRMException(org.dcache.srm.SRMException) SrmCheckPermissionResponse(org.dcache.srm.v2_2.SrmCheckPermissionResponse) SRMInvalidRequestException(org.dcache.srm.SRMInvalidRequestException) FileMetaData(org.dcache.srm.FileMetaData)

Example 24 with SRMInternalErrorException

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

the class SrmExtendFileLifeTime method extendSurlLifeTime.

private TSURLLifetimeReturnStatus extendSurlLifeTime(org.apache.axis.types.URI surl, long newLifetimeInMillis) throws SRMInternalErrorException {
    TSURLLifetimeReturnStatus status = new TSURLLifetimeReturnStatus();
    status.setSurl(surl);
    TReturnStatus returnStatus;
    try {
        long lifetimeLeftInMillis = storage.srmExtendSurlLifetime(user, URI.create(surl.toString()), newLifetimeInMillis);
        status.setFileLifetime(toSeconds(lifetimeLeftInMillis));
        returnStatus = new TReturnStatus(TStatusCode.SRM_SUCCESS, null);
    } catch (SRMInternalErrorException e) {
        throw new SRMInternalErrorException("File lifetime extension failed for SURL " + surl + ": " + e.getMessage(), e);
    } catch (SRMException e) {
        returnStatus = new TReturnStatus(TStatusCode.SRM_FAILURE, e.toString());
    }
    status.setStatus(returnStatus);
    return status;
}
Also used : SRMInternalErrorException(org.dcache.srm.SRMInternalErrorException) SRMException(org.dcache.srm.SRMException) TReturnStatus(org.dcache.srm.v2_2.TReturnStatus) TSURLLifetimeReturnStatus(org.dcache.srm.v2_2.TSURLLifetimeReturnStatus) ArrayOfTSURLLifetimeReturnStatus(org.dcache.srm.v2_2.ArrayOfTSURLLifetimeReturnStatus)

Example 25 with SRMInternalErrorException

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

the class SrmExtendFileLifeTime method extendTurlOrPinLifeTime.

private TSURLLifetimeReturnStatus extendTurlOrPinLifeTime(ContainerRequest<?> request, org.apache.axis.types.URI surl, long newLifetimeInMillis) throws SRMInternalErrorException {
    TSURLLifetimeReturnStatus status = new TSURLLifetimeReturnStatus();
    status.setSurl(surl);
    TReturnStatus returnStatus;
    try {
        FileRequest<?> fileRequest = request.getFileRequestBySurl(URI.create(surl.toString()));
        long lifetimeLeftMillis = fileRequest.extendLifetime(newLifetimeInMillis);
        status.setPinLifetime(toSeconds(lifetimeLeftMillis));
        returnStatus = new TReturnStatus(TStatusCode.SRM_SUCCESS, null);
    } catch (SRMFileRequestNotFoundException e) {
        returnStatus = new TReturnStatus(TStatusCode.SRM_INVALID_PATH, "SURL does match any existing file request associated with the request token");
    } catch (SRMInvalidRequestException e) {
        returnStatus = new TReturnStatus(TStatusCode.SRM_INVALID_REQUEST, "TURL is no longer valid and cannot be extended");
    } catch (SRMReleasedException e) {
        returnStatus = new TReturnStatus(TStatusCode.SRM_RELEASED, "TURL has been released and cannot be extended");
    } catch (SRMAbortedException e) {
        returnStatus = new TReturnStatus(TStatusCode.SRM_ABORTED, "TURL has been aborted and cannot be extended");
    } catch (SRMInternalErrorException e) {
        throw new SRMInternalErrorException("File lifetime extension failed for request " + request.getClientRequestId() + " with SURL " + surl + ": " + e.getMessage(), e);
    } catch (SRMException e) {
        LOGGER.warn("File lifetime extension failed for request {} with SURL {}: {}", request.getClientRequestId(), surl, e.getMessage());
        returnStatus = new TReturnStatus(TStatusCode.SRM_FAILURE, "TURL for request " + request.getClientRequestId() + " with SURL " + surl + " cannot be extended: " + e.getMessage());
    }
    status.setStatus(returnStatus);
    return status;
}
Also used : SRMInternalErrorException(org.dcache.srm.SRMInternalErrorException) SRMException(org.dcache.srm.SRMException) TReturnStatus(org.dcache.srm.v2_2.TReturnStatus) SRMFileRequestNotFoundException(org.dcache.srm.SRMFileRequestNotFoundException) SRMReleasedException(org.dcache.srm.SRMReleasedException) SRMAbortedException(org.dcache.srm.SRMAbortedException) TSURLLifetimeReturnStatus(org.dcache.srm.v2_2.TSURLLifetimeReturnStatus) ArrayOfTSURLLifetimeReturnStatus(org.dcache.srm.v2_2.ArrayOfTSURLLifetimeReturnStatus) SRMInvalidRequestException(org.dcache.srm.SRMInvalidRequestException)

Aggregations

SRMInternalErrorException (org.dcache.srm.SRMInternalErrorException)46 SRMException (org.dcache.srm.SRMException)34 SRMAuthorizationException (org.dcache.srm.SRMAuthorizationException)26 SRMInvalidPathException (org.dcache.srm.SRMInvalidPathException)21 CacheException (diskCacheV111.util.CacheException)20 PermissionDeniedCacheException (diskCacheV111.util.PermissionDeniedCacheException)19 TimeoutCacheException (diskCacheV111.util.TimeoutCacheException)18 FileCorruptedCacheException (diskCacheV111.util.FileCorruptedCacheException)17 FileExistsCacheException (diskCacheV111.util.FileExistsCacheException)17 FileIsNewCacheException (diskCacheV111.util.FileIsNewCacheException)17 FileNotFoundCacheException (diskCacheV111.util.FileNotFoundCacheException)17 NotDirCacheException (diskCacheV111.util.NotDirCacheException)17 FsPath (diskCacheV111.util.FsPath)13 TReturnStatus (org.dcache.srm.v2_2.TReturnStatus)13 NoRouteToCellException (dmg.cells.nucleus.NoRouteToCellException)10 Subject (javax.security.auth.Subject)10 URI (java.net.URI)9 PnfsHandler (diskCacheV111.util.PnfsHandler)8 SRMInvalidRequestException (org.dcache.srm.SRMInvalidRequestException)7 SRMDuplicationException (org.dcache.srm.SRMDuplicationException)6