Search in sources :

Example 1 with ONAPComponentsList

use of org.onap.logging.filter.base.ONAPComponentsList in project so by onap.

the class ExecuteBuildingBlockRainyDay method updateExtSystemErrorSource.

public void updateExtSystemErrorSource(DelegateExecution execution) {
    try {
        String requestId = (String) execution.getVariable("mso-request-id");
        WorkflowException exception = (WorkflowException) execution.getVariable("WorkflowException");
        if (exception == null) {
            String errorMessage = (String) execution.getVariable("WorkflowExceptionMessage");
            exception = exceptionBuilder.buildWorkflowException(execution, 500, errorMessage, ONAPComponents.EXTERNAL);
        }
        ONAPComponentsList extSystemErrorSource = exception.getExtSystemErrorSource();
        InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId);
        Boolean isRollbackFailure = (Boolean) execution.getVariable("isRollback");
        if (isRollbackFailure == null) {
            isRollbackFailure = false;
        }
        if (extSystemErrorSource != null) {
            String extSystemErrorSourceString = extSystemErrorSource.toString();
            if (isRollbackFailure) {
                logger.debug("Updating extSystemErrorSource for isRollbackFailure to {} for request: {}", extSystemErrorSourceString, requestId);
                request.setRollbackExtSystemErrorSource(extSystemErrorSourceString);
            } else {
                logger.debug("Updating extSystemErrorSource to {} for request: {}", extSystemErrorSourceString, requestId);
                request.setExtSystemErrorSource(extSystemErrorSourceString);
            }
        } else if (isRollbackFailure) {
            logger.debug("rollbackExtSystemErrorSource is null for isRollbackFailure. Setting rollbackExtSystemErrorSource to UNKNOWN");
            request.setRollbackExtSystemErrorSource(Components.UNKNOWN.toString());
        } else {
            logger.debug("extSystemErrorSource is null. Setting extSystemErrorSource to UNKNOWN");
            request.setExtSystemErrorSource(Components.UNKNOWN.toString());
        }
        request.setLastModifiedBy("CamundaBPMN");
        requestDbclient.updateInfraActiveRequests(request);
    } catch (Exception e) {
        logger.error("Failed to update Request db with extSystemErrorSource or rollbackExtSystemErrorSource: ", e);
    }
}
Also used : WorkflowException(org.onap.so.bpmn.core.WorkflowException) InfraActiveRequests(org.onap.so.db.request.beans.InfraActiveRequests) ONAPComponentsList(org.onap.logging.filter.base.ONAPComponentsList) WorkflowException(org.onap.so.bpmn.core.WorkflowException)

Aggregations

ONAPComponentsList (org.onap.logging.filter.base.ONAPComponentsList)1 WorkflowException (org.onap.so.bpmn.core.WorkflowException)1 InfraActiveRequests (org.onap.so.db.request.beans.InfraActiveRequests)1