use of org.onap.so.client.PreconditionFailedException in project so by onap.
the class AbstractCDSProcessingBBUtils method getCdsResponse.
private CDSResponse getCdsResponse(ExecutionServiceInput executionServiceInput) throws BadResponseException {
CDSProperties props = RestPropertiesLoader.getInstance().getNewImpl(CDSProperties.class);
if (props == null) {
throw new PreconditionFailedException("No RestProperty.CDSProperties implementation found on classpath, can't create client.");
}
CDSResponse cdsResponse = new CDSResponse();
try (CDSProcessingClient cdsClient = new CDSProcessingClient(new ResponseHandler(cdsResponse))) {
CountDownLatch countDownLatch = cdsClient.sendRequest(executionServiceInput);
countDownLatch.await(props.getTimeout(), TimeUnit.SECONDS);
} catch (InterruptedException ex) {
logger.error("Caught exception in sendRequestToCDSClient in AbstractCDSProcessingBBUtils : ", ex);
Thread.currentThread().interrupt();
}
String cdsResponseStatus = cdsResponse.status;
/**
* throw CDS failed exception.
*/
if (!cdsResponseStatus.equals(SUCCESS)) {
throw new BadResponseException("CDS call failed with status: " + cdsResponse.status + " and errorMessage: " + cdsResponse.errorMessage);
}
return cdsResponse;
}
Aggregations