Search in sources :

Example 1 with SRMFileRequestNotFoundException

use of org.dcache.srm.SRMFileRequestNotFoundException 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)

Example 2 with SRMFileRequestNotFoundException

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

the class GetRequest method releaseFiles.

public TSURLReturnStatus[] releaseFiles(org.apache.axis.types.URI[] surls) throws SRMInternalErrorException {
    SRMUser user = getUser();
    int len = surls.length;
    TSURLReturnStatus[] surlReturnStatuses = new TSURLReturnStatus[len];
    for (int i = 0; i < len; i++) {
        org.apache.axis.types.URI surl = surls[i];
        URI uri = URI.create(surl.toString());
        LOGGER.debug("releaseFiles, releasing {}", surl);
        try {
            GetFileRequest fr = getFileRequestBySurl(uri);
            surlReturnStatuses[i] = new TSURLReturnStatus(surl, fr.release());
        } catch (SRMFileRequestNotFoundException e) {
            String requestToken = String.valueOf(getId());
            TReturnStatus status = BringOnlineFileRequest.unpinBySURLandRequestToken(getStorage(), user, requestToken, uri);
            surlReturnStatuses[i] = new TSURLReturnStatus(surl, status);
        }
    }
    return surlReturnStatuses;
}
Also used : SRMUser(org.dcache.srm.SRMUser) TReturnStatus(org.dcache.srm.v2_2.TReturnStatus) SRMFileRequestNotFoundException(org.dcache.srm.SRMFileRequestNotFoundException) TSURLReturnStatus(org.dcache.srm.v2_2.TSURLReturnStatus) URI(java.net.URI)

Example 3 with SRMFileRequestNotFoundException

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

the class GetRequest method getArrayOfTGetRequestFileStatus.

private TGetRequestFileStatus[] getArrayOfTGetRequestFileStatus(org.apache.axis.types.URI[] surls) throws SRMInvalidRequestException {
    if (surls == null) {
        return getArrayOfTGetRequestFileStatus();
    }
    int len = surls.length;
    TGetRequestFileStatus[] getFileStatuses = new TGetRequestFileStatus[len];
    for (int i = 0; i < len; ++i) {
        try {
            getFileStatuses[i] = getFileRequestBySurl(URI.create(surls[i].toString())).getTGetRequestFileStatus();
        } catch (SRMFileRequestNotFoundException e) {
            TGetRequestFileStatus fileStatus = new TGetRequestFileStatus();
            fileStatus.setStatus(new TReturnStatus(TStatusCode.SRM_INVALID_PATH, "No such file request associated with request token"));
            fileStatus.setSourceSURL(surls[i]);
            getFileStatuses[i] = fileStatus;
        }
    }
    return getFileStatuses;
}
Also used : TReturnStatus(org.dcache.srm.v2_2.TReturnStatus) SRMFileRequestNotFoundException(org.dcache.srm.SRMFileRequestNotFoundException) ArrayOfTGetRequestFileStatus(org.dcache.srm.v2_2.ArrayOfTGetRequestFileStatus) TGetRequestFileStatus(org.dcache.srm.v2_2.TGetRequestFileStatus)

Example 4 with SRMFileRequestNotFoundException

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

the class BringOnlineRequest method releaseFiles.

public TSURLReturnStatus[] releaseFiles(org.apache.axis.types.URI[] surls) throws SRMInternalErrorException {
    SRMUser user = getUser();
    int len = surls.length;
    TSURLReturnStatus[] surlReturnStatuses = new TSURLReturnStatus[len];
    for (int i = 0; i < len; i++) {
        org.apache.axis.types.URI surl = surls[i];
        URI uri = URI.create(surl.toString());
        LOGGER.debug("releaseFiles, releasing {}", surl);
        try {
            BringOnlineFileRequest fr = getFileRequestBySurl(uri);
            surlReturnStatuses[i] = new TSURLReturnStatus(surl, fr.release(user));
        } catch (SRMFileRequestNotFoundException e) {
            String requestToken = String.valueOf(getId());
            TReturnStatus status = BringOnlineFileRequest.unpinBySURLandRequestToken(getStorage(), user, requestToken, uri);
            surlReturnStatuses[i] = new TSURLReturnStatus(surl, status);
        }
    }
    return surlReturnStatuses;
}
Also used : SRMUser(org.dcache.srm.SRMUser) TReturnStatus(org.dcache.srm.v2_2.TReturnStatus) SRMFileRequestNotFoundException(org.dcache.srm.SRMFileRequestNotFoundException) TSURLReturnStatus(org.dcache.srm.v2_2.TSURLReturnStatus) URI(java.net.URI)

Example 5 with SRMFileRequestNotFoundException

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

the class SrmPutDone method srmPutDone.

private SrmPutDoneResponse srmPutDone() throws SRMInvalidRequestException, SRMRequestTimedOutException, SRMAbortedException, SRMInternalErrorException, SRMAuthorizationException {
    URI[] surls = getSurls(request);
    PutRequest putRequest = Request.getRequest(request.getRequestToken(), PutRequest.class);
    try (JDC ignored = putRequest.applyJdc()) {
        putRequest.wlock();
        try {
            if (!user.hasAccessTo(putRequest)) {
                throw new SRMAuthorizationException("User is not the owner of request " + request.getRequestToken() + ".");
            }
            switch(putRequest.getState()) {
                case FAILED:
                    if (putRequest.getStatusCode() == TStatusCode.SRM_REQUEST_TIMED_OUT) {
                        throw new SRMRequestTimedOutException("Total request time exceeded");
                    }
                    break;
                case CANCELED:
                    throw new SRMAbortedException("Request has been aborted.");
            }
            TSURLReturnStatus[] returnStatuses = new TSURLReturnStatus[surls.length];
            for (int i = 0; i < surls.length; ++i) {
                if (surls[i] == null) {
                    throw new SRMInvalidRequestException("SiteURLs[" + (i + 1) + "] is null.");
                }
                TReturnStatus returnStatus;
                try {
                    PutFileRequest fileRequest = putRequest.getFileRequestBySurl(java.net.URI.create(surls[i].toString()));
                    try (JDC ignore = fileRequest.applyJdc()) {
                        returnStatus = fileRequest.done(this.user);
                    }
                } catch (SRMFileRequestNotFoundException e) {
                    returnStatus = new TReturnStatus(TStatusCode.SRM_INVALID_PATH, "File does not exist.");
                }
                returnStatuses[i] = new TSURLReturnStatus(surls[i], returnStatus);
            }
            putRequest.updateStatus();
            return new SrmPutDoneResponse(ReturnStatuses.getSummaryReturnStatus(returnStatuses), new ArrayOfTSURLReturnStatus(returnStatuses));
        } finally {
            putRequest.wunlock();
        }
    }
}
Also used : SRMAuthorizationException(org.dcache.srm.SRMAuthorizationException) TReturnStatus(org.dcache.srm.v2_2.TReturnStatus) SRMFileRequestNotFoundException(org.dcache.srm.SRMFileRequestNotFoundException) JDC(org.dcache.srm.util.JDC) SRMAbortedException(org.dcache.srm.SRMAbortedException) PutRequest(org.dcache.srm.request.PutRequest) ArrayOfAnyURI(org.dcache.srm.v2_2.ArrayOfAnyURI) URI(org.apache.axis.types.URI) SRMRequestTimedOutException(org.dcache.srm.SRMRequestTimedOutException) PutFileRequest(org.dcache.srm.request.PutFileRequest) SrmPutDoneResponse(org.dcache.srm.v2_2.SrmPutDoneResponse) ArrayOfTSURLReturnStatus(org.dcache.srm.v2_2.ArrayOfTSURLReturnStatus) TSURLReturnStatus(org.dcache.srm.v2_2.TSURLReturnStatus) ArrayOfTSURLReturnStatus(org.dcache.srm.v2_2.ArrayOfTSURLReturnStatus) SRMInvalidRequestException(org.dcache.srm.SRMInvalidRequestException)

Aggregations

SRMFileRequestNotFoundException (org.dcache.srm.SRMFileRequestNotFoundException)5 TReturnStatus (org.dcache.srm.v2_2.TReturnStatus)5 TSURLReturnStatus (org.dcache.srm.v2_2.TSURLReturnStatus)3 URI (java.net.URI)2 SRMAbortedException (org.dcache.srm.SRMAbortedException)2 SRMInvalidRequestException (org.dcache.srm.SRMInvalidRequestException)2 SRMUser (org.dcache.srm.SRMUser)2 URI (org.apache.axis.types.URI)1 SRMAuthorizationException (org.dcache.srm.SRMAuthorizationException)1 SRMException (org.dcache.srm.SRMException)1 SRMInternalErrorException (org.dcache.srm.SRMInternalErrorException)1 SRMReleasedException (org.dcache.srm.SRMReleasedException)1 SRMRequestTimedOutException (org.dcache.srm.SRMRequestTimedOutException)1 PutFileRequest (org.dcache.srm.request.PutFileRequest)1 PutRequest (org.dcache.srm.request.PutRequest)1 JDC (org.dcache.srm.util.JDC)1 ArrayOfAnyURI (org.dcache.srm.v2_2.ArrayOfAnyURI)1 ArrayOfTGetRequestFileStatus (org.dcache.srm.v2_2.ArrayOfTGetRequestFileStatus)1 ArrayOfTSURLLifetimeReturnStatus (org.dcache.srm.v2_2.ArrayOfTSURLLifetimeReturnStatus)1 ArrayOfTSURLReturnStatus (org.dcache.srm.v2_2.ArrayOfTSURLReturnStatus)1