AT&T 1712 and 1802 release code
[so.git] / bpmn / MSOCommonBPMN / src / main / groovy / org / openecomp / mso / bpmn / common / scripts / ExceptionUtil.groovy
index 121e0c8..b65ce74 100644 (file)
@@ -22,9 +22,11 @@ package org.openecomp.mso.bpmn.common.scripts
 
 import static org.apache.commons.lang3.StringUtils.*
 
+import com.google.common.xml.XmlEscapers
+
 import org.apache.commons.lang3.*
 import org.camunda.bpm.engine.delegate.BpmnError
-import org.camunda.bpm.engine.runtime.Execution
+import org.camunda.bpm.engine.delegate.DelegateExecution
 import org.openecomp.mso.bpmn.core.WorkflowException
 
 /**
@@ -44,7 +46,7 @@ class ExceptionUtil extends AbstractServiceTaskProcessor {
         * @param execution the execution
         * @param response the aai exception
         */
-       WorkflowException MapAAIExceptionToWorkflowException(String response, Execution execution)
+       WorkflowException MapAAIExceptionToWorkflowException(String response, DelegateExecution execution)
        {
                def utils=new MsoUtils()
                def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
@@ -116,7 +118,7 @@ class ExceptionUtil extends AbstractServiceTaskProcessor {
         * @param execution the execution
         * @param response the aai exception
         */
-       WorkflowException MapAAIExceptionToWorkflowExceptionGeneric(Execution execution, String response, int resCode){
+       WorkflowException MapAAIExceptionToWorkflowExceptionGeneric(DelegateExecution execution, String response, int resCode){
                def utils=new MsoUtils()
                def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled")
                utils.log("DEBUG", "Start MapAAIExceptionToWorkflowExceptionGeneric Process", isDebugLogEnabled)
@@ -159,7 +161,7 @@ class ExceptionUtil extends AbstractServiceTaskProcessor {
        String buildErrorResponseXml(WorkflowException wfex) {
                String xml
                if(wfex != null){
-                       String mes = wfex.getErrorMessage()
+                       String mes = XmlEscapers.xmlContentEscaper().escape(wfex.getErrorMessage())
                        int code = wfex.getErrorCode()
                        xml =
                        """<aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1">
@@ -221,12 +223,11 @@ class ExceptionUtil extends AbstractServiceTaskProcessor {
                        errorMessage=""
                }
                if( errorCode.equals('5010')){
-                                       return 'Could not communicate with A&amp;AI'
+                       return 'Could not communicate with A&AI'
                }else if (errorCode.equals('5020')){
-                       return 'No response from A&amp;AI'
+                       return 'No response from A&AI'
                }else{
-                       errorMessage = errorMessage.replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;")
-                       return 'Received error from A&amp;AI (' +errorMessage +')'
+                       return 'Received error from A&AI (' +errorMessage +')'
                }
        }
 
@@ -261,7 +262,7 @@ class ExceptionUtil extends AbstractServiceTaskProcessor {
         * @param errorCode the error code
         * @param errorMessage the error message
         */
-       public void buildWorkflowException(Execution execution, int errorCode, String errorMessage) {
+       public void buildWorkflowException(DelegateExecution execution, int errorCode, String errorMessage) {
                MsoUtils utils = new MsoUtils()
                def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
                String processKey = getProcessKey(execution);
@@ -281,7 +282,7 @@ class ExceptionUtil extends AbstractServiceTaskProcessor {
         * @param errorCode the error code
         * @param errorMessage the error message
         */
-       public void buildAndThrowWorkflowException(Execution execution, int errorCode, String errorMessage) {
+       public void buildAndThrowWorkflowException(DelegateExecution execution, int errorCode, String errorMessage) {
                def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
                String processKey = getProcessKey(execution);
                utils.log("Building a WorkflowException for Subflow " + processKey, isDebugLogEnabled)
@@ -302,7 +303,7 @@ class ExceptionUtil extends AbstractServiceTaskProcessor {
         * @param - execution
         *
         */
-       public void processSubflowsBPMNException(Execution execution){
+       public void processSubflowsBPMNException(DelegateExecution execution){
                def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
                String processKey = getProcessKey(execution)
                try{
@@ -329,7 +330,7 @@ class ExceptionUtil extends AbstractServiceTaskProcessor {
         * @return - falloutHandlerRequest
         *
         */
-       public String processMainflowsBPMNException(Execution execution, String requestInfo){
+       public String processMainflowsBPMNException(DelegateExecution execution, String requestInfo){
                def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
                String processKey = getProcessKey(execution)
                try{
@@ -339,7 +340,7 @@ class ExceptionUtil extends AbstractServiceTaskProcessor {
                        }
                        requestInfo = utils.removeXmlPreamble(requestInfo)
                        WorkflowException wfex = execution.getVariable("WorkflowException")
-                       String errorMessage = wfex.getErrorMessage()
+                       String errorMessage = XmlEscapers.xmlContentEscaper().escape(wfex.getErrorMessage())
                        int errorCode = wfex.getErrorCode()
 
                        String falloutHandlerRequest =
@@ -354,13 +355,14 @@ class ExceptionUtil extends AbstractServiceTaskProcessor {
                                        </aetgt:FalloutHandlerRequest>"""
 
                        utils.log("DEBUG", processKey + " Outgoing WorkflowException is: " + execution.getVariable("WorkflowException"), isDebugEnabled)
-                       utils.log("DEBUG", processKey + "Completed ProcessMainflowBPMNException Outgoing FalloutHandler Request is: " + falloutHandlerRequest, isDebugEnabled)
+                       utils.log("DEBUG", processKey + " Outgoing FalloutHandler Request is: " + falloutHandlerRequest, isDebugEnabled)
                        return falloutHandlerRequest
 
                }catch(Exception e){
                        utils.log("DEBUG", "Caught Exception during ProcessMainflowBPMNException Method: " + e, isDebugEnabled)
                        return null
                }
+               utils.log("DEBUG", "Completed ProcessMainflowBPMNException Method", isDebugEnabled)
        }
 
        /**
@@ -371,7 +373,7 @@ class ExceptionUtil extends AbstractServiceTaskProcessor {
         * @param - execution
         *
         */
-       public void processJavaException(Execution execution){
+       public void processJavaException(DelegateExecution execution){
                def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
                String processKey = getProcessKey(execution)
                try{
@@ -389,7 +391,7 @@ class ExceptionUtil extends AbstractServiceTaskProcessor {
        }
 
 
-       public void preProcessRequest(Execution execution) {
+       public void preProcessRequest(DelegateExecution execution) {
                // TODO Auto-generated method stub
 
        }