InitServiceOperationStatus for UpdateE2ESVCInst

Change-Id: Idaa55084f5ecb0dd3636c232cebc14fa5f0641f6
Issue-ID: SO-419
Signed-off-by: Yulian Han <elaine.hanyulian@huawei.com>
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateCustomE2EServiceInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateCustomE2EServiceInstance.groovy
index 1c87c11..240b8d0 100644
--- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateCustomE2EServiceInstance.groovy
+++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateCustomE2EServiceInstance.groovy
@@ -138,6 +138,61 @@
 		}
 		utils.log("INFO"," ***** Exit preProcessRequest *****",  isDebugEnabled)
 	}
+	
+	/**
+	 * Init the service Operation Status
+	 */
+	public void prepareInitServiceOperationStatus(DelegateExecution execution){
+		def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
+		utils.log("DEBUG", " ======== STARTED prepareInitServiceOperationStatus Process ======== ", isDebugEnabled)
+		try{
+			String serviceId = execution.getVariable("serviceInstanceId")
+			String operationId = UUID.randomUUID().toString()
+			String operationType = execution.getVariable("operationType")
+			String userId = ""
+			String result = "processing"
+			String progress = "0"
+			String reason = ""
+			String operationContent = "Prepare service updating"
+			utils.log("DEBUG", "Generated new operation for Service Instance serviceId:" + serviceId + " operationId:" + operationId, isDebugEnabled)
+			serviceId = UriUtils.encode(serviceId,"UTF-8")
+			execution.setVariable("serviceInstanceId", serviceId)
+			execution.setVariable("operationId", operationId)
+			execution.setVariable("operationType", operationType)
+
+			def dbAdapterEndpoint = execution.getVariable("URN_mso_adapters_openecomp_db_endpoint")
+			execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint)
+			utils.log("DEBUG", "DB Adapter Endpoint is: " + dbAdapterEndpoint, isDebugEnabled)
+
+			String payload =
+				"""<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
+                        xmlns:ns="http://org.openecomp.mso/requestsdb">
+                        <soapenv:Header/>
+                        <soapenv:Body>
+                            <ns:updateServiceOperationStatus xmlns:ns="http://org.openecomp.mso/requestsdb">
+                            <serviceId>${serviceId}</serviceId>
+                            <operationId>${operationId}</operationId>
+                            <operationType>${operationType}</operationType>
+                            <userId>${userId}</userId>
+                            <result>${result}</result>
+                            <operationContent>${operationContent}</operationContent>
+                            <progress>${progress}</progress>
+                            <reason>${reason}</reason>
+                        </ns:updateServiceOperationStatus>
+                    </soapenv:Body>
+                </soapenv:Envelope>"""
+
+			payload = utils.formatXml(payload)
+			execution.setVariable("CVFMI_updateServiceOperStatusRequest", payload)
+			utils.log("DEBUG", "Outgoing updateServiceOperStatusRequest: \n" + payload, isDebugEnabled)
+			utils.logAudit("CreateVfModuleInfra Outgoing updateServiceOperStatusRequest Request: " + payload)
+
+		}catch(Exception e){
+			utils.log("ERROR", "Exception Occured Processing prepareInitServiceOperationStatus. Exception is:\n" + e, isDebugEnabled)
+			execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during prepareInitServiceOperationStatus Method:\n" + e.getMessage())
+		}
+		utils.log("DEBUG", "======== COMPLETED prepareInitServiceOperationStatus Process ======== ", isDebugEnabled)
+	}
 
 	public void sendSyncResponse (DelegateExecution execution) {
 		def isDebugEnabled=execution.getVariable("isDebugLogEnabled")