Merge "Fix attribute mismatch in NSMF,NSSMF & OOF"
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeAllocateSliceSubnet.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeAllocateSliceSubnet.groovy
index 7c2f53f..0cb72ab 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeAllocateSliceSubnet.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeAllocateSliceSubnet.groovy
@@ -139,7 +139,8 @@
         ResourceOperationStatus initStatus = new ResourceOperationStatus()
         initStatus.setServiceId(nsiId)
         initStatus.setOperationId(jobId)
-        initStatus.setResourceTemplateUUID(modelUuid)
+        //initStatus.setResourceTemplateUUID(modelUuid)
+        initStatus.setResourceInstanceID(nssiId)
         initStatus.setOperType("Deallocate")
         requestDBUtil.prepareInitResourceOperationStatus(execution, initStatus)
 
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy
index 147e623..554f7a6 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy
@@ -129,7 +129,7 @@
         if(serviceCategory ==~ /CN.*/){
             return SubnetType.CN.getNetworkType()
         }
-        if (serviceCategory ==~ /AN.*NF.*/){
+        if (serviceCategory ==~ /AN.*/){
             return SubnetType.AN.getNetworkType()
         }
         if (serviceCategory ==~ /TN.*BH.*/){
@@ -166,6 +166,7 @@
         deAllocateNssi.setTerminateNssiOption(0)
         deAllocateNssi.setSnssaiList(Arrays.asList(snssai))
         deAllocateNssi.setScriptName(scriptName)
+        deAllocateNssi.setSliceProfileId(profileId)
         
         ServiceInfo serviceInfo = new ServiceInfo()
         serviceInfo.setServiceInvariantUuid(serviceInvariantUuid)
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceService.groovy
index 5fd06fd..7dc63b6 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceService.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceService.groovy
@@ -31,6 +31,7 @@
 import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory
 import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder
 import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types
+import org.onap.so.client.oof.adapter.beans.payload.OofRequest
 import org.onap.logging.filter.base.ONAPComponents
 import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
 import org.onap.so.bpmn.common.scripts.ExceptionUtil
@@ -40,6 +41,7 @@
 import org.onap.so.client.HttpClientFactory
 import org.slf4j.Logger
 import org.slf4j.LoggerFactory
+import com.fasterxml.jackson.databind.ObjectMapper
 
 import javax.ws.rs.NotFoundException
 import javax.ws.rs.core.Response
@@ -404,11 +406,12 @@
     {
         LOGGER.debug("Start terminateNSIQuery")
 
-        return
+        //return
 
         //To test
         String requestId = execution.getVariable("msoRequestId")
-        String nxlId = currentNSSI['nsiServiceInstanceId']
+        String nxlId = execution.getVariable("nsiId")
+        //String nxlId = currentNSSI['nsiServiceInstanceId']
         String nxlType = "NSI"
         String messageType = "nsiTerminationResponse"
         String serviceInstanceId = execution.getVariable("serviceInstanceId")
@@ -433,12 +436,17 @@
             exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Internal Error - BasicAuth " +
                     "value null")
         }
-
-        URL requestUrl = new URL(oofUrl + "/api/oof/terminate/nxi/v1")
+        String oofUrl = UrnPropertiesReader.getVariable("mso.adapters.oof.endpoint", execution)
+        URL requestUrl = new URL(oofUrl)
         String oofRequest = oofUtils.buildTerminateNxiRequest(requestId, nxlId, nxlType, messageType, serviceInstanceId)
+        OofRequest oofPayload = new OofRequest()
+	oofPayload.setApiPath("/api/oof/terminate/nxi/v1")
+	oofPayload.setRequestDetails(oofRequest)
+	ObjectMapper objectMapper = new ObjectMapper()
+	String requestJson = objectMapper.writeValueAsString(oofPayload)
         HttpClient httpClient = new HttpClientFactory().newJsonClient(requestUrl, ONAPComponents.OOF)
         httpClient.addAdditionalHeader("Authorization", authHeader)
-        Response httpResponse = httpClient.post(oofRequest)
+        Response httpResponse = httpClient.post(requestJson)
 
         int responseCode = httpResponse.getStatus()
         LOGGER.debug("OOF sync response code is: " + responseCode)
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnf/tasks/CnfAdapterCreateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnf/tasks/CnfAdapterCreateTasks.java
index 2dda267..ed01f22 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnf/tasks/CnfAdapterCreateTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnf/tasks/CnfAdapterCreateTasks.java
@@ -130,6 +130,14 @@
     public void prepareForCnfUpdateOrDelete(BuildingBlockExecution execution) {
 
         GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
+        GenericVnf genericVnfId = null;
+        VfModule vfModuleId = null;
+        try {
+            genericVnfId = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+            vfModuleId = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
+        } catch (Exception ex) {
+            logger.error("Exception occurred", ex);
+        }
 
         String heatStackId = execution.getVariable("heatStackId");
 
@@ -140,7 +148,9 @@
         String callbackUrl =
                 "http://so-bpmn-infra.onap:8081/mso/WorkflowMessage/" + CNF_ADAPTER_MESSAGE_TYPE + "/" + requestId;
 
-        CnfAaiUpdateRequest aaiRequest = createCnfAaiUpdateRequest(heatStackId, cloudRegion, callbackUrl);
+        CnfAaiUpdateRequest aaiRequest =
+                createCnfAaiUpdateRequest(heatStackId, cloudRegion, callbackUrl, genericVnfId, vfModuleId);
+
         logger.debug("aaiRequest: {}", aaiRequest);
 
         String cnfRequestPayload = "";
@@ -192,14 +202,15 @@
     }
 
     protected CnfAaiUpdateRequest createCnfAaiUpdateRequest(String heatStackId, CloudRegion cloudRegion,
-            String callbackUrl) {
+            String callbackUrl, GenericVnf genericVnfId, VfModule vfModuleId) {
         CnfAaiUpdateRequest request = new CnfAaiUpdateRequest();
         request.setCallbackUrl(callbackUrl);
         request.setCloudOwner(cloudRegion.getCloudOwner());
         request.setCloudRegion(cloudRegion.getLcpCloudRegionId());
         request.setTenantId(cloudRegion.getTenantId());
         request.setInstanceId(heatStackId);
-
+        request.setGenericVnfId(genericVnfId.getVnfId());
+        request.setVfModuleId(vfModuleId.getVfModuleId());
         return request;
     }
 
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/CnfAaiUpdateRequest.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/CnfAaiUpdateRequest.java
index 4cc675f..2847074 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/CnfAaiUpdateRequest.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/CnfAaiUpdateRequest.java
@@ -23,6 +23,13 @@
     @JsonProperty("callbackUrl")
     private String callbackUrl;
 
+    @JsonProperty("genericVnfId")
+    private String genericVnfId;
+
+    @JsonProperty("vfModuleId")
+    private String vfModuleId;
+
+
     public String getInstanceId() {
         return instanceId;
     }
@@ -63,10 +70,27 @@
         this.callbackUrl = callbackUrl;
     }
 
+    public String getGenericVnfId() {
+        return genericVnfId;
+    }
+
+    public void setGenericVnfId(String genericVnfId) {
+        this.genericVnfId = genericVnfId;
+    }
+
+    public String getVfModuleId() {
+        return vfModuleId;
+    }
+
+    public void setVfModuleId(String vfModuleId) {
+        this.vfModuleId = vfModuleId;
+    }
+
     @Override
     public String toString() {
         return "CnfAaiUpdateRequest [instanceId=" + instanceId + ", cloudRegion=" + cloudRegion + ", cloudOwner="
-                + cloudOwner + ", tenantId=" + tenantId + ", callbackUrl=" + callbackUrl + "]";
+                + cloudOwner + ", tenantId=" + tenantId + ", callbackUrl=" + callbackUrl + ", genericVnfId="
+                + genericVnfId + ", vfModuleId=" + vfModuleId + " ]";
     }
 
 }
diff --git a/docs/release-notes.rst b/docs/release-notes.rst
index 90fd8aa..f3b8d45 100644
--- a/docs/release-notes.rst
+++ b/docs/release-notes.rst
@@ -14,6 +14,17 @@
 Release Notes
 =============
 
+Version: 9.0
+==============
+
+Release Purpose
+----------------
+SO Istanbul Release
+
+**Epics**
+
+*  `REQ-627 <https://jira.onap.org/browse/REQ-627>`_ - ONAP CNF orchestration - Istanbul Enhancements
+
 Version: 8.0
 ==============
 
diff --git a/pom.xml b/pom.xml
index c732c6f..5d8825c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -701,14 +701,17 @@
     <dependency>
       <groupId>org.onap.logging-analytics</groupId>
       <artifactId>logging-slf4j</artifactId>
+      <version>${onap-logging-version}</version>
     </dependency>
     <dependency>
       <groupId>org.onap.logging-analytics</groupId>
       <artifactId>logging-filter-base</artifactId>
+      <version>${onap-logging-version}</version>
     </dependency>
     <dependency>
       <groupId>org.onap.logging-analytics</groupId>
       <artifactId>logging-filter-spring</artifactId>
+      <version>${onap-logging-version}</version>
     </dependency>
     <dependency>
       <groupId>com.fasterxml.jackson.core</groupId>