private HealthStatus getHealthStatus(Status status) { switch (status) { case OK: case WARN: case FAIL: return HealthStatus.valueOf(status.name()); } throw new IllegalArgumentException("Cannot convert Status." + status + " to a HealthStatus"); }
private RestrictedHealthStatus getHealth() throws HealthException { RestrictedHealthStatus currentState = RestrictedHealthStatus.OK; if (monitorRegistry == null) { logger.log(Level.SEVERE, "MonitorRegistry is null"); throw new HealthException(ResponseCode.InternalError, HealthExceptionErrorCodeEnum.NULL); } StatusAggregator agg = monitorRegistry.getStatusAggregator(); if (agg == null) { logger.log(Level.SEVERE, "StatusAggregator is null"); throw new HealthException(ResponseCode.InternalError, HealthExceptionErrorCodeEnum.NULL); } Status status = agg.getStatus(); if (status == null) { logger.log(Level.SEVERE, "Status is null"); throw new HealthException(ResponseCode.InternalError, HealthExceptionErrorCodeEnum.NULL); } if (status.equals(Status.FAIL)) { currentState = RestrictedHealthStatus.FAIL; } return currentState; }