Merge "Enhanced List Level flow with backward support"
[so.git] / bpmn / MSOCommonBPMN / src / main / groovy / org / onap / so / bpmn / common / scripts / ExceptionUtil.groovy
index a77320b..c231503 100644 (file)
@@ -22,6 +22,9 @@
 
 package org.onap.so.bpmn.common.scripts
 
+import org.onap.so.logger.LoggingAnchor
+import org.onap.so.logger.ErrorCode
+
 import static org.apache.commons.lang3.StringUtils.*
 
 import com.google.common.xml.XmlEscapers
@@ -31,7 +34,7 @@ import org.camunda.bpm.engine.delegate.BpmnError
 import org.camunda.bpm.engine.delegate.DelegateExecution
 import org.onap.so.bpmn.core.WorkflowException
 import org.onap.so.logger.MessageEnum
-import org.onap.so.logger.MsoLogger
+import org.onap.so.utils.TargetEntities
 import org.slf4j.Logger
 import org.slf4j.LoggerFactory
 
@@ -90,8 +93,8 @@ class ExceptionUtil extends AbstractServiceTaskProcessor {
                        buildWorkflowException(execution, 5000, modifiedErrorMessage)
 
                        wfex = execution.getVariable("WorkflowException")
-                       logger.error("{} {} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Fault", "BPMN",
-                                       MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError.getValue(), wfex.errorMessage);
+                       logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Fault", "BPMN",
+                                       ErrorCode.UnknownError.getValue(), wfex.errorMessage);
                        return wfex
                } else {
                        try {
@@ -103,8 +106,8 @@ class ExceptionUtil extends AbstractServiceTaskProcessor {
 
                                logger.debug("mappedErrorMessage " + mappedErrorMessage)
                                wfex = execution.getVariable("WorkflowException")
-                               logger.error("{} {} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Fault", "BPMN",
-                                               MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError.getValue(), wfex.errorMessage);
+                               logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Fault", "BPMN",
+                                               ErrorCode.UnknownError.getValue(), wfex.errorMessage);
                                return wfex
                        } catch(Exception ex) {
                                logger.debug("error mapping error, return null: " + ex)
@@ -281,6 +284,16 @@ class ExceptionUtil extends AbstractServiceTaskProcessor {
                execution.setVariable("WorkflowException", exception);
                logger.debug("Outgoing WorkflowException is " + exception)
        }
+       
+       public void buildWorkflowException(DelegateExecution execution, int errorCode, String errorMessage, TargetEntities extSystemErrorSource) {
+               MsoUtils utils = new MsoUtils()
+               String processKey = getProcessKey(execution);
+               logger.debug("Building a WorkflowException for " + processKey)
+
+               WorkflowException exception = new WorkflowException(processKey, errorCode, errorMessage, extSystemErrorSource);
+               execution.setVariable("WorkflowException", exception);
+               logger.debug("Outgoing WorkflowException is " + exception)
+       }
 
        /**
         * This error handling method builds a WorkflowException Object and throws a