* ============LICENSE_END=========================================================
*/
-package com.att.bpm.scripts
+package org.openecomp.mso.bpmn.common.scripts
-import org.openecomp.mso.bpmn.core.WorkflowException
+import static org.apache.commons.lang3.StringUtils.*
+import org.apache.commons.lang3.*
import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.runtime.Execution
-import org.apache.commons.lang3.*
-
-import static org.apache.commons.lang3.StringUtils.*;
+import org.openecomp.mso.bpmn.core.WorkflowException
/**
* @version 1.0
String modifiedErrorMessage = 'Received error from A&AI (' + text +')'
utils.log("DEBUG", "ModifiedErrorMessage " + modifiedErrorMessage, isDebugEnabled)
// let $ModifiedErrorMessage := concat( 'Received error from A',$exceptionaai:ampersand,'AI (' ,functx:replace-multi($ErrorMessage,$from,$Variables ),')')
- String message = """<aetgt:WorkflowException xmlns:aetgt="http://ecomp.att.com/mso/workflow/schema/v1">
+ String message = """<aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1">
<aetgt:ErrorMessage>$modifiedErrorMessage</aetgt:ErrorMessage>
<aetgt:ErrorCode>$errorCode</aetgt:ErrorCode>
</aetgt:WorkflowException>"""
errorCode = MapErrorCode(errorMsg)
String mappedErrorMessage = MapErrorMessage(errorMsg, errorCode)
- String message = """<aetgt:WorkflowException xmlns:aetgt="http://ecomp.att.com/mso/workflow/schema/v1">
+ String message = """<aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1">
<aetgt:ErrorMessage>$mappedErrorMessage</aetgt:ErrorMessage>
<aetgt:ErrorCode>$errorCode</aetgt:ErrorCode>
</aetgt:WorkflowException>"""
*/
@Deprecated
String buildWorkflowExceptionXml(String errorCode, String errorMessage) {
- return """<aetgt:WorkflowException xmlns:aetgt="http://ecomp.att.com/mso/workflow/schema/v1">
+ return """<aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1">
<aetgt:ErrorMessage>${errorMessage}</aetgt:ErrorMessage>
<aetgt:ErrorCode>${errorCode}</aetgt:ErrorCode>
</aetgt:WorkflowException>"""
String mes = wfex.getErrorMessage()
int code = wfex.getErrorCode()
xml =
- """<aetgt:WorkflowException xmlns:aetgt="http://ecomp.att.com/mso/workflow/schema/v1">
+ """<aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1">
<aetgt:ErrorMessage>${mes}</aetgt:ErrorMessage>
<aetgt:ErrorCode>${code}</aetgt:ErrorCode>
</aetgt:WorkflowException>"""
}else{
xml =
- """<aetgt:WorkflowException xmlns:aetgt="http://ecomp.att.com/mso/workflow/schema/v1">
+ """<aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1">
<aetgt:ErrorMessage>Internal Error</aetgt:ErrorMessage>
<aetgt:ErrorCode>2500</aetgt:ErrorCode>
</aetgt:WorkflowException>"""
if(errorMessage == null){
errorMessage=""
}
- if( errorCode.equals('5010'))
- return 'Could not communicate with A&AI'
- else if (errorCode.equals('5020'))
+ if( errorCode.equals('5010')) {
+ return 'Could not communicate with A&AI'
+ } else if (errorCode.equals('5020')) {
return 'No response from A&AI'
- else
+ } else {
+ errorMessage = errorMessage.replace("&", "&").replace("<", "<").replace(">", ">")
return 'Received error from A&AI (' +errorMessage +')'
+ }
}
String MapCategoryToErrorCode(String errorCategory)
int errorCode = wfex.getErrorCode()
String falloutHandlerRequest =
- """<aetgt:FalloutHandlerRequest xmlns:aetgt="http://ecomp.att.com/mso/workflow/schema/v1"
- xmlns:ns="http://ecomp.att.com/mso/request/types/v1"
- xmlns:wfsch="http://ecomp.att.com/mso/workflow/schema/v1">
+ """<aetgt:FalloutHandlerRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"
+ xmlns:ns="http://org.openecomp/mso/request/types/v1"
+ xmlns:wfsch="http://org.openecomp/mso/workflow/schema/v1">
${requestInfo}
- <aetgt:WorkflowException xmlns:aetgt="http://ecomp.att.com/mso/workflow/schema/v1">
+ <aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1">
<aetgt:ErrorMessage>${errorMessage}</aetgt:ErrorMessage>
<aetgt:ErrorCode>${errorCode}</aetgt:ErrorCode>
</aetgt:WorkflowException>
utils.log("DEBUG", "Completed ProcessMainflowBPMNException Method", isDebugEnabled)
}
+ /**
+ *
+ * This method should only be used by DHV Flows. This method is
+ * executed after an MSOWorkflowException is caught by a Mainflow.
+ * It builds and returns a FalloutHandler Request. It also
+ * verifies the WorkflowException variable is populated.
+ *
+ * @param - execution
+ * @param - requestInfo
+ *
+ * @return - falloutHandlerRequest
+ *
+ */
+ public String processMainflowsBPMNExceptionDHV(Execution execution, String requestId, def source, def action, def notificationUrl, def serviceInstanceId, def startTime){
+ def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
+ String processKey = getProcessKey(execution)
+ try{
+ utils.log("DEBUG", "Started ProcessMainflowBPMNExceptionDHV Method", isDebugEnabled)
+
+ def WorkflowException workflowException = execution.getVariable("WorkflowException")
+ int errorResponseCode = 0
+ def errorResponseMsg = ""
+ if(workflowException != null){
+ errorResponseCode = workflowException.getErrorCode()
+ def errorMsg = workflowException.getErrorMessage()
+ if (errorMsg != null) {
+ errorResponseMsg = errorMsg.replace("&", "&").replace("<", "<").replace(">", ">")
+ }
+ }else{
+ errorResponseCode = 2500
+ errorResponseMsg = "Internal Error occured during " + action + ", unable to retrieve error information."
+ }
+
+
+ String request =
+ """<FalloutHandlerRequest xmlns="http://org.openecomp/mso/workflow/schema/v1">
+ <request-information xmlns="http://org.openecomp/mso/request/types/v1">
+ <request-id>${requestId}</request-id>
+ <request-action>${action}</request-action>
+ <source>${source}</source>
+ <notification-url>${notificationUrl}</notification-url>
+ </request-information>
+ <mso-bpel-name>BPMN</mso-bpel-name>
+ <is-srv-inst-req>true</is-srv-inst-req>
+ <resp-content-type>JSON</resp-content-type>
+ <service-instance-id>${serviceInstanceId}</service-instance-id>
+ <start-time>${startTime}</start-time>
+ <WorkflowException>
+ <ErrorMessage>${errorResponseMsg}</ErrorMessage>
+ <ErrorCode>${errorResponseCode}</ErrorCode>
+ </WorkflowException>
+ </FalloutHandlerRequest>"""
+
+
+ request = utils.formatXml(request)
+ utils.log("DEBUG", processKey + " Outgoing WorkflowException is: " + execution.getVariable("WorkflowException"), isDebugEnabled)
+ utils.log("DEBUG", processKey + " Outgoing FalloutHandler Request is: " + request, isDebugEnabled)
+
+ return request
+
+ }catch(Exception e){
+ utils.log("DEBUG", "Caught Exception during ProcessMainflowBPMNException Method: " + e, isDebugEnabled)
+ return null
+ }
+ utils.log("DEBUG", "Completed ProcessMainflowBPMNExceptionDHV Method", isDebugEnabled)
+ }
+
/**
* This method is executed after an Java Exception is caught.
* It sets the WorkflowException variable and throws an MSOWorkflowException.
* @param - execution
*
*/
+ @Deprecated
public void processSubflowsJavaException(Execution execution){
def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
String processKey = getProcessKey(execution)
utils.log("DEBUG", "Completed processJavaException Method", isDebugEnabled)
}
+ /**
+ *
+ * This method is executed after an Java Exception is caught
+ * It sets the WorkflowException variable. The method can be used in either mainflow or subflows.
+ *
+ * @param - execution
+ *
+ */
+ public void processJavaException(Execution execution){
+ def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
+ String processKey = getProcessKey(execution)
+ try{
+ utils.log("DEBUG", "Caught a Java Exception in " + processKey, isDebugEnabled)
+ utils.log("DEBUG", "Started processJavaException Method", isDebugEnabled)
+ buildWorkflowException(execution, 2500, "Catch a Java Lang Exception in " + processKey)
- public void preProcessRequest(Execution execution) {
- // TODO Auto-generated method stub
-
+ }catch(BpmnError b){
+ throw b
+ }catch(Exception e){
+ utils.log("DEBUG", "Caught Exception during processJavaException Method: " + e, isDebugEnabled)
+ buildWorkflowException(execution, 2500, "Internal Error - During Process Java Exception")
+ }
+ utils.log("DEBUG", "Completed processJavaException Method", isDebugEnabled)
}
+ public void preProcessRequest(Execution execution) {
+ // TODO Auto-generated method stub
-
+ }
}