Search in sources :

Example 11 with JDC

use of org.dcache.srm.util.JDC in project dcache by dCache.

the class Job method applyJdc.

public JDC applyJdc() {
    JDC current = jdc.apply();
    JDC.appendToSession(String.valueOf(id));
    return current;
}
Also used : JDC(org.dcache.srm.util.JDC)

Example 12 with JDC

use of org.dcache.srm.util.JDC in project dcache by dCache.

the class SrmStatusOfGetRequest method srmGetStatus.

private SrmStatusOfGetRequestResponse srmGetStatus() throws SRMInvalidRequestException {
    String requestToken = request.getRequestToken();
    GetRequest getRequest = Request.getRequest(requestToken, GetRequest.class);
    try (JDC ignored = getRequest.applyJdc()) {
        getRequest.tryToReady();
        if (request.getArrayOfSourceSURLs() == null) {
            return getRequest.getSrmStatusOfGetRequestResponse();
        }
        URI[] surls = request.getArrayOfSourceSURLs().getUrlArray();
        if (surls.length == 0) {
            return getRequest.getSrmStatusOfGetRequestResponse();
        }
        return getRequest.getSrmStatusOfGetRequestResponse(surls);
    }
}
Also used : GetRequest(org.dcache.srm.request.GetRequest) JDC(org.dcache.srm.util.JDC) URI(org.apache.axis.types.URI)

Example 13 with JDC

use of org.dcache.srm.util.JDC in project dcache by dCache.

the class SrmStatusOfPutRequest method srmPutStatus.

private SrmStatusOfPutRequestResponse srmPutStatus() throws SRMException {
    String requestToken = statusOfPutRequestRequest.getRequestToken();
    PutRequest putRequest = Request.getRequest(requestToken, PutRequest.class);
    try (JDC ignored = putRequest.applyJdc()) {
        putRequest.tryToReady();
        if (statusOfPutRequestRequest.getArrayOfTargetSURLs() == null) {
            return putRequest.getSrmStatusOfPutRequestResponse();
        }
        URI[] surls = statusOfPutRequestRequest.getArrayOfTargetSURLs().getUrlArray();
        if (surls.length == 0) {
            return putRequest.getSrmStatusOfPutRequestResponse();
        }
        return putRequest.getSrmStatusOfPutRequestResponse(surls);
    }
}
Also used : JDC(org.dcache.srm.util.JDC) PutRequest(org.dcache.srm.request.PutRequest) URI(org.apache.axis.types.URI)

Example 14 with JDC

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

Example 15 with JDC

use of org.dcache.srm.util.JDC in project dcache by dCache.

the class SrmReleaseFiles method srmReleaseFiles.

private SrmReleaseFilesResponse srmReleaseFiles() throws DataAccessException, SRMInvalidRequestException, SRMInternalErrorException {
    ArrayOfAnyURI arrayOfSURLs = srmReleaseFilesRequest.getArrayOfSURLs();
    org.apache.axis.types.URI[] surls;
    if (arrayOfSURLs != null) {
        surls = arrayOfSURLs.getUrlArray();
    } else {
        surls = null;
    }
    if (surls != null && surls.length == 0) {
        throw new SRMInvalidRequestException("Request contains no SURL");
    }
    String requestToken = srmReleaseFilesRequest.getRequestToken();
    if (requestToken == null) {
        if (surls == null) {
            throw new SRMInvalidRequestException("Request contains no SURL");
        }
        return releaseBySURLs(surls);
    }
    ContainerRequest<?> requestToRelease;
    try {
        requestToRelease = Request.getRequest(requestToken, ContainerRequest.class);
    } catch (SRMInvalidRequestException e) {
        return unpinBySURLAndRequestToken(requestToken, surls);
    }
    try (JDC ignored = requestToRelease.applyJdc()) {
        TSURLReturnStatus[] surlReturnStatuses;
        if (requestToRelease instanceof GetRequest) {
            GetRequest getRequest = (GetRequest) requestToRelease;
            if (surls == null) {
                surlReturnStatuses = getRequest.release();
            } else {
                surlReturnStatuses = getRequest.releaseFiles(surls);
            }
            getRequest.updateStatus();
        } else if (requestToRelease instanceof BringOnlineRequest) {
            BringOnlineRequest bringOnlineRequest = (BringOnlineRequest) requestToRelease;
            if (surls == null) {
                surlReturnStatuses = bringOnlineRequest.release();
            } else {
                surlReturnStatuses = bringOnlineRequest.releaseFiles(surls);
            }
            bringOnlineRequest.updateStatus();
        } else {
            throw new SRMInvalidRequestException("No such get or bring online request: " + requestToken);
        }
        return new SrmReleaseFilesResponse(getSummaryReturnStatus(surlReturnStatuses), new ArrayOfTSURLReturnStatus(surlReturnStatuses));
    }
}
Also used : JDC(org.dcache.srm.util.JDC) ArrayOfAnyURI(org.dcache.srm.v2_2.ArrayOfAnyURI) URI(java.net.URI) SrmReleaseFilesResponse(org.dcache.srm.v2_2.SrmReleaseFilesResponse) GetRequest(org.dcache.srm.request.GetRequest) BringOnlineRequest(org.dcache.srm.request.BringOnlineRequest) ContainerRequest(org.dcache.srm.request.ContainerRequest) 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) ArrayOfAnyURI(org.dcache.srm.v2_2.ArrayOfAnyURI)

Aggregations

JDC (org.dcache.srm.util.JDC)18 URI (java.net.URI)7 SRMInvalidRequestException (org.dcache.srm.SRMInvalidRequestException)6 URI (org.apache.axis.types.URI)4 SRMInternalErrorException (org.dcache.srm.SRMInternalErrorException)4 SRMAuthorizationException (org.dcache.srm.SRMAuthorizationException)3 SRMNotSupportedException (org.dcache.srm.SRMNotSupportedException)3 GetRequest (org.dcache.srm.request.GetRequest)3 PutRequest (org.dcache.srm.request.PutRequest)3 IllegalStateTransition (org.dcache.srm.scheduler.IllegalStateTransition)3 ArrayOfAnyURI (org.dcache.srm.v2_2.ArrayOfAnyURI)3 ArrayOfTSURLReturnStatus (org.dcache.srm.v2_2.ArrayOfTSURLReturnStatus)3 TReturnStatus (org.dcache.srm.v2_2.TReturnStatus)3 TSURLReturnStatus (org.dcache.srm.v2_2.TSURLReturnStatus)3 BringOnlineRequest (org.dcache.srm.request.BringOnlineRequest)2 CopyRequest (org.dcache.srm.request.CopyRequest)2 TAccessLatency (org.dcache.srm.v2_2.TAccessLatency)2 TOverwriteMode (org.dcache.srm.v2_2.TOverwriteMode)2 TRetentionPolicy (org.dcache.srm.v2_2.TRetentionPolicy)2 CacheException (diskCacheV111.util.CacheException)1