use of org.dcache.srm.v2_2.SrmPingResponse in project dcache by dCache.
the class SrmHandler method handleRequest.
public Object handleRequest(String requestName, Object request) throws RemoteException {
long startTimeStamp = System.currentTimeMillis();
// requestName values all start "srm". This is redundant, so may
// be removed when creating the session id. The initial character is
// converted to lowercase, so "srmPrepareToPut" becomes "prepareToPut".
String session = "srm2:" + Character.toLowerCase(requestName.charAt(3)) + requestName.substring(4);
try (JDC ignored = JDC.createSession(session)) {
for (RequestLogger logger : loggers) {
logger.request(requestName, request);
}
Subject user = Subject.getSubject(AccessController.getContext());
Object response;
if (requestName.equals("srmPing")) {
// Ping is special as it isn't authenticated and unable to return a failure
response = new SrmPingResponse("v2.2", pingExtraInfo);
} else {
try {
response = dispatch(user, requestName, request);
} catch (SRMInternalErrorException e) {
LOGGER.error(e.getMessage());
response = getFailedResponse(requestName, e.getStatusCode(), "Authentication failed (server log contains additional information).");
} catch (SRMAuthorizationException e) {
LOGGER.info(e.getMessage());
response = getFailedResponse(requestName, e.getStatusCode(), "Permission denied.");
} catch (SRMAuthenticationException e) {
LOGGER.warn(e.getMessage());
response = getFailedResponse(requestName, e.getStatusCode(), "Authentication failed (server log contains additional information).");
} catch (SRMException e) {
response = getFailedResponse(requestName, e.getStatusCode(), e.getMessage());
} catch (PermissionDeniedCacheException e) {
response = getFailedResponse(requestName, TStatusCode.SRM_AUTHORIZATION_FAILURE, e.getMessage());
} catch (CacheException e) {
response = getFailedResponse(requestName, TStatusCode.SRM_INTERNAL_ERROR, e.getMessage());
} catch (InterruptedException e) {
response = getFailedResponse(requestName, TStatusCode.SRM_FATAL_INTERNAL_ERROR, "Server shutdown.");
} catch (NoRouteToCellException e) {
LOGGER.error(e.getMessage());
response = getFailedResponse(requestName, TStatusCode.SRM_INTERNAL_ERROR, "SRM backend serving this request is currently offline.");
}
}
long time = System.currentTimeMillis() - startTimeStamp;
for (RequestLogger logger : loggers) {
logger.response(requestName, request, response, user, time);
}
return response;
}
}
use of org.dcache.srm.v2_2.SrmPingResponse in project dcache by dCache.
the class SRMPingClientV2 method start.
@Override
public void start() throws IOException {
SrmPingRequest request = new SrmPingRequest();
SrmPingResponse response = srm.srmPing(request);
say("received response");
if (response == null) {
throw new IOException(" null response");
}
StringBuilder sb = new StringBuilder();
sb.append("VersionInfo : ").append(response.getVersionInfo()).append("\n");
if (response.getOtherInfo() != null) {
ArrayOfTExtraInfo info = response.getOtherInfo();
if (info.getExtraInfoArray() != null) {
for (int i = 0; i < info.getExtraInfoArray().length; i++) {
TExtraInfo extraInfo = info.getExtraInfoArray()[i];
sb.append(extraInfo.getKey()).append(":").append(extraInfo.getValue()).append("\n");
}
}
}
System.out.println(sb.toString());
}
Aggregations