Search in sources :

Example 1 with RouteException

use of org.onap.msb.sdk.discovery.common.RouteException in project so by onap.

the class AbstractSdncOperationTask method httpPost.

protected String httpPost(String url, HttpPost httpPost) throws RouteException {
    logger.info("AbstractSdncOperationTask.httpPost begin!");
    String result = null;
    String errorMsg;
    try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
        CloseableHttpResponse closeableHttpResponse = httpClient.execute(httpPost);
        result = EntityUtils.toString(closeableHttpResponse.getEntity());
        logger.info("result = {}", result);
        if (closeableHttpResponse.getStatusLine().getStatusCode() != 200) {
            logger.info("exception: fail for status code = {}", closeableHttpResponse.getStatusLine().getStatusCode());
            throw new RouteException(result, "SERVICE_GET_ERR");
        }
        closeableHttpResponse.close();
    } catch (IOException e) {
        errorMsg = url + ":httpPostWithJSON connect faild";
        logger.info("exception: POST_CONNECT_FAILD : {}", errorMsg);
        throwsRouteException(errorMsg, e, "POST_CONNECT_FAILD");
    }
    logger.info("AbstractSdncOperationTask.httpPost end!");
    return result;
}
Also used : CloseableHttpClient(org.apache.http.impl.client.CloseableHttpClient) RouteException(org.onap.msb.sdk.discovery.common.RouteException) CloseableHttpResponse(org.apache.http.client.methods.CloseableHttpResponse) IOException(java.io.IOException)

Example 2 with RouteException

use of org.onap.msb.sdk.discovery.common.RouteException in project so by onap.

the class SdncNetworkTopologyOperationTask method saveOutput.

private void saveOutput(DelegateExecution execution, RpcNetworkTopologyOperationOutputEntity output) throws RouteException {
    logger.info("SdncNetworkTopologyOperationTask.saveOutput begin!");
    String responseCode = output.getOutput().getResponseCode();
    if (!"200".equals(responseCode)) {
        String processKey = getProcessKey(execution);
        int errorCode = Integer.parseInt(responseCode);
        String errorMessage = output.getOutput().getResponseMessage();
        WorkflowException workflowException = new WorkflowException(processKey, errorCode, errorMessage);
        execution.setVariable("SDNCA_SuccessIndicator", workflowException);
        updateProgress(execution, RequestsDbConstant.Status.ERROR, String.valueOf(errorCode), "100", errorMessage);
        logger.info("exception: SdncNetworkTopologyOperationTask.saveOutput fail!");
        throw new RouteException();
    }
    logger.info("SdncNetworkTopologyOperationTask.saveOutput end!");
}
Also used : RouteException(org.onap.msb.sdk.discovery.common.RouteException) WorkflowException(org.onap.so.bpmn.core.WorkflowException)

Example 3 with RouteException

use of org.onap.msb.sdk.discovery.common.RouteException in project so by onap.

the class SdncServiceTopologyOperationTask method saveOutput.

private void saveOutput(DelegateExecution execution, RpcServiceTopologyOperationOutputEntity output) throws Exception {
    logger.info("SdncServiceTopologyOperationTask.saveOutput begin!");
    String responseCode = output.getOutput().getResponseCode();
    if (!"200".equals(responseCode)) {
        String processKey = getProcessKey(execution);
        int errorCode = Integer.parseInt(responseCode);
        String errorMessage = output.getOutput().getResponseMessage();
        WorkflowException workflowException = new WorkflowException(processKey, errorCode, errorMessage);
        execution.setVariable("SDNCA_SuccessIndicator", workflowException);
        updateProgress(execution, RequestsDbConstant.Status.ERROR, String.valueOf(errorCode), null, errorMessage);
        logger.info("exception: SdncServiceTopologyOperationTask.saveOutput fail!");
        throw new RouteException();
    }
    logger.info("SdncServiceTopologyOperationTask.saveOutput end!");
}
Also used : RouteException(org.onap.msb.sdk.discovery.common.RouteException) WorkflowException(org.onap.so.bpmn.core.WorkflowException)

Aggregations

RouteException (org.onap.msb.sdk.discovery.common.RouteException)3 WorkflowException (org.onap.so.bpmn.core.WorkflowException)2 IOException (java.io.IOException)1 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)1 CloseableHttpClient (org.apache.http.impl.client.CloseableHttpClient)1