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));
}
}
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);
}
}
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);
}
}
Aggregations