Merge "Correct E2E svc to update RequestDb"
diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapter.java b/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapter.java
index 9648922..43273df 100644
--- a/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapter.java
+++ b/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapter.java
@@ -55,5 +55,21 @@
 
     @WebMethod
     public boolean getSiteStatus (@WebParam(name="siteName") @XmlElement(required = true) String siteName);
+    
+    @WebMethod
+    public void updateServiceOperationStatus (@WebParam(name = "serviceId") @XmlElement(required = true) String serviceId,
+                                    @WebParam(name = "operationId") @XmlElement(required = false) String operationId,
+                                    @WebParam(name = "operationType") @XmlElement(required = false) String operationType,
+                                    @WebParam(name = "userId") @XmlElement(required = false) String userId,
+                                    @WebParam(name = "result") @XmlElement(required = false) String result,
+                                    @WebParam(name = "operationContent") @XmlElement(required = false) String operationContent,
+                                    @WebParam(name = "progress") @XmlElement(required = false) String progress,
+                                    @WebParam(name = "reason") @XmlElement(required = false) String reason) throws MsoRequestsDbException;
+
+    @WebMethod
+    public void initResourceOperationStatus (@WebParam(name = "serviceId") @XmlElement(required = true) String serviceId,
+                                    @WebParam(name = "operationId") @XmlElement(required = true) String operationId,
+                                    @WebParam(name = "operationType") @XmlElement(required = true) String operationType,
+                                    @WebParam(name = "resourceTemplateUUIDs") @XmlElement(required = true) String resourceTemplateUUIDs) throws MsoRequestsDbException;
 
 }
diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapterImpl.java b/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapterImpl.java
index f8a2c98..87be2e1 100644
--- a/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapterImpl.java
+++ b/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapterImpl.java
@@ -22,20 +22,24 @@
 
 import java.sql.Timestamp;
 
+import javax.jws.WebMethod;
 import javax.jws.WebService;
 
-import org.openecomp.mso.requestsdb.SiteStatus;
-import org.openecomp.mso.utils.UUIDChecker;
 import org.hibernate.HibernateException;
 import org.hibernate.Query;
 import org.hibernate.Session;
-
 import org.openecomp.mso.adapters.requestsdb.exceptions.MsoRequestsDbException;
+import org.openecomp.mso.db.AbstractSessionFactoryManager;
 import org.openecomp.mso.logger.MessageEnum;
 import org.openecomp.mso.logger.MsoLogger;
-import org.openecomp.mso.db.AbstractSessionFactoryManager;
-import org.openecomp.mso.requestsdb.RequestsDbSessionFactoryManager;
 import org.openecomp.mso.requestsdb.InfraActiveRequests;
+import org.openecomp.mso.requestsdb.OperationStatus;
+import org.openecomp.mso.requestsdb.RequestsDatabase;
+import org.openecomp.mso.requestsdb.RequestsDbConstant;
+import org.openecomp.mso.requestsdb.RequestsDbSessionFactoryManager;
+import org.openecomp.mso.requestsdb.ResourceOperationStatus;
+import org.openecomp.mso.requestsdb.SiteStatus;
+import org.openecomp.mso.utils.UUIDChecker;
 
 @WebService(serviceName = "RequestsDbAdapter", endpointInterface = "org.openecomp.mso.adapters.requestsdb.MsoRequestsDbAdapter", targetNamespace = "http://org.openecomp.mso/requestsdb")
 public class MsoRequestsDbAdapterImpl implements MsoRequestsDbAdapter {
@@ -262,4 +266,61 @@
             return siteStatus.getStatus();
         }
     }
+    
+    /**
+     * update operation status
+     * <br>
+     * 
+     * @param serviceId
+     * @param operationId
+     * @param operationType
+     * @param userId
+     * @param result
+     * @param operationContent
+     * @param progress
+     * @param reason
+     * @throws MsoRequestsDbException
+     * @since   ONAP Amsterdam Release
+     */
+    @Override
+    public void updateServiceOperationStatus(String serviceId, String operationId, String operationType, String userId,
+            String result, String operationContent, String progress, String reason) throws MsoRequestsDbException {
+        OperationStatus operStatus = new OperationStatus();
+        operStatus.setServiceId(serviceId);
+        operStatus.setOperationId(operationId);
+        operStatus.setUserId(userId);
+        operStatus.setOperation(operationType);
+        operStatus.setReason(reason);
+        operStatus.setProgress(progress);
+        operStatus.setOperationContent(operationContent);
+        RequestsDatabase.getInstance().updateOperationStatus(operStatus);
+    }
+    
+    /**
+     * init the operation status of  all the resources 
+     * <br>
+     * 
+     * @param serviceId the service Id
+     * @param operationId the operation Id
+     * @param operationType the operationType
+     * @param resourceTemplateUUIDs the resources, the UUID is split by ":"
+     * @throws MsoRequestsDbException
+     * @since   ONAP Amsterdam Release
+     */
+    @Override
+    public void initResourceOperationStatus(String serviceId, String operationId, String operationType,
+            String resourceTemplateUUIDs) throws MsoRequestsDbException{
+        String[] resourceLst = resourceTemplateUUIDs.split(":");
+        for(String resource: resourceLst){
+            ResourceOperationStatus resourceStatus = new ResourceOperationStatus();
+            resourceStatus.setOperationId(operationId);
+            resourceStatus.setServiceId(serviceId);
+            resourceStatus.setResourceTemplateUUID(resource);
+            resourceStatus.setOperType(operationType);
+            resourceStatus.setStatus(RequestsDbConstant.Status.PROCESSING);
+            resourceStatus.setStatusDescription("Waiting for start");
+            RequestsDatabase.getInstance().updateResOperStatus(resourceStatus);
+        }     
+    }
+
 }
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateCustomE2EServiceInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateCustomE2EServiceInstance.groovy
index 33bbbd8..7f4f787 100644
--- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateCustomE2EServiceInstance.groovy
+++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateCustomE2EServiceInstance.groovy
@@ -282,4 +282,59 @@
 		}
 		utils.log("DEBUG", "*** Exit prepareFalloutRequest ***", isDebugEnabled)
 	}
+	
+	/**
+	 * Init the service Operation Status
+	 */
+	public void prepareInitServiceOperationStatus(Execution 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 = "CREATE"
+            String userId = ""
+            String result = "processing"
+            String progress = "0"
+            String reason = ""
+            String operationContent = "Prepare service creation"
+            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_openecomp_adapters_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}</responseBody>
+                            <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)    
+	}
 }
\ No newline at end of file
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy
index 4129a76..7505eed 100644
--- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy
+++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy
@@ -606,4 +606,64 @@
 		utils.log("DEBUG"," *** Exit postProcessRollback *** ", isDebugEnabled)
 	}
 
+	public void preInitResourcesOperStatus(Execution execution){
+        def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
+
+        utils.log("DEBUG", " ======== STARTED preInitResourcesOperStatus Process ======== ", isDebugEnabled)
+        try{
+            String serviceId = execution.getVariable("serviceInstanceId")
+            String operationId = execution.getVariable("operationId")
+            String operationType = execution.getVariable("operationType")
+            String resourceTemplateUUIDs = ""
+            String result = "processing"
+            String progress = "0"
+            String reason = ""
+            String operationContent = "Prepare service creation"
+            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 jsonSlurper = new JsonSlurper()
+            def jsonOutput = new JsonOutput()
+            String incomingRequest = execution.getVariable("bpmnRequest")
+            Map serviceReq =  jsonSlurper.parseText(incomingRequest)
+            def segmentList = serviceReq.service.parameters.segments
+                    
+            if (segmentList != null) {
+                segmentList.each {
+                    resourceTemplateUUIDs  = resourcesUUIDs + it.resourceUUID + ":"
+                }
+            }            
+
+            def dbAdapterEndpoint = execution.getVariable("URN_mso_openecomp_adapters_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:initResourceOperationStatus xmlns:ns="http://org.openecomp.mso/requestsdb">
+                            <serviceId>${serviceId}</serviceId>
+                            <operationId>${operationId}</operationId>
+                            <operationType>${operationType}</operationType>
+                            <resourceTemplateUUIDs>${resourceTemplateUUIDs}</resourceTemplateUUIDs>
+                        </ns:initResourceOperationStatus>
+                    </soapenv:Body>
+                </soapenv:Envelope>"""
+
+            payload = utils.formatXml(payload)
+            execution.setVariable("CVFMI_initResOperStatusRequest", payload)
+            utils.log("DEBUG", "Outgoing initResourceOperationStatus: \n" + payload, isDebugEnabled)
+            utils.logAudit("CreateVfModuleInfra Outgoing initResourceOperationStatus Request: " + payload)
+
+        }catch(Exception e){
+            utils.log("ERROR", "Exception Occured Processing preInitResourcesOperStatus. Exception is:\n" + e, isDebugEnabled)
+            execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during preInitResourcesOperStatus Method:\n" + e.getMessage())
+        }
+        utils.log("DEBUG", "======== COMPLETED preInitResourcesOperStatus Process ======== ", isDebugEnabled)  
+	}
+	
 }
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateCustomE2EServiceInstance.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateCustomE2EServiceInstance.bpmn
index a0a77fa..0a80602 100644
--- a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateCustomE2EServiceInstance.bpmn
+++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateCustomE2EServiceInstance.bpmn
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.7.2">
+<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.10.0">
   <bpmn:process id="CreateCustomE2EServiceInstance" name="CreateCustomE2EServiceInstance" isExecutable="true">
     <bpmn:startEvent id="StartEvent_00qj6ro" name="Create SI Start Flow">
       <bpmn:outgoing>SequenceFlow_0s2spoq</bpmn:outgoing>
@@ -113,7 +113,7 @@
       <bpmn:sequenceFlow id="SequenceFlow_01umodj" sourceRef="ScriptTask_0u8o9p2" targetRef="CallActivity_1ang7q8" />
     </bpmn:subProcess>
     <bpmn:scriptTask id="ScriptTask_0xupxj9" name="Send Sync Ack Response" scriptFormat="groovy">
-      <bpmn:incoming>SequenceFlow_0z4faf9</bpmn:incoming>
+      <bpmn:incoming>SequenceFlow_081z8l2</bpmn:incoming>
       <bpmn:outgoing>SequenceFlow_19eilro</bpmn:outgoing>
       <bpmn:script><![CDATA[import org.openecomp.mso.bpmn.infrastructure.scripts.*
 def csi = new  CreateCustomE2EServiceInstance()
@@ -132,7 +132,7 @@
     <bpmn:sequenceFlow id="SequenceFlow_19eilro" sourceRef="ScriptTask_0xupxj9" targetRef="DoCreateE2EServiceInstance" />
     <bpmn:sequenceFlow id="SequenceFlow_0klbpxx" sourceRef="DoCreateE2EServiceInstance" targetRef="ExclusiveGateway_0aqn64l" />
     <bpmn:sequenceFlow id="SequenceFlow_0yayvrf" sourceRef="CallActivity_02fyxz0" targetRef="EndEvent_0bpd6c0" />
-    <bpmn:sequenceFlow id="SequenceFlow_0z4faf9" sourceRef="ScriptTask_1s09c7d" targetRef="ScriptTask_0xupxj9" />
+    <bpmn:sequenceFlow id="SequenceFlow_0z4faf9" sourceRef="ScriptTask_1s09c7d" targetRef="Task_1tqjch6" />
     <bpmn:sequenceFlow id="SequenceFlow_14zu6wr" name="yes" sourceRef="ExclusiveGateway_0aqn64l" targetRef="ScriptTask_0ttvn8r">
       <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[#{execution.getVariable("WorkflowException") == null}]]></bpmn:conditionExpression>
     </bpmn:sequenceFlow>
@@ -140,14 +140,45 @@
     <bpmn:sequenceFlow id="SequenceFlow_1fueo69" name="no" sourceRef="ExclusiveGateway_0aqn64l" targetRef="EndEvent_07uk5iy">
       <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[#{execution.getVariable("WorkflowException") != null}]]></bpmn:conditionExpression>
     </bpmn:sequenceFlow>
+    <bpmn:sequenceFlow id="SequenceFlow_1euqjsp" sourceRef="Task_1tqjch6" targetRef="Task_19mxcw3" />
+    <bpmn:scriptTask id="Task_1tqjch6" name="Init Service Operation Status" scriptFormat="groovy">
+      <bpmn:incoming>SequenceFlow_0z4faf9</bpmn:incoming>
+      <bpmn:outgoing>SequenceFlow_1euqjsp</bpmn:outgoing>
+      <bpmn:script><![CDATA[import org.openecomp.mso.bpmn.infrastructure.scripts.*
+def csi= new CreateCustomE2EServiceInstance()
+csi.InitServiceOperationStatus(execution)]]></bpmn:script>
+    </bpmn:scriptTask>
+    <bpmn:sequenceFlow id="SequenceFlow_081z8l2" sourceRef="Task_19mxcw3" targetRef="ScriptTask_0xupxj9" />
+    <bpmn:serviceTask id="Task_19mxcw3" name="Update Service Operation Status">
+      <bpmn:extensionElements>
+        <camunda:connector>
+          <camunda:inputOutput>
+            <camunda:inputParameter name="url">${URN_mso_openecomp_adapters_db_endpoint}</camunda:inputParameter>
+            <camunda:inputParameter name="headers">
+              <camunda:map>
+                <camunda:entry key="content-type">application/soap+xml</camunda:entry>
+                <camunda:entry key="Authorization">#{BasicAuthHeaderValueDB}</camunda:entry>
+              </camunda:map>
+            </camunda:inputParameter>
+            <camunda:inputParameter name="payload">${CVFMI_updateServiceOperStatusRequest}</camunda:inputParameter>
+            <camunda:inputParameter name="method">POST</camunda:inputParameter>
+            <camunda:outputParameter name="CVFMI_dbResponseCode">${statusCode}</camunda:outputParameter>
+            <camunda:outputParameter name="CVFMI_dbResponse">${response}</camunda:outputParameter>
+          </camunda:inputOutput>
+          <camunda:connectorId>http-connector</camunda:connectorId>
+        </camunda:connector>
+      </bpmn:extensionElements>
+      <bpmn:incoming>SequenceFlow_1euqjsp</bpmn:incoming>
+      <bpmn:outgoing>SequenceFlow_081z8l2</bpmn:outgoing>
+    </bpmn:serviceTask>
   </bpmn:process>
   <bpmn:error id="Error_0nbdy47" name="MSOWorkflowException" errorCode="MSOWorkflowException" />
   <bpmndi:BPMNDiagram id="BPMNDiagram_1">
     <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="CreateCustomE2EServiceInstance">
       <bpmndi:BPMNShape id="StartEvent_00qj6ro_di" bpmnElement="StartEvent_00qj6ro">
-        <dc:Bounds x="235" y="180" width="36" height="36" />
+        <dc:Bounds x="82" y="180" width="36" height="36" />
         <bpmndi:BPMNLabel>
-          <dc:Bounds x="216" y="221" width="75" height="24" />
+          <dc:Bounds x="64" y="221" width="73" height="24" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="SubProcess_0ka59nc_di" bpmnElement="SubProcess_0ka59nc" isExpanded="true">
@@ -163,7 +194,7 @@
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="ScriptTask_1s09c7d_di" bpmnElement="ScriptTask_1s09c7d">
-        <dc:Bounds x="353" y="158" width="100" height="80" />
+        <dc:Bounds x="158" y="158" width="100" height="80" />
       </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="ScriptTask_0ttvn8r_di" bpmnElement="ScriptTask_0ttvn8r">
         <dc:Bounds x="1038" y="158" width="100" height="80" />
@@ -175,7 +206,7 @@
         <dc:Bounds x="348" y="370" width="679" height="194" />
       </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="ScriptTask_0xupxj9_di" bpmnElement="ScriptTask_0xupxj9">
-        <dc:Bounds x="521" y="158" width="100" height="80" />
+        <dc:Bounds x="550" y="158" width="100" height="80" />
       </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="ExclusiveGateway_0aqn64l_di" bpmnElement="ExclusiveGateway_0aqn64l" isMarkerVisible="true">
         <dc:Bounds x="903" y="173" width="50" height="50" />
@@ -190,17 +221,17 @@
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNShape>
       <bpmndi:BPMNEdge id="SequenceFlow_0s2spoq_di" bpmnElement="SequenceFlow_0s2spoq">
-        <di:waypoint xsi:type="dc:Point" x="271" y="198" />
-        <di:waypoint xsi:type="dc:Point" x="353" y="198" />
+        <di:waypoint xsi:type="dc:Point" x="118" y="198" />
+        <di:waypoint xsi:type="dc:Point" x="158" y="198" />
         <bpmndi:BPMNLabel>
-          <dc:Bounds x="267" y="183" width="0" height="12" />
+          <dc:Bounds x="93" y="177" width="90" height="12" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="SequenceFlow_19eilro_di" bpmnElement="SequenceFlow_19eilro">
-        <di:waypoint xsi:type="dc:Point" x="621" y="198" />
+        <di:waypoint xsi:type="dc:Point" x="650" y="198" />
         <di:waypoint xsi:type="dc:Point" x="701" y="198" />
         <bpmndi:BPMNLabel>
-          <dc:Bounds x="616" y="183" width="0" height="12" />
+          <dc:Bounds x="630.5" y="177" width="90" height="12" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="SequenceFlow_0klbpxx_di" bpmnElement="SequenceFlow_0klbpxx">
@@ -218,10 +249,10 @@
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="SequenceFlow_0z4faf9_di" bpmnElement="SequenceFlow_0z4faf9">
-        <di:waypoint xsi:type="dc:Point" x="453" y="198" />
-        <di:waypoint xsi:type="dc:Point" x="521" y="198" />
+        <di:waypoint xsi:type="dc:Point" x="258" y="198" />
+        <di:waypoint xsi:type="dc:Point" x="298" y="198" />
         <bpmndi:BPMNLabel>
-          <dc:Bounds x="442" y="183" width="0" height="12" />
+          <dc:Bounds x="233" y="177" width="90" height="12" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="SequenceFlow_14zu6wr_di" bpmnElement="SequenceFlow_14zu6wr">
@@ -331,6 +362,26 @@
           <dc:Bounds x="715.5" y="459" width="0" height="12" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
+      <bpmndi:BPMNEdge id="SequenceFlow_1euqjsp_di" bpmnElement="SequenceFlow_1euqjsp">
+        <di:waypoint xsi:type="dc:Point" x="398" y="198" />
+        <di:waypoint xsi:type="dc:Point" x="425.46307385229545" y="198" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="411.7315369261477" y="177" width="0" height="12" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNShape id="ScriptTask_1a3vwas_di" bpmnElement="Task_1tqjch6">
+        <dc:Bounds x="298" y="158" width="100" height="80" />
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNEdge id="SequenceFlow_081z8l2_di" bpmnElement="SequenceFlow_081z8l2">
+        <di:waypoint xsi:type="dc:Point" x="525.4630738522955" y="198" />
+        <di:waypoint xsi:type="dc:Point" x="550" y="198" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="537.7315369261478" y="177" width="0" height="12" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNShape id="ServiceTask_1afiuuq_di" bpmnElement="Task_19mxcw3">
+        <dc:Bounds x="426" y="158" width="100" height="80" />
+      </bpmndi:BPMNShape>
     </bpmndi:BPMNPlane>
   </bpmndi:BPMNDiagram>
 </bpmn:definitions>
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateE2EServiceInstance.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateE2EServiceInstance.bpmn
index 758de28..2e996e2 100644
--- a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateE2EServiceInstance.bpmn
+++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateE2EServiceInstance.bpmn
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="_MagIIMOUEeW8asg-vCEgWQ" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="Camunda Modeler" exporterVersion="1.7.2" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd">
+<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="_MagIIMOUEeW8asg-vCEgWQ" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="Camunda Modeler" exporterVersion="1.10.0" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd">
   <bpmn2:process id="DoCreateE2EServiceInstance" name="DoCreateE2EServiceInstance" isExecutable="true">
     <bpmn2:startEvent id="createSI_startEvent" name="Start Flow">
       <bpmn2:outgoing>SequenceFlow_1</bpmn2:outgoing>
@@ -135,7 +135,7 @@
 csi.preSDNCRequest(execution)]]></bpmn2:script>
     </bpmn2:scriptTask>
     <bpmn2:scriptTask id="ScriptTask_0wvq4t8" name="Prepare VF-C Adaptor Data Request" scriptFormat="groovy">
-      <bpmn2:incoming>SequenceFlow_1170ztf</bpmn2:incoming>
+      <bpmn2:incoming>SequenceFlow_05gdjox</bpmn2:incoming>
       <bpmn2:outgoing>SequenceFlow_15zgrcq</bpmn2:outgoing>
       <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.infrastructure.scripts.*
 def csi = new  DoCreateE2EServiceInstance()
@@ -160,11 +160,42 @@
     <bpmn2:sequenceFlow id="SequenceFlow_15zgrcq" sourceRef="ScriptTask_0wvq4t8" targetRef="CallActivity_0uwm4l1" />
     <bpmn2:sequenceFlow id="SequenceFlow_1vvdkcs" sourceRef="CallActivity_09c3ajg" targetRef="ScriptTask_1xdjlzm" />
     <bpmn2:sequenceFlow id="SequenceFlow_092ghvu" sourceRef="ScriptTask_1xdjlzm" targetRef="EndEvent_0kbbt94" />
-    <bpmn2:sequenceFlow id="SequenceFlow_1170ztf" sourceRef="ExclusiveGateway_1nk6aol" targetRef="ScriptTask_0wvq4t8" />
+    <bpmn2:sequenceFlow id="SequenceFlow_1170ztf" sourceRef="ExclusiveGateway_1nk6aol" targetRef="Task_0uiekmn" />
     <bpmn2:endEvent id="EndEvent_0kbbt94">
       <bpmn2:incoming>SequenceFlow_092ghvu</bpmn2:incoming>
     </bpmn2:endEvent>
     <bpmn2:sequenceFlow id="SequenceFlow_0k4q7jm" sourceRef="CallActivity_0uwm4l1" targetRef="ScriptTask_0081lne" />
+    <bpmn2:sequenceFlow id="SequenceFlow_1qctzm0" sourceRef="Task_0uiekmn" targetRef="Task_0raqlqc" />
+    <bpmn2:scriptTask id="Task_0uiekmn" name="Prepare Resource Oper Status">
+      <bpmn2:incoming>SequenceFlow_1170ztf</bpmn2:incoming>
+      <bpmn2:outgoing>SequenceFlow_1qctzm0</bpmn2:outgoing>
+      <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.infrastructure.scripts.*
+def ddsi = new DoCreateE2EServiceInstance()
+ddsi.preInitResourcesOperStatus(execution)]]></bpmn2:script>
+    </bpmn2:scriptTask>
+    <bpmn2:sequenceFlow id="SequenceFlow_05gdjox" sourceRef="Task_0raqlqc" targetRef="ScriptTask_0wvq4t8" />
+    <bpmn2:serviceTask id="Task_0raqlqc" name="Init Resource Oper Status">
+      <bpmn2:extensionElements>
+        <camunda:connector>
+          <camunda:inputOutput>
+            <camunda:inputParameter name="url">${URN_mso_openecomp_adapters_db_endpoint}</camunda:inputParameter>
+            <camunda:inputParameter name="headers">
+              <camunda:map>
+                <camunda:entry key="content-type">application/soap+xml</camunda:entry>
+                <camunda:entry key="Authorization">#{BasicAuthHeaderValueDB}</camunda:entry>
+              </camunda:map>
+            </camunda:inputParameter>
+            <camunda:inputParameter name="payload">${CVFMI_initResOperStatusRequest}</camunda:inputParameter>
+            <camunda:inputParameter name="method">POST</camunda:inputParameter>
+            <camunda:outputParameter name="CVFMI_dbResponseCode">${statusCode}</camunda:outputParameter>
+            <camunda:outputParameter name="CVFMI_dbResponse">${response}</camunda:outputParameter>
+          </camunda:inputOutput>
+          <camunda:connectorId>http-connector</camunda:connectorId>
+        </camunda:connector>
+      </bpmn2:extensionElements>
+      <bpmn2:incoming>SequenceFlow_1qctzm0</bpmn2:incoming>
+      <bpmn2:outgoing>SequenceFlow_05gdjox</bpmn2:outgoing>
+    </bpmn2:serviceTask>
   </bpmn2:process>
   <bpmn2:error id="Error_2" name="MSOWorkflowException" errorCode="MSOWorkflowException" />
   <bpmn2:error id="Error_1" name="java.lang.Exception" errorCode="java.lang.Exception" />
@@ -340,69 +371,89 @@
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNShape id="ScriptTask_0081lne_di" bpmnElement="ScriptTask_0081lne">
-        <dc:Bounds x="850" y="819" width="100" height="80" />
+        <dc:Bounds x="477" y="819" width="100" height="80" />
       </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="ScriptTask_0wvq4t8_di" bpmnElement="ScriptTask_0wvq4t8">
-        <dc:Bounds x="972" y="564" width="100" height="80" />
+        <dc:Bounds x="848" y="819" width="100" height="80" />
       </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="CallActivity_09c3ajg_di" bpmnElement="CallActivity_09c3ajg">
-        <dc:Bounds x="601" y="819" width="100" height="80" />
+        <dc:Bounds x="295" y="819" width="100" height="80" />
       </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="CallActivity_0uwm4l1_di" bpmnElement="CallActivity_0uwm4l1">
-        <dc:Bounds x="972" y="690" width="100" height="80" />
+        <dc:Bounds x="632" y="819" width="100" height="80" />
       </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="ScriptTask_1xdjlzm_di" bpmnElement="ScriptTask_1xdjlzm">
-        <dc:Bounds x="372" y="819" width="100" height="80" />
+        <dc:Bounds x="101" y="819" width="100" height="80" />
       </bpmndi:BPMNShape>
       <bpmndi:BPMNEdge id="SequenceFlow_0ofqw6v_di" bpmnElement="SequenceFlow_0ofqw6v">
-        <di:waypoint xsi:type="dc:Point" x="850" y="859" />
-        <di:waypoint xsi:type="dc:Point" x="701" y="859" />
+        <di:waypoint xsi:type="dc:Point" x="477" y="859" />
+        <di:waypoint xsi:type="dc:Point" x="395" y="859" />
         <bpmndi:BPMNLabel>
-          <dc:Bounds x="730.5" y="838" width="90" height="12" />
+          <dc:Bounds x="391" y="838" width="90" height="12" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="SequenceFlow_15zgrcq_di" bpmnElement="SequenceFlow_15zgrcq">
-        <di:waypoint xsi:type="dc:Point" x="1022" y="644" />
-        <di:waypoint xsi:type="dc:Point" x="1022" y="690" />
+        <di:waypoint xsi:type="dc:Point" x="848" y="859" />
+        <di:waypoint xsi:type="dc:Point" x="732" y="859" />
         <bpmndi:BPMNLabel>
-          <dc:Bounds x="992" y="661" width="90" height="12" />
+          <dc:Bounds x="745" y="838" width="90" height="12" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="SequenceFlow_1vvdkcs_di" bpmnElement="SequenceFlow_1vvdkcs">
-        <di:waypoint xsi:type="dc:Point" x="601" y="859" />
-        <di:waypoint xsi:type="dc:Point" x="472" y="859" />
+        <di:waypoint xsi:type="dc:Point" x="295" y="859" />
+        <di:waypoint xsi:type="dc:Point" x="201" y="859" />
         <bpmndi:BPMNLabel>
-          <dc:Bounds x="491.5" y="838" width="90" height="12" />
+          <dc:Bounds x="203" y="838" width="90" height="12" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="SequenceFlow_092ghvu_di" bpmnElement="SequenceFlow_092ghvu">
-        <di:waypoint xsi:type="dc:Point" x="372" y="859" />
-        <di:waypoint xsi:type="dc:Point" x="222" y="859" />
+        <di:waypoint xsi:type="dc:Point" x="101" y="859" />
+        <di:waypoint xsi:type="dc:Point" x="11" y="859" />
         <bpmndi:BPMNLabel>
-          <dc:Bounds x="252" y="838" width="90" height="12" />
+          <dc:Bounds x="11" y="838" width="90" height="12" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="SequenceFlow_1170ztf_di" bpmnElement="SequenceFlow_1170ztf">
         <di:waypoint xsi:type="dc:Point" x="1022" y="510" />
-        <di:waypoint xsi:type="dc:Point" x="1022" y="564" />
+        <di:waypoint xsi:type="dc:Point" x="1022" y="588" />
         <bpmndi:BPMNLabel>
-          <dc:Bounds x="992" y="531" width="90" height="12" />
+          <dc:Bounds x="992" y="543" width="90" height="12" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNShape id="EndEvent_01p249c_di" bpmnElement="EndEvent_0kbbt94">
-        <dc:Bounds x="186" y="841" width="36" height="36" />
+        <dc:Bounds x="-25" y="841" width="36" height="36" />
         <bpmndi:BPMNLabel>
-          <dc:Bounds x="68" y="881" width="90" height="12" />
+          <dc:Bounds x="-143" y="881" width="90" height="12" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNShape>
       <bpmndi:BPMNEdge id="SequenceFlow_0k4q7jm_di" bpmnElement="SequenceFlow_0k4q7jm">
-        <di:waypoint xsi:type="dc:Point" x="1022" y="770" />
-        <di:waypoint xsi:type="dc:Point" x="1022" y="859" />
-        <di:waypoint xsi:type="dc:Point" x="950" y="859" />
+        <di:waypoint xsi:type="dc:Point" x="632" y="859" />
+        <di:waypoint xsi:type="dc:Point" x="577" y="859" />
         <bpmndi:BPMNLabel>
-          <dc:Bounds x="1037" y="808.5" width="0" height="12" />
+          <dc:Bounds x="559.5" y="838" width="90" height="12" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
+      <bpmndi:BPMNEdge id="SequenceFlow_1qctzm0_di" bpmnElement="SequenceFlow_1qctzm0">
+        <di:waypoint xsi:type="dc:Point" x="1022" y="668" />
+        <di:waypoint xsi:type="dc:Point" x="1022" y="704" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="1037" y="680" width="0" height="12" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNShape id="ScriptTask_0v81r5h_di" bpmnElement="Task_0uiekmn">
+        <dc:Bounds x="972" y="588" width="100" height="80" />
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNEdge id="SequenceFlow_05gdjox_di" bpmnElement="SequenceFlow_05gdjox">
+        <di:waypoint xsi:type="dc:Point" x="1022" y="784" />
+        <di:waypoint xsi:type="dc:Point" x="1022" y="859" />
+        <di:waypoint xsi:type="dc:Point" x="948" y="859" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="1037" y="815.5" width="0" height="12" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNShape id="ServiceTask_14tnuxf_di" bpmnElement="Task_0raqlqc">
+        <dc:Bounds x="972" y="704" width="100" height="80" />
+      </bpmndi:BPMNShape>
     </bpmndi:BPMNPlane>
   </bpmndi:BPMNDiagram>
 </bpmn2:definitions>
diff --git a/docs/Install_Configure_SO.rst b/docs/Install_Configure_SO.rst
index 026a287..5771a10 100644
--- a/docs/Install_Configure_SO.rst
+++ b/docs/Install_Configure_SO.rst
@@ -2,8 +2,8 @@
 .. http://creativecommons.org/licenses/by/4.0

 .. Copyright 2017 Huawei Technologies Co., Ltd.

 

-Install and Configure an Ubuntu VM

-==================================

+Install and Configure Service Orchestrator

+==========================================

 

 Get Ubuntu

 ----------

diff --git a/docs/architecture.rst b/docs/architecture.rst
index 58aaabb..67cf67f 100644
--- a/docs/architecture.rst
+++ b/docs/architecture.rst
@@ -2,9 +2,15 @@
 .. http://creativecommons.org/licenses/by/4.0

 .. Copyright 2017 Huawei Technologies Co., Ltd.

 

-ONAP Service Orchestration Documentation - Architecture

+ONAP Service Orchestration - Architecture

 ========================================================

 

+SO Architecture

+----------------

+SO architecture and internal details could be found in the below wiki link

+

+https://wiki.onap.org/pages/viewpage.action?pageId=9830754

+

 .. toctree::

    :maxdepth: 1

-   https://wiki.onap.org/pages/viewpage.action?pageId=9830754
\ No newline at end of file
+   
\ No newline at end of file
diff --git a/docs/index.rst b/docs/index.rst
index 7a1a2b2..e2fbfcd 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -8,6 +8,7 @@
 .. toctree::

    :maxdepth: 1

 

+   Install_Configure_SO.rst

    architecture.rst

    offered_consumed_apis.rst

-   Install_Configure_SO.rst
\ No newline at end of file
+   
\ No newline at end of file
diff --git a/docs/installation.rst b/docs/installation.rst
index 6e45709..fc5af91 100644
--- a/docs/installation.rst
+++ b/docs/installation.rst
@@ -3,8 +3,8 @@
 .. http://creativecommons.org/licenses/by/4.0

 .. Copyright 2017 Huawei Technologies Co., Ltd.

 

-Install and Configure an Ubuntu VM

-==================================

+Install and Configure Service Orchestrator

+==========================================

 

 Get Ubuntu

 ----------

diff --git a/docs/offered_consumed_apis.rst b/docs/offered_consumed_apis.rst
index 623e7da..f7110c7 100644
--- a/docs/offered_consumed_apis.rst
+++ b/docs/offered_consumed_apis.rst
@@ -2,9 +2,15 @@
 .. http://creativecommons.org/licenses/by/4.0

 .. Copyright 2017 Huawei Technologies Co., Ltd.

 

-ONAP Service Orchestration Documentation - Architecture

-========================================================

+ONAP Service Orchestration APIs

+=====================================

 

+SO APIs

+--------

+All the Service Orchestrator APIs, both inward and outward are documented in the below link of onap wiki.

+

+   https://wiki.onap.org/display/DW/SO+R1+Interfaces

+   

+   

 .. toctree::

    :maxdepth: 1

-   https://wiki.onap.org/display/DW/SO+R1+Interfaces
\ No newline at end of file