use of org.dcache.srm.SRMInternalErrorException in project dcache by dCache.
the class SrmMkdir method srmMkdir.
private SrmMkdirResponse srmMkdir() {
TReturnStatus returnStatus;
try {
storage.createDirectory(user, URI.create(request.getSURL().toString()));
returnStatus = new TReturnStatus(TStatusCode.SRM_SUCCESS, null);
} catch (SRMInternalErrorException e) {
LOGGER.error(e.getMessage());
returnStatus = new TReturnStatus(TStatusCode.SRM_INTERNAL_ERROR, e.getMessage());
} catch (SRMDuplicationException e) {
returnStatus = new TReturnStatus(TStatusCode.SRM_DUPLICATION_ERROR, e.getMessage());
} catch (SRMAuthorizationException e) {
returnStatus = new TReturnStatus(TStatusCode.SRM_AUTHORIZATION_FAILURE, e.getMessage());
} catch (SRMInvalidPathException e) {
returnStatus = new TReturnStatus(TStatusCode.SRM_INVALID_PATH, e.getMessage());
} catch (SRMException e) {
returnStatus = new TReturnStatus(TStatusCode.SRM_FAILURE, e.getMessage());
}
return new SrmMkdirResponse(returnStatus);
}
use of org.dcache.srm.SRMInternalErrorException in project dcache by dCache.
the class SrmBringOnline method srmBringOnline.
private SrmBringOnlineResponse srmBringOnline() throws SRMInvalidRequestException, SRMInternalErrorException, SRMNotSupportedException {
String[] protocols = getProtocols(request);
String clientHost = getClientNetwork(request).orElse(this.clientHost);
TGetFileRequest[] fileRequests = getFileRequests(request);
URI[] surls = getSurls(fileRequests);
long requestTime = Lifetimes.calculateLifetime(request.getDesiredTotalRequestTime(), configuration.getBringOnlineLifetime());
long desiredLifetimeInSeconds = getDesiredLifetime(request, requestTime);
if (protocols != null && protocols.length > 0) {
String[] supportedProtocols = storage.supportedGetProtocols();
boolean isAnyProtocolSupported = any(asList(protocols), in(asList(supportedProtocols)));
if (!isAnyProtocolSupported) {
throw new SRMNotSupportedException("Protocol(s) not supported: " + Arrays.toString(protocols));
}
}
BringOnlineRequest r = new BringOnlineRequest(srm.getSrmId(), user, surls, protocols, requestTime, desiredLifetimeInSeconds, configuration.getBringOnlineMaxPollPeriod(), request.getUserRequestDescription(), clientHost);
try (JDC ignored = r.applyJdc()) {
srm.acceptNewJob(r);
return r.getSrmBringOnlineResponse(configuration.getBringOnlineSwitchToAsynchronousModeDelay());
} catch (InterruptedException e) {
throw new SRMInternalErrorException("Operation interrupted", e);
} catch (IllegalStateTransition e) {
throw new SRMInternalErrorException("Scheduling failure", e);
}
}
use of org.dcache.srm.SRMInternalErrorException in project dcache by dCache.
the class SrmCheckPermission method srmCheckPermission.
private SrmCheckPermissionResponse srmCheckPermission() throws SRMInternalErrorException, SRMInvalidRequestException {
org.apache.axis.types.URI[] surls = request.getArrayOfSURLs().getUrlArray();
if (surls == null || surls.length == 0) {
throw new SRMInvalidRequestException("arrayOfSURLs is empty");
}
int length = surls.length;
TSURLPermissionReturn[] permissions = new TSURLPermissionReturn[length];
boolean hasSuccess = false;
boolean hasFailure = false;
for (int i = 0; i < length; i++) {
TReturnStatus returnStatus;
TPermissionMode pm = null;
try {
FileMetaData fmd = storage.getFileMetaData(user, URI.create(surls[i].toString()), false);
int mode = fmd.permMode;
if (fmd.isOwner(user)) {
pm = PermissionMaskToTPermissionMode.maskToTPermissionMode(((mode >> 6) & 0x7));
} else if (fmd.isGroupMember(user)) {
pm = PermissionMaskToTPermissionMode.maskToTPermissionMode(((mode >> 3) & 0x7));
} else {
pm = PermissionMaskToTPermissionMode.maskToTPermissionMode((mode & 0x7));
}
returnStatus = new TReturnStatus(TStatusCode.SRM_SUCCESS, null);
hasSuccess = true;
} catch (SRMInternalErrorException e) {
throw e;
} catch (SRMInvalidPathException e) {
returnStatus = new TReturnStatus(TStatusCode.SRM_INVALID_PATH, e.getMessage());
hasFailure = true;
} catch (SRMAuthorizationException e) {
returnStatus = new TReturnStatus(TStatusCode.SRM_AUTHORIZATION_FAILURE, e.getMessage());
hasFailure = true;
} catch (SRMException e) {
LOGGER.warn(e.toString());
returnStatus = new TReturnStatus(TStatusCode.SRM_FAILURE, e.getMessage());
hasFailure = true;
}
permissions[i] = new TSURLPermissionReturn(surls[i], returnStatus, pm);
}
return new SrmCheckPermissionResponse(ReturnStatuses.getSummaryReturnStatus(hasFailure, hasSuccess), new ArrayOfTSURLPermissionReturn(permissions));
}
use of org.dcache.srm.SRMInternalErrorException in project dcache by dCache.
the class SrmExtendFileLifeTime method extendSurlLifeTime.
private TSURLLifetimeReturnStatus extendSurlLifeTime(org.apache.axis.types.URI surl, long newLifetimeInMillis) throws SRMInternalErrorException {
TSURLLifetimeReturnStatus status = new TSURLLifetimeReturnStatus();
status.setSurl(surl);
TReturnStatus returnStatus;
try {
long lifetimeLeftInMillis = storage.srmExtendSurlLifetime(user, URI.create(surl.toString()), newLifetimeInMillis);
status.setFileLifetime(toSeconds(lifetimeLeftInMillis));
returnStatus = new TReturnStatus(TStatusCode.SRM_SUCCESS, null);
} catch (SRMInternalErrorException e) {
throw new SRMInternalErrorException("File lifetime extension failed for SURL " + surl + ": " + e.getMessage(), e);
} catch (SRMException e) {
returnStatus = new TReturnStatus(TStatusCode.SRM_FAILURE, e.toString());
}
status.setStatus(returnStatus);
return status;
}
use of org.dcache.srm.SRMInternalErrorException 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;
}
Aggregations