use of org.dcache.srm.v2_2.TStatusCode.SRM_INVALID_PATH in project dcache by dCache.
the class SrmHandler method mapReleaseFilesResponse.
private SrmReleaseFilesResponse mapReleaseFilesResponse(SrmReleaseFilesRequest request, List<SrmResponse> responses) {
Map<URI, TSURLReturnStatus> map = new HashMap<>();
for (SrmResponse srmResponse : responses) {
SrmReleaseFilesResponse response = (SrmReleaseFilesResponse) srmResponse.getResponse();
for (TSURLReturnStatus status : response.getArrayOfFileStatuses().getStatusArray()) {
if (status.getStatus().getStatusCode() == SRM_SUCCESS) {
map.put(status.getSurl(), status);
} else if (status.getStatus().getStatusCode() == SRM_INVALID_PATH) {
// no entry
} else if (status.getStatus().getStatusCode() == SRM_AUTHORIZATION_FAILURE) {
map.putIfAbsent(status.getSurl(), status);
} else if (status.getStatus().getStatusCode() == SRM_FILE_LIFETIME_EXPIRED) {
map.putIfAbsent(status.getSurl(), status);
} else if (status.getStatus().getStatusCode() == SRM_FAILURE) {
map.putIfAbsent(status.getSurl(), status);
}
}
}
TSURLReturnStatus[] statuses = Stream.of(request.getArrayOfSURLs().getUrlArray()).map(surl -> {
TSURLReturnStatus status = map.get(surl);
return (status != null) ? status : new TSURLReturnStatus(surl, new TReturnStatus(SRM_INVALID_PATH, "File not found"));
}).toArray(TSURLReturnStatus[]::new);
return new SrmReleaseFilesResponse(getSummaryReturnStatus(statuses), new ArrayOfTSURLReturnStatus(statuses));
}
use of org.dcache.srm.v2_2.TStatusCode.SRM_INVALID_PATH in project dcache by dCache.
the class SrmRm method srmRm.
private SrmRmResponse srmRm() throws DataAccessException, InterruptedException, SRMInternalErrorException, SRMInvalidRequestException {
if (request.getArrayOfSURLs() == null) {
throw new SRMInvalidRequestException("arrayOfSURLs is empty");
}
org.apache.axis.types.URI[] surls = request.getArrayOfSURLs().getUrlArray();
if (surls == null || surls.length == 0) {
throw new SRMInvalidRequestException("arrayOfSURLs is empty");
}
TSURLReturnStatus[] returnStatuses = new TSURLReturnStatus[surls.length];
Semaphore semaphore = new Semaphore(sizeOfSingleRemoveBatch);
for (int i = 0; i < surls.length; i++) {
semaphore.acquire();
returnStatuses[i] = new TSURLReturnStatus(surls[i], null);
URI surl = URI.create(surls[i].toString());
storage.removeFile(user, surl, new Callback(semaphore, returnStatuses[i]));
}
semaphore.acquire(sizeOfSingleRemoveBatch);
for (int i = 0; i < surls.length; i++) {
TSURLReturnStatus returnStatus = returnStatuses[i];
if (returnStatus.getStatus().getStatusCode() == TStatusCode.SRM_INTERNAL_ERROR) {
throw new SRMInternalErrorException(returnStatus.getStatus().getExplanation());
}
if (returnStatus.getStatus().getStatusCode() == TStatusCode.SRM_SUCCESS || returnStatus.getStatus().getStatusCode() == TStatusCode.SRM_INVALID_PATH) {
// [SRM 2.2, 4.3.2, e)] srmRm aborts the SURLs from srmPrepareToPut requests not yet
// in SRM_PUT_DONE state, and must set its file status as SRM_ABORTED.
//
// [SRM 2.2, 4.3.2, f)] srmRm must remove SURLs even if the statuses of the SURLs
// are SRM_FILE_BUSY. In this case, operations such as srmPrepareToPut or srmCopy
// that holds the SURL status as SRM_FILE_BUSY must return SRM_INVALID_PATH upon
// status request or srmPutDone.
//
// It seems the SRM specs is undecided about whether to move put requests to
// SRM_ABORTED or SRM_INVALID_PATH. We choose SRM_ABORTED as it seems like the saner
// of the two options.
// [SRM 2.2, 4.3.2, d)] srmLs,srmPrepareToGet or srmBringOnline must not find these
// removed files any more. It must set file requests on SURL from srmPrepareToGet
// as SRM_ABORTED.
URI surl = URI.create(surls[i].toString());
try {
if (srm.abortTransfers(surl, "File was deleted by request " + JDC.getSession() + ".")) {
returnStatus.setStatus(new TReturnStatus(TStatusCode.SRM_SUCCESS, "Upload was aborted."));
}
} catch (SRMException e) {
returnStatus.setStatus(new TReturnStatus(e.getStatusCode(), e.getMessage()));
}
}
}
return new SrmRmResponse(ReturnStatuses.getSummaryReturnStatus(returnStatuses), new ArrayOfTSURLReturnStatus(returnStatuses));
}
Aggregations