Search in sources :

Example 1 with PreconditionFailedException

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;
}
Also used : BadResponseException(org.onap.so.client.exception.BadResponseException) PreconditionFailedException(org.onap.so.client.PreconditionFailedException) CountDownLatch(java.util.concurrent.CountDownLatch)

Aggregations

CountDownLatch (java.util.concurrent.CountDownLatch)1 PreconditionFailedException (org.onap.so.client.PreconditionFailedException)1 BadResponseException (org.onap.so.client.exception.BadResponseException)1