use of io.apiman.manager.api.beans.summary.GatewayTestResultBean in project apiman by apiman.
the class GatewayResourceImpl method test.
/**
* @see IGatewayResource#test(io.apiman.manager.api.beans.gateways.NewGatewayBean)
*/
@Override
public GatewayTestResultBean test(NewGatewayBean gatewayToTest) throws NotAuthorizedException {
securityContext.checkAdminPermissions();
GatewayTestResultBean rval = new GatewayTestResultBean();
try {
GatewayBean testGateway = new GatewayBean();
testGateway.setName(gatewayToTest.getName());
testGateway.setType(gatewayToTest.getType());
testGateway.setConfiguration(gatewayToTest.getConfiguration());
IGatewayLink gatewayLink = gatewayLinkFactory.create(testGateway);
SystemStatus status = gatewayLink.getStatus();
String detail = MAPPER.writer().writeValueAsString(status);
rval.setSuccess(true);
rval.setDetail(detail);
} catch (GatewayAuthenticationException e) {
rval.setSuccess(false);
// $NON-NLS-1$
rval.setDetail(Messages.i18n.format("GatewayResourceImpl.AuthenticationFailed"));
} catch (Exception e) {
rval.setSuccess(false);
rval.setDetail(e.getMessage());
}
return rval;
}
Aggregations