Merge changes I17e37e7a,Ic34984ab,Ie7a82e78,I22ff6b3b,I71c16816, ...
[so.git] / bpmn / MSOInfrastructureBPMN / src / main / groovy / org / openecomp / mso / bpmn / infrastructure / scripts / DoCustomDeleteE2EServiceInstance.groovy
index f141bbd..85261ee 100644 (file)
@@ -309,6 +309,13 @@ public class DoCustomDeleteE2EServiceInstance extends AbstractServiceTaskProcess
                String msg = ""
 
                try {
+                       execution.setVariable("serviceInstanceId","serviceInstanceId")
+                       execution.setVariable("GENGS_FoundIndicator",true)
+                       execution.setVariable("GENGS_siResourceLink","GENGS_siResourceLink")
+                       execution.setVariable("globalSubscriberId","globalSubscriberId")
+                       execution.setVariable("subscriptionServiceType","subscriptionServiceType")
+                       execution.setVariable("GENGS_service","GENGS_service")
+                       execution.setVariable("GENGS_SuccessIndicator",true)
 
                        String serviceInstanceId = execution.getVariable("serviceInstanceId")
                        boolean foundInAAI = execution.getVariable("GENGS_FoundIndicator")
@@ -362,7 +369,7 @@ public class DoCustomDeleteE2EServiceInstance extends AbstractServiceTaskProcess
                                        utils.log("DEBUG", msg, isDebugEnabled)
                                        exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
                                }
-                               else
+                       /*      else
                                {
                                        utils.log("DEBUG", "SI Data" + siData, isDebugEnabled)
                                        serviceType = utils.getNodeText1(siData,"service-type")
@@ -412,7 +419,7 @@ public class DoCustomDeleteE2EServiceInstance extends AbstractServiceTaskProcess
                                                }
 
                                        }
-                               }
+                               }*/
                        }else{
                                boolean succInAAI = execution.getVariable("GENGS_SuccessIndicator")
                                if(succInAAI != true){
@@ -472,6 +479,85 @@ public class DoCustomDeleteE2EServiceInstance extends AbstractServiceTaskProcess
                utils.log("DEBUG"," *** Exit postProcessAAIDEL *** ", 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 + " operationType:" + oprationType, isDebugEnabled)
+            serviceId = UriUtils.encode(serviceId,"UTF-8")
+            execution.setVariable("serviceInstanceId", serviceId)
+            execution.setVariable("operationId", operationId)
+            execution.setVariable("operationType", operationType)
+            // we use resource instance ids for delete flow as resourceTemplateUUIDs
+            /*[
+             {
+                 "resourceInstanceId":"1111",
+                 "resourceType":"vIMS"
+             },
+             {
+                 "resourceInstanceId":"222",
+                 "resourceType":"vEPC"
+             },
+             {
+                 "resourceInstanceId":"3333",
+                 "resourceType":"overlay"
+             },
+             {
+                 "resourceInstanceId":"4444",
+                 "resourceType":"underlay"
+             }
+         ]*/
+            String serviceRelationShip = execution.getVariable("serviceRelationShip")
+            
+            def jsonSlurper = new JsonSlurper()
+            def jsonOutput = new JsonOutput()         
+            List relationShipList =  jsonSlurper.parseText(serviceRelationShip)
+                    
+            if (relationShipList != null) {
+                relationShipList.each {
+                    resourceTemplateUUIDs  = resourceTemplateUUIDs + it.resourceInstanceId + ":"
+                }
+            }           
+
+            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)  
+    }
+    
    /**
     * prepare delete parameters
     */
@@ -502,12 +588,12 @@ public class DoCustomDeleteE2EServiceInstance extends AbstractServiceTaskProcess
                
        if (relationShipList != null) {
            relationShipList.each {
-               if(resouceName.equals(it.resouceType))
+               if(resourceName.equals(it.resourceType))
                String resouceTemplateUUID = it.resourceInstanceId
-               String resouceInstanceUUID = it.resouceInstanceId
+               String resouceInstanceUUID = it.resourceInstanceId
                execution.setVariable("resouceTemplateUUID", resouceTemplateUUID)
                execution.setVariable("resouceInstanceId", resouceInstanceUUID)
-               execution.setResourceType("resourceType", resouceName)
+               execution.setResourceType("resourceType", resourceName)
            }
        }    
    }