use of org.dcache.srm.v2_2.SrmRmResponse in project dcache by dCache.
the class SRMRmClientV2 method start.
@Override
public void start() throws Exception {
checkCredentialValid();
SrmRmRequest req = new SrmRmRequest();
URI[] uris = new URI[surls.length];
for (int i = 0; i < surls.length; ++i) {
uris[i] = new URI(surl_strings[i]);
}
req.setArrayOfSURLs(new ArrayOfAnyURI(uris));
configuration.getStorageSystemInfo().ifPresent(req::setStorageSystemInfo);
SrmRmResponse resp = srm.srmRm(req);
TReturnStatus rs = resp.getReturnStatus();
if (rs.getStatusCode() != TStatusCode.SRM_SUCCESS) {
TStatusCode rc = rs.getStatusCode();
StringBuilder sb = new StringBuilder();
sb.append("Return code: ").append(rc.toString()).append("\n");
sb.append("Explanation: ").append(rs.getExplanation()).append("\n");
if (resp.getArrayOfFileStatuses() != null) {
TSURLReturnStatus[] arrayOfStatuses = resp.getArrayOfFileStatuses().getStatusArray();
if (arrayOfStatuses != null) {
for (int i = 0; i < arrayOfStatuses.length; i++) {
if (arrayOfStatuses[i] != null) {
sb.append("file#").append(i).append(" : ");
if (arrayOfStatuses[i].getSurl() != null) {
sb.append(arrayOfStatuses[i].getSurl());
}
if (arrayOfStatuses[i].getStatus() != null) {
sb.append(", ");
sb.append(arrayOfStatuses[i].getStatus().getStatusCode());
sb.append(", \"");
sb.append(arrayOfStatuses[i].getStatus().getExplanation());
sb.append("\"");
}
sb.append('\n');
}
}
}
}
System.out.println(sb.toString());
System.exit(1);
}
}
use of org.dcache.srm.v2_2.SrmRmResponse 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));
}
use of org.dcache.srm.v2_2.SrmRmResponse in project dcache by dCache.
the class SrmRm method getResponse.
public static final SrmRmResponse getResponse(String error, TStatusCode statusCode) {
SrmRmResponse response = new SrmRmResponse();
response.setReturnStatus(new TReturnStatus(statusCode, error));
return response;
}
Aggregations