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