AT&T 1712 and 1802 release code
[so.git] / bpmn / MSOCommonBPMN / src / main / groovy / org / openecomp / mso / bpmn / common / scripts / CompleteMsoProcess.groovy
index 66a7c8e..57a04e5 100644 (file)
-/*-\r
- * ============LICENSE_START=======================================================\r
- * ONAP - SO\r
- * ================================================================================\r
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
- * ================================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- *      http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-package org.openecomp.mso.bpmn.common.scripts\r
-\r
-import org.apache.commons.lang3.*\r
-import org.camunda.bpm.engine.delegate.BpmnError\r
-import org.camunda.bpm.engine.runtime.Execution\r
-\r
-\r
-public class CompleteMsoProcess extends AbstractServiceTaskProcessor {\r
-\r
-       String Prefix="CMSO_"\r
-       ExceptionUtil exceptionUtil = new ExceptionUtil()\r
-\r
-       // Complete MSO Request processing\r
-       public initializeProcessVariables(Execution execution){\r
-\r
-               def method = getClass().getSimpleName() + '.initializeProcessVariables(' +'execution=' + execution.getId() +')'\r
-               def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')\r
-               logDebug('Entered ' + method, isDebugLogEnabled)\r
-               try {\r
-\r
-                       /* Initialize all the process request variables in this block */\r
-                       execution.setVariable("prefix",Prefix)\r
-                       execution.setVariable("CMSO_request_id","")\r
-                       execution.setVariable("CMSO_notification-url","")\r
-                       execution.setVariable("CMSO_mso-bpel-name","")\r
-                       execution.setVariable("CMSO_request_action","")\r
-                       execution.setVariable("CMSO_notification-url-Ok", false)\r
-                       execution.setVariable("CMSO_request_id-Ok", false)\r
-\r
-                       //updateRequest Adapter process variables\r
-                       execution.setVariable("CMSO_updateRequestResponse", "")\r
-                       execution.setVariable("CMSO_updateRequestResponseCode", "")\r
-                       execution.setVariable("CMSO_updateFinalNotifyAckStatusFailedPayload", "")\r
-\r
-                       //Set DB adapter variables here\r
-                       execution.setVariable("CMSO_updateDBStatusToSuccessPayload", "")\r
-                       execution.setVariable("CMSO_updateInfraRequestDBPayload", "")\r
-                       execution.setVariable("CMSO_setUpdateDBstatustoSuccessPayload", "")\r
-\r
-                       //Auth variables\r
-                       execution.setVariable("BasicAuthHeaderValue","")\r
-\r
-                       //Response variables\r
-                       execution.setVariable("CompletionHandlerResponse","")\r
-                       execution.setVariable("CMSO_ErrorResponse", null)\r
-                       execution.setVariable("CMSO_ResponseCode", "")\r
-\r
-                       setSuccessIndicator(execution, false)\r
-\r
-               } catch (BpmnError e) {\r
-                       throw e;\r
-               } catch (Exception e) {\r
-                       logError('Caught exception in ' + method, e)\r
-                       exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in" + method)\r
-               }\r
-\r
-       }\r
-\r
-       public void preProcessRequest (Execution execution) {\r
-\r
-               initializeProcessVariables(execution)\r
-               def method = getClass().getSimpleName() + '.preProcessRequest(' +'execution=' + execution.getId() +')'\r
-               def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')\r
-//             utils.log("DEBUG", "*** Started CompleteMsoProcess preProcessRequest Method ***", isDebugLogEnabled);\r
-               logDebug('Entered ' + method, isDebugLogEnabled)\r
-               \r
-               setBasicDBAuthHeader(execution, isDebugLogEnabled)\r
-               \r
-               try {\r
-                       def xml = execution.getVariable("CompleteMsoProcessRequest")\r
-\r
-                       utils.logAudit("CompleteMsoProcess Request: " + xml)\r
-                       utils.log("DEBUG", "Incoming Request is: "+ xml, isDebugLogEnabled)\r
-\r
-                       //mso-bpel-name from the incoming request\r
-                       def msoBpelName = utils.getNodeText1(xml,"mso-bpel-name")\r
-                       execution.setVariable("CMSO_mso-bpel-name",msoBpelName)\r
-\r
-                       //Check the incoming request type\r
-                       //Incoming request can be ACTIVE_REQUESTS (request-information node) or  INFRA_ACTIVE_REQUESTS (request-info node)\r
-                       if (utils.nodeExists(xml, "request-information")) {\r
-                               execution.setVariable("CMSO_request_id-Ok", true) // Incoming request is for ACTIVE_REQUESTS\r
-                       }\r
-\r
-                       //Check notification-url for the incoming request type\r
-                       //ACTIVE_REQUESTS may have notificationurl node\r
-                       //INFRA_ACTIVE_REQUESTS notificationurl node does not exist\r
-                       def notificationurl = ""\r
-                       if (utils.nodeExists(xml, "notification-url")) {\r
-                               notificationurl = utils.getNodeText(xml,"notification-url")\r
-                               if(notificationurl != null && !notificationurl.isEmpty()) {\r
-                                       execution.setVariable("CMSO_notification-url-Ok", true)\r
-                                       execution.setVariable("CMSO_notification-url",notificationurl)\r
-                               }\r
-                       }\r
-\r
-                       //Check request_id for the incoming request type\r
-                       //For INFRA_ACTIVE_REQUESTS payload request-id IS optional (Not sure why this is option since req id is primary key ... also tried exe through SOAP UI to check if MSO code handles null like auto generated seq not it does not)\r
-                       //For ACTIVE_REQUESTS payload request-id is NOT optional\r
-                       def request_id = ""\r
-                       if (utils.nodeExists(xml, "request-id")) {\r
-                               execution.setVariable("CMSO_request_id",utils.getNodeText(xml,"request-id"))\r
-                       }\r
-\r
-\r
-                       // INFRA_ACTIVE_REQUESTS         have "action" element ... mandatory\r
-                       // ACTIVE_REQUEST have "request-action" ... mandatory\r
-                       if (utils.nodeExists(xml, "request-action")) {\r
-                               execution.setVariable("CMSO_request_action",utils.getNodeText(xml,"request-action"))\r
-                       } else if (utils.nodeExists(xml, "action")) {\r
-                               execution.setVariable("CMSO_request_action",utils.getNodeText(xml,"action"))\r
-                       }\r
-\r
-                       //Check source for the incoming request type\r
-                       //For INFRA_ACTIVE_REQUESTS payload source IS optional\r
-                       //For ACTIVE_REQUESTS payload source is NOT optional\r
-                       def source = ""\r
-                       if (utils.nodeExists(xml, "source")) {\r
-                               execution.setVariable("CMSO_source",utils.getNodeText(xml,"source"))\r
-                       }\r
-\r
-                       utils.log("DEBUG", "CMSO_notification-url-Ok --> " + execution.getVariable("CMSO_notification-url-Ok"), isDebugLogEnabled)\r
-                       utils.log("DEBUG", "CMSO_request_id-Ok --> " + execution.getVariable("CMSO_request_id-Ok"), isDebugLogEnabled)\r
-\r
-                       // set the DHV/Service Instantiation values if specified in the request\r
-                       execution.setVariable("CMSO_is_srv_inst_req", String.valueOf("true".equals(utils.getNodeText1(xml, "is-srv-inst-req"))))\r
-                       utils.log("DEBUG", "CMSO_is_srv_inst_req --> " + execution.getVariable("CMSO_is_srv_inst_req"), isDebugLogEnabled)\r
-                       execution.setVariable("CMSO_is_json_content", String.valueOf("JSON".equals(utils.getNodeText1(xml, "resp-content-type"))))\r
-                       utils.log("DEBUG", "CMSO_is_json_content --> " + execution.getVariable("CMSO_is_json_content"), isDebugLogEnabled)\r
-                       execution.setVariable("CMSO_service_inst_id", utils.getNodeText1(xml, "service-instance-id"))\r
-                       utils.log("DEBUG", "CMSO_service_inst_id --> " + execution.getVariable("CMSO_service_inst_id"), isDebugLogEnabled)\r
-                       execution.setVariable("CMSO_start_time", utils.getNodeText1(xml, "start-time"))\r
-                       utils.log("DEBUG", "CMSO_start_time --> " + execution.getVariable("CMSO_start_time"), isDebugLogEnabled)\r
-                       // this variable is used by the camunda flow to set the Content-Type for the async response\r
-                       if (execution.getVariable("CMSO_is_srv_inst_req").equals("true") &&\r
-                               execution.getVariable("CMSO_is_json_content").equals("true")) {\r
-                               execution.setVariable("CMSO_content_type", "application/json")\r
-                       } else {\r
-                               execution.setVariable("CMSO_content_type", "text/xml")\r
-                       }\r
-                       \r
-                       logDebug('Exited ' + method, isDebugLogEnabled)\r
-               } catch (BpmnError e) {\r
-                       throw e;\r
-               } catch (Exception e) {\r
-                       utils.log("DEBUG", "Exception Occured During PreProcessRequest: " + e, isDebugLogEnabled);\r
-                       exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in " + method)\r
-               }\r
-\r
-//             utils.log("DEBUG", "*** Completed CompleteMsoProcess preProcessRequest Method ***", isDebugLogEnabled);\r
-       }\r
-\r
-       public void setUpdateDBstatustoSuccessPayload (Execution execution){\r
-\r
-               def method = getClass().getSimpleName() + '.setUpdateDBstatustoSuccessPayload(' +'execution=' + execution.getId() +')'\r
-               def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')\r
-               logDebug('Entered ' + method, isDebugLogEnabled)\r
-\r
-               try {\r
-\r
-                       def xml = execution.getVariable("CompleteMsoProcessRequest")\r
-\r
-                       //Get statusMessage if exists\r
-                       def statusMessage\r
-                       if(utils.nodeExists(xml, "status-message")){\r
-                               statusMessage = utils.getNodeText1(xml, "status-message")\r
-                       }else{\r
-                               statusMessage = "Resource Completed Successfully"\r
-                       }\r
-\r
-                       //Get instance Id if exist\r
-                       String idXml = ""\r
-                       if(utils.nodeExists(xml, "vnfId")){\r
-                               idXml = utils.getNodeXml(xml, "vnfId")\r
-                       }else if(utils.nodeExists(xml, "networkId")){\r
-                               idXml = utils.getNodeXml(xml, "networkId")\r
-                       }else if(utils.nodeExists(xml, "serviceInstanceId")){\r
-                               idXml = utils.getNodeXml(xml, "serviceInstanceId")\r
-                       }else if(utils.nodeExists(xml, "vfModuleId")){\r
-                               idXml = utils.getNodeXml(xml, "vfModuleId")\r
-                       }else if(utils.nodeExists(xml, "volumeGroupId")){\r
-                               idXml = utils.getNodeXml(xml, "volumeGroupId")\r
-                       }else{\r
-                               idXml = ""\r
-                       }\r
-                       idXml = utils.removeXmlPreamble(idXml)\r
-                       utils.log("DEBUG", "Incoming Instance Id Xml: " + idXml, isDebugLogEnabled)\r
-\r
-                       String payload = """\r
-                                               <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http://org.openecomp.mso/requestsdb">\r
-                                                  <soapenv:Header/>\r
-                                                  <soapenv:Body>\r
-                                                     <req:updateInfraRequest>\r
-                                                        <requestId>${execution.getVariable("CMSO_request_id")}</requestId>\r
-                                                        <lastModifiedBy>${execution.getVariable("CMSO_mso-bpel-name")}</lastModifiedBy>\r
-                                                        <statusMessage>${statusMessage}</statusMessage>\r
-                                                        <requestStatus>COMPLETE</requestStatus>\r
-                                                                <progress>100</progress>\r
-                                                                ${idXml}\r
-                                                     </req:updateInfraRequest>\r
-                                                  </soapenv:Body>\r
-                                               </soapenv:Envelope>"""\r
-\r
-                       execution.setVariable("CMSO_setUpdateDBstatustoSuccessPayload", payload)\r
-                       utils.log("DEBUG", "Outgoing Update Mso Request Payload is: " + payload, isDebugLogEnabled)\r
-                       utils.logAudit("setUpdateDBstatustoSuccessPayload: " + payload)\r
-\r
-               } catch (BpmnError e) {\r
-                       throw e;\r
-               } catch (Exception e) {\r
-                       logError('Caught exception in ' + method, e)\r
-                       exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in" + method)\r
-               }\r
-               logDebug('Exited ' + method, isDebugLogEnabled)\r
-       }\r
-\r
-       public void buildDataError (Execution execution, String message) {\r
-\r
-               def method = getClass().getSimpleName() + '.buildDataError(' +'execution=' + execution.getId() +')'\r
-               def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')\r
-               logDebug('Entered ' + method, isDebugLogEnabled)\r
-               try {\r
-\r
-                       def msoCompletionResponse = """\r
-                       <sdncadapterworkflow:MsoCompletionResponse xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1">\r
-                          <sdncadapterworkflow:out>BPEL ${execution.getVariable("CMSO_mso-bpel-name")} FAILED</sdncadapterworkflow:out>\r
-                       </sdncadapterworkflow:MsoCompletionResponse>\r
-                       """.trim()\r
-\r
-                       // Format Response\r
-                       def xmlMsoCompletionResponse = utils.formatXml(msoCompletionResponse)\r
-                       String buildMsoCompletionResponseAsString = xmlMsoCompletionResponse.drop(38).trim()\r
-                       utils.logAudit("CompleteMsoProcess Response: " + buildMsoCompletionResponseAsString)\r
-                       execution.setVariable("CompleteMsoProcessResponse", buildMsoCompletionResponseAsString)\r
-                       utils.log("DEBUG", "@@ CompleteMsoProcess Response @@ " + "\n" + execution.getVariable("CompletionHandlerResponse"), isDebugLogEnabled)\r
-\r
-                       exceptionUtil.buildAndThrowWorkflowException(execution, 500, message)\r
-\r
-               } catch (BpmnError e) {\r
-                       utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugLogEnabled)\r
-                       throw e;\r
-               } catch (Exception e) {\r
-                       logError('Caught exception in ' + method, e)\r
-                       exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in" + method)\r
-               }\r
-\r
-       }\r
-       \r
-       public void postProcessResponse (Execution execution) {\r
-               \r
-                               def method = getClass().getSimpleName() + '.postProcessResponse(' +'execution=' + execution.getId() +')'\r
-                               def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')\r
-                               logDebug('Entered ' + method, isDebugLogEnabled)\r
-               //              utils.log("DEBUG", "*** Started CompleteMsoProcess PostProcessRequest Method ***", isDebugLogEnabled);\r
-                               try {\r
-               \r
-                                       def msoCompletionResponse = """\r
-                       <sdncadapterworkflow:MsoCompletionResponse xmlns:sdncadapterworkflow="http://ecomp.com/mso/workflow/schema/v1">\r
-                          <sdncadapterworkflow:out>BPEL ${execution.getVariable("CMSO_mso-bpel-name")} completed</sdncadapterworkflow:out>\r
-                       </sdncadapterworkflow:MsoCompletionResponse>\r
-                       """.trim()\r
-               \r
-                                       // Format Response\r
-                                       def xmlMsoCompletionResponse = utils.formatXML(msoCompletionResponse)\r
-                                       String buildMsoCompletionResponseAsString = xmlMsoCompletionResponse.drop(38).trim()\r
-                                       // TODO: Should deprecate use of processKey+Response variable for the response. Will use "WorkflowResponse" instead\r
-                                       execution.setVariable("WorkflowResponse", buildMsoCompletionResponseAsString)\r
-                                       utils.logAudit("CompleteMsoProcess Response: " + buildMsoCompletionResponseAsString)\r
-                                       execution.setVariable("CompleteMsoProcessResponse", buildMsoCompletionResponseAsString)\r
-                                       execution.setVariable("CMSO_ResponseCode", "200")\r
-               \r
-                                       setSuccessIndicator(execution, true)\r
-               \r
-                                       utils.log("DEBUG", "@@ CompleteMsoProcess Response @@ " + "\n" + execution.getVariable("CompleteMsoProcessResponse"), isDebugLogEnabled)\r
-               \r
-                                       logDebug('Exited ' + method, isDebugLogEnabled)\r
-                               } catch (BpmnError e) {\r
-                                       throw e;\r
-                               } catch (Exception e) {\r
-                                       logError('Caught exception in ' + method, e)\r
-                                       exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in" + method)\r
-                               }\r
-               //              utils.log("DEBUG", "*** Completed CompleteMsoProcess PostProcessRequest Method ***", isDebugLogEnabled);\r
-               \r
-       }\r
-                       \r
-\r
-}\r
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.bpmn.common.scripts
+
+import org.apache.commons.lang3.*
+import org.camunda.bpm.engine.delegate.BpmnError
+import org.camunda.bpm.engine.delegate.DelegateExecution\r
+
+
+public class CompleteMsoProcess extends AbstractServiceTaskProcessor {
+
+       String Prefix="CMSO_"
+       ExceptionUtil exceptionUtil = new ExceptionUtil()
+
+       // Complete MSO Request processing
+       public initializeProcessVariables(DelegateExecution execution){\r
+
+               def method = getClass().getSimpleName() + '.initializeProcessVariables(' +'execution=' + execution.getId() +')'
+               def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
+               logDebug('Entered ' + method, isDebugLogEnabled)
+               try {
+
+                       /* Initialize all the process request variables in this block */
+                       execution.setVariable("prefix",Prefix)
+                       execution.setVariable("CMSO_request_id","")
+                       execution.setVariable("CMSO_notification-url","")
+                       execution.setVariable("CMSO_mso-bpel-name","")
+                       execution.setVariable("CMSO_request_action","")
+                       execution.setVariable("CMSO_notification-url-Ok", false)
+                       execution.setVariable("CMSO_request_id-Ok", false)
+
+                       //updateRequest Adapter process variables
+                       execution.setVariable("CMSO_updateRequestResponse", "")
+                       execution.setVariable("CMSO_updateRequestResponseCode", "")
+                       execution.setVariable("CMSO_updateFinalNotifyAckStatusFailedPayload", "")
+
+                       //Set DB adapter variables here
+                       execution.setVariable("CMSO_updateDBStatusToSuccessPayload", "")
+                       execution.setVariable("CMSO_updateInfraRequestDBPayload", "")
+                       execution.setVariable("CMSO_setUpdateDBstatustoSuccessPayload", "")
+
+                       //Auth variables
+                       execution.setVariable("BasicAuthHeaderValue","")
+
+                       //Response variables
+                       execution.setVariable("CompletionHandlerResponse","")
+                       execution.setVariable("CMSO_ErrorResponse", null)
+                       execution.setVariable("CMSO_ResponseCode", "")
+
+                       setSuccessIndicator(execution, false)
+
+               } catch (BpmnError e) {
+                       throw e;
+               } catch (Exception e) {
+                       logError('Caught exception in ' + method, e)
+                       exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in" + method)
+               }
+
+       }
+
+       public void preProcessRequest (DelegateExecution execution) {\r
+
+               initializeProcessVariables(execution)
+               def method = getClass().getSimpleName() + '.preProcessRequest(' +'execution=' + execution.getId() +')'
+               def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
+//             utils.log("DEBUG", "*** Started CompleteMsoProcess preProcessRequest Method ***", isDebugLogEnabled);
+               logDebug('Entered ' + method, isDebugLogEnabled)
+
+               setBasicDBAuthHeader(execution, isDebugLogEnabled)
+
+               try {
+                       def xml = execution.getVariable("CompleteMsoProcessRequest")
+
+                       utils.logAudit("CompleteMsoProcess Request: " + xml)
+                       utils.log("DEBUG", "Incoming Request is: "+ xml, isDebugLogEnabled)
+
+                       //mso-bpel-name from the incoming request
+                       def msoBpelName = utils.getNodeText1(xml,"mso-bpel-name")
+                       execution.setVariable("CMSO_mso-bpel-name",msoBpelName)
+
+                       //Check the incoming request type
+                       //Incoming request can be ACTIVE_REQUESTS (request-information node) or  INFRA_ACTIVE_REQUESTS (request-info node)
+                       if (utils.nodeExists(xml, "request-information")) {
+                               execution.setVariable("CMSO_request_id-Ok", true) // Incoming request is for ACTIVE_REQUESTS
+                       }
+
+                       //Check for rehome indicator
+                       def rehomeIndicator = utils.getNodeText1(xml,"rehomeDone")
+                       execution.setVariable("rehomeDone", rehomeIndicator)
+
+                       //Check notification-url for the incoming request type
+                       //ACTIVE_REQUESTS may have notificationurl node
+                       //INFRA_ACTIVE_REQUESTS notificationurl node does not exist
+                       def notificationurl = ""
+                       if (utils.nodeExists(xml, "notification-url")) {
+                               notificationurl = utils.getNodeText(xml,"notification-url")
+                               if(notificationurl != null && !notificationurl.isEmpty()) {
+                                       execution.setVariable("CMSO_notification-url-Ok", true)
+                                       execution.setVariable("CMSO_notification-url",notificationurl)
+                               }
+                       }
+
+                       //Check request_id for the incoming request type
+                       //For INFRA_ACTIVE_REQUESTS payload request-id IS optional (Not sure why this is option since req id is primary key ... also tried exe through SOAP UI to check if MSO code handles null like auto generated seq not it does not)
+                       //For ACTIVE_REQUESTS payload request-id is NOT optional
+                       def request_id = ""
+                       if (utils.nodeExists(xml, "request-id")) {
+                               execution.setVariable("CMSO_request_id",utils.getNodeText(xml,"request-id"))
+                       }
+
+
+                       // INFRA_ACTIVE_REQUESTS         have "action" element ... mandatory
+                       // ACTIVE_REQUEST have "request-action" ... mandatory
+                       if (utils.nodeExists(xml, "request-action")) {
+                               execution.setVariable("CMSO_request_action",utils.getNodeText(xml,"request-action"))
+                       } else if (utils.nodeExists(xml, "action")) {
+                               execution.setVariable("CMSO_request_action",utils.getNodeText(xml,"action"))
+                       }
+
+                       //Check source for the incoming request type
+                       //For INFRA_ACTIVE_REQUESTS payload source IS optional
+                       //For ACTIVE_REQUESTS payload source is NOT optional
+                       def source = ""
+                       if (utils.nodeExists(xml, "source")) {
+                               execution.setVariable("CMSO_source",utils.getNodeText(xml,"source"))
+                       }
+
+                       utils.log("DEBUG", "CMSO_notification-url-Ok --> " + execution.getVariable("CMSO_notification-url-Ok"), isDebugLogEnabled)
+                       utils.log("DEBUG", "CMSO_request_id-Ok --> " + execution.getVariable("CMSO_request_id-Ok"), isDebugLogEnabled)
+
+                       // set the DHV/Service Instantiation values if specified in the request
+                       execution.setVariable("CMSO_is_srv_inst_req", String.valueOf("true".equals(utils.getNodeText1(xml, "is-srv-inst-req"))))
+                       utils.log("DEBUG", "CMSO_is_srv_inst_req --> " + execution.getVariable("CMSO_is_srv_inst_req"), isDebugLogEnabled)
+                       execution.setVariable("CMSO_is_json_content", String.valueOf("JSON".equals(utils.getNodeText1(xml, "resp-content-type"))))
+                       utils.log("DEBUG", "CMSO_is_json_content --> " + execution.getVariable("CMSO_is_json_content"), isDebugLogEnabled)
+                       execution.setVariable("CMSO_service_inst_id", utils.getNodeText1(xml, "service-instance-id"))
+                       utils.log("DEBUG", "CMSO_service_inst_id --> " + execution.getVariable("CMSO_service_inst_id"), isDebugLogEnabled)
+                       execution.setVariable("CMSO_start_time", utils.getNodeText1(xml, "start-time"))
+                       utils.log("DEBUG", "CMSO_start_time --> " + execution.getVariable("CMSO_start_time"), isDebugLogEnabled)
+                       // this variable is used by the camunda flow to set the Content-Type for the async response
+                       if (execution.getVariable("CMSO_is_srv_inst_req").equals("true") &&
+                               execution.getVariable("CMSO_is_json_content").equals("true")) {
+                               execution.setVariable("CMSO_content_type", "application/json")
+                       } else {
+                               execution.setVariable("CMSO_content_type", "text/xml")
+                       }
+
+                       logDebug('Exited ' + method, isDebugLogEnabled)
+               } catch (BpmnError e) {
+                       throw e;
+               } catch (Exception e) {
+                       utils.log("DEBUG", "Exception Occured During PreProcessRequest: " + e, isDebugLogEnabled);
+                       exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in " + method)
+               }
+
+//             utils.log("DEBUG", "*** Completed CompleteMsoProcess preProcessRequest Method ***", isDebugLogEnabled);
+       }
+
+       public void setUpdateDBstatustoSuccessPayload (DelegateExecution execution){\r
+
+               def method = getClass().getSimpleName() + '.setUpdateDBstatustoSuccessPayload(' +'execution=' + execution.getId() +')'
+               def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
+               logDebug('Entered ' + method, isDebugLogEnabled)
+
+               try {
+
+                       def xml = execution.getVariable("CompleteMsoProcessRequest")
+
+                       //Get statusMessage if exists
+                       def statusMessage
+                       if(utils.nodeExists(xml, "status-message")){
+                               statusMessage = utils.getNodeText1(xml, "status-message")
+                       }else{
+                               statusMessage = "Resource Completed Successfully"
+                       }
+
+                       //Get instance Id if exist
+                       String idXml = ""
+                       if(utils.nodeExists(xml, "vnfId")){
+                               idXml = utils.getNodeXml(xml, "vnfId")
+                       }else if(utils.nodeExists(xml, "networkId")){
+                               idXml = utils.getNodeXml(xml, "networkId")
+                       }else if(utils.nodeExists(xml, "configurationId")){
+                               idXml = utils.getNodeXml(xml, "configurationId")
+                       }else if(utils.nodeExists(xml, "serviceInstanceId")){
+                               idXml = utils.getNodeXml(xml, "serviceInstanceId")
+                       }else if(utils.nodeExists(xml, "vfModuleId")){
+                               idXml = utils.getNodeXml(xml, "vfModuleId")
+                       }else if(utils.nodeExists(xml, "volumeGroupId")){
+                               idXml = utils.getNodeXml(xml, "volumeGroupId")
+                       }else{
+                               idXml = ""
+                       }
+                       idXml = utils.removeXmlPreamble(idXml)
+                       utils.log("DEBUG", "Incoming Instance Id Xml: " + idXml, isDebugLogEnabled)
+
+                       String payload = """
+                                               <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http://org.openecomp.mso/requestsdb">
+                                                  <soapenv:Header/>
+                                                  <soapenv:Body>
+                                                     <req:updateInfraRequest>
+                                                        <requestId>${execution.getVariable("CMSO_request_id")}</requestId>
+                                                        <lastModifiedBy>${execution.getVariable("CMSO_mso-bpel-name")}</lastModifiedBy>
+                                                        <statusMessage>${statusMessage}</statusMessage>
+                                                        <requestStatus>COMPLETE</requestStatus>
+                                                                <progress>100</progress>
+                                                                ${idXml}
+                                                     </req:updateInfraRequest>
+                                                  </soapenv:Body>
+                                               </soapenv:Envelope>"""
+
+                       execution.setVariable("CMSO_setUpdateDBstatustoSuccessPayload", payload)
+                       utils.log("DEBUG", "Outgoing Update Mso Request Payload is: " + payload, isDebugLogEnabled)
+                       utils.logAudit("setUpdateDBstatustoSuccessPayload: " + payload)
+
+               } catch (BpmnError e) {
+                       throw e;
+               } catch (Exception e) {
+                       logError('Caught exception in ' + method, e)
+                       exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in" + method)
+               }
+               logDebug('Exited ' + method, isDebugLogEnabled)
+       }
+
+       public void buildDataError (DelegateExecution execution, String message) {\r
+
+               def method = getClass().getSimpleName() + '.buildDataError(' +'execution=' + execution.getId() +')'
+               def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
+               logDebug('Entered ' + method, isDebugLogEnabled)
+               try {
+
+                       def msoCompletionResponse = """
+                       <sdncadapterworkflow:MsoCompletionResponse xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1">
+                          <sdncadapterworkflow:out>BPEL ${execution.getVariable("CMSO_mso-bpel-name")} FAILED</sdncadapterworkflow:out>
+                       </sdncadapterworkflow:MsoCompletionResponse>
+                       """.trim()
+
+                       // Format Response
+                       def xmlMsoCompletionResponse = utils.formatXml(msoCompletionResponse)
+                       String buildMsoCompletionResponseAsString = xmlMsoCompletionResponse.drop(38).trim()
+                       utils.logAudit("CompleteMsoProcess Response: " + buildMsoCompletionResponseAsString)
+                       execution.setVariable("CompleteMsoProcessResponse", buildMsoCompletionResponseAsString)
+                       utils.log("DEBUG", "@@ CompleteMsoProcess Response @@ " + "\n" + execution.getVariable("CompletionHandlerResponse"), isDebugLogEnabled)
+
+                       exceptionUtil.buildAndThrowWorkflowException(execution, 500, message)
+
+               } catch (BpmnError e) {
+                       utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugLogEnabled)
+                       throw e;
+               } catch (Exception e) {
+                       logError('Caught exception in ' + method, e)
+                       exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in" + method)
+               }
+
+       }
+
+       public void postProcessResponse (DelegateExecution execution) {\r
+
+                               def method = getClass().getSimpleName() + '.postProcessResponse(' +'execution=' + execution.getId() +')'
+                               def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
+                               logDebug('Entered ' + method, isDebugLogEnabled)
+               //              utils.log("DEBUG", "*** Started CompleteMsoProcess PostProcessRequest Method ***", isDebugLogEnabled);
+                               try {
+
+                                       def msoCompletionResponse = """
+                       <sdncadapterworkflow:MsoCompletionResponse xmlns:sdncadapterworkflow="http://ecomp.com/mso/workflow/schema/v1">
+                          <sdncadapterworkflow:out>BPEL ${execution.getVariable("CMSO_mso-bpel-name")} completed</sdncadapterworkflow:out>
+                       </sdncadapterworkflow:MsoCompletionResponse>
+                       """.trim()
+
+                                       // Format Response
+                                       def xmlMsoCompletionResponse = utils.formatXML(msoCompletionResponse)
+                                       String buildMsoCompletionResponseAsString = xmlMsoCompletionResponse.drop(38).trim()
+                                       // TODO: Should deprecate use of processKey+Response variable for the response. Will use "WorkflowResponse" instead
+                                       execution.setVariable("WorkflowResponse", buildMsoCompletionResponseAsString)
+                                       utils.logAudit("CompleteMsoProcess Response: " + buildMsoCompletionResponseAsString)
+                                       execution.setVariable("CompleteMsoProcessResponse", buildMsoCompletionResponseAsString)
+                                       execution.setVariable("CMSO_ResponseCode", "200")
+
+                                       setSuccessIndicator(execution, true)
+
+                                       utils.log("DEBUG", "@@ CompleteMsoProcess Response @@ " + "\n" + execution.getVariable("CompleteMsoProcessResponse"), isDebugLogEnabled)
+
+                                       logDebug('Exited ' + method, isDebugLogEnabled)
+                               } catch (BpmnError e) {
+                                       throw e;
+                               } catch (Exception e) {
+                                       logError('Caught exception in ' + method, e)
+                                       exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in" + method)
+                               }
+               //              utils.log("DEBUG", "*** Completed CompleteMsoProcess PostProcessRequest Method ***", isDebugLogEnabled);
+
+       }
+
+
+}