Search in sources :

Example 16 with JDC

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

the class SrmAbortFiles method abortFiles.

private SrmAbortFilesResponse abortFiles() throws SRMInvalidRequestException, SRMAuthorizationException {
    ContainerRequest<?> requestToAbort = Request.getRequest(this.request.getRequestToken(), ContainerRequest.class);
    try (JDC ignored = requestToAbort.applyJdc()) {
        if (!user.hasAccessTo(requestToAbort)) {
            throw new SRMAuthorizationException("User is not the owner of request " + request.getRequestToken() + ".");
        }
        org.apache.axis.types.URI[] surls = getSurls();
        TSURLReturnStatus[] surlReturnStatusArray = new TSURLReturnStatus[surls.length];
        for (int i = 0; i < surls.length; i++) {
            TReturnStatus returnStatus = abortSurl(requestToAbort, surls[i]);
            surlReturnStatusArray[i] = new TSURLReturnStatus(surls[i], returnStatus);
        }
        requestToAbort.updateStatus();
        return new SrmAbortFilesResponse(getSummaryReturnStatus(surlReturnStatusArray), new ArrayOfTSURLReturnStatus(surlReturnStatusArray));
    }
}
Also used : SRMAuthorizationException(org.dcache.srm.SRMAuthorizationException) TReturnStatus(org.dcache.srm.v2_2.TReturnStatus) JDC(org.dcache.srm.util.JDC) ArrayOfAnyURI(org.dcache.srm.v2_2.ArrayOfAnyURI) URI(java.net.URI) SrmAbortFilesResponse(org.dcache.srm.v2_2.SrmAbortFilesResponse) ArrayOfTSURLReturnStatus(org.dcache.srm.v2_2.ArrayOfTSURLReturnStatus) TSURLReturnStatus(org.dcache.srm.v2_2.TSURLReturnStatus) ArrayOfTSURLReturnStatus(org.dcache.srm.v2_2.ArrayOfTSURLReturnStatus)

Example 17 with JDC

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

the class SrmCopy method srmCopy.

private SrmCopyResponse srmCopy() throws SRMInvalidRequestException, SRMNotSupportedException, SRMInternalErrorException {
    TCopyFileRequest[] arrayOfFileRequests = getFileRequests(request);
    long lifetime = Lifetimes.calculateLifetime(request.getDesiredTotalRequestTime(), configuration.getCopyLifetime());
    String spaceToken = request.getTargetSpaceToken();
    URI[] from_urls = new URI[arrayOfFileRequests.length];
    URI[] to_urls = new URI[arrayOfFileRequests.length];
    for (int i = 0; i < arrayOfFileRequests.length; i++) {
        from_urls[i] = URI.create(arrayOfFileRequests[i].getSourceSURL().toString());
        to_urls[i] = URI.create(arrayOfFileRequests[i].getTargetSURL().toString());
    }
    TRetentionPolicy targetRetentionPolicy = null;
    TAccessLatency targetAccessLatency = null;
    if (request.getTargetFileRetentionPolicyInfo() != null) {
        targetRetentionPolicy = request.getTargetFileRetentionPolicyInfo().getRetentionPolicy();
        targetAccessLatency = request.getTargetFileRetentionPolicyInfo().getAccessLatency();
    }
    TOverwriteMode overwriteMode = getOverwriteMode(request);
    ImmutableMap<String, String> extraInfo = getExtraInfo(request);
    credential.acceptAlternative(extraInfo.get("credential"));
    CopyRequest r = new CopyRequest(srm.getSrmId(), user, credential.getId(), from_urls, to_urls, spaceToken, lifetime, configuration.getCopyMaxPollPeriod(), request.getTargetFileStorageType(), targetRetentionPolicy, targetAccessLatency, request.getUserRequestDescription(), clientHost, overwriteMode, extraInfo);
    try (JDC ignored = r.applyJdc()) {
        srm.acceptNewJob(r);
        return r.getSrmCopyResponse();
    } catch (IllegalStateTransition e) {
        throw new SRMInternalErrorException("Scheduling failure", e);
    }
}
Also used : IllegalStateTransition(org.dcache.srm.scheduler.IllegalStateTransition) SrmCopyRequest(org.dcache.srm.v2_2.SrmCopyRequest) CopyRequest(org.dcache.srm.request.CopyRequest) TRetentionPolicy(org.dcache.srm.v2_2.TRetentionPolicy) JDC(org.dcache.srm.util.JDC) TCopyFileRequest(org.dcache.srm.v2_2.TCopyFileRequest) TOverwriteMode(org.dcache.srm.v2_2.TOverwriteMode) URI(java.net.URI) SRMInternalErrorException(org.dcache.srm.SRMInternalErrorException) TAccessLatency(org.dcache.srm.v2_2.TAccessLatency)

Example 18 with JDC

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

the class SrmLs method srmLs.

private SrmLsResponse srmLs() throws SRMInvalidRequestException, SRMInternalErrorException {
    int numOfLevels = Math.min(getNumOfLevels(request), maxNumOfLevels);
    int offset = getOffset(request);
    int count = getCount(request);
    boolean longFormat = getFullDetailedList(request);
    URI[] surls = getSurls(request);
    LsRequest r = new LsRequest(srm.getSrmId(), user, surls, TimeUnit.HOURS.toMillis(1), configuration.getLsMaxPollPeriod(), clientHost, count, offset, numOfLevels, longFormat, max_results_num);
    try (JDC ignored = r.applyJdc()) {
        srm.acceptNewJob(r);
        return r.getSrmLsResponse(configuration.getLsSwitchToAsynchronousModeDelay());
    } catch (InterruptedException e) {
        throw new SRMInternalErrorException("Operation interrupted", e);
    } catch (IllegalStateTransition e) {
        throw new SRMInternalErrorException("Scheduling failure", e);
    }
}
Also used : SRMInternalErrorException(org.dcache.srm.SRMInternalErrorException) IllegalStateTransition(org.dcache.srm.scheduler.IllegalStateTransition) LsRequest(org.dcache.srm.request.LsRequest) SrmLsRequest(org.dcache.srm.v2_2.SrmLsRequest) JDC(org.dcache.srm.util.JDC) URI(java.net.URI)

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