[MSO-8] Update the maven dependency
[so.git] / bpmn / MSOCommonBPMN / src / main / groovy / org / openecomp / mso / bpmn / common / scripts / VnfAdapterRestV1.groovy
  * ============LICENSE_END=========================================================
  */
 
-package com.att.bpm.scripts
+package org.openecomp.mso.bpmn.common.scripts
 
-import groovy.xml.XmlUtil
-
-import java.text.SimpleDateFormat
-import java.net.URLEncoder
-
-import org.apache.commons.codec.binary.Base64
 import org.apache.commons.lang3.*
 import org.camunda.bpm.engine.delegate.BpmnError
 import org.camunda.bpm.engine.runtime.Execution
-
-import org.openecomp.mso.bpmn.core.WorkflowException
 import org.openecomp.mso.rest.APIResponse
 import org.openecomp.mso.rest.RESTClient
 import org.openecomp.mso.rest.RESTConfig
@@ -52,7 +44,7 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor {
                setSuccessIndicator(execution, false)
 
                try {
-                       String request = validateRequest(execution, "att-mso-request-id")
+                       String request = validateRequest(execution, "mso-request-id")
 
                        // Get the request type (the name of the root element) from the request
 
@@ -72,8 +64,8 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor {
                                exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
                        }
 
-                       execution.setVariable(prefix + 'messageId', messageId)
-                       logDebug(getProcessKey(execution) + ': ' + prefix + 'messageId = ' + messageId, isDebugLogEnabled)
+                       execution.setVariable('VNFAResponse_CORRELATOR', messageId)
+                       logDebug(getProcessKey(execution) + ': VNFAResponse_CORRELATOR = ' + messageId, isDebugLogEnabled)
 
                        // Get the notificationUrl from the request
 
@@ -338,30 +330,27 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor {
                def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
                logDebug('Entered ' + method, isDebugLogEnabled)
 
-               String prefix = execution.getVariable('prefix')
-               String callback = execution.getVariable(prefix + 'callback')
+               String callback = execution.getVariable('VNFAResponse_MESSAGE')
 
                try {
                        logDebug(getProcessKey(execution) + ": received callback:\n" + callback, isDebugLogEnabled)
 
-                       Node root = new XmlParser().parseText(callback)
-                       if (root.name().endsWith('Exception')) {
-                               vnfAdapterWorkflowException(execution, callback)
-                       }
-
                        // The XML callback is available to the calling flow in any case,
-                       // even if a WorkflowException was generated.
+                       // even if a WorkflowException is generated.
                        execution.setVariable(getProcessKey(execution) + 'Response', callback)
                        // TODO: Should deprecate use of processKey+Response variable for the response. Will use "WorkflowResponse" instead.
                        execution.setVariable("WorkflowResponse", callback)
-               } catch(BpmnError b){
-                       throw b
+
+                       Node root = new XmlParser().parseText(callback)
+                       if (root.name().endsWith('Exception')) {
+                               vnfAdapterWorkflowException(execution, callback)
+                       }
                } catch (Exception e) {
                        e.printStackTrace()
                        callback = callback == null || String.valueOf(callback).isEmpty() ? "NONE" : callback
                        String msg = "Received error from VnfAdapter: " + callback
                        logDebug(getProcessKey(execution) + ': ' + msg, isDebugLogEnabled)
-                       exceptionUtil.buildAndThrowWorkflowException(execution, 7020, msg)
+                       exceptionUtil.buildWorkflowException(execution, 7020, msg)
                }
        }
 
@@ -379,13 +368,11 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor {
                        message = message == null || message.isEmpty() ? "" : " message='" + message + "'"
                        String rolledBack = getChildText(root, "rolledBack")
                        rolledBack = rolledBack == null || rolledBack.isEmpty() ? "" : " rolledBack='" + rolledBack + "'"
-                       exceptionUtil.buildAndThrowWorkflowException(execution, 7020, "Received " + root.name() +
+                       exceptionUtil.buildWorkflowException(execution, 7020, "Received " + root.name() +
                                " from VnfAdapter:" + category + message + rolledBack);
-               }catch(BpmnError b){
-                       throw b
-               }catch (Exception e) {
+               } catch (Exception e) {
                        response = response == null || String.valueOf(response).isEmpty() ? "NONE" : response
-                       exceptionUtil.buildAndThrowWorkflowException(execution, 7020, "Received error from VnfAdapter: " + response)
+                       exceptionUtil.buildWorkflowException(execution, 7020, "Received error from VnfAdapter: " + response)
                }
        }