AT&T 1712 and 1802 release code
[so.git] / bpmn / MSOInfrastructureBPMN / src / main / groovy / org / openecomp / mso / bpmn / infrastructure / scripts / DoDeleteServiceInstance.groovy
index fd4162f..8fc1f41 100644 (file)
@@ -37,7 +37,7 @@ import javax.xml.parsers.DocumentBuilder
 import javax.xml.parsers.DocumentBuilderFactory
 
 import org.camunda.bpm.engine.delegate.BpmnError
-import org.camunda.bpm.engine.runtime.Execution
+import org.camunda.bpm.engine.delegate.DelegateExecution
 import org.json.JSONObject;
 import org.apache.commons.lang3.*
 import org.apache.commons.codec.binary.Base64;
@@ -75,7 +75,7 @@ public class DoDeleteServiceInstance extends AbstractServiceTaskProcessor {
        ExceptionUtil exceptionUtil = new ExceptionUtil()
        JsonUtils jsonUtil = new JsonUtils()
 
-       public void preProcessRequest (Execution execution) {
+       public void preProcessRequest (DelegateExecution execution) {
                def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
                utils.log("DEBUG"," ***** preProcessRequest *****",  isDebugEnabled)
                String msg = ""
@@ -83,7 +83,7 @@ public class DoDeleteServiceInstance extends AbstractServiceTaskProcessor {
                try {
                        String requestId = execution.getVariable("msoRequestId")
                        execution.setVariable("prefix",Prefix)
-
+                       
                        //Inputs
                        //requestDetails.subscriberInfo. for AAI GET & PUT & SDNC assignToplology
                        String globalSubscriberId = execution.getVariable("globalSubscriberId") //globalCustomerId
@@ -150,57 +150,40 @@ public class DoDeleteServiceInstance extends AbstractServiceTaskProcessor {
                utils.log("DEBUG"," ***** Exit preProcessRequest *****",  isDebugEnabled)
        }
 
-       public void preProcessSDNCDelete (Execution execution) {
+       public void preProcessSDNCDelete (DelegateExecution execution) {
                def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
                utils.log("DEBUG"," ***** preProcessSDNCDelete *****", isDebugEnabled)
                String msg = ""
 
                try {
-                       def serviceInstanceId = execution.getVariable("serviceInstanceId")
-                       def serviceInstanceName = execution.getVariable("serviceInstanceName")
-                       def callbackURL = execution.getVariable("sdncCallbackUrl")
-                       def requestId = execution.getVariable("msoRequestId")
-                       def serviceId = execution.getVariable("productFamilyId")
-                       def subscriptionServiceType = execution.getVariable("subscriptionServiceType")
-                       def globalSubscriberId = execution.getVariable("globalSubscriberId") //globalCustomerId
-
-                       String serviceModelInfo = execution.getVariable("serviceModelInfo")
+                       def serviceInstanceId = execution.getVariable("serviceInstanceId") ?: ""
+                       def serviceInstanceName = execution.getVariable("serviceInstanceName") ?: ""
+                       def callbackURL = execution.getVariable("sdncCallbackUrl") ?: ""
+                       def requestId = execution.getVariable("msoRequestId") ?: ""
+                       def serviceId = execution.getVariable("productFamilyId") ?: ""
+                       def subscriptionServiceType = execution.getVariable("subscriptionServiceType") ?: ""
+                       def globalSubscriberId = execution.getVariable("globalSubscriberId") ?: "" //globalCustomerId
+
+                       String serviceModelInfo = execution.getVariable("serviceModelInfo") ?: ""
                        def modelInvariantUuid = ""
                        def modelVersion = ""
                        def modelUuid = ""
                        def modelName = ""
                        if (!isBlank(serviceModelInfo))
                        {
-                               modelInvariantUuid = jsonUtil.getJsonValue(serviceModelInfo, "modelInvariantUuid")
-                               modelVersion = jsonUtil.getJsonValue(serviceModelInfo, "modelVersion")
-                               modelUuid = jsonUtil.getJsonValue(serviceModelInfo, "modelUuid")
-                               modelName = jsonUtil.getJsonValue(serviceModelInfo, "modelName")
+                               modelInvariantUuid = jsonUtil.getJsonValue(serviceModelInfo, "modelInvariantUuid") ?: ""
+                               modelVersion = jsonUtil.getJsonValue(serviceModelInfo, "modelVersion") ?: ""
+                               modelUuid = jsonUtil.getJsonValue(serviceModelInfo, "modelUuid") ?: ""
+                               modelName = jsonUtil.getJsonValue(serviceModelInfo, "modelName") ?: ""
 
-                               if (modelInvariantUuid == null) {
-                                       modelInvariantUuid = ""
-                               }
-                               if (modelVersion == null) {
-                                       modelVersion = ""
-                               }
-                               if (modelUuid == null) {
-                                       modelUuid = ""
-                               }
-                               if (modelName == null) {
-                                       modelName = ""
-                               }
-                       }
-                       if (serviceInstanceName == null) {
-                               serviceInstanceName = ""
-                       }
-                       if (serviceId == null) {
-                               serviceId = ""
                        }
 
-                       def siParamsXml = execution.getVariable("siParamsXml")
-                       def serviceType = execution.getVariable("serviceType")
-                       if (serviceType == null)
+                       def siParamsXml = execution.getVariable("siParamsXml") ?: ""
+                       def msoAction = ""
+                       // special URL for SDNW, msoAction helps set diff url in SDNCA
+                       if("TRANSPORT".equalsIgnoreCase(execution.getVariable("serviceType")))
                        {
-                               serviceType = ""
+                               msoAction = "TRANSPORT"
                        }
 
                        def sdncRequestId = UUID.randomUUID().toString()
@@ -215,7 +198,7 @@ public class DoDeleteServiceInstance extends AbstractServiceTaskProcessor {
                                                        <sdncadapter:SvcAction>delete</sdncadapter:SvcAction>
                                                        <sdncadapter:SvcOperation>service-topology-operation</sdncadapter:SvcOperation>
                                                        <sdncadapter:CallbackUrl>${callbackURL}</sdncadapter:CallbackUrl>
-                                                       <sdncadapter:MsoAction>${serviceType}</sdncadapter:MsoAction>
+                                                       <sdncadapter:MsoAction>${msoAction}</sdncadapter:MsoAction>
                                        </sdncadapter:RequestHeader>
                                <sdncadapterworkflow:SDNCRequestData>
                                        <request-information>
@@ -229,12 +212,12 @@ public class DoDeleteServiceInstance extends AbstractServiceTaskProcessor {
                                        <service-information>
                                                <service-id>${serviceId}</service-id>
                                                <subscription-service-type>${subscriptionServiceType}</subscription-service-type>
-                                               <onap-model-information>
+                                               <ecomp-model-information>
                                                 <model-invariant-uuid>${modelInvariantUuid}</model-invariant-uuid>
                                                 <model-uuid>${modelUuid}</model-uuid>
                                                 <model-version>${modelVersion}</model-version>
                                                 <model-name>${modelName}</model-name>
-                                           </onap-model-information>
+                                           </ecomp-model-information>
                                                <service-instance-id>${serviceInstanceId}</service-instance-id>
                                                <subscriber-name/>
                                                <global-customer-id>${globalSubscriberId}</global-customer-id>
@@ -264,7 +247,7 @@ public class DoDeleteServiceInstance extends AbstractServiceTaskProcessor {
                utils.log("DEBUG"," *****Exit preProcessSDNCDelete *****", isDebugEnabled)
        }
 
-       public void postProcessSDNCDelete(Execution execution, String response, String method) {
+       public void postProcessSDNCDelete(DelegateExecution execution, String response, String method) {
 
                def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
                utils.log("DEBUG"," ***** postProcessSDNC " + method + " *****", isDebugEnabled)
@@ -297,7 +280,7 @@ public class DoDeleteServiceInstance extends AbstractServiceTaskProcessor {
                utils.log("DEBUG"," *** Exit postProcessSDNC " + method + " ***", isDebugEnabled)
        }
 
-       public void postProcessAAIGET(Execution execution) {
+       public void postProcessAAIGET(DelegateExecution execution) {
                def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
                utils.log("DEBUG"," ***** postProcessAAIGET ***** ", isDebugEnabled)
                String msg = ""
@@ -406,6 +389,33 @@ public class DoDeleteServiceInstance extends AbstractServiceTaskProcessor {
                                                }
 
                                        }
+                                       
+                                       //alacarte SIs are NOT sent to sdnc. exceptions are listed in config variable
+                                       String svcTypes = execution.getVariable("URN_sdnc_si_svc_types") ?: ""
+                                       utils.log("DEBUG", "SDNC SI serviceTypes:" + svcTypes, isDebugEnabled)
+                                       List<String> svcList = Arrays.asList(svcTypes.split("\\s*,\\s*"));
+                                       boolean isSdncService= false
+                                       for (String listEntry : svcList){
+                                               if (listEntry.equalsIgnoreCase(serviceType)){
+                                                       isSdncService = true
+                                                       break;
+                                               }
+                                       }
+                                       
+                                       //All Macros are sent to SDNC, TRANSPORT(Macro) is sent to SDNW
+                                       //Alacartes are sent to SDNC if they are listed in config variable above
+                                       execution.setVariable("sendToSDNC", true)
+                                       if(execution.getVariable("sdncVersion").equals("1610")) //alacarte
+                                       {
+                                               if(!isSdncService){
+                                                       execution.setVariable("sendToSDNC", false)
+                                               }
+                                       }
+                                       
+                                       utils.log("DEBUG", "isSdncService: " + isSdncService, isDebugEnabled)
+                                       utils.log("DEBUG", "Send To SDNC: " + execution.getVariable("sendToSDNC"), isDebugEnabled)
+                                       utils.log("DEBUG", "Service Type: " + execution.getVariable("serviceType"), isDebugEnabled)
+                                       
                                }
                        }else{
                                boolean succInAAI = execution.getVariable("GENGS_SuccessIndicator")
@@ -436,7 +446,7 @@ public class DoDeleteServiceInstance extends AbstractServiceTaskProcessor {
                utils.log("DEBUG"," *** Exit postProcessAAIGET *** ", isDebugEnabled)
        }
 
-       public void postProcessAAIDEL(Execution execution) {
+       public void postProcessAAIDEL(DelegateExecution execution) {
                def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
                utils.log("DEBUG"," ***** postProcessAAIDEL ***** ", isDebugEnabled)
                String msg = ""