Merge "5G core nssmf - Allocate api"
authorLukasz Muszkieta <lukasz.muszkieta@nokia.com>
Thu, 7 Jan 2021 06:51:57 +0000 (06:51 +0000)
committerGerrit Code Review <gerrit@onap.org>
Thu, 7 Jan 2021 06:51:57 +0000 (06:51 +0000)
64 files changed:
adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/AuthenticationMethodFactory.java
adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java
adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java
adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V8.8.1__AddColumnAdminProjectDomainName.sql [new file with mode: 0644]
adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V8.8__AddSoftwareVersionToPnfCustomization.sql [new file with mode: 0644]
adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/ExternalNssmfManager.java
adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/external/ExternalAnNssmfManager.java
adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java
adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/TaskServices.java
adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/DeleteAAIInventory.java
adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/orchestration/PollService.java
adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/orchestration/StackService.java
adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java
adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImpl.java
adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java
adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/orchestration/PollServiceTest.java
adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/orchestration/StackServiceTest.java
asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java
asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCControllerITTest.java
asdc-controller/src/test/resources/download/service-Testserviceforpnf-csar.csar [new file with mode: 0644]
asdc-controller/src/test/resources/schema.sql
bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/PayloadClient.java
bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/appc/payload/PayloadClientTest.java
bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AnNssmfutils.groovy
bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationService.groovy
bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSliceService.groovy
bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateTnNssi.groovy
bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateAccessNSSI.groovy
bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSI.groovy
bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateTnNssiInstance.groovy
bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy
bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy
bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceService.groovy
bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/QueryJobStatus.groovy
bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy
bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnNssmfUtils.groovy
bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ServiceLevelUpgrade.bpmn
bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoActivateTransportNSSI.bpmn
bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateAccessNSSI.bpmn
bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateTransportNSSI.bpmn
bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateTnNssiInstance.bpmn
bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeallocateNSSI.bpmn
bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeallocateTransportNSSI.bpmn
bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteSliceService.bpmn
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/AaiResourceIdValidator.java [new file with mode: 0644]
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java
bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/controller/sdnc/prepare/PrepareSdncUpgradePreCheckPnfBBTest.java [new file with mode: 0644]
bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/AaiResourceIdValidatorTest.java [new file with mode: 0644]
bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java
bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionExtractResourcesAAITest.java [new file with mode: 0644]
bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java
docs/developer_info/Working_with_so_monitoring.rst
docs/release-notes.rst
graph-inventory/aai-client/pom.xml
graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryResourcesClient.java
graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIResourcesClientTest.java
graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/SwaggerConverter.java
mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql
mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CloudIdentity.java
mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/PnfResourceCustomization.java
mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java
mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/NetworkResourceRepository.java
mso-catalog-db/src/test/resources/schema.sql

index ab02390..c1c7ed5 100644 (file)
@@ -100,7 +100,7 @@ public final class AuthenticationMethodFactory {
         Project project = new Project();
         Project.Domain projectDomain = new Project.Domain();
         userDomain.setName(cloudIdentity.getUserDomainName());
-        projectDomain.setName(cloudIdentity.getProjectDomainName());
+        projectDomain.setName(cloudIdentity.getAdminProjectDomainName());
         user.setName(cloudIdentity.getMsoId());
         user.setPassword(CryptoUtils.decryptCloudConfigPassword(cloudIdentity.getMsoPass()));
         user.setDomain(userDomain);
index c4ef367..ba4b309 100644 (file)
@@ -31,9 +31,10 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
-import java.util.Set;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
+import static org.apache.commons.lang3.StringUtils.isBlank;
+import static org.apache.commons.lang3.StringUtils.isNotBlank;
 import org.onap.logging.filter.base.ErrorCode;
 import org.onap.logging.ref.slf4j.ONAPLogConstants;
 import org.onap.so.adapters.vdu.CloudInfo;
@@ -49,6 +50,11 @@ import org.onap.so.adapters.vdu.VduStatus;
 import org.onap.so.cloud.authentication.KeystoneAuthHolder;
 import org.onap.so.db.catalog.beans.HeatTemplate;
 import org.onap.so.db.catalog.beans.HeatTemplateParam;
+import org.onap.so.db.catalog.beans.NetworkResource;
+import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
+import org.onap.so.db.catalog.beans.VfModule;
+import org.onap.so.db.catalog.beans.VfModuleCustomization;
+import org.onap.so.db.catalog.client.CatalogDbClient;
 import org.onap.so.db.request.beans.CloudApiRequests;
 import org.onap.so.db.request.beans.InfraActiveRequests;
 import org.onap.so.db.request.client.RequestsDbClient;
@@ -108,6 +114,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
     public static final String EXCEPTION_ROLLING_BACK_STACK =
             "{} Create Stack: Nested exception rolling back stack: {} ";
     public static final String IN_PROGRESS = "in_progress";
+    private static final int DEFAULT_POLLING_TIMEOUT = 118;
 
     @Autowired
     private Environment environment;
@@ -121,6 +128,9 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
     @Autowired
     RequestsDbClient requestDBClient;
 
+    @Autowired
+    private CatalogDbClient catalogClient;
+
     private static final Logger logger = LoggerFactory.getLogger(MsoHeatUtils.class);
 
     // Properties names and variables (with default values)
@@ -898,11 +908,6 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
         if (inputs == null) {
             return new HashMap<>();
         }
-        try {
-            Set<HeatTemplateParam> paramSet = template.getParameters();
-        } catch (Exception e) {
-            logger.debug("Exception occurred in convertInputMap {} :", e.getMessage(), e);
-        }
 
         for (HeatTemplateParam htp : template.getParameters()) {
             params.put(htp.getParamName(), htp);
@@ -1232,4 +1237,72 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
         }
     }
 
+    public int getVfHeatTimeoutValue(String modelCustomizationUuid, boolean isVolumeGroup) {
+        int timeoutMinutes = DEFAULT_POLLING_TIMEOUT;
+        try {
+            VfModuleCustomization vfmc = null;
+            if (modelCustomizationUuid != null) {
+                vfmc = catalogClient.getVfModuleCustomizationByModelCuztomizationUUID(modelCustomizationUuid);
+                if (vfmc != null) {
+                    VfModule vf = vfmc.getVfModule();
+                    if (vf != null) {
+                        HeatTemplate heat = vf.getModuleHeatTemplate();
+                        if (isVolumeGroup) {
+                            heat = vf.getVolumeHeatTemplate();
+                        }
+                        if (heat != null && heat.getTimeoutMinutes() != null) {
+                            if (heat.getTimeoutMinutes() < DEFAULT_POLLING_TIMEOUT) {
+                                timeoutMinutes = heat.getTimeoutMinutes();
+                            }
+                        }
+                    }
+                } else {
+                    logger.debug(
+                            "Unable to find Vf Module Customization with model customization uuid {}. Using default timeout {}",
+                            modelCustomizationUuid, timeoutMinutes);
+                }
+            }
+        } catch (Exception e) {
+            logger.warn("Exception occured while getting heat timeout value. Using default timeout {}", timeoutMinutes,
+                    e);
+        }
+        return timeoutMinutes;
+    }
+
+    public int getNetworkHeatTimeoutValue(String modelCustomizationUuid, String networkType) {
+        int timeoutMinutes = DEFAULT_POLLING_TIMEOUT;
+        try {
+            NetworkResource networkResource = null;
+            if (isBlank(modelCustomizationUuid)) {
+                if (isNotBlank(networkType)) {
+                    networkResource = catalogClient.getNetworkResourceByModelName(networkType);
+                }
+            } else {
+                NetworkResourceCustomization nrc =
+                        catalogClient.getNetworkResourceCustomizationByModelCustomizationUUID(modelCustomizationUuid);
+                if (nrc != null) {
+                    networkResource = nrc.getNetworkResource();
+                }
+            }
+
+            if (networkResource != null) {
+                networkResource.getHeatTemplate().getTimeoutMinutes();
+                HeatTemplate heat = networkResource.getHeatTemplate();
+                if (heat != null && heat.getTimeoutMinutes() != null) {
+                    if (heat.getTimeoutMinutes() < DEFAULT_POLLING_TIMEOUT) {
+                        timeoutMinutes = heat.getTimeoutMinutes();
+                    }
+                }
+            } else {
+                logger.debug(
+                        "Unable to find Network Resource with model customization uuid {} or network type {}. Using default timeout {}",
+                        modelCustomizationUuid, networkType, timeoutMinutes);
+            }
+        } catch (Exception e) {
+            logger.warn("Exception occured while getting heat timeout value. Using default timeout {}", timeoutMinutes,
+                    e);
+        }
+        return timeoutMinutes;
+    }
+
 }
index 5bd7c29..f20f6f1 100644 (file)
@@ -46,6 +46,12 @@ import org.mockito.Mockito;
 import org.mockito.Spy;
 import org.mockito.junit.MockitoJUnitRunner;
 import org.onap.logging.ref.slf4j.ONAPLogConstants;
+import org.onap.so.db.catalog.beans.HeatTemplate;
+import org.onap.so.db.catalog.beans.NetworkResource;
+import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
+import org.onap.so.db.catalog.beans.VfModule;
+import org.onap.so.db.catalog.beans.VfModuleCustomization;
+import org.onap.so.db.catalog.client.CatalogDbClient;
 import org.onap.so.db.request.beans.CloudApiRequests;
 import org.onap.so.db.request.beans.InfraActiveRequests;
 import org.onap.so.db.request.client.RequestsDbClient;
@@ -103,6 +109,9 @@ public class MsoHeatUtilsTest extends MsoHeatUtils {
     @Mock
     private CreateStack mockCreateStack;
 
+    @Mock
+    private CatalogDbClient catalogDbClient;
+
     private String cloudSiteId = "cloudSiteId";
     private String tenantId = "tenantId";
 
@@ -564,4 +573,38 @@ public class MsoHeatUtilsTest extends MsoHeatUtils {
         Mockito.verify(heatUtils, times(0)).handleUnknownCreateStackFailure(stack, 120, cloudSiteId, tenantId);
     }
 
+    @Test
+    public void testGetVfHeatTimeoutValue() {
+
+        VfModuleCustomization vfmc = new VfModuleCustomization();
+        VfModule vf = new VfModule();
+        HeatTemplate heat = new HeatTemplate();
+        heat.setTimeoutMinutes(110);
+        vf.setModuleHeatTemplate(heat);
+        vfmc.setVfModule(vf);
+
+        Mockito.when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("uuid")).thenReturn(vfmc);
+
+        int timeout = heatUtils.getVfHeatTimeoutValue("uuid", false);
+        assertEquals(110, timeout);
+        Mockito.verify(catalogDbClient, times(1)).getVfModuleCustomizationByModelCuztomizationUUID("uuid");
+    }
+
+    @Test
+    public void testGetNetworkHeatTimeoutValue() {
+
+        NetworkResourceCustomization mc = new NetworkResourceCustomization();
+        NetworkResource nr = new NetworkResource();
+        HeatTemplate heat = new HeatTemplate();
+        heat.setTimeoutMinutes(110);
+        nr.setHeatTemplate(heat);
+        mc.setNetworkResource(nr);
+
+        Mockito.when(catalogDbClient.getNetworkResourceCustomizationByModelCustomizationUUID("uuid")).thenReturn(mc);
+
+        int timeout = heatUtils.getNetworkHeatTimeoutValue("uuid", "type");
+        assertEquals(110, timeout);
+        Mockito.verify(catalogDbClient, times(1)).getNetworkResourceCustomizationByModelCustomizationUUID("uuid");
+    }
+
 }
diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V8.8.1__AddColumnAdminProjectDomainName.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V8.8.1__AddColumnAdminProjectDomainName.sql
new file mode 100644 (file)
index 0000000..a883466
--- /dev/null
@@ -0,0 +1,3 @@
+use catalogdb;
+
+ALTER TABLE identity_services ADD COLUMN ADMIN_PROJECT_DOMAIN_NAME varchar(255) DEFAULT 'Default';
\ No newline at end of file
diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V8.8__AddSoftwareVersionToPnfCustomization.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V8.8__AddSoftwareVersionToPnfCustomization.sql
new file mode 100644 (file)
index 0000000..5578d3e
--- /dev/null
@@ -0,0 +1,6 @@
+use catalogdb;
+
+ALTER TABLE pnf_resource_customization
+ADD DEFAULT_SOFTWARE_VERSION varchar(4000) null;
+
+
index 7ec6c0f..96f2956 100644 (file)
@@ -99,7 +99,8 @@ public abstract class ExternalNssmfManager extends BaseNssmfManager {
 
                 restUtil.createServiceInstance(nssiInstance, serviceInfo);
             } else if (ActionType.DEALLOCATE.equals(jobOperType)) {
-                restUtil.deleteServiceInstance(serviceInfo);
+                // TODO
+                // restUtil.deleteServiceInstance(serviceInfo);
             }
         }
     }
index 3d0d092..20ad3d1 100644 (file)
@@ -93,7 +93,7 @@ public class ExternalAnNssmfManager extends ExternalNssmfManager {
             status.setResourceInstanceID(nssiId);
             status.setOperType(actionType.toString());
 
-            updateDbStatus(status, restResponse.getStatus(), JobStatus.FINISHED,
+            updateDbStatus(status, restResponse.getStatus(), JobStatus.STARTED,
                     NssmfAdapterUtil.getStatusDesc(actionType));
         }
         // todo
index 489585c..b84d2a8 100644 (file)
@@ -31,6 +31,8 @@ import java.util.Map;
 import java.util.Optional;
 import javax.jws.WebService;
 import javax.xml.ws.Holder;
+import org.apache.commons.lang3.mutable.MutableBoolean;
+import org.onap.logging.filter.base.ErrorCode;
 import org.onap.so.adapters.network.beans.ContrailPolicyRef;
 import org.onap.so.adapters.network.beans.ContrailPolicyRefSeq;
 import org.onap.so.adapters.network.beans.ContrailSubnet;
@@ -47,7 +49,6 @@ import org.onap.so.db.catalog.data.repository.NetworkResourceCustomizationReposi
 import org.onap.so.db.catalog.data.repository.NetworkResourceRepository;
 import org.onap.so.db.catalog.utils.MavenLikeVersioning;
 import org.onap.so.entity.MsoRequest;
-import org.onap.logging.filter.base.ErrorCode;
 import org.onap.so.logger.LoggingAnchor;
 import org.onap.so.logger.MessageEnum;
 import org.onap.so.openstack.beans.HeatStatus;
@@ -150,7 +151,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
         Holder<String> networkFqdn = new Holder<>();
         createNetwork(cloudSiteId, tenantId, networkType, modelCustomizationUuid, networkName, physicalNetworkName,
                 vlans, null, shared, external, failIfExists, backout, subnets, null, null, msoRequest, networkId,
-                neutronNetworkId, networkFqdn, subnetIdMap, rollback, true);
+                neutronNetworkId, networkFqdn, subnetIdMap, rollback, true, new MutableBoolean());
     }
 
     @Deprecated
@@ -164,7 +165,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
             throws NetworkException {
         createNetwork(cloudSiteId, tenantId, networkType, modelCustomizationUuid, networkName, null, null, routeTargets,
                 shared, external, failIfExists, backout, subnets, policyFqdns, routeTableFqdns, msoRequest, networkId,
-                neutronNetworkId, networkFqdn, subnetIdMap, rollback, true);
+                neutronNetworkId, networkFqdn, subnetIdMap, rollback, true, new MutableBoolean());
     }
 
     /**
@@ -195,13 +196,14 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
             String shared, String external, Boolean failIfExists, Boolean backout, List<Subnet> subnets,
             List<String> policyFqdns, List<String> routeTableFqdns, MsoRequest msoRequest, Holder<String> networkId,
             Holder<String> neutronNetworkId, Holder<String> networkFqdn, Holder<Map<String, String>> subnetIdMap,
-            Holder<NetworkRollback> rollback, Boolean pollForCompletion) throws NetworkException {
+            Holder<NetworkRollback> rollback, Boolean pollForCompletion, MutableBoolean isOs3Nw)
+            throws NetworkException {
         logger.debug("*** CREATE Network: {} of type {} in {}/{}", networkName, networkType, cloudSiteId, tenantId);
 
         // Will capture execution time for metrics
         long startTime = System.currentTimeMillis();
 
-        // Build a default rollback object (no actions performed)
+        // Build a default rollback object (no actions performed) //TODO remove
         NetworkRollback networkRollback = new NetworkRollback();
         networkRollback.setCloudId(cloudSiteId);
         networkRollback.setTenantId(tenantId);
@@ -241,13 +243,13 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
         template = template.replaceAll("\r\n", "\n");
 
         boolean os3template = false;
-        String os3nw = OS3_NW;
 
-        os3nw = environment.getProperty(OS3_NW_PROPERTY, OS3_NW);
+        String os3nw = environment.getProperty(OS3_NW_PROPERTY, OS3_NW);
 
         if (template.contains(os3nw))
             os3template = true;
 
+        isOs3Nw.setValue(os3template);
         // First, look up to see if the Network already exists (by name).
         // For HEAT orchestration of networks, the stack name will always match the network name
         StackInfo heatStack = null;
@@ -280,20 +282,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
                     }
                     Map<String, Object> outputs = heatStack.getOutputs();
 
-                    for (Map.Entry<String, Object> entry : outputs.entrySet()) {
-                        String key = entry.getKey();
-                        if (key != null && key.startsWith("subnet")) {
-                            if (os3template) // one subnet_id output
-                            {
-                                Map<String, String> map = getSubnetUUId(key, outputs, subnets);
-                                sMap.putAll(map);
-                            } else // multiples subnet_%aaid% outputs
-                            {
-                                String subnetUUId = (String) outputs.get(key);
-                                sMap.put(key.substring("subnet_id_".length()), subnetUUId);
-                            }
-                        }
-                    }
+                    sMap = buildSubnetMap(outputs, subnets, os3template);
                 }
                 subnetIdMap.value = sMap;
                 logger.warn("{} {} Found Existing network stack, status={} networkName={} for {}/{}",
@@ -390,20 +379,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
         Map<String, Object> outputs = heatStack.getOutputs();
         Map<String, String> sMap = new HashMap<>();
         if (outputs != null) {
-            for (Map.Entry<String, Object> entry : outputs.entrySet()) {
-                String key = entry.getKey();
-                if (key != null && key.startsWith("subnet")) {
-                    if (os3template) // one subnet output expected
-                    {
-                        Map<String, String> map = getSubnetUUId(key, outputs, subnets);
-                        sMap.putAll(map);
-                    } else // multiples subnet_%aaid% outputs allowed
-                    {
-                        String subnetUUId = (String) outputs.get(key);
-                        sMap.put(key.substring("subnet_id_".length()), subnetUUId);
-                    }
-                }
-            }
+            sMap = buildSubnetMap(outputs, subnets, os3template);
             networkRollback.setNeutronNetworkId((String) outputs.get(NETWORK_ID));
         }
         subnetIdMap.value = sMap;
@@ -686,20 +662,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
             Map<String, Object> outputs = heatStack.getOutputs();
             Map<String, String> sMap = new HashMap<>();
             if (outputs != null) {
-                for (Map.Entry<String, Object> entry : outputs.entrySet()) {
-                    String key = entry.getKey();
-                    if (key != null && key.startsWith("subnet")) {
-                        if (os3template) // one subnet output expected
-                        {
-                            Map<String, String> map = getSubnetUUId(key, outputs, subnets);
-                            sMap.putAll(map);
-                        } else // multiples subnet_%aaid% outputs allowed
-                        {
-                            String subnetUUId = (String) outputs.get(key);
-                            sMap.put(key.substring("subnet_id_".length()), subnetUUId);
-                        }
-                    }
-                }
+                sMap = buildSubnetMap(outputs, subnets, os3template);
             }
             subnetIdMap.value = sMap;
 
@@ -962,31 +925,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
             pollForCompletion = true;
         }
 
-        // Retrieve the Network Resource definition
-        NetworkResource networkResource = null;
-        if (commonUtils.isNullOrEmpty(modelCustomizationUuid)) {
-            if (!commonUtils.isNullOrEmpty(networkType)) {
-                networkResource = networkResourceRepo.findFirstByModelNameOrderByModelVersionDesc(networkType);
-            }
-        } else {
-            NetworkResourceCustomization nrc =
-                    networkCustomRepo.findOneByModelCustomizationUUID(modelCustomizationUuid);
-            if (nrc != null) {
-                networkResource = nrc.getNetworkResource();
-            }
-        }
-
-        int timeoutMinutes = 118;
-        if (networkResource != null) {
-            logger.debug(LOG_DEBUG_MSG, networkResource.toString());
-            networkResource.getHeatTemplate().getTimeoutMinutes();
-            HeatTemplate heat = networkResource.getHeatTemplate();
-            if (heat != null && heat.getTimeoutMinutes() != null) {
-                if (heat.getTimeoutMinutes() < 118) {
-                    timeoutMinutes = heat.getTimeoutMinutes();
-                }
-            }
-        }
+        int timeoutMinutes = heat.getNetworkHeatTimeoutValue(modelCustomizationUuid, networkType);
 
         try {
             StackInfo stack =
@@ -1385,7 +1324,8 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
         return heatTemplate;
     }
 
-    private Map<String, String> getSubnetUUId(String key, Map<String, Object> outputs, List<Subnet> subnets) {
+    // TODO remove
+    public Map<String, String> getSubnetUUId(String key, Map<String, Object> outputs, List<Subnet> subnets) {
 
         Map<String, String> sMap = new HashMap<>();
 
@@ -1442,4 +1382,24 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
         return updatedTemplate;
     }
 
+    public Map<String, String> buildSubnetMap(Map<String, Object> outputs, List<Subnet> subnets, boolean os3template) {
+
+        Map<String, String> sMap = new HashMap<>();
+        for (Map.Entry<String, Object> entry : outputs.entrySet()) {
+            String key = entry.getKey();
+            if (key != null && key.startsWith("subnet")) {
+                if (os3template) // one subnet_id output
+                {
+                    Map<String, String> map = getSubnetUUId(key, outputs, subnets);
+                    sMap.putAll(map);
+                } else // multiples subnet_%aaid% outputs
+                {
+                    String subnetUUId = (String) outputs.get(key);
+                    sMap.put(key.substring("subnet_id_".length()), subnetUUId);
+                }
+            }
+        }
+        return sMap;
+    }
+
 }
index 4e0c4ad..bd71474 100644 (file)
@@ -28,8 +28,6 @@ import org.onap.so.adapters.tasks.orchestration.PollService;
 import org.onap.so.adapters.tasks.orchestration.RollbackService;
 import org.onap.so.adapters.tasks.orchestration.StackService;
 import org.onap.so.utils.ExternalTaskServiceUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Profile;
 import org.springframework.stereotype.Component;
@@ -38,8 +36,6 @@ import org.springframework.stereotype.Component;
 @Profile("!test")
 public class TaskServices {
 
-    private static final Logger logger = LoggerFactory.getLogger(TaskServices.class);
-
     @Autowired
     private ExternalTaskServiceUtils externalTaskServiceUtils;
 
index f5a6355..f904788 100644 (file)
@@ -48,10 +48,16 @@ public class DeleteAAIInventory {
     @Autowired
     protected Environment env;
 
+    private static final String MULTICLOUD_MODE = "MULTICLOUD";
+
     public void heatbridge(CloudInformation cloudInformation) throws MsoCloudSiteNotFound, HeatBridgeException {
         logger.debug("Heatbridge delete executing");
         CloudSite cloudSite = cloudConfig.getCloudSite(cloudInformation.getRegionId())
                 .orElseThrow(() -> new MsoCloudSiteNotFound(cloudInformation.getRegionId()));
+        if (cloudSite.getOrchestrator() != null && MULTICLOUD_MODE.equalsIgnoreCase(cloudSite.getOrchestrator())) {
+            logger.debug("Skipping Heatbridge as CloudSite orchestrator is: " + MULTICLOUD_MODE);
+            return;
+        }
         CloudIdentity cloudIdentity = cloudSite.getIdentityService();
         HeatBridgeApi heatBridgeClient = new HeatBridgeImpl(new AAIResourcesClient(), cloudIdentity,
                 cloudInformation.getOwner(), cloudInformation.getRegionId(), cloudSite.getRegionId(),
index c319fdc..4f16674 100644 (file)
@@ -33,16 +33,31 @@ import javax.xml.parsers.DocumentBuilderFactory;
 import org.apache.commons.lang3.mutable.MutableBoolean;
 import org.camunda.bpm.client.task.ExternalTask;
 import org.camunda.bpm.client.task.ExternalTaskService;
+import org.onap.so.adapters.network.MsoNetworkAdapterImpl;
 import org.onap.so.adapters.nwrest.CreateNetworkRequest;
+import org.onap.so.adapters.nwrest.CreateNetworkResponse;
+import org.onap.so.adapters.nwrest.DeleteNetworkRequest;
+import org.onap.so.adapters.nwrest.DeleteNetworkResponse;
+import org.onap.so.adapters.nwrest.UpdateNetworkRequest;
+import org.onap.so.adapters.nwrest.UpdateNetworkResponse;
+import org.onap.so.adapters.vnf.MsoVnfAdapterImpl;
+import org.onap.so.adapters.vnf.VnfAdapterUtils;
 import org.onap.so.adapters.vnfrest.CreateVfModuleRequest;
+import org.onap.so.adapters.vnfrest.CreateVfModuleResponse;
 import org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest;
+import org.onap.so.adapters.vnfrest.CreateVolumeGroupResponse;
 import org.onap.so.adapters.vnfrest.DeleteVfModuleRequest;
+import org.onap.so.adapters.vnfrest.DeleteVfModuleResponse;
 import org.onap.so.adapters.vnfrest.DeleteVolumeGroupRequest;
-import org.onap.so.adapters.nwrest.DeleteNetworkRequest;
-import org.onap.so.adapters.nwrest.UpdateNetworkRequest;
-import org.onap.so.adapters.vnf.VnfAdapterUtils;
+import org.onap.so.adapters.vnfrest.DeleteVolumeGroupResponse;
+import org.onap.so.adapters.vnfrest.VfModuleRollback;
+import org.onap.so.adapters.vnfrest.VolumeGroupRollback;
 import org.onap.so.logging.tasks.AuditMDCSetup;
+import org.onap.so.openstack.beans.NetworkRollback;
+import org.onap.so.openstack.beans.StackInfo;
+import org.onap.so.openstack.beans.VnfRollback;
 import org.onap.so.openstack.exceptions.MsoException;
+import org.onap.so.openstack.mappers.StackInfoMapper;
 import org.onap.so.openstack.utils.MsoHeatUtils;
 import org.onap.so.utils.ExternalTaskUtils;
 import org.onap.so.utils.RetrySequenceLevel;
@@ -57,6 +72,12 @@ public class PollService extends ExternalTaskUtils {
 
     private static final Logger logger = LoggerFactory.getLogger(PollService.class);
 
+    @Autowired
+    private MsoVnfAdapterImpl vnfAdapterImpl;
+
+    @Autowired
+    private MsoNetworkAdapterImpl networkAdapterImpl;
+
     @Autowired
     private MsoHeatUtils msoHeatUtils;
 
@@ -76,43 +97,60 @@ public class PollService extends ExternalTaskUtils {
         Map<String, Object> variables = new HashMap<>();
         MutableBoolean success = new MutableBoolean();
         String errorMessage = null;
+        String response = "";
         try {
             String xmlRequest = externalTask.getVariable("openstackAdapterTaskRequest");
             if (xmlRequest != null) {
                 Optional<String> requestType = findRequestType(xmlRequest);
                 if ("createVolumeGroupRequest".equals(requestType.get())) {
-                    determineCreateVolumeGroupStatus(xmlRequest, externalTask, success);
+                    response = determineCreateVolumeGroupStatus(xmlRequest, externalTask, success);
                 } else if ("createVfModuleRequest".equals(requestType.get())) {
-                    determineCreateVfModuleStatus(xmlRequest, externalTask, success);
+                    response = determineCreateVfModuleStatus(xmlRequest, externalTask, success);
                 } else if ("deleteVfModuleRequest".equals(requestType.get())) {
                     logger.debug("Executing External Task Poll Service for Delete Vf Module");
+                    String stackId = externalTask.getVariable("stackId");
                     DeleteVfModuleRequest req =
                             JAXB.unmarshal(new StringReader(xmlRequest), DeleteVfModuleRequest.class);
                     boolean isMulticloud = vnfAdapterUtils.isMulticloudMode(null, req.getCloudSiteId());
                     if (!isMulticloud) {
-                        pollDeleteResource(req.getCloudSiteId(), req.getTenantId(), externalTask, success);
-                    } else {
-                        success.setTrue();
+                        int timeoutMinutes = msoHeatUtils.getVfHeatTimeoutValue(req.getModelCustomizationUuid(), false);
+                        StackInfo stack = pollDeleteResource(timeoutMinutes, req.getCloudSiteId(), req.getTenantId(),
+                                stackId, success);
+                        DeleteVfModuleResponse deleteResponse =
+                                new DeleteVfModuleResponse(req.getVnfId(), req.getVfModuleId(), Boolean.TRUE,
+                                        req.getMessageId(), vnfAdapterImpl.copyStringOutputs(stack.getOutputs()));
+                        response = deleteResponse.toXmlString();
                     }
                 } else if ("deleteVolumeGroupRequest".equals(requestType.get())) {
                     logger.debug("Executing External Task Poll Service for Delete Volume Group");
+                    String stackId = externalTask.getVariable("stackId");
                     DeleteVolumeGroupRequest req =
                             JAXB.unmarshal(new StringReader(xmlRequest), DeleteVolumeGroupRequest.class);
                     boolean isMulticloud = vnfAdapterUtils.isMulticloudMode(null, req.getCloudSiteId());
                     if (!isMulticloud) {
-                        pollDeleteResource(req.getCloudSiteId(), req.getTenantId(), externalTask, success);
+                        pollDeleteResource(118, req.getCloudSiteId(), req.getTenantId(), stackId, success);
+                        DeleteVolumeGroupResponse deleteResponse =
+                                new DeleteVolumeGroupResponse(true, req.getMessageId());
+                        response = deleteResponse.toXmlString();
                     } else {
                         success.setTrue();
                     }
                 } else if ("createNetworkRequest".equals(requestType.get())) {
-                    determineCreateNetworkStatus(xmlRequest, externalTask, success);
+                    response = determineCreateNetworkStatus(xmlRequest, externalTask, success);
                 } else if ("deleteNetworkRequest".equals(requestType.get())) {
                     logger.debug("Executing External Task Poll Service for Delete Network");
+                    String stackId = externalTask.getVariable("stackId");
                     DeleteNetworkRequest req = JAXB.unmarshal(new StringReader(xmlRequest), DeleteNetworkRequest.class);
-                    pollDeleteResource(req.getCloudSiteId(), req.getTenantId(), externalTask, success);
+                    pollDeleteResource(118, req.getCloudSiteId(), req.getTenantId(), stackId, success);
+                    DeleteNetworkResponse deleteResponse =
+                            new DeleteNetworkResponse(req.getNetworkId(), true, req.getMessageId());
+                    response = deleteResponse.toXmlString();
                 } else if ("updateNetworkRequest".equals(requestType.get())) {
                     UpdateNetworkRequest req = JAXB.unmarshal(new StringReader(xmlRequest), UpdateNetworkRequest.class);
                     pollUpdateResource(req.getCloudSiteId(), req.getTenantId(), externalTask, success);
+                    UpdateNetworkResponse updateResponse =
+                            new UpdateNetworkResponse(req.getNetworkId(), null, null, req.getMessageId());
+                    response = updateResponse.toXmlString();
                 }
             }
         } catch (Exception e) {
@@ -121,6 +159,7 @@ public class PollService extends ExternalTaskUtils {
             variables.put("openstackAdapterErrorMessage", errorMessage);
         }
 
+        variables.put("WorkflowResponse", response);
         variables.put("OpenstackPollSuccess", success.booleanValue());
         if (success.isTrue()) {
             externalTaskService.complete(externalTask, variables);
@@ -144,72 +183,119 @@ public class PollService extends ExternalTaskUtils {
         }
     }
 
-    private void determineCreateVolumeGroupStatus(String xmlRequest, ExternalTask externalTask, MutableBoolean success)
-            throws MsoException {
+    private String determineCreateVolumeGroupStatus(String xmlRequest, ExternalTask externalTask,
+            MutableBoolean success) throws MsoException {
         CreateVolumeGroupRequest req = JAXB.unmarshal(new StringReader(xmlRequest), CreateVolumeGroupRequest.class);
         boolean isMulticloud = vnfAdapterUtils.isMulticloudMode(null, req.getCloudSiteId());
         if (!isMulticloud) {
             boolean pollRollbackStatus = externalTask.getVariable("PollRollbackStatus");
+            String stackId = externalTask.getVariable("stackId");
             if (pollRollbackStatus) {
                 logger.debug("Executing External Task Poll Service for Rollback Create Volume Group");
-                pollDeleteResource(req.getCloudSiteId(), req.getTenantId(), externalTask, success);
+                pollDeleteResource(118, req.getCloudSiteId(), req.getTenantId(), stackId, success);
+                DeleteVolumeGroupResponse deleteResponse = new DeleteVolumeGroupResponse(true, req.getMessageId());
+                return deleteResponse.toXmlString();
             } else {
-                pollCreateResource(req.getCloudSiteId(), req.getTenantId(), externalTask, success);
+                int timeoutMinutes = msoHeatUtils.getVfHeatTimeoutValue(req.getModelCustomizationUuid(), true);
+                StackInfo stack =
+                        pollCreateResource(timeoutMinutes, req.getCloudSiteId(), req.getTenantId(), stackId, success);
+                VolumeGroupRollback rb =
+                        new VolumeGroupRollback(req.getVolumeGroupId(), stackId, true, req.getTenantId(),
+                                req.getCloudOwner(), req.getCloudSiteId(), req.getMsoRequest(), req.getMessageId());
+                CreateVolumeGroupResponse createResponse = new CreateVolumeGroupResponse(req.getVolumeGroupId(),
+                        stackId, true, vnfAdapterImpl.copyStringOutputs(stack.getOutputs()), rb, req.getMessageId());
+                return createResponse.toXmlString();
             }
         } else {
             success.setTrue();
+            return null;
         }
     }
 
-    private void determineCreateVfModuleStatus(String xmlRequest, ExternalTask externalTask, MutableBoolean success)
+    private String determineCreateVfModuleStatus(String xmlRequest, ExternalTask externalTask, MutableBoolean success)
             throws MsoException {
         CreateVfModuleRequest req = JAXB.unmarshal(new StringReader(xmlRequest), CreateVfModuleRequest.class);
         boolean isMulticloud = vnfAdapterUtils.isMulticloudMode(null, req.getCloudSiteId());
+        String stackId = externalTask.getVariable("stackId");
         if (!isMulticloud) {
             boolean pollRollbackStatus = externalTask.getVariable("PollRollbackStatus");
+            int timeoutMinutes = msoHeatUtils.getVfHeatTimeoutValue(req.getModelCustomizationUuid(), false);
             if (pollRollbackStatus) {
                 logger.debug("Executing External Task Poll Service for Rollback Create Vf Module");
-                pollDeleteResource(req.getCloudSiteId(), req.getTenantId(), externalTask, success);
+                StackInfo stack =
+                        pollDeleteResource(timeoutMinutes, req.getCloudSiteId(), req.getTenantId(), stackId, success);
+                DeleteVfModuleResponse deleteResponse = new DeleteVfModuleResponse(req.getVnfId(), req.getVfModuleId(),
+                        Boolean.TRUE, req.getMessageId(), vnfAdapterImpl.copyStringOutputs(stack.getOutputs()));
+                return deleteResponse.toXmlString();
             } else {
                 logger.debug("Executing External Task Poll Service for Create Vf Module");
-                pollCreateResource(req.getCloudSiteId(), req.getTenantId(), externalTask, success);
+                StackInfo stack =
+                        pollCreateResource(timeoutMinutes, req.getCloudSiteId(), req.getTenantId(), stackId, success);
+                VfModuleRollback modRollback = new VfModuleRollback(buildVnfRollback(req, stackId, isMulticloud),
+                        req.getVfModuleId(), stackId, req.getMessageId());
+                CreateVfModuleResponse createResponse =
+                        new CreateVfModuleResponse(req.getVnfId(), req.getVfModuleId(), stackId, Boolean.TRUE,
+                                vnfAdapterImpl.copyStringOutputs(stack.getOutputs()), modRollback, req.getMessageId());
+                return createResponse.toXmlString();
             }
         } else {
             success.setTrue();
+            return null;
         }
     }
 
-    private void determineCreateNetworkStatus(String xmlRequest, ExternalTask externalTask, MutableBoolean success)
+    private String determineCreateNetworkStatus(String xmlRequest, ExternalTask externalTask, MutableBoolean success)
             throws MsoException {
         CreateNetworkRequest req = JAXB.unmarshal(new StringReader(xmlRequest), CreateNetworkRequest.class);
+        String stackId = externalTask.getVariable("stackId");
         boolean pollRollbackStatus = externalTask.getVariable("PollRollbackStatus");
+        int timeoutMinutes =
+                msoHeatUtils.getNetworkHeatTimeoutValue(req.getModelCustomizationUuid(), req.getNetworkType());
         if (pollRollbackStatus) {
             logger.debug("Executing External Task Poll Service for Rollback Create Network");
-            pollDeleteResource(req.getCloudSiteId(), req.getTenantId(), externalTask, success);
+            pollDeleteResource(timeoutMinutes, req.getCloudSiteId(), req.getTenantId(), stackId, success);
+            DeleteNetworkResponse response = new DeleteNetworkResponse(req.getNetworkId(), true, req.getMessageId());
+            return response.toXmlString();
         } else {
             logger.debug("Executing External Task Poll Service for Create Network");
-            pollCreateResource(req.getCloudSiteId(), req.getTenantId(), externalTask, success);
+            boolean os3Nw = externalTask.getVariable("os3Nw");
+            StackInfo stack =
+                    pollCreateResource(timeoutMinutes, req.getCloudSiteId(), req.getTenantId(), stackId, success);
+            String networkFqdn = "";
+            String neutronNetworkId = "";
+            Map<String, String> subnetMap = new HashMap<>();
+            if (stack.getOutputs() != null) {
+                networkFqdn = (String) stack.getOutputs().get("network_fqdn");
+                neutronNetworkId = (String) stack.getOutputs().get("network_id");
+                subnetMap = networkAdapterImpl.buildSubnetMap(stack.getOutputs(), req.getSubnets(), os3Nw);
+            }
+            CreateNetworkResponse response = new CreateNetworkResponse(req.getNetworkId(), neutronNetworkId, stackId,
+                    networkFqdn, true, subnetMap, buildNetworkRollback(req, stackId), req.getMessageId());
+            return response.toXmlString();
+
         }
     }
 
-    private void pollCreateResource(String cloudSiteId, String tenantId, ExternalTask externalTask,
+    private StackInfo pollCreateResource(int pollingTimeout, String cloudSiteId, String tenantId, String stackId,
             MutableBoolean success) throws MsoException {
-        Stack currentStack = createCurrentStack(externalTask.getVariable("stackId"));
-        Stack stack =
-                msoHeatUtils.pollStackForStatus(1, currentStack, "CREATE_IN_PROGRESS", cloudSiteId, tenantId, false);
+        Stack currentStack = createCurrentStack(stackId);
+        Stack stack = msoHeatUtils.pollStackForStatus(pollingTimeout, currentStack, "CREATE_IN_PROGRESS", cloudSiteId,
+                tenantId, false);
         msoHeatUtils.postProcessStackCreate(stack, false, 0, false, cloudSiteId, tenantId, null);
         success.setTrue();
+        return new StackInfoMapper(stack).map();
     }
 
-    private void pollDeleteResource(String cloudSiteId, String tenantId, ExternalTask externalTask,
+    private StackInfo pollDeleteResource(int pollingTimeout, String cloudSiteId, String tenantId, String stackId,
             MutableBoolean success) throws MsoException {
-        Stack currentStack = createCurrentStack(externalTask.getVariable("stackId"));
-        Stack stack =
-                msoHeatUtils.pollStackForStatus(1, currentStack, "DELETE_IN_PROGRESS", cloudSiteId, tenantId, true);
+        Stack currentStack = createCurrentStack(stackId);
+        Stack stack = msoHeatUtils.pollStackForStatus(pollingTimeout, currentStack, "DELETE_IN_PROGRESS", cloudSiteId,
+                tenantId, true);
         if (stack != null) { // if stack is null it was not found and no need to do post process
             msoHeatUtils.postProcessStackDelete(stack);
         }
         success.setTrue();
+        return new StackInfoMapper(stack).map();
     }
 
     private void pollUpdateResource(String cloudSiteId, String tenantId, ExternalTask externalTask,
@@ -246,4 +332,35 @@ public class PollService extends ExternalTaskUtils {
         return currentStack;
     }
 
+    private VnfRollback buildVnfRollback(CreateVfModuleRequest req, String stackId, boolean isMulticloud) {
+        VnfRollback vfRollback = new VnfRollback();
+        vfRollback.setCloudSiteId(req.getCloudSiteId());
+        vfRollback.setCloudOwner(req.getCloudOwner());
+        vfRollback.setTenantId(req.getTenantId());
+        vfRollback.setMsoRequest(req.getMsoRequest());
+        vfRollback.setRequestType(req.getRequestType());
+        vfRollback.setVolumeGroupHeatStackId(req.getVolumeGroupStackId());
+        vfRollback.setBaseGroupHeatStackId(req.getBaseVfModuleStackId());
+        vfRollback.setIsBase(false);
+        vfRollback.setModelCustomizationUuid(req.getModelCustomizationUuid());
+        vfRollback.setVnfId(stackId);
+        vfRollback.setVnfCreated(true);
+        if (isMulticloud) {
+            vfRollback.setMode("CFY");
+        }
+        return vfRollback;
+    }
+
+    private NetworkRollback buildNetworkRollback(CreateNetworkRequest req, String stackId) {
+        NetworkRollback networkRollback = new NetworkRollback();
+        networkRollback.setCloudId(req.getCloudSiteId());
+        networkRollback.setTenantId(req.getTenantId());
+        networkRollback.setMsoRequest(req.getMsoRequest());
+        networkRollback.setModelCustomizationUuid(req.getModelCustomizationUuid());
+        networkRollback.setNetworkStackId(stackId);
+        networkRollback.setNetworkCreated(true);
+        networkRollback.setNetworkType(req.getNetworkType());
+
+        return networkRollback;
+    }
 }
index 7be1620..6b76c3a 100644 (file)
@@ -39,12 +39,9 @@ import org.onap.so.adapters.network.MsoNetworkAdapterImpl;
 import org.onap.so.adapters.network.exceptions.NetworkException;
 import org.onap.so.adapters.nwrest.ContrailNetwork;
 import org.onap.so.adapters.nwrest.CreateNetworkRequest;
-import org.onap.so.adapters.nwrest.CreateNetworkResponse;
 import org.onap.so.adapters.nwrest.DeleteNetworkRequest;
-import org.onap.so.adapters.nwrest.DeleteNetworkResponse;
 import org.onap.so.adapters.nwrest.ProviderVlanNetwork;
 import org.onap.so.adapters.nwrest.RollbackNetworkRequest;
-import org.onap.so.adapters.nwrest.RollbackNetworkResponse;
 import org.onap.so.adapters.nwrest.UpdateNetworkRequest;
 import org.onap.so.adapters.nwrest.UpdateNetworkResponse;
 import org.onap.so.adapters.vnf.MsoVnfAdapterImpl;
@@ -52,15 +49,9 @@ import org.onap.so.adapters.vnf.MsoVnfPluginAdapterImpl;
 import org.onap.so.adapters.vnf.VnfAdapterUtils;
 import org.onap.so.adapters.vnf.exceptions.VnfException;
 import org.onap.so.adapters.vnfrest.CreateVfModuleRequest;
-import org.onap.so.adapters.vnfrest.CreateVfModuleResponse;
 import org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest;
-import org.onap.so.adapters.vnfrest.CreateVolumeGroupResponse;
 import org.onap.so.adapters.vnfrest.DeleteVfModuleRequest;
-import org.onap.so.adapters.vnfrest.DeleteVfModuleResponse;
 import org.onap.so.adapters.vnfrest.DeleteVolumeGroupRequest;
-import org.onap.so.adapters.vnfrest.DeleteVolumeGroupResponse;
-import org.onap.so.adapters.vnfrest.VfModuleRollback;
-import org.onap.so.adapters.vnfrest.VolumeGroupRollback;
 import org.onap.so.logging.tasks.AuditMDCSetup;
 import org.onap.so.openstack.beans.NetworkRollback;
 import org.onap.so.openstack.beans.RouteTarget;
@@ -94,7 +85,6 @@ public class StackService extends ExternalTaskUtils {
     private static final String SHARED = "shared";
     private static final String EXTERNAL = "external";
 
-    // TODO set backout earlier in case of exception??
     public void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService) {
         Map<String, Object> variables = new HashMap<>();
         mdcSetup.setupMDC(externalTask);
@@ -102,7 +92,7 @@ public class StackService extends ExternalTaskUtils {
         logger.debug("Starting External Task Stack Service. {}", xmlRequest);
         MutableBoolean success = new MutableBoolean();
         MutableBoolean backout = new MutableBoolean();
-        String response = "";
+        MutableBoolean os3Nw = new MutableBoolean();
         Holder<String> canonicalStackId = new Holder<>();
         String errorMessage = "";
         try {
@@ -117,26 +107,26 @@ public class StackService extends ExternalTaskUtils {
                 Holder<NetworkRollback> networkRollback = new Holder<>();
                 if ("createVolumeGroupRequest".equals(requestType.get())) {
                     logger.debug("Executing External Task Stack Service For Create Volume Group");
-                    response = createVolumeGroup(xmlRequest, outputs, vnfRollback, canonicalStackId, backout, success);
+                    createVolumeGroup(xmlRequest, outputs, vnfRollback, canonicalStackId, backout, success);
                 } else if ("createVfModuleRequest".equals(requestType.get())) {
                     logger.debug("Executing External Task Stack Service For Create Vf Module");
-                    response = createVfModule(xmlRequest, outputs, vnfRollback, canonicalStackId, backout, success);
+                    createVfModule(xmlRequest, outputs, vnfRollback, canonicalStackId, backout, success);
                 } else if ("deleteVfModuleRequest".equals(requestType.get())) {
                     logger.debug("Executing External Task Stack Service For Delete Vf Module");
-                    response = deleteVfModule(xmlRequest, outputs, vnfRollback, canonicalStackId, backout, success);
+                    deleteVfModule(xmlRequest, outputs, vnfRollback, canonicalStackId, backout, success);
                 } else if ("deleteVolumeGroupRequest".equals(requestType.get())) {
                     logger.debug("Executing External Task Stack Service For Delete Volume Group");
-                    response = deleteVolumeGroup(xmlRequest, outputs, vnfRollback, canonicalStackId, backout, success);
+                    deleteVolumeGroup(xmlRequest, outputs, vnfRollback, canonicalStackId, backout, success);
                 } else if ("createNetworkRequest".equals(requestType.get())) {
-                    response = createNetwork(xmlRequest, networkId, neutronNetworkId, networkFqdn, subnetIdMap,
-                            networkRollback, canonicalStackId, backout, success);
+                    createNetwork(xmlRequest, networkId, neutronNetworkId, networkFqdn, subnetIdMap, networkRollback,
+                            canonicalStackId, backout, success, os3Nw);
                 } else if ("deleteNetworkRequest".equals(requestType.get())) {
-                    response = deleteNetwork(xmlRequest, canonicalStackId, backout, success);
+                    deleteNetwork(xmlRequest, canonicalStackId, backout, success);
                 } else if ("updateNetworkRequest".equals(requestType.get())) {
-                    response =
-                            updateNetwork(xmlRequest, subnetIdMap, networkRollback, canonicalStackId, backout, success);
+
+                    updateNetwork(xmlRequest, subnetIdMap, networkRollback, canonicalStackId, backout, success);
                 } else if ("rollbackNetworkRequest".equals(requestType.get())) {
-                    response = rollbackNetwork(xmlRequest, canonicalStackId, backout, success);
+                    rollbackNetwork(xmlRequest, canonicalStackId, backout, success);
                 }
             }
         } catch (Exception e) {
@@ -144,7 +134,6 @@ public class StackService extends ExternalTaskUtils {
             errorMessage = e.getMessage();
         }
         variables.put("backout", backout.booleanValue());
-        variables.put("WorkflowResponse", response);
         variables.put("OpenstackInvokeSuccess", success.booleanValue());
         variables.put("stackId", canonicalStackId.value);
         variables.put("openstackAdapterErrorMessage", errorMessage);
@@ -152,6 +141,7 @@ public class StackService extends ExternalTaskUtils {
         variables.put("rollbackPerformed", false);
         variables.put("OpenstackRollbackSuccess", false);
         variables.put("OpenstackPollSuccess", false);
+        variables.put("os3Nw", os3Nw.booleanValue());
 
         if (success.isTrue()) {
             externalTaskService.complete(externalTask, variables);
@@ -162,10 +152,9 @@ public class StackService extends ExternalTaskUtils {
         }
     }
 
-    private String createVolumeGroup(String xmlRequest, Holder<Map<String, String>> outputs,
+    private void createVolumeGroup(String xmlRequest, Holder<Map<String, String>> outputs,
             Holder<VnfRollback> vnfRollback, Holder<String> canonicalStackId, MutableBoolean backout,
             MutableBoolean success) throws VnfException {
-        Holder<String> stackId = new Holder<>();
         CreateVolumeGroupRequest req = JAXB.unmarshal(new StringReader(xmlRequest), CreateVolumeGroupRequest.class);
         String completeVnfVfModuleType = req.getVnfType() + "::" + req.getVfModuleType();
         boolean isMulticloud = vnfAdapterUtils.isMulticloudMode(null, req.getCloudSiteId());
@@ -173,28 +162,19 @@ public class StackService extends ExternalTaskUtils {
             vnfPluginImpl.createVfModule(req.getCloudSiteId(), req.getCloudOwner(), req.getTenantId(),
                     completeVnfVfModuleType, req.getVnfVersion(), "", req.getVolumeGroupName(), "", "VOLUME", null,
                     null, req.getModelCustomizationUuid(), req.getVolumeGroupParams(), false, true,
-                    req.getEnableBridge(), req.getMsoRequest(), stackId, outputs, vnfRollback);
+                    req.getEnableBridge(), req.getMsoRequest(), canonicalStackId, outputs, vnfRollback);
         } else {
             vnfAdapterImpl.createVfModule(req.getCloudSiteId(), req.getCloudOwner(), req.getTenantId(),
                     completeVnfVfModuleType, req.getVnfVersion(), "", req.getVolumeGroupName(), "", "VOLUME", null,
                     null, req.getModelCustomizationUuid(), req.getVolumeGroupParams(), false, true,
-                    req.getEnableBridge(), req.getMsoRequest(), stackId, outputs, vnfRollback);
+                    req.getEnableBridge(), req.getMsoRequest(), canonicalStackId, outputs, vnfRollback);
         }
         success.setTrue();
         backout.setValue(!req.getSuppressBackout());
-        VolumeGroupRollback rb = new VolumeGroupRollback(req.getVolumeGroupId(), stackId.value,
-                vnfRollback.value.getVnfCreated(), req.getTenantId(), req.getCloudOwner(), req.getCloudSiteId(),
-                req.getMsoRequest(), req.getMessageId());
-        canonicalStackId.value = stackId.value;
-        CreateVolumeGroupResponse createResponse = new CreateVolumeGroupResponse(req.getVolumeGroupId(), stackId.value,
-                vnfRollback.value.getVnfCreated(), outputs.value, rb, req.getMessageId());
-        return createResponse.toXmlString();
     }
 
-    private String createVfModule(String xmlRequest, Holder<Map<String, String>> outputs,
-            Holder<VnfRollback> vnfRollback, Holder<String> canonicalStackId, MutableBoolean backout,
-            MutableBoolean success) throws VnfException {
-        Holder<String> stackId = new Holder<>();
+    private void createVfModule(String xmlRequest, Holder<Map<String, String>> outputs, Holder<VnfRollback> vnfRollback,
+            Holder<String> canonicalStackId, MutableBoolean backout, MutableBoolean success) throws VnfException {
         CreateVfModuleRequest req = JAXB.unmarshal(new StringReader(xmlRequest), CreateVfModuleRequest.class);
         String completeVnfVfModuleType = req.getVnfType() + "::" + req.getVfModuleType();
         boolean isMulticloud = vnfAdapterUtils.isMulticloudMode(null, req.getCloudSiteId());
@@ -203,27 +183,20 @@ public class StackService extends ExternalTaskUtils {
                     completeVnfVfModuleType, req.getVnfVersion(), req.getVnfId(), req.getVfModuleName(),
                     req.getVfModuleId(), req.getRequestType(), req.getVolumeGroupStackId(),
                     req.getBaseVfModuleStackId(), req.getModelCustomizationUuid(), req.getVfModuleParams(), false,
-                    false, req.getEnableBridge(), req.getMsoRequest(), stackId, outputs, vnfRollback);
+                    false, req.getEnableBridge(), req.getMsoRequest(), canonicalStackId, outputs, vnfRollback);
         } else {
             vnfAdapterImpl.createVfModule(req.getCloudSiteId(), req.getCloudOwner(), req.getTenantId(),
                     completeVnfVfModuleType, req.getVnfVersion(), req.getVnfId(), req.getVfModuleName(),
                     req.getVfModuleId(), req.getRequestType(), req.getVolumeGroupStackId(),
                     req.getBaseVfModuleStackId(), req.getModelCustomizationUuid(), req.getVfModuleParams(), false,
-                    false, req.getEnableBridge(), req.getMsoRequest(), stackId, outputs, vnfRollback);
+                    false, req.getEnableBridge(), req.getMsoRequest(), canonicalStackId, outputs, vnfRollback);
         }
         success.setTrue();
         backout.setValue(req.getBackout());
-        canonicalStackId.value = stackId.value;
-        VfModuleRollback modRollback =
-                new VfModuleRollback(vnfRollback.value, req.getVfModuleId(), stackId.value, req.getMessageId());
-        CreateVfModuleResponse createResponse = new CreateVfModuleResponse(req.getVnfId(), req.getVfModuleId(),
-                stackId.value, Boolean.TRUE, outputs.value, modRollback, req.getMessageId());
-        return createResponse.toXmlString();
     }
 
-    private String deleteVfModule(String xmlRequest, Holder<Map<String, String>> outputs,
-            Holder<VnfRollback> vnfRollback, Holder<String> canonicalStackId, MutableBoolean backout,
-            MutableBoolean success) throws VnfException {
+    private void deleteVfModule(String xmlRequest, Holder<Map<String, String>> outputs, Holder<VnfRollback> vnfRollback,
+            Holder<String> canonicalStackId, MutableBoolean backout, MutableBoolean success) throws VnfException {
         backout.setFalse();
         DeleteVfModuleRequest req = JAXB.unmarshal(new StringReader(xmlRequest), DeleteVfModuleRequest.class);
         boolean isMulticloud = vnfAdapterUtils.isMulticloudMode(null, req.getCloudSiteId());
@@ -241,12 +214,9 @@ public class StackService extends ExternalTaskUtils {
         } else {
             canonicalStackId.value = req.getVfModuleStackId();
         }
-        DeleteVfModuleResponse deleteResponse = new DeleteVfModuleResponse(req.getVnfId(), req.getVfModuleId(),
-                Boolean.TRUE, req.getMessageId(), outputs.value);
-        return deleteResponse.toXmlString();
     }
 
-    private String deleteVolumeGroup(String xmlRequest, Holder<Map<String, String>> outputs,
+    private void deleteVolumeGroup(String xmlRequest, Holder<Map<String, String>> outputs,
             Holder<VnfRollback> vnfRollback, Holder<String> canonicalStackId, MutableBoolean backout,
             MutableBoolean success) throws VnfException {
         backout.setFalse();
@@ -255,14 +225,12 @@ public class StackService extends ExternalTaskUtils {
                 req.getVolumeGroupStackId(), req.getMsoRequest(), false);
         success.setTrue();
         canonicalStackId.value = req.getVolumeGroupStackId();
-        DeleteVolumeGroupResponse deleteResponse = new DeleteVolumeGroupResponse(true, req.getMessageId());
-        return deleteResponse.toXmlString();
     }
 
-    private String createNetwork(String xmlRequest, Holder<String> networkId, Holder<String> neutronNetworkId,
+    private void createNetwork(String xmlRequest, Holder<String> networkId, Holder<String> neutronNetworkId,
             Holder<String> networkFqdn, Holder<Map<String, String>> subnetIdMap,
             Holder<NetworkRollback> networkRollback, Holder<String> canonicalStackId, MutableBoolean backout,
-            MutableBoolean success) throws NetworkException {
+            MutableBoolean success, MutableBoolean os3) throws NetworkException {
         CreateNetworkRequest req = JAXB.unmarshal(new StringReader(xmlRequest), CreateNetworkRequest.class);
         HashMap<String, String> params = (HashMap<String, String>) req.getNetworkParams();
         if (params == null) {
@@ -306,18 +274,13 @@ public class StackService extends ExternalTaskUtils {
         networkAdapterImpl.createNetwork(req.getCloudSiteId(), req.getTenantId(), req.getNetworkType(),
                 req.getModelCustomizationUuid(), req.getNetworkName(), physicalNetworkName, vlans, routeTargets, shared,
                 external, req.getFailIfExists(), false, req.getSubnets(), fqdns, routeTable, req.getMsoRequest(),
-                networkId, neutronNetworkId, networkFqdn, subnetIdMap, networkRollback, true);
+                networkId, neutronNetworkId, networkFqdn, subnetIdMap, networkRollback, true, os3);
         success.setTrue();
         backout.setValue(req.getBackout());
         canonicalStackId.value = networkRollback.value.getNetworkStackId();
-
-        CreateNetworkResponse response = new CreateNetworkResponse(req.getNetworkId(), neutronNetworkId.value,
-                networkRollback.value.getNetworkStackId(), networkFqdn.value, networkRollback.value.getNetworkCreated(),
-                subnetIdMap.value, networkRollback.value, req.getMessageId());
-        return response.toXmlString();
     }
 
-    private String deleteNetwork(String xmlRequest, Holder<String> canonicalStackId, MutableBoolean backout,
+    private void deleteNetwork(String xmlRequest, Holder<String> canonicalStackId, MutableBoolean backout,
             MutableBoolean success) throws NetworkException {
         backout.setFalse();
         DeleteNetworkRequest req = JAXB.unmarshal(new StringReader(xmlRequest), DeleteNetworkRequest.class);
@@ -328,13 +291,9 @@ public class StackService extends ExternalTaskUtils {
 
         canonicalStackId.value = req.getNetworkStackId();
         success.setTrue();
-
-        DeleteNetworkResponse response =
-                new DeleteNetworkResponse(req.getNetworkId(), networkDeleted.value, req.getMessageId());
-        return response.toXmlString();
     }
 
-    private String rollbackNetwork(String xmlRequest, Holder<String> canonicalStackId, MutableBoolean backout,
+    private void rollbackNetwork(String xmlRequest, Holder<String> canonicalStackId, MutableBoolean backout,
             MutableBoolean success) throws NetworkException {
         backout.setFalse();
         RollbackNetworkRequest req = JAXB.unmarshal(new StringReader(xmlRequest), RollbackNetworkRequest.class);
@@ -344,9 +303,6 @@ public class StackService extends ExternalTaskUtils {
 
         canonicalStackId.value = rollback.getNetworkStackId();
         success.setTrue();
-
-        RollbackNetworkResponse response = new RollbackNetworkResponse(true, req.getMessageId());
-        return response.toXmlString();
     }
 
     private String updateNetwork(String xmlRequest, Holder<Map<String, String>> subnetIdMap,
index 26bce5f..4ee6cf2 100644 (file)
@@ -158,6 +158,7 @@ public class MsoVnfAdapterImpl {
      * @param outputs Holder for Map of VNF outputs from heat (assigned IPs, etc)
      * @param rollback Holder for returning VnfRollback object
      */
+    @Deprecated
     public void createVnf(String cloudSiteId, String cloudOwner, String tenantId, String vnfType, String vnfVersion,
             String vnfName, String requestType, String volumeGroupHeatStackId, Map<String, Object> inputs,
             Boolean failIfExists, Boolean backout, Boolean enableBridge, MsoRequest msoRequest, Holder<String> vnfId,
@@ -212,6 +213,7 @@ public class MsoVnfAdapterImpl {
      * @param vnfName VNF Name or Openstack ID
      * @param msoRequest Request tracking information for logs
      */
+    @Deprecated
     public void deleteVnf(String cloudSiteId, String cloudOwner, String tenantId, String vnfName, MsoRequest msoRequest)
             throws VnfException {
 
@@ -251,6 +253,7 @@ public class MsoVnfAdapterImpl {
      * @param vnfName VNF Name or Openstack ID
      * @param msoRequest Request tracking information for logs
      */
+    @Deprecated
     public void deleteVnf(String cloudSiteId, String cloudOwner, String tenantId, String vnfName, MsoRequest msoRequest,
             boolean pollStackStatus) throws VnfException {
 
@@ -315,7 +318,7 @@ public class MsoVnfAdapterImpl {
         return;
     }
 
-    private Map<String, String> copyStringOutputs(Map<String, Object> stackOutputs) {
+    public Map<String, String> copyStringOutputs(Map<String, Object> stackOutputs) {
         Map<String, String> stringOutputs = new HashMap<>();
         for (Map.Entry<String, Object> entry : stackOutputs.entrySet()) {
             String key = entry.getKey();
@@ -405,6 +408,7 @@ public class MsoVnfAdapterImpl {
         return stringMap;
     }
 
+    // TODO remove rollback and outputs and polling
     public void createVfModule(String cloudSiteId, String cloudOwner, String tenantId, String vnfType,
             String vnfVersion, String genericVnfName, String vnfName, String vfModuleId, String requestType,
             String volumeGroupHeatStackId, String baseVfHeatStackId, String modelCustomizationUuid,
@@ -461,6 +465,7 @@ public class MsoVnfAdapterImpl {
         logger.debug("requestTypeString = " + requestTypeString + ", nestedStackId = " + nestedStackId
                 + ", nestedBaseStackId = " + nestedBaseStackId);
 
+        // TODO remove
         // Build a default rollback object (no actions performed)
         VnfRollback vfRollback = new VnfRollback();
         vfRollback.setCloudSiteId(cloudSiteId);
@@ -960,7 +965,7 @@ public class MsoVnfAdapterImpl {
 
             vnfId.value = heatStack.getCanonicalName();
             outputs.value = copyStringOutputs(heatStack.getOutputs());
-            rollback.value = vfRollback;
+            rollback.value = vfRollback; // TODO remove
             logger.debug("VF Module {} successfully created", vfModuleName);
         } catch (Exception e) {
             logger.debug("unhandled exception in create VF", e);
@@ -988,29 +993,7 @@ public class MsoVnfAdapterImpl {
         // call method which handles the conversion from Map<String,Object> to Map<String,String> for our expected
         // Object types
         outputs.value = this.convertMapStringObjectToStringString(stackOutputs);
-        int timeoutMinutes = 118;
-        VfModule vf = null;
-        VfModuleCustomization vfmc = null;
-        if (modelCustomizationUuid != null) {
-            vfmc = vfModuleCustomRepo.findFirstByModelCustomizationUUIDOrderByCreatedDesc(modelCustomizationUuid);
-            if (vfmc != null) {
-                vf = vfmc.getVfModule();
-            }
-            if (vf != null) {
-                logger.trace("Found vfModuleCust entry {}", vfmc.toString());
-                HeatTemplate heat = vf.getModuleHeatTemplate();
-                if (heat != null && heat.getTimeoutMinutes() != null) {
-                    if (heat.getTimeoutMinutes() < 118) {
-                        timeoutMinutes = heat.getTimeoutMinutes();
-                    }
-                }
-
-            } else {
-                logger.debug(
-                        "Unable to find vfModuleCust with modelCustomizationUuid={} . Using default timeout for polling",
-                        modelCustomizationUuid);
-            }
-        }
+        int timeoutMinutes = msoHeatUtils.getVfHeatTimeoutValue(modelCustomizationUuid, false);
 
         try {
             StackInfo currentStack =
index 6b97983..58c43be 100644 (file)
@@ -1120,7 +1120,9 @@ public class MsoVnfPluginAdapterImpl {
         long subStartTime = System.currentTimeMillis();
         try {
             // TODO: Get an appropriate timeout value - require access to the model
-            vduPlugin.deleteVdu(cloudInfo, vfModuleId, 5);
+            if (!vduInstance.getStatus().getState().equals(VduStateType.NOTFOUND)) {
+                vduPlugin.deleteVdu(cloudInfo, vfModuleId, 5);
+            }
         } catch (VduException me) {
             me.addContext("DeleteVfModule");
             // Convert to a generic VnfException
index eb0529c..9b20139 100644 (file)
@@ -765,7 +765,7 @@ public class HeatBridgeImpl implements HeatBridgeApi {
                         if (env.getProperty("heatBridgeDryrun", Boolean.class, false)) {
                             logger.debug("Would delete Vserver: {}", vserverUri.build().toString());
                         } else {
-                            resourcesClient.delete(vserverUri);
+                            resourcesClient.deleteIfExists(vserverUri);
                         }
                     }
                 }
index 6082670..0214fdd 100644 (file)
@@ -52,15 +52,17 @@ public class PollServiceTest {
         Mockito.when(mockExternalTask.getVariable("openstackAdapterTaskRequest")).thenReturn(xmlString);
         Mockito.when(mockExternalTask.getVariable("PollRollbackStatus")).thenReturn(false);
         Mockito.when(mockExternalTask.getVariable("stackId")).thenReturn("stackId/stack123");
-        Mockito.when(msoHeatUtils.pollStackForStatus(eq(1), any(Stack.class), eq("CREATE_IN_PROGRESS"), eq("regionOne"),
-                eq("0422ffb57ba042c0800a29dc85ca70f8"), eq(false))).thenReturn(new Stack());
+        Mockito.when(msoHeatUtils.pollStackForStatus(eq(118), any(Stack.class), eq("CREATE_IN_PROGRESS"),
+                eq("regionOne"), eq("0422ffb57ba042c0800a29dc85ca70f8"), eq(false))).thenReturn(new Stack());
+        Mockito.when(msoHeatUtils.getVfHeatTimeoutValue(any(), eq(false))).thenReturn(118);
         // Mockito.doNothing().when(msoHeatUtils).postProcessStackCreate(Mockito.any(), Mockito.any(), Mockito.any(),
         // Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any());
 
         pollService.executeExternalTask(mockExternalTask, mockExternalTaskService);
 
-        Mockito.verify(msoHeatUtils).pollStackForStatus(eq(1), any(Stack.class), eq("CREATE_IN_PROGRESS"),
+        Mockito.verify(msoHeatUtils).pollStackForStatus(eq(118), any(Stack.class), eq("CREATE_IN_PROGRESS"),
                 eq("regionOne"), eq("0422ffb57ba042c0800a29dc85ca70f8"), eq(false));
+        Mockito.verify(msoHeatUtils).getVfHeatTimeoutValue(any(), eq(false));
 
     }
 
@@ -72,16 +74,16 @@ public class PollServiceTest {
         Mockito.when(mockExternalTask.getVariable("openstackAdapterTaskRequest")).thenReturn(xmlString);
         Mockito.when(mockExternalTask.getVariable("PollRollbackStatus")).thenReturn(true);
         Mockito.when(mockExternalTask.getVariable("stackId")).thenReturn("stackId/stack123");
-        Mockito.when(msoHeatUtils.pollStackForStatus(eq(1), any(), eq("DELETE_IN_PROGRESS"), eq("regionOne"),
+        Mockito.when(msoHeatUtils.pollStackForStatus(eq(118), any(), eq("DELETE_IN_PROGRESS"), eq("regionOne"),
                 eq("0422ffb57ba042c0800a29dc85ca70f8"), eq(true))).thenReturn(new Stack());
         Mockito.doNothing().when(msoHeatUtils).postProcessStackDelete(Mockito.any());
-
+        Mockito.when(msoHeatUtils.getVfHeatTimeoutValue(any(), eq(false))).thenReturn(118);
 
         pollService.executeExternalTask(mockExternalTask, mockExternalTaskService);
 
-        Mockito.verify(msoHeatUtils).pollStackForStatus(eq(1), any(), eq("DELETE_IN_PROGRESS"), eq("regionOne"),
+        Mockito.verify(msoHeatUtils).pollStackForStatus(eq(118), any(), eq("DELETE_IN_PROGRESS"), eq("regionOne"),
                 eq("0422ffb57ba042c0800a29dc85ca70f8"), eq(true));
-
+        Mockito.verify(msoHeatUtils).getVfHeatTimeoutValue(any(), eq(false));
     }
 
 }
index afe7e17..7a00cfe 100644 (file)
@@ -89,14 +89,15 @@ public class StackServiceTest {
 
         Map<String, Object> variables = new HashMap<>();
         variables.put("backout", true);
-        variables.put("WorkflowResponse", "");
         variables.put("OpenstackInvokeSuccess", true);
         variables.put("stackId", null);
-        variables.put("openstackAdapterErrorMessage", null);
+        variables.put("openstackAdapterErrorMessage", "");
         variables.put("PollRollbackStatus", false);
         variables.put("rollbackPerformed", false);
         variables.put("OpenstackRollbackSuccess", false);
         variables.put("OpenstackPollSuccess", false);
+        variables.put("os3Nw", false);
+
 
         Mockito.verify(vnfAdapterImpl, Mockito.times(1)).createVfModule(Mockito.eq("regionOne"),
                 Mockito.eq("CloudOwner"), Mockito.eq("0422ffb57ba042c0800a29dc85ca70f8"),
index 7efc397..73b825d 100644 (file)
@@ -46,6 +46,7 @@ import org.onap.sdc.api.notification.IResourceInstance;
 import org.onap.sdc.api.notification.IStatusData;
 import org.onap.sdc.tosca.parser.api.IEntityDetails;
 import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
+import org.onap.sdc.tosca.parser.elements.EntityDetails;
 import org.onap.sdc.tosca.parser.elements.queries.EntityQuery;
 import org.onap.sdc.tosca.parser.elements.queries.EntityQuery.EntityQueryBuilder;
 import org.onap.sdc.tosca.parser.elements.queries.TopologyTemplateQuery;
@@ -133,6 +134,8 @@ public class ToscaResourceInstaller {
 
     private static final String CDS_MODEL_VERSION = "cds_model_version";
 
+    private static final String DEFAULT_SOFTWARE_VERSION = "default_software_version";
+
     @Autowired
     protected ServiceRepository serviceRepo;
 
@@ -932,6 +935,7 @@ public class ToscaResourceInstaller {
         pnfResourceCustomization.setBlueprintVersion(getStringValue(properties.get(SDNC_MODEL_VERSION)));
         pnfResourceCustomization.setSkipPostInstConf(getBooleanValue(properties.get(SKIP_POST_INST_CONF)));
         pnfResourceCustomization.setControllerActor(getStringValue(properties.get(CONTROLLER_ACTOR)));
+        pnfResourceCustomization.setDefaultSoftwareVersion(getStringValue(properties.get(DEFAULT_SOFTWARE_VERSION)));
         pnfResourceCustomization.setPnfResources(pnfResource);
         return pnfResourceCustomization;
     }
index 3db017c..eafb42a 100644 (file)
@@ -320,33 +320,6 @@ public class ASDCControllerITTest extends BaseTest {
         }
     }
 
-    private ArtifactInfoImpl constructPnfServiceArtifact() {
-        ArtifactInfoImpl artifactInfo = new ArtifactInfoImpl();
-        artifactInfo.setArtifactType(ASDCConfiguration.TOSCA_CSAR);
-        artifactInfo.setArtifactURL("/download/service-pnfservice.csar");
-        artifactInfo.setArtifactName("service-pnfservice.csar");
-        artifactInfo.setArtifactVersion("1.0");
-        artifactInfo.setArtifactUUID(artifactUuid);
-        return artifactInfo;
-    }
-
-    /**
-     * Construct the PnfResourceInfo based on the resource-Test140Pnf-template.yml from
-     * service-Testservice140-csar.csar.
-     */
-    private ResourceInfoImpl constructPnfResourceInfo() {
-        ResourceInfoImpl resourceInfo = new ResourceInfoImpl();
-        resourceInfo.setResourceInstanceName("PNF CDS Test");
-        resourceInfo.setResourceInvariantUUID("17d9d183-cee5-4a46-b5c4-6d5203f7d2e8");
-        resourceInfo.setResoucreType("PNF");
-        resourceInfo.setCategory("Application L4+");
-        resourceInfo.setSubcategory("Firewall");
-        resourceInfo.setResourceUUID("aa5d0562-80e7-43e9-af74-3085e57ab09f");
-        resourceInfo.setResourceCustomizationUUID("9f01263a-eaf7-4d98-a37b-3785f751903e");
-        resourceInfo.setResourceVersion("1.0");
-        return resourceInfo;
-    }
-
     /**
      * Testing with the service-Svc140-VF-csar.csar.
      */
@@ -479,6 +452,144 @@ public class ASDCControllerITTest extends BaseTest {
         }
     }
 
+    /**
+     * Test with service-pnfservice.csar.
+     */
+    @Test
+    public void treatNotification_ValidPnfResource_With_Software_Version_ExpectedOutput() {
+
+        /**
+         * service UUID/invariantUUID from global metadata in service-PnfServiceTestCds-template.yml.
+         */
+        String serviceUuid = "888d93bd-ef31-4ab8-9d9e-3935e9a71845";// "77cf276e-905c-43f6-8d54-dda474be2f2e";
+        String serviceInvariantUuid = "e5c5fd11-392f-4aa7-aeeb-b340c596d4bd";// "913e6776-4bc3-49b9-b399-b5bb4690f0c7";
+
+        initMockAaiServer(serviceUuid, serviceInvariantUuid);
+
+        NotificationDataImpl notificationData = new NotificationDataImpl();
+        notificationData.setServiceUUID(serviceUuid);
+        notificationData.setDistributionID(distributionId);
+        notificationData.setServiceInvariantUUID(serviceInvariantUuid);
+        notificationData.setServiceVersion("1.0");
+
+        ResourceInfoImpl resourceInfo = constructPnfResourceInfoWithSWV();
+        List<ResourceInfoImpl> resourceInfoList = new ArrayList<>();
+        resourceInfoList.add(resourceInfo);
+        notificationData.setResources(resourceInfoList);
+
+        ArtifactInfoImpl artifactInfo = constructPnfServiceArtifactWithSWV();
+        List<ArtifactInfoImpl> artifactInfoList = new ArrayList<>();
+        artifactInfoList.add(artifactInfo);
+        notificationData.setServiceArtifacts(artifactInfoList);
+
+        try {
+            asdcController.treatNotification(notificationData);
+
+            logger.info("Checking the database for PNF ingestion");
+
+            /**
+             * Check the tosca csar entity, it should be the same as provided from NotficationData.
+             */
+            ToscaCsar toscaCsar = toscaCsarRepository.findById(artifactUuid)
+                    .orElseThrow(() -> new EntityNotFoundException("Tosca csar: " + artifactUuid + " not found"));
+            assertEquals("tosca csar UUID", artifactUuid, toscaCsar.getArtifactUUID());
+            assertEquals("tosca csar name", "service-Testserviceforpnf-csar.csar", toscaCsar.getName());
+            assertEquals("tosca csar version", "1.0", toscaCsar.getVersion());
+            assertNull("tosca csar descrption", toscaCsar.getDescription());
+            assertEquals("tosca csar checksum", "MANUAL_RECORD", toscaCsar.getArtifactChecksum());
+            assertEquals("toscar csar URL", "/download/service-Testserviceforpnf-csar.csar", toscaCsar.getUrl());
+
+            /**
+             * Check the service entity, it should be the same as global metadata information in
+             * service-Testservice140-template.yml inside csar.
+             */
+            Service service = serviceRepository.findById(serviceUuid)
+                    .orElseThrow(() -> new EntityNotFoundException("Service: " + serviceUuid + " not found"));
+
+            /**
+             * Check PNF resource, it should be the same as metadata in the topology template in
+             * service-PnfServiceTestCds-template.yml OR global metadata in the resource-PnfServiceTestCds-template.yml
+             */
+            String pnfResourceKey = "72a2c44c-bb8a-4086-824b-0662d40bcd68";
+
+            /**
+             * Check PNF resource customization, it should be the same as metadata in the topology template in
+             * service-PnfServiceTestCds-template.yml OR global metadata in the resource-PnfServiceTestCds-template.yml
+             */
+            String pnfCustomizationKey = "96642e60-17cd-48c1-875d-b00b08fdb37b";// "9f01263a-eaf7-4d98-a37b-3785f751903e";
+            PnfResourceCustomization pnfCustomization = pnfCustomizationRepository.findById(pnfCustomizationKey)
+                    .orElseThrow(() -> new EntityNotFoundException(
+                            "PNF resource customization: " + pnfCustomizationKey + " not found"));
+            assertEquals("model customizationUUID", pnfCustomizationKey, pnfCustomization.getModelCustomizationUUID());
+            assertEquals("model instance name", "VSP_WithPNFD 1", pnfCustomization.getModelInstanceName());
+            assertEquals("NF type", "", pnfCustomization.getNfType());
+            assertEquals("NF Role", "", pnfCustomization.getNfRole());
+            assertEquals("NF function", "", pnfCustomization.getNfFunction());
+            assertEquals("NF naming code", "", pnfCustomization.getNfNamingCode());
+            assertEquals("PNF resource model UUID", pnfResourceKey, pnfCustomization.getPnfResources().getModelUUID());
+            assertEquals("Multi stage design", "", pnfCustomization.getMultiStageDesign());
+            assertNull("resource input", pnfCustomization.getResourceInput());
+            assertEquals("cds blueprint name(sdnc_model_name property)", "pm_control",
+                    pnfCustomization.getBlueprintName());
+            assertEquals("cds blueprint version(sdnc_model_version property)", "1.0.0",
+                    pnfCustomization.getBlueprintVersion());
+            assertEquals("default software version", "4.0.0", pnfCustomization.getDefaultSoftwareVersion());
+            assertTrue("skip post instantiation configuration", pnfCustomization.isSkipPostInstConf());
+            assertEquals("controller actor", "SO-REF-DATA", pnfCustomization.getControllerActor());
+
+            /**
+             * Check the pnf resource customization with service mapping
+             */
+            List<PnfResourceCustomization> pnfCustList = service.getPnfCustomizations();
+            assertEquals("PNF resource customization entity", 1, pnfCustList.size());
+            assertEquals(pnfCustomizationKey, pnfCustList.get(0).getModelCustomizationUUID());
+
+            /**
+             * Check the watchdog for component distribution status
+             */
+            List<WatchdogComponentDistributionStatus> distributionList =
+                    watchdogCDStatusRepository.findByDistributionId(this.distributionId);
+            assertNotNull(distributionList);
+            assertEquals(1, distributionList.size());
+            WatchdogComponentDistributionStatus distributionStatus = distributionList.get(0);
+            assertEquals("COMPONENT_DONE_OK", distributionStatus.getComponentDistributionStatus());
+            assertEquals("SO", distributionStatus.getComponentName());
+
+
+        } catch (Exception e) {
+            logger.info(e.getMessage(), e);
+            fail(e.getMessage());
+        }
+    }
+
+
+    private ArtifactInfoImpl constructPnfServiceArtifact() {
+        ArtifactInfoImpl artifactInfo = new ArtifactInfoImpl();
+        artifactInfo.setArtifactType(ASDCConfiguration.TOSCA_CSAR);
+        artifactInfo.setArtifactURL("/download/service-pnfservice.csar");
+        artifactInfo.setArtifactName("service-pnfservice.csar");
+        artifactInfo.setArtifactVersion("1.0");
+        artifactInfo.setArtifactUUID(artifactUuid);
+        return artifactInfo;
+    }
+
+    /**
+     * Construct the PnfResourceInfo based on the resource-Test140Pnf-template.yml from
+     * service-Testservice140-csar.csar.
+     */
+    private ResourceInfoImpl constructPnfResourceInfo() {
+        ResourceInfoImpl resourceInfo = new ResourceInfoImpl();
+        resourceInfo.setResourceInstanceName("PNF CDS Test");
+        resourceInfo.setResourceInvariantUUID("17d9d183-cee5-4a46-b5c4-6d5203f7d2e8");
+        resourceInfo.setResoucreType("PNF");
+        resourceInfo.setCategory("Application L4+");
+        resourceInfo.setSubcategory("Firewall");
+        resourceInfo.setResourceUUID("aa5d0562-80e7-43e9-af74-3085e57ab09f");
+        resourceInfo.setResourceCustomizationUUID("9f01263a-eaf7-4d98-a37b-3785f751903e");
+        resourceInfo.setResourceVersion("1.0");
+        return resourceInfo;
+    }
+
     private ArtifactInfoImpl constructVnfServiceArtifact() {
         ArtifactInfoImpl artifactInfo = new ArtifactInfoImpl();
         artifactInfo.setArtifactType(ASDCConfiguration.TOSCA_CSAR);
@@ -505,4 +616,31 @@ public class ASDCControllerITTest extends BaseTest {
         resourceInfo.setArtifacts(Collections.EMPTY_LIST);
         return resourceInfo;
     }
+
+    private ArtifactInfoImpl constructPnfServiceArtifactWithSWV() {
+        ArtifactInfoImpl artifactInfo = new ArtifactInfoImpl();
+        artifactInfo.setArtifactType(ASDCConfiguration.TOSCA_CSAR);
+        artifactInfo.setArtifactURL("/download/service-Testserviceforpnf-csar.csar");// service-pnfservice.csar");
+        artifactInfo.setArtifactName("service-Testserviceforpnf-csar.csar");// "service-pnfservice.csar");
+        artifactInfo.setArtifactVersion("1.0");
+        artifactInfo.setArtifactUUID(artifactUuid);
+        return artifactInfo;
+    }
+
+    /**
+     * Construct the PnfResourceInfo based on the resource-Test140Pnf-template.yml from
+     * service-Testservice140-csar.csar.
+     */
+    private ResourceInfoImpl constructPnfResourceInfoWithSWV() {
+        ResourceInfoImpl resourceInfo = new ResourceInfoImpl();
+        resourceInfo.setResourceInstanceName("PNF CDS Test");
+        resourceInfo.setResourceInvariantUUID("bf150ca9-b8d3-4450-b50a-d80382a12462");// "17d9d183-cee5-4a46-b5c4-6d5203f7d2e8");
+        resourceInfo.setResoucreType("PNF");
+        resourceInfo.setCategory("Application L4+");
+        resourceInfo.setSubcategory("Firewall");
+        resourceInfo.setResourceUUID("72a2c44c-bb8a-4086-824b-0662d40bcd68");// "aa5d0562-80e7-43e9-af74-3085e57ab09f");
+        resourceInfo.setResourceCustomizationUUID("96642e60-17cd-48c1-875d-b00b08fdb37b");// "9f01263a-eaf7-4d98-a37b-3785f751903e");
+        resourceInfo.setResourceVersion("1.0");
+        return resourceInfo;
+    }
 }
diff --git a/asdc-controller/src/test/resources/download/service-Testserviceforpnf-csar.csar b/asdc-controller/src/test/resources/download/service-Testserviceforpnf-csar.csar
new file mode 100644 (file)
index 0000000..d061012
Binary files /dev/null and b/asdc-controller/src/test/resources/download/service-Testserviceforpnf-csar.csar differ
index f94f74d..1260461 100644 (file)
@@ -1205,6 +1205,7 @@ CREATE TABLE IF NOT EXISTS `pnf_resource_customization` (
   `CDS_BLUEPRINT_VERSION` varchar(20) DEFAULT NULL,
   `SKIP_POST_INSTANTIATION_CONFIGURATION` boolean default true,
   `CONTROLLER_ACTOR` varchar(200) DEFAULT NULL,
+  `DEFAULT_SOFTWARE_VERSION` varchar(4000) DEFAULT NULL,
   PRIMARY KEY (`MODEL_CUSTOMIZATION_UUID`),
   KEY `fk_pnf_resource_customization__pnf_resource1_idx` (`PNF_RESOURCE_MODEL_UUID`),
   CONSTRAINT `fk_pnf_resource_customization__pnf_resource1` FOREIGN KEY (`PNF_RESOURCE_MODEL_UUID`) REFERENCES `pnf_resource` (`MODEL_UUID`) ON DELETE CASCADE ON UPDATE CASCADE
index d966528..c18680a 100644 (file)
 
 package org.onap.so.bpmn.appc.payload;
 
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
 import java.util.Optional;
+import org.onap.so.bpmn.appc.payload.beans.ConfigurationParametersDistributeTraffic;
+import org.onap.so.bpmn.appc.payload.beans.ConfigurationParametersHealthCheck;
 import org.onap.so.bpmn.appc.payload.beans.ConfigurationParametersQuiesce;
 import org.onap.so.bpmn.appc.payload.beans.ConfigurationParametersResumeTraffic;
-import org.onap.so.bpmn.appc.payload.beans.ConfigurationParametersDistributeTraffic;
 import org.onap.so.bpmn.appc.payload.beans.ConfigurationParametersUpgrade;
+import org.onap.so.bpmn.appc.payload.beans.DistributeTrafficAction;
+import org.onap.so.bpmn.appc.payload.beans.DistributeTrafficCheckAction;
 import org.onap.so.bpmn.appc.payload.beans.HealthCheckAction;
 import org.onap.so.bpmn.appc.payload.beans.QuiesceTrafficAction;
 import org.onap.so.bpmn.appc.payload.beans.RequestParametersHealthCheck;
 import org.onap.so.bpmn.appc.payload.beans.ResumeTrafficAction;
-import org.onap.so.bpmn.appc.payload.beans.DistributeTrafficAction;
-import org.onap.so.bpmn.appc.payload.beans.DistributeTrafficCheckAction;
 import org.onap.so.bpmn.appc.payload.beans.SnapshotAction;
 import org.onap.so.bpmn.appc.payload.beans.StartStopAction;
 import org.onap.so.bpmn.appc.payload.beans.UpgradeAction;
 import org.onap.so.bpmn.core.json.JsonUtils;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
 
 public class PayloadClient {
 
@@ -122,6 +123,12 @@ public class PayloadClient {
         RequestParametersHealthCheck requestParams = new RequestParametersHealthCheck();
         requestParams.setHostIpAddress(vnfHostIpAddress);
         payloadResult.setRequestParameters(requestParams);
+
+        ConfigurationParametersHealthCheck configurationParametersHealthCheck =
+                new ConfigurationParametersHealthCheck();
+        configurationParametersHealthCheck.setVnfName(vnfName);
+        payloadResult.setConfigurationParameters(configurationParametersHealthCheck);
+
         return Optional.of((mapper.writeValueAsString(payloadResult)));
     }
 
index 2ecf741..2e16572 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP - SO
  * ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. 
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -66,7 +66,8 @@ public class PayloadClientTest {
 
     @Test
     public void healthCheckFormatTest() throws Exception {
-        String payloadResult = "{\"request-parameters\":{\"host-ip-address\":\"hostIpAddress1\"}}";
+        String payloadResult =
+                "{\"request-parameters\":{\"host-ip-address\":\"hostIpAddress1\"},\"configuration-parameters\":{\"vnf_name\":\"vnfName1\"}}";
         Optional<String> payloadClient = PayloadClient.healthCheckFormat("vnfName1", "hostIpAddress1");
         assertEquals(payloadResult, payloadClient.get());
     }
index 1d8de35..da95847 100644 (file)
@@ -55,7 +55,7 @@ import org.onap.aai.domain.yang.ServiceInstance
 import org.onap.aai.domain.yang.SliceProfile
 import org.onap.aai.domain.yang.SliceProfiles
 import org.onap.aai.domain.yang.Relationship
-
+import com.google.gson.Gson
 
 class AnNssmfUtils {
 
@@ -193,7 +193,7 @@ public void createSliceProfilesInAai(DelegateExecution execution) {
        ANNF_sliceProfileInstance.setServiceType(serviceType)
        String serviceStatus = "deactivated"
        ANNF_sliceProfileInstance.setOrchestrationStatus(serviceStatus)
-       String serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("ranNfSliceProfile"), "pLMNIdList")
+       String serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("ranNfSliceProfile"), "plmnIdList")
        ANNF_sliceProfileInstance.setServiceInstanceLocationId(serviceInstanceLocationid)
        String serviceRole = "slice-profile-instance"
        ANNF_sliceProfileInstance.setServiceRole(serviceRole)
@@ -213,7 +213,7 @@ public void createSliceProfilesInAai(DelegateExecution execution) {
        serviceType = jsonUtil.getJsonValue(execution.getVariable("tnFhSliceProfile"), "sST")
        TNFH_sliceProfileInstance.setServiceType(serviceType)
        TNFH_sliceProfileInstance.setOrchestrationStatus(serviceStatus)
-       serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("tnFhSliceProfile"), "pLMNIdList")
+       serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("tnFhSliceProfile"), "plmnIdList")
        TNFH_sliceProfileInstance.setServiceInstanceLocationId(serviceInstanceLocationid)
        TNFH_sliceProfileInstance.setServiceRole(serviceRole)
        TNFH_sliceProfileInstance.setEnvironmentContext(snssai)
@@ -230,7 +230,7 @@ public void createSliceProfilesInAai(DelegateExecution execution) {
        serviceType = jsonUtil.getJsonValue(execution.getVariable("tnMhSliceProfile"), "sST")
        TNMH_sliceProfileInstance.setServiceType(serviceType)
        TNMH_sliceProfileInstance.setOrchestrationStatus(serviceStatus)
-       serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("tnMhSliceProfile"), "pLMNIdList")
+       serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("tnMhSliceProfile"), "plmnIdList")
        TNMH_sliceProfileInstance.setServiceInstanceLocationId(serviceInstanceLocationid)
        TNMH_sliceProfileInstance.setServiceRole(serviceRole)
        TNMH_sliceProfileInstance.setEnvironmentContext(snssai)
@@ -268,7 +268,7 @@ private SliceProfile createSliceProfile(String domainType, DelegateExecution exe
        Map<String,Object> profile
        switch(domainType) {
                case "AN-NF":
-                       profile = objectMapper.readValue(execution.getVariable("ranNfSliceProfile"), Map.class)//pending fields - maxBandwidth, sST, pLMNIdList, cSReliabilityMeanTime, 
+                       profile = objectMapper.readValue(execution.getVariable("ranNfSliceProfile"), Map.class)//pending fields - maxBandwidth, sST, plmnIdList, cSReliabilityMeanTime, 
                                                                                                                                                                                                        //msgSizeByte, maxNumberofPDUSessions,overallUserDensity,transferIntervalTarget
                        result.setJitter(profile.get("jitter"))
                        result.setLatency(profile.get("latency"))
@@ -286,14 +286,14 @@ private SliceProfile createSliceProfile(String domainType, DelegateExecution exe
                        result.setProfileId(execution.getVariable("ANNF_sliceProfileId"))
                        break
                case "TN-FH":
-                       profile = objectMapper.readValue(execution.getVariable("tnFhSliceProfile"), Map.class) //pending fields - maxBandwidth, sST, pLMNIdList
+                       profile = objectMapper.readValue(execution.getVariable("tnFhSliceProfile"), Map.class) //pending fields - maxBandwidth, sST, plmnIdList
                        result.setJitter(profile.get("jitter"))
                        result.setLatency(profile.get("latency"))
                        result.setResourceSharingLevel(profile.get("resourceSharingLevel"))
                        result.setProfileId(execution.getVariable("TNFH_sliceProfileId"))
                        break
                case "TN-MH":
-                       profile = objectMapper.readValue(execution.getVariable("tnMhSliceProfile"), Map.class)//pending fields - maxBandwidth, sST, pLMNIdList
+                       profile = objectMapper.readValue(execution.getVariable("tnMhSliceProfile"), Map.class)//pending fields - maxBandwidth, sST, plmnIdList
                        result.setJitter(profile.get("jitter"))
                        result.setLatency(profile.get("latency"))
                        result.setResourceSharingLevel(profile.get("resourceSharingLevel"))
@@ -342,16 +342,17 @@ private SliceProfile createSliceProfile(String domainType, DelegateExecution exe
        
        public String buildCreateNSSMFRequest(DelegateExecution execution, String domainType, String action) {
                JsonObject esrInfo = new JsonObject()
-           esrInfo.addProperty("networkType", "tn")
-           esrInfo.addProperty("vendor", "ONAP_internal")
+               esrInfo.addProperty("networkType", "tn")
+               esrInfo.addProperty("vendor", "ONAP_internal")
                JsonObject response = new JsonObject()
                JsonObject allocateTnNssi = new JsonObject()
                JsonObject serviceInfo = new JsonObject()
                JsonArray transportSliceNetworksList  = new JsonArray()
                JsonArray connectionLinksList = new JsonArray()
                JsonObject connectionLinks = new JsonObject()
+               Gson jsonConverter = new Gson()
                if(action.equals("allocate")){
-                       Map<String, String> endpoints
+                       JsonObject endpoints = new JsonObject()
                        if(domainType.equals("TN_FH")) {
                                serviceInfo.addProperty("serviceInvariantUuid", execution.getVariable("TNFH_modelInvariantUuid"))
                                serviceInfo.addProperty("serviceUuid", execution.getVariable("TNFH_modelUuid"))
@@ -359,12 +360,10 @@ private SliceProfile createSliceProfile(String domainType, DelegateExecution exe
                                allocateTnNssi.addProperty("nssiName", execution.getVariable("TNFH_modelName"))
                                Map<String,Object> sliceProfile = objectMapper.readValue(execution.getVariable("tnFhSliceProfile"), Map.class)
                                sliceProfile.put("sliceProfileId", execution.getVariable("TNFH_sliceProfileInstanceId"))
-                               String sliceProfileString = objectMapper.writeValueAsString(sliceProfile)
-                               allocateTnNssi.addProperty("sliceProfile", sliceProfileString)
-                               endpoints.put("transportEndpointA", execution.getVariable("tranportEp_ID_RU"))
-                               endpoints.put("transportEndpointB", execution.getVariable("tranportEp_ID_DUIN"))
-                               String endpointsString = objectMapper.writeValueAsString(endpoints)
-                               connectionLinksList.add(endpointsString)
+                               allocateTnNssi.add("sliceProfile", jsonConverter.toJsonTree(sliceProfile))
+                               endpoints.addProperty("transportEndpointA", execution.getVariable("tranportEp_ID_RU"))
+                               endpoints.addProperty("transportEndpointB", execution.getVariable("tranportEp_ID_DUIN"))
+                               connectionLinksList.add(endpoints)
                        }else if(domainType.equals("TN_MH")) {
                                serviceInfo.addProperty("serviceInvariantUuid", execution.getVariable("TNMH_modelInvariantUuid"))
                                serviceInfo.addProperty("serviceUuid", execution.getVariable("TNMH_modelUuid"))
@@ -372,41 +371,32 @@ private SliceProfile createSliceProfile(String domainType, DelegateExecution exe
                                allocateTnNssi.addProperty("nssiName", execution.getVariable("TNMH_modelName"))
                                Map<String,Object> sliceProfile = objectMapper.readValue(execution.getVariable("tnMhSliceProfile"), Map.class)
                                sliceProfile.put("sliceProfileId", execution.getVariable("TNMH_sliceProfileInstanceId"))
-                               String sliceProfileString = objectMapper.writeValueAsString(sliceProfile)
-                               allocateTnNssi.addProperty("sliceProfile", sliceProfileString)
-                               endpoints.put("transportEndpointA", execution.getVariable("tranportEp_ID_DUEG"))
-                               endpoints.put("transportEndpointB", execution.getVariable("tranportEp_ID_CUIN"))
-                               String endpointsString = objectMapper.writeValueAsString(endpoints)
-                               connectionLinksList.add(endpointsString)
+                               allocateTnNssi.add("sliceProfile", jsonConverter.toJsonTree(sliceProfile))
+                                endpoints.addProperty("transportEndpointA", execution.getVariable("tranportEp_ID_DUEG"))
+                               endpoints.addProperty("transportEndpointB", execution.getVariable("tranportEp_ID_CUIN"))
+                               connectionLinksList.add(endpoints)
                        }
                        
                        //Connection links
                        connectionLinks.add("connectionLinks", connectionLinksList)
                        transportSliceNetworksList.add(connectionLinks)
                        allocateTnNssi.add("transportSliceNetworks", transportSliceNetworksList)
-                       allocateTnNssi.addProperty("nssiId", null)
-                       serviceInfo.addProperty("nssiId", null)
                }else if(action.equals("modify-allocate")) {
                        if(domainType.equals("TN_FH")) {
-                               serviceInfo.addProperty("serviceInvariantUuid", null)
-                               serviceInfo.addProperty("serviceUuid", null)
-                               allocateTnNssi.addProperty("nsstId", null)
                                allocateTnNssi.addProperty("nssiName", execution.getVariable("TNFH_nssiName"))
                                allocateTnNssi.addProperty("sliceProfileId", execution.getVariable("TNFH_sliceProfileInstanceId"))
                                allocateTnNssi.addProperty("nssiId", execution.getVariable("TNFH_NSSI"))
                                serviceInfo.addProperty("nssiId", execution.getVariable("TNFH_NSSI"))
                        }else if(domainType.equals("TN_MH")) {
-                               serviceInfo.addProperty("serviceInvariantUuid", null)
-                               serviceInfo.addProperty("serviceUuid", null)
-                               allocateTnNssi.addProperty("nsstId", null)
                                allocateTnNssi.addProperty("nssiName", execution.getVariable("TNMH_nssiName"))
                                allocateTnNssi.addProperty("sliceProfileId", execution.getVariable("TNMH_sliceProfileInstanceId"))
                                allocateTnNssi.addProperty("nssiId", execution.getVariable("TNMH_NSSI"))
                                serviceInfo.addProperty("nssiId", execution.getVariable("TNMH_NSSI"))
                        }
                }
+               JsonParser parser = new JsonParser()
                String nsiInfo = jsonUtil.getJsonValue(execution.getVariable("sliceParams"), "nsiInfo")
-               allocateTnNssi.addProperty("nsiInfo", nsiInfo)
+               allocateTnNssi.add("nsiInfo",(JsonObject) parser.parse(nsiInfo))
                allocateTnNssi.addProperty("scriptName", "TN1")
                serviceInfo.addProperty("nsiId", execution.getVariable("nsiId"))
                serviceInfo.addProperty("globalSubscriberId", execution.getVariable("globalSubscriberId"))
index 8cab146..b94c81b 100644 (file)
@@ -215,11 +215,12 @@ class DeleteCommunicationService extends AbstractServiceTaskProcessor {
 
             String msoKey = UrnPropertiesReader.getVariable("mso.msoKey", execution)
             String basicAuth =  UrnPropertiesReader.getVariable("mso.infra.endpoint.auth", execution)
-            String basicAuthValue = utils.encrypt(basicAuth, msoKey)
-            String encodeString = utils.getBasicAuth(basicAuthValue, msoKey)
+//            String basicAuthValue = utils.encrypt(basicAuth, msoKey)
+//            String encodeString = utils.getBasicAuth(basicAuthValue, msoKey)
 
             HttpClient httpClient = getHttpClientFactory().newJsonClient(new URL(url), ONAPComponents.SO)
-            httpClient.addAdditionalHeader("Authorization", encodeString)
+//            httpClient.addAdditionalHeader("Authorization", encodeString)
+            httpClient.addAdditionalHeader("Authorization", basicAuth)
             httpClient.addAdditionalHeader("Accept", "application/json")
             Response httpResponse = httpClient.delete(requestBody)
             handleNSSMFWFResponse(httpResponse, execution)
index 4c008a2..8c04675 100644 (file)
@@ -20,6 +20,8 @@
 
 package org.onap.so.bpmn.infrastructure.scripts
 
+import org.onap.aaiclient.client.aai.entities.uri.AAISimpleUri
+
 import static org.apache.commons.lang3.StringUtils.isBlank
 import javax.ws.rs.NotFoundException
 import org.camunda.bpm.engine.delegate.BpmnError
@@ -176,11 +178,11 @@ class DeleteSliceService extends AbstractServiceTaskProcessor {
                 ServiceProfile serviceProfile = serviceProfiles.getServiceProfile().get(0)
                 profileId = serviceProfile ? serviceProfile.getProfileId() : ""
             }
-            resourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(serviceInstanceId).serviceProfile(profileId))
-            if (!getAAIClient().exists(resourceUri)) {
+            AAISimpleUri profileUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(serviceInstanceId).serviceProfile(profileId))
+            if (!getAAIClient().exists(profileUri)) {
                 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service Instance was not found in aai")
             }
-            getAAIClient().delete(resourceUri)
+            getAAIClient().delete(profileUri)
         }
         catch (any)
         {
index 05996d3..f3f8c8b 100644 (file)
@@ -83,6 +83,7 @@ public class DoActivateTnNssi extends AbstractServiceTaskProcessor {
         String actionType = operationType.equals("activateInstance") ? "activate" : "deactivate"
         execution.setVariable("actionType", actionType)
 
+        tnNssmfUtils.setEnableSdncConfig(execution)
 
         logger.debug("Finish preProcessRequest")
     }
@@ -142,20 +143,17 @@ public class DoActivateTnNssi extends AbstractServiceTaskProcessor {
                                 String status,
                                 String progress,
                                 String statusDescription) {
-        String serviceId = execution.getVariable("sliceServiceInstanceId")
+        String ssInstanceId = execution.getVariable("sliceServiceInstanceId")
+        String modelUuid = execution.getVariable("modelUuid")
         String jobId = execution.getVariable("jobId")
         String nsiId = execution.getVariable("nsiId")
         String operType = execution.getVariable("actionType")
+        operType = operType.toUpperCase()
+
 
+        ResourceOperationStatus roStatus = tnNssmfUtils.buildRoStatus(modelUuid, ssInstanceId,
+                jobId, nsiId, operType, status, progress, statusDescription)
 
-        ResourceOperationStatus roStatus = new ResourceOperationStatus()
-        roStatus.setServiceId(serviceId)
-        roStatus.setOperationId(jobId)
-        roStatus.setResourceTemplateUUID(nsiId)
-        roStatus.setOperType(operType)
-        roStatus.setProgress(progress)
-        roStatus.setStatus(status)
-        roStatus.setStatusDescription(statusDescription)
         requestDBUtil.prepareUpdateResourceOperationStatus(execution, roStatus)
     }
 
index e1719aa..33724bd 100644 (file)
@@ -34,6 +34,7 @@ import org.slf4j.LoggerFactory
 import java.util.List
 import static org.apache.commons.lang3.StringUtils.isBlank
 import com.google.gson.JsonObject
+import com.google.gson.Gson
 import com.fasterxml.jackson.databind.ObjectMapper
 import com.google.gson.JsonArray
 import com.google.gson.JsonParser
@@ -98,8 +99,8 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor {
                                execution.setVariable("sliceProfile", sliceProfile)
                        }
                        String sliceProfileId = jsonUtil.getJsonValue(sliceProfile, "sliceProfileId")
-                       def snssaiList = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(sliceProfile, "sNSSAI"))
-                       def plmnIdList = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(sliceProfile, "pLMNIdList"))
+                       def snssaiList = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(sliceProfile, "snssaiList"))
+                       def plmnIdList = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(sliceProfile, "plmnIdList"))
                        def coverageAreaTAList = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(sliceProfile, "coverageAreaTAList"))
 
                        if (isBlank(sliceProfileId) || (snssaiList.empty) || (plmnIdList.empty)
@@ -577,7 +578,7 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor {
        def createSdnrRequest = { DelegateExecution execution ->
                logger.debug(Prefix+"createSdnrRequest method start")
                String callbackUrl = UrnPropertiesReader.getVariable("mso.workflow.message.endpoint") + "/AsyncSdnrResponse/"+execution.getVariable("msoRequestId")
-               String sdnrRequest = buildSdnrAllocateRequest(execution, "allocate", "InstantiateRANSlice", callbackUrl)
+               String sdnrRequest = buildSdnrAllocateRequest(execution, "allocate", "instantiateRANSlice", callbackUrl)
                execution.setVariable("createNSSI_sdnrRequest", sdnrRequest)
                execution.setVariable("createNSSI_timeout", "PT10M")
                execution.setVariable("createNSSI_correlator", execution.getVariable("msoRequestId"))
@@ -697,12 +698,12 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor {
        }
        
        def createFhAllocateNssiJobQuery = { DelegateExecution execution ->
-               logger.debug(Prefix+"createModifyNssiQueryJobStatus method start")
+               logger.debug(Prefix+"createFhAllocateNssiJobQuery method start")
                createTnAllocateNssiJobQuery(execution, "TN_FH")                
        }
        
        def createMhAllocateNssiJobQuery = { DelegateExecution execution ->
-               logger.debug(Prefix+"createModifyNssiQueryJobStatus method start")
+               logger.debug(Prefix+"createMhAllocateNssiJobQuery method start")
                createTnAllocateNssiJobQuery(execution, "TN_MH")
        }
        
@@ -712,7 +713,6 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor {
            esrInfo.addProperty("vendor", "ONAP_internal")
                execution.setVariable("esrInfo", esrInfo.toString())
                JsonObject serviceInfo = new JsonObject()
-               serviceInfo.addProperty("nssiId", null)
                serviceInfo.addProperty("nsiId", execution.getVariable("nsiId"))
                String sST = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "sST")
                serviceInfo.addProperty("sST", sST)
@@ -736,14 +736,14 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor {
                logger.debug(Prefix+"processJobStatusRsp method start")
                String jobResponse = execution.getVariable("TNFH_jobResponse")
                logger.debug("Job status response "+jobResponse)
-               String status = jsonUtil.getJsonValue(jobResponse, "responseDescriptor.status")
-               String nssi = jsonUtil.getJsonValue(jobResponse, "responseDescriptor.nssi")
+               String status = jsonUtil.getJsonValue(jobResponse, "status")
+               String nssi = jsonUtil.getJsonValue(jobResponse, "nssiId")
                if(status.equalsIgnoreCase("finished")) {
                        execution.setVariable("TNFH_NSSI", nssi)
                        logger.debug("Job successfully completed ... proceeding with flow for nssi : "+nssi)
                }
                else {
-                       String statusDescription = jsonUtil.getJsonValue(jobResponse, "responseDescriptor.statusDescription")
+                       String statusDescription = jsonUtil.getJsonValue(jobResponse, "statusDescription")
                        logger.error("received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription)
                        exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription)
                }
@@ -753,14 +753,14 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor {
                logger.debug(Prefix+"processJobStatusRsp method start")
                String jobResponse = execution.getVariable("TNMH_jobResponse")
                logger.debug("Job status response "+jobResponse)
-               String status = jsonUtil.getJsonValue(jobResponse, "responseDescriptor.status")
-               String nssi = jsonUtil.getJsonValue(jobResponse, "responseDescriptor.nssi")
+               String status = jsonUtil.getJsonValue(jobResponse, "status")
+               String nssi = jsonUtil.getJsonValue(jobResponse, "nssiId")
                if(status.equalsIgnoreCase("finished")) {
                        execution.setVariable("TNMH_NSSI", nssi)
                        logger.debug("Job successfully completed ... proceeding with flow for nssi : "+nssi)
                }
                else {
-                       String statusDescription = jsonUtil.getJsonValue(jobResponse, "responseDescriptor.statusDescription")
+                       String statusDescription = jsonUtil.getJsonValue(jobResponse, "statusDescription")
                        logger.error("received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription)
                        exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription)
                }
@@ -770,13 +770,13 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor {
                logger.debug(Prefix+"processJobStatusRsp method start")
                String jobResponse = execution.getVariable("jobResponse")
                logger.debug("Job status response "+jobResponse)
-               String status = jsonUtil.getJsonValue(jobResponse, "responseDescriptor.status")
-               String nssi = jsonUtil.getJsonValue(jobResponse, "responseDescriptor.nssi")
+               String status = jsonUtil.getJsonValue(jobResponse, "status")
+               String nssi = jsonUtil.getJsonValue(jobResponse, "nssiId")
                if(status.equalsIgnoreCase("finished")) {
                        logger.debug("Job successfully completed ... proceeding with flow for nssi : "+nssi)
                }
                else {
-                       String statusDescription = jsonUtil.getJsonValue(jobResponse, "responseDescriptor.statusDescription")
+                       String statusDescription = jsonUtil.getJsonValue(jobResponse, "statusDescription")
                        logger.error("received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription)
                        exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription)
                }
@@ -899,29 +899,30 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor {
                sliceProfile.put("maxNumberofConns", sliceProfile.get("maxNumberofPDUSessions"))
                sliceProfile.put("uLThptPerSlice", sliceProfile.get("expDataRateUL"))
                sliceProfile.put("dLThptPerSlice", sliceProfile.get("expDataRateDL"))
-               String sliceProfileString = objectMapper.writeValueAsString(sliceProfile)
+
                JsonObject response = new JsonObject()
                JsonObject body = new JsonObject()
                JsonObject input = new JsonObject()
                JsonObject commonHeader = new JsonObject()
                JsonObject payload = new JsonObject()
                JsonObject payloadInput = new JsonObject()
-               commonHeader.addProperty("TimeStamp",new Date(System.currentTimeMillis()).format("yyyy-MM-dd'T'HH:mm:ss.sss", TimeZone.getDefault()))
-               commonHeader.addProperty("APIver", "1.0")
-               commonHeader.addProperty("RequestID", requestId)
-               commonHeader.addProperty("SubRequestID", "1")
-               commonHeader.add("RequestTrack", new JsonObject())
-               commonHeader.add("Flags", new JsonObject())
-               payloadInput.addProperty("sliceProfile", sliceProfileString)
+               commonHeader.addProperty("TimeStamp",new Date(System.currentTimeMillis()).format("yyyy-MM-dd'T'HH:mm:ss.sss'Z'", TimeZone.getDefault()))
+               commonHeader.addProperty("api-ver", "1.0")
+               commonHeader.addProperty("request-id", requestId)
+               commonHeader.addProperty("sub-request-id", "1")
+               commonHeader.add("request-track", new JsonObject())
+               commonHeader.add("flags", new JsonObject())
+               Gson jsonConverter = new Gson() 
+               payloadInput.add("sliceProfile", jsonConverter.toJsonTree(sliceProfile))
                payloadInput.addProperty("RANNSSIId", execution.getVariable("RANServiceInstanceId"))
                payloadInput.addProperty("NSIID", execution.getVariable("nsiId"))
                payloadInput.addProperty("RANNFNSSIId", execution.getVariable("RANNFServiceInstanceId"))
                payloadInput.addProperty("callbackURL", callbackUrl)
                payloadInput.add("additionalproperties", new JsonObject())
                payload.add("input", payloadInput)
-               input.add("CommonHeader", commonHeader)
-               input.addProperty("Action", action)
-               input.addProperty("Payload", payload.toString())
+               input.add("common-header", commonHeader)
+               input.addProperty("action", action)
+               input.addProperty("payload", payload.toString())
                body.add("input", input)
                response.add("body", body)
                response.addProperty("version", "1.0")
index 0311c3d..059a209 100644 (file)
@@ -394,6 +394,7 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{
 
         AllocateAnNssi allocateAnNssi = new AllocateAnNssi()
         allocateAnNssi.sliceProfile = sliceTaskInfo.sliceProfile.trans2AnProfile()
+        allocateAnNssi.sliceProfile.sliceProfileId = sliceTaskInfo.sliceInstanceId
         allocateAnNssi.nsstId = sliceTaskInfo.NSSTInfo.UUID
         allocateAnNssi.nssiId = sliceTaskInfo.suggestNssiId
         allocateAnNssi.nssiName = "nssi_an" + execution.getVariable("sliceServiceInstanceName")
@@ -537,6 +538,8 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{
         allocateCnNssi.nssiId = sliceTaskInfo.suggestNssiId
         allocateCnNssi.nssiName = "nssi_cn" + execution.getVariable("sliceServiceInstanceName")
         allocateCnNssi.sliceProfile = sliceTaskInfo.sliceProfile.trans2CnProfile()
+        allocateCnNssi.sliceProfile.sliceProfileId = sliceTaskInfo.sliceInstanceId
+
         NsiInfo nsiInfo = new NsiInfo()
         nsiInfo.nsiId = sliceParams.suggestNsiId
         nsiInfo.nsiName = sliceParams.suggestNsiName
index 4eb70a5..04f07b6 100644 (file)
@@ -34,6 +34,8 @@ import org.onap.so.bpmn.core.json.JsonUtils
 import org.slf4j.Logger
 import org.slf4j.LoggerFactory
 
+import static org.apache.commons.lang3.StringUtils.isBlank
+
 class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor {
 
     private static final Logger logger = LoggerFactory.getLogger(DoCreateTnNssiInstance.class);
@@ -61,6 +63,8 @@ class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor {
              }"""
         execution.setVariable("serviceModelInfo", serviceModelInfo)
 
+        tnNssmfUtils.setEnableSdncConfig(execution)
+
         logger.trace("Exit preProcessRequest")
     }
 
@@ -109,15 +113,18 @@ class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor {
             org.onap.aai.domain.yang.ServiceInstance ss = new org.onap.aai.domain.yang.ServiceInstance()
             ss.setServiceInstanceId(ssInstanceId)
             String sliceInstanceName = execution.getVariable("sliceServiceInstanceName")
+            if (isBlank(sliceInstanceName)) {
+                logger.error("ERROR: createServiceInstance: sliceInstanceName is null")
+                sliceInstanceName = ssInstanceId
+            }
             ss.setServiceInstanceName(sliceInstanceName)
             ss.setServiceType(serviceType)
-            String serviceStatus = "activated"
+            String serviceStatus = "deactivated"
             ss.setOrchestrationStatus(serviceStatus)
             String modelInvariantUuid = execution.getVariable("modelInvariantUuid")
             String modelUuid = execution.getVariable("modelUuid")
-            //TODO: need valid model ID from the caller, as AAI does not accept invalid IDs
-            //ss.setModelInvariantId(modelInvariantUuid)
-            //ss.setModelVersionId(modelUuid)
+            ss.setModelInvariantId(modelInvariantUuid)
+            ss.setModelVersionId(modelUuid)
             String serviceInstanceLocationid = tnNssmfUtils.getFirstPlmnIdFromSliceProfile(sliceProfileStr)
             ss.setServiceInstanceLocationId(serviceInstanceLocationid)
             String snssai = tnNssmfUtils.getFirstSnssaiFromSliceProfile(sliceProfileStr)
index f3bc47e..147e623 100644 (file)
@@ -21,25 +21,26 @@ package org.onap.so.bpmn.infrastructure.scripts
 
 import com.fasterxml.jackson.databind.ObjectMapper
 import org.camunda.bpm.engine.delegate.DelegateExecution
+import org.onap.aai.domain.yang.SliceProfiles
+import org.onap.aaiclient.client.aai.entities.AAIResultWrapper
+import org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri
 import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri
+import org.onap.aaiclient.client.aai.entities.uri.AAISimpleUri
 import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory
 import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder
-import org.onap.so.beans.nsmf.DeAllocateNssi
-import org.onap.so.beans.nsmf.EsrInfo
-import org.onap.so.beans.nsmf.NetworkType
-import org.onap.so.beans.nsmf.NssiResponse
-import org.onap.so.beans.nsmf.ServiceInfo
+import org.onap.so.beans.nsmf.*
+import org.onap.so.beans.nsmf.oof.SubnetType
 import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
 import org.onap.so.bpmn.common.scripts.ExceptionUtil
 import org.onap.so.bpmn.common.scripts.NssmfAdapterUtils
 import org.onap.so.bpmn.common.scripts.RequestDBUtil
-import org.onap.so.bpmn.core.domain.ServiceArtifact
 import org.onap.so.bpmn.core.domain.ServiceDecomposition
 import org.onap.so.bpmn.core.json.JsonUtils
 import org.onap.so.db.request.beans.OperationStatus
 import org.slf4j.Logger
 import org.slf4j.LoggerFactory
 
+import javax.ws.rs.NotFoundException
 
 class DoDeallocateNSSI extends AbstractServiceTaskProcessor
 {
@@ -103,15 +104,13 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor
 
         try {
             ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") as ServiceDecomposition
-            ServiceArtifact serviceArtifact = serviceDecomposition ?.getServiceInfo()?.getServiceArtifact()?.get(0)
-            String content = serviceArtifact.getContent()
-            String vendor = jsonUtil.getJsonValue(content, "metadata.vendor")
-            String domainType  = jsonUtil.getJsonValue(content, "metadata.domainType")
+            String vendor = serviceDecomposition ?.getServiceRole()
+            NetworkType domainType = convertServiceCategory(serviceDecomposition.getServiceCategory())
 
             def currentNSSI = execution.getVariable("currentNSSI")
             currentNSSI['vendor'] = vendor
             currentNSSI['domainType'] = domainType
-            LOGGER.info("processDecomposition, current vendor-domainType:" +String.join("-", vendor, domainType))
+            LOGGER.info("processDecomposition, current vendor-domainType:" +String.join("-", vendor, domainType.toString()))
 
         } catch (any) {
             String exceptionMessage = "Bpmn error encountered in deallocate nssi. processDecomposition() - " + any.getMessage()
@@ -120,6 +119,27 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor
         }
         LOGGER.debug("*****${PREFIX} Exit processDecomposition *****")
     }
+
+
+    /**
+     * get subnetType from serviceCategory
+     * @return
+     */
+    private NetworkType convertServiceCategory(String serviceCategory){
+        if(serviceCategory ==~ /CN.*/){
+            return SubnetType.CN.getNetworkType()
+        }
+        if (serviceCategory ==~ /AN.*NF.*/){
+            return SubnetType.AN.getNetworkType()
+        }
+        if (serviceCategory ==~ /TN.*BH.*/){
+            return SubnetType.TN_BH.getNetworkType()
+        }
+        if(serviceCategory ==~ /TN.*MH.*/){
+            return SubnetType.TN_MH.getNetworkType()
+        }
+        return null
+    }
     
     /**
      * send deallocate request to nssmf
@@ -136,9 +156,9 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor
         String scriptName = execution.getVariable("scriptName")
 
         String serviceInvariantUuid = currentNSSI['modelInvariantId']
-        String serviceUuid = currentNSSI['modelId']
+        String serviceUuid = currentNSSI['modelVersionId']
         String globalSubscriberId = currentNSSI['globalSubscriberId']
-        String subscriptionServiceType = execution.getVariable("serviceType")
+        String subscriptionServiceType = currentNSSI['serviceType']
         
         DeAllocateNssi deAllocateNssi = new DeAllocateNssi()
         deAllocateNssi.setNsiId(nsiId)
@@ -191,8 +211,6 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor
     {
         def currentNSSI = execution.getVariable("currentNSSI")
         String jobId = currentNSSI['jobId']
-
-        execution.setVariable("responseId", "3")
         execution.setVariable("jobId", jobId)
     }
 
@@ -245,11 +263,11 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor
 
     private EsrInfo getEsrInfo(def currentNSSI)
     {
-        String domaintype = currentNSSI['domainType']
+        NetworkType domainType = currentNSSI['domainType']
         String vendor = currentNSSI['vendor']
         
         EsrInfo info = new EsrInfo()
-        info.setNetworkType(NetworkType.fromString(domaintype))
+        info.setNetworkType(domainType)
         info.setVendor(vendor)
         return info
     }
@@ -264,17 +282,17 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor
         def currentNSSI = execution.getVariable("currentNSSI")
         int currentProgress = currentNSSI["jobProgress"]
         def proportion = currentNSSI['proportion']
-        def statusDes = currentNSSI["statusDescription"]
         int progress = (currentProgress as int) == 0 ? 0 : (currentProgress as int) / 100 * (proportion as int)
         def status = currentNSSI['status']
-        
+
+
         OperationStatus operationStatus = new OperationStatus()
         operationStatus.setServiceId(currentNSSI['e2eServiceInstanceId'] as String)
         operationStatus.setOperationId(currentNSSI['operationId'] as String)
         operationStatus.setOperation("DELETE")
-        operationStatus.setResult(status as String)
+        operationStatus.setResult("processing")
         operationStatus.setProgress(progress as String)
-        operationStatus.setOperationContent(statusDes as String)
+        operationStatus.setOperationContent(currentNSSI['domainType'].toString() + " " + status.toString())
         requestDBUtil.prepareUpdateOperationStatus(execution, operationStatus)
         LOGGER.debug("update operation, currentProgress=${currentProgress}, proportion=${proportion}, progress = ${progress}" )
     }
@@ -283,20 +301,20 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor
      * delete slice profile from aai
      * @param execution
      */
-    void delSliceProfileFromAAI(DelegateExecution execution)
+    void delSliceProfileServiceFromAAI(DelegateExecution execution)
     {
         LOGGER.debug("*****${PREFIX} start delSliceProfileFromAAI *****")
         def currentNSSI = execution.getVariable("currentNSSI")
         String nssiServiceInstanceId = currentNSSI['nssiServiceInstanceId']
         String profileId = currentNSSI['profileId']
         String globalSubscriberId = currentNSSI["globalSubscriberId"]
-        String serviceType = execution.getVariable("serviceType")
+        String serviceType = currentNSSI['serviceType']
 
         try
         {
             LOGGER.debug("delete nssiServiceInstanceId:${nssiServiceInstanceId}, profileId:${profileId}")
             AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(
-                AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(nssiServiceInstanceId).sliceProfile(profileId))
+                AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(profileId))
             if (!getAAIClient().exists(resourceUri)) {
                 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service Instance was not found in aai")
             }
@@ -310,4 +328,41 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor
         }
         LOGGER.debug("*****${PREFIX} Exist delSliceProfileFromAAI *****")
     }
+
+    void delSliceProfileFromAAI(DelegateExecution execution){
+
+        LOGGER.debug("*****${PREFIX} start delSliceProfileFromAAI *****")
+        def currentNSSI = execution.getVariable("currentNSSI")
+        String globalSubscriberId = currentNSSI["globalSubscriberId"]
+        String serviceType = currentNSSI['serviceType']
+        String sliceProfileInstId = currentNSSI['profileId']
+
+        try
+        {
+            AAIPluralResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(sliceProfileInstId).sliceProfiles())
+            AAIResultWrapper wrapper = getAAIClient().get(resourceUri, NotFoundException.class)
+            Optional<SliceProfiles> sliceProfilesOpt =wrapper.asBean(SliceProfiles.class)
+            SliceProfiles sliceProfiles
+            String profileId
+            if(sliceProfilesOpt.isPresent()){
+                sliceProfiles = sliceProfilesOpt.get()
+                org.onap.aai.domain.yang.SliceProfile sliceProfile = sliceProfiles.getSliceProfile().get(0)
+                profileId = sliceProfile ? sliceProfile.getProfileId() : ""
+            }
+            if (profileId){
+                AAISimpleUri profileUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(sliceProfileInstId).sliceProfile(profileId))
+                if (!getAAIClient().exists(profileUri)) {
+                    exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service Instance was not found in aai")
+                }
+                getAAIClient().delete(profileUri)
+            }
+
+        }
+        catch (any)
+        {
+            String msg = "delete service profile from aai failed! cause-"+any.getCause()
+            LOGGER.error(any.printStackTrace())
+            exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg);
+        }
+    }
 }
index c817eaa..a715e77 100644 (file)
@@ -25,7 +25,6 @@ import groovy.json.JsonSlurper
 import org.camunda.bpm.engine.delegate.BpmnError
 import org.camunda.bpm.engine.delegate.DelegateExecution
 import org.onap.aai.domain.yang.ServiceInstance
-import org.onap.aaiclient.client.aai.AAIObjectType
 import org.onap.aaiclient.client.aai.AAIResourcesClient
 import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri
 import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory
@@ -81,6 +80,9 @@ class DoDeallocateTnNssi extends AbstractServiceTaskProcessor {
             "modelVersion":""
              }"""
         execution.setVariable("serviceModelInfo", serviceModelInfo)
+
+        tnNssmfUtils.setEnableSdncConfig(execution)
+
         logger.debug("Finish preProcessRequest")
     }
 
@@ -150,18 +152,15 @@ class DoDeallocateTnNssi extends AbstractServiceTaskProcessor {
                                 String status,
                                 String progress,
                                 String statusDescription) {
-        String serviceId = execution.getVariable("sliceServiceInstanceId")
+        String ssInstanceId = execution.getVariable("sliceServiceInstanceId")
+        String modelUuid = execution.getVariable("modelUuid")
         String jobId = execution.getVariable("jobId")
         String nsiId = execution.getVariable("nsiId")
 
-        ResourceOperationStatus roStatus = new ResourceOperationStatus()
-        roStatus.setServiceId(serviceId)
-        roStatus.setOperationId(jobId)
-        roStatus.setResourceTemplateUUID(nsiId)
-        roStatus.setOperType("Deallocate")
-        roStatus.setProgress(progress)
-        roStatus.setStatus(status)
-        roStatus.setStatusDescription(statusDescription)
+        ResourceOperationStatus roStatus = tnNssmfUtils.buildRoStatus(modelUuid, ssInstanceId,
+                jobId, nsiId, "DEALLOCATE", status, progress, statusDescription)
+
+        logger.debug("DoDeallocateTnNssi: roStatus={}", roStatus)
         requestDBUtil.prepareUpdateResourceOperationStatus(execution, roStatus)
     }
 }
index c432122..2889f79 100644 (file)
@@ -19,6 +19,9 @@
  */
 package org.onap.so.bpmn.infrastructure.scripts
 
+import org.onap.aai.domain.yang.SliceProfiles
+import org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri
+
 import static org.apache.commons.lang3.StringUtils.isBlank
 import javax.ws.rs.NotFoundException
 import javax.ws.rs.core.Response
@@ -99,7 +102,7 @@ class DoDeleteSliceService extends AbstractServiceTaskProcessor {
      * save snssai
      * @param execution
      */
-    void queryE2ESliceSeriveFromAAI(DelegateExecution execution)
+    void queryServiceProfileFromAAI(DelegateExecution execution)
     {
         LOGGER.trace(" *****${PREFIX} Start queryE2ESliceSeriveFromAAI *****")
         String serviceInstanceId = execution.getVariable("serviceInstanceId")
@@ -111,11 +114,11 @@ class DoDeleteSliceService extends AbstractServiceTaskProcessor {
         if(si.isPresent())
         {
             String snssai = si.get()?.getEnvironmentContext()
-            ServiceProfiles serviceProfiles = si.get()?.getServiceProfiles()
-            ServiceProfile serviceProfile = serviceProfiles.getServiceProfile().get(0)
-            String serviceProfileId = serviceProfile ? serviceProfile.getProfileId() : ""
             execution.setVariable("snssai", snssai ?: "")
-            execution.setVariable("serviceProfileId",serviceProfileId)
+//            ServiceProfiles serviceProfiles = si.get()?.getServiceProfiles()
+//            ServiceProfile serviceProfile = serviceProfiles.getServiceProfile().get(0)
+//            String serviceProfileId = serviceProfile ? serviceProfile.getProfileId() : ""
+//            execution.setVariable("serviceProfileId", serviceProfileId)
             List<ServiceInstance> sliceProfileList = []
             List<Relationship> relationshipList = si.get().getRelationshipList().getRelationship()
             for (Relationship relationship : relationshipList) {
@@ -127,7 +130,7 @@ class DoDeleteSliceService extends AbstractServiceTaskProcessor {
                     Optional<ServiceInstance> serviceInstance = wrapper1.asBean(ServiceInstance.class)
                     if (serviceInstance.isPresent()) {
                         ServiceInstance instance = serviceInstance.get()
-                        if ("slice-profile-instance".equalsIgnoreCase(instance.getServiceRole())) {
+                        if ("slice-profile".equalsIgnoreCase(instance.getServiceRole())) {
                             sliceProfileList.add(instance)
                         }
                     }
@@ -158,7 +161,7 @@ class DoDeleteSliceService extends AbstractServiceTaskProcessor {
         try
         {
             String errorMsg = "query allotted resource from aai failed."
-            AAIResultWrapper wrapper = queryAAI(execution, Types.ALLOTTED_RESOURCES, serviceInstanceId, errorMsg)
+            AAIResultWrapper wrapper = queryAAI(execution, Types.ALLOTTED_RESOURCE, serviceInstanceId, errorMsg)
             Optional<AllottedResources> ars = wrapper?.asBean(AllottedResources.class)
             if(ars.isPresent() && ars.get().getAllottedResource())
             {
@@ -209,6 +212,7 @@ class DoDeleteSliceService extends AbstractServiceTaskProcessor {
                         String instanceId = relatedLink ? relatedLink.substring(relatedLink.lastIndexOf("/") + 1,relatedLink.length()) : ""
                         AAIResultWrapper wrapper1 = queryAAI(execution, Types.SERVICE_INSTANCE, instanceId, errorMsg)
                         Optional<ServiceInstance> serviceInstance = wrapper1.asBean(ServiceInstance.class)
+                        def nssiId
                         if (serviceInstance.isPresent()) {
                             ServiceInstance instance = serviceInstance.get()
                             if ("nssi".equalsIgnoreCase(instance.getServiceRole())) {
@@ -274,14 +278,39 @@ class DoDeleteSliceService extends AbstractServiceTaskProcessor {
         List<ServiceInstance> nssiInstanceList = execution.getVariable("nssiInstanceList")
         List<ServiceInstance> sliceProfileList = execution.getVariable("sliceProfileList")
         int currentIndex = execution.getVariable("currentNSSIIndex") as int
-        String profileId = ""
+        String profileInstId = ""
         ServiceInstance nssi = nssiInstanceList?.get(currentIndex)
+        List<Relationship> relationshipList = nssi.getRelationshipList()?.getRelationship()
         for(ServiceInstance sliceProfileInstance : sliceProfileList) {
-            if(sliceProfileInstance.getWorkloadContext().equalsIgnoreCase(nssi.getWorkloadContext()))
-            {
-                profileId = sliceProfileInstance.getServiceInstanceId()
+            for (Relationship relationship : relationshipList) {
+                String relatedTo = relationship.getRelatedTo()
+                if (relatedTo == "service-instance"){
+                    String relatedLink = relationship.getRelatedLink()?:""
+                    String instanceId = relatedLink ? relatedLink.substring(relatedLink.lastIndexOf("/") + 1,relatedLink.length()) : ""
+                    if(instanceId.equals(sliceProfileInstance.getServiceInstanceId())){
+                        profileInstId = sliceProfileInstance.getServiceInstanceId()
+                        break
+                    }
+                }
+            }
+            if(profileInstId){
+                break
             }
         }
+
+        //@TODO Temp begin*******************
+//        AAIPluralResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("serviceType")).serviceInstance(profileInstId).sliceProfiles())
+//        AAIResultWrapper wrapper = getAAIClient().get(resourceUri, NotFoundException.class)
+//        Optional<SliceProfiles> sliceProfilesOpt =wrapper.asBean(SliceProfiles.class)
+//        SliceProfiles sliceProfiles
+//        String sliceProfileId
+//        if(sliceProfilesOpt.isPresent()){
+//            sliceProfiles = sliceProfilesOpt.get()
+//            org.onap.aai.domain.yang.SliceProfile sliceProfile = sliceProfiles.getSliceProfile().get(0)
+//            sliceProfileId = sliceProfile ? sliceProfile.getProfileId() : ""
+//        }
+        //@TODO Temp end*******************
+
         def currentNSSI = [:]
         currentNSSI['nssiServiceInstanceId'] = nssi?.getServiceInstanceId()
         currentNSSI['modelInvariantId'] = nssi?.getModelInvariantId()
@@ -289,7 +318,10 @@ class DoDeleteSliceService extends AbstractServiceTaskProcessor {
         currentNSSI['nssiName'] = nssi?.getServiceInstanceName()
         currentNSSI['sST'] = nssi?.getServiceType()
         currentNSSI['PLMNIdList'] = nssi?.getServiceInstanceLocationId()
-        currentNSSI['profileId'] =  profileId
+        //@TODO Temp
+
+        currentNSSI['profileId'] =  profileInstId
+//        currentNSSI['profileId'] =  sliceProfileId
         currentNSSI['snssai'] = execution.getVariable("snssai") ?: ""
         currentNSSI['nsiServiceInstanceId'] = execution.getVariable("nsiId") ?: ""
         currentNSSI['operationId'] = execution.getVariable("operationId") ?: ""
@@ -343,7 +375,7 @@ class DoDeleteSliceService extends AbstractServiceTaskProcessor {
 
         org.onap.aaiclient.client.generated.fluentbuilders.ServiceInstance serviceInstanceType = AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(instanceId)
         def type
-        if (aaiObjectName == Types.ALLOTTED_RESOURCES) {
+        if (aaiObjectName == Types.ALLOTTED_RESOURCE) {
             type = serviceInstanceType.allottedResources()
         } else if (aaiObjectName == Types.SLICE_PROFILES) {
             type = serviceInstanceType.sliceProfiles()
@@ -361,8 +393,10 @@ class DoDeleteSliceService extends AbstractServiceTaskProcessor {
 
     void terminateNSIQuery(DelegateExecution execution)
     {
-        logger.debug("Start terminateNSIQuery")
-        
+        LOGGER.debug("Start terminateNSIQuery")
+
+        return
+        //To test
         String requestId = execution.getVariable("msoRequestId")
         String nxlId = currentNSSI['nsiServiceInstanceId']
         String nxlType = "NSI"
@@ -375,17 +409,17 @@ class DoDeleteSliceService extends AbstractServiceTaskProcessor {
 
         String basicAuthValue = utils.encrypt(basicAuth, msokey)
         if (basicAuthValue != null) {
-            logger.debug( "Obtained BasicAuth username and password for OOF: " + basicAuthValue)
+            LOGGER.debug( "Obtained BasicAuth username and password for OOF: " + basicAuthValue)
             try {
                 authHeader = utils.getBasicAuth(basicAuthValue, msokey)
                 execution.setVariable("BasicAuthHeaderValue", authHeader)
             } catch (Exception ex) {
-                logger.debug( "Unable to encode username and password string: " + ex)
+                LOGGER.debug( "Unable to encode username and password string: " + ex)
                 exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Internal Error - Unable to " +
                         "encode username and password string")
             }
         } else {
-            logger.debug( "Unable to obtain BasicAuth - BasicAuth value null")
+            LOGGER.debug( "Unable to obtain BasicAuth - BasicAuth value null")
             exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Internal Error - BasicAuth " +
                     "value null")
         }
@@ -397,7 +431,7 @@ class DoDeleteSliceService extends AbstractServiceTaskProcessor {
         Response httpResponse = httpClient.post(oofRequest)
 
         int responseCode = httpResponse.getStatus()
-        logger.debug("OOF sync response code is: " + responseCode)
+        LOGGER.debug("OOF sync response code is: " + responseCode)
 
         if(responseCode != 200){
             exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from OOF.")
@@ -407,9 +441,9 @@ class DoDeleteSliceService extends AbstractServiceTaskProcessor {
             boolean terminateResponse = resMap.get("terminateResponse")
             execution.setVariable("terminateNSI", terminateResponse)
         } catch (Exception ex) {
-            logger.debug( "Failed to get terminate Response suggested by OOF.")
+            LOGGER.debug( "Failed to get terminate Response suggested by OOF.")
             exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Failed to get terminate Response suggested by OOF.")
         }
-        logger.debug("Finish terminateNSIQuery")
+        LOGGER.debug("Finish terminateNSIQuery")
     }
 }
index 5cdf540..74c9a49 100644 (file)
 
 package org.onap.so.bpmn.infrastructure.scripts
 
+import com.fasterxml.jackson.databind.ObjectMapper
 import groovy.json.JsonSlurper
 import org.json.JSONObject
 import org.camunda.bpm.engine.delegate.DelegateExecution
+import org.onap.so.beans.nsmf.JobStatusRequest
 import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
 import org.onap.so.bpmn.common.scripts.ExceptionUtil
 import org.onap.so.bpmn.core.json.JsonUtils
@@ -43,16 +45,15 @@ public class QueryJobStatus extends AbstractServiceTaskProcessor{
         try{
             String requestId = execution.getVariable("msoRequestId")
             logger.debug("RequestId :" + requestId)
-            String responseId = execution.getVariable("responseId")
-            String jobId = execution.getVariable("jobId")   
+            String jobId = execution.getVariable("jobId")
             def jsonSlurper = new JsonSlurper()
             
-            HashMap<String,?> esrInfo=jsonSlurper.parseText(execution.getVariable("esrInfo"))
+            HashMap<String,?> esrInfo = jsonSlurper.parseText(execution.getVariable("esrInfo"))
             logger.debug("esrInfo" + esrInfo.toString())
             
-            HashMap<String,?> serviceInfo=jsonSlurper.parseText(execution.getVariable("serviceInfo"))
+            HashMap<String,?> serviceInfo = jsonSlurper.parseText(execution.getVariable("serviceInfo"))
             logger.debug("serviceInfo" + serviceInfo.toString())
-            
+
             execution.setVariable("esrInfo", esrInfo)
             execution.setVariable("serviceInfo", serviceInfo)
             
@@ -60,10 +61,9 @@ public class QueryJobStatus extends AbstractServiceTaskProcessor{
             String endPoint = String.format("/api/rest/provMns/v1/NSS/jobs/%s", jobId)          
             String url = nssmfEndpoint + endPoint 
             execution.setVariable("NSSMF_AdapterEndpoint", url)
-            
+
             String payload = """
                 {
-                  "responseId": "${responseId}",
                   "esrInfo":  ${execution.getVariable("esrInfo") as JSONObject},
                   "serviceInfo": ${execution.getVariable("serviceInfo") as JSONObject}
                 }
index 88db216..deeec94 100644 (file)
@@ -72,7 +72,7 @@ class TnAllocateNssi extends AbstractServiceTaskProcessor {
 
             String additionalPropJsonStr = execution.getVariable("sliceParams")
 
-            String tnNssiId = execution.getVariable("serviceInstanceID")
+            String tnNssiId = jsonUtil.getJsonValue(additionalPropJsonStr, "serviceInstanceID") //for debug
             if (isBlank(tnNssiId)) {
                 tnNssiId = UUID.randomUUID().toString()
             }
index d97f416..009b0a1 100644 (file)
@@ -32,6 +32,7 @@ import org.onap.so.bpmn.core.RollbackData
 import org.onap.so.bpmn.core.UrnPropertiesReader
 import org.onap.so.bpmn.core.WorkflowException
 import org.onap.so.bpmn.core.json.JsonUtils
+import org.onap.so.db.request.beans.ResourceOperationStatus
 import org.slf4j.Logger
 import org.slf4j.LoggerFactory
 
@@ -122,7 +123,7 @@ class TnNssmfUtils {
         }
 
         String sdncRequest =
-        """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.onap/so/request/types/v1"
+                """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.onap/so/request/types/v1"
                                                     xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
                                                     xmlns:sdncadapter="http://org.onap/workflow/sdnc/adapter/schema/v1">
          <sdncadapter:RequestHeader>
@@ -332,4 +333,39 @@ class TnNssmfUtils {
         createRelationShipInAAI(execution, aaiResourceUri, relationship)
 
     }
+
+    ResourceOperationStatus buildRoStatus(String nsstId,
+                                          String nssiId,
+                                          String jobId,
+                                          String nsiId,
+                                          String action,
+                                          String status,
+                                          String progress,
+                                          String statusDescription) {
+        ResourceOperationStatus roStatus = new ResourceOperationStatus()
+        roStatus.setResourceTemplateUUID(nsstId)
+        roStatus.setResourceInstanceID(nssiId)
+        roStatus.setServiceId(nsiId)
+        roStatus.setOperationId(jobId)
+        roStatus.setOperType(action)
+        roStatus.setProgress(progress)
+        roStatus.setStatus(status)
+        roStatus.setStatusDescription(statusDescription)
+
+        return roStatus
+    }
+
+
+    void setEnableSdncConfig(DelegateExecution execution) {
+        String enableSdnc = UrnPropertiesReader.getVariable(
+                "mso.workflow.TnNssmf.enableSDNCNetworkConfig")
+        if (isBlank(enableSdnc)) {
+            logger.debug("mso.workflow.TnNssmf.enableSDNCNetworkConfig is undefined, so use default value (true)")
+            enableSdnc = "true"
+        }
+
+        logger.debug("setEnableSdncConfig: enableSdnc=" + enableSdnc)
+
+        execution.setVariable("enableSdnc", enableSdnc)
+    }
 }
index 8ff1a1e..a12d8fe 100644 (file)
@@ -415,4 +415,4 @@ pnfSwUpgrade.prepareFalloutHandler(execution)</bpmn:script>
       </bpmndi:BPMNShape>
     </bpmndi:BPMNPlane>
   </bpmndi:BPMNDiagram>
-</bpmn:definitions>
+</bpmn:definitions>
\ No newline at end of file
index 4447b32..51448b0 100644 (file)
@@ -36,6 +36,7 @@ runScript.prepareUpdateJobStatus(execution,"finished","100","Activate or Deactiv
     <bpmn:sequenceFlow id="SequenceFlow_1qv8qw1" sourceRef="ScriptTask_1ssh2l9" targetRef="Activity_0nhxd67" />
     <bpmn:scriptTask id="ScriptTask_19uxoi8" name="Update AAI Status" scriptFormat="groovy">
       <bpmn:incoming>SequenceFlow_1jdb2oq</bpmn:incoming>
+      <bpmn:incoming>Flow_0b2uim4</bpmn:incoming>
       <bpmn:outgoing>SequenceFlow_0kixzdj</bpmn:outgoing>
       <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.*
 def actionType = execution.getVariable("actionType")
@@ -45,7 +46,7 @@ runScript.updateAAIOrchStatus(execution)</bpmn:script>
     </bpmn:scriptTask>
     <bpmn:sequenceFlow id="SequenceFlow_0kixzdj" sourceRef="ScriptTask_19uxoi8" targetRef="ScriptTask_1ssh2l9" />
     <bpmn:scriptTask id="Activity_1tw8eyy" name="PreProcess SDNC Activate or Deactivate TN NSSI Request" scriptFormat="groovy">
-      <bpmn:incoming>SequenceFlow_07e12rt</bpmn:incoming>
+      <bpmn:incoming>Flow_0046aj5</bpmn:incoming>
       <bpmn:outgoing>Flow_0cpctye</bpmn:outgoing>
       <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.*
 def runScript = new DoActivateTnNssi()
@@ -84,7 +85,7 @@ runScript.validateSDNCResponse(execution, response)</bpmn:script>
 def runScript = new DoActivateTnNssi()
 runScript.preProcessRequest(execution)</bpmn:script>
     </bpmn:scriptTask>
-    <bpmn:sequenceFlow id="SequenceFlow_07e12rt" sourceRef="ScriptTask_1tc44ge" targetRef="Activity_1tw8eyy" />
+    <bpmn:sequenceFlow id="SequenceFlow_07e12rt" sourceRef="ScriptTask_1tc44ge" targetRef="Gateway_1v41rsb" />
     <bpmn:serviceTask id="Activity_0nhxd67" name="Update Resource Operation Status">
       <bpmn:extensionElements>
         <camunda:connector>
@@ -108,46 +109,69 @@ runScript.preProcessRequest(execution)</bpmn:script>
       <bpmn:outgoing>Flow_1032bi1</bpmn:outgoing>
     </bpmn:serviceTask>
     <bpmn:sequenceFlow id="Flow_1032bi1" sourceRef="Activity_0nhxd67" targetRef="EndEvent_05h01gx" />
+    <bpmn:exclusiveGateway id="Gateway_1v41rsb" name="Enable SDNC?">
+      <bpmn:incoming>SequenceFlow_07e12rt</bpmn:incoming>
+      <bpmn:outgoing>Flow_0046aj5</bpmn:outgoing>
+      <bpmn:outgoing>Flow_0b2uim4</bpmn:outgoing>
+    </bpmn:exclusiveGateway>
+    <bpmn:sequenceFlow id="Flow_0046aj5" name="Yes" sourceRef="Gateway_1v41rsb" targetRef="Activity_1tw8eyy">
+      <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("enableSdnc" )  == true)}</bpmn:conditionExpression>
+    </bpmn:sequenceFlow>
+    <bpmn:sequenceFlow id="Flow_0b2uim4" name="No" sourceRef="Gateway_1v41rsb" targetRef="ScriptTask_19uxoi8" />
   </bpmn:process>
   <bpmn:message id="Message_0c4b2r5" name="SliceServiceTask" />
   <bpmn:error id="Error_03akl5v" name="MSOWorkflowException" errorCode="MSOWorkflowException" />
   <bpmn:error id="Error_0p2naox" name="MSOWorkflowException" errorCode="MSOWorkflowException" />
   <bpmndi:BPMNDiagram id="BPMNDiagram_1">
     <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DoActivateTransportNSSI">
+      <bpmndi:BPMNEdge id="Flow_1032bi1_di" bpmnElement="Flow_1032bi1">
+        <di:waypoint x="1040" y="380" />
+        <di:waypoint x="1192" y="380" />
+      </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="SequenceFlow_07e12rt_di" bpmnElement="SequenceFlow_07e12rt">
         <di:waypoint x="385" y="121" />
-        <di:waypoint x="509" y="121" />
+        <di:waypoint x="465" y="121" />
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="Flow_1jdb2oq_di" bpmnElement="SequenceFlow_1jdb2oq">
-        <di:waypoint x="1080" y="121" />
-        <di:waypoint x="1220" y="121" />
-        <di:waypoint x="1220" y="210" />
-        <di:waypoint x="335" y="210" />
-        <di:waypoint x="335" y="310" />
+        <di:waypoint x="1210" y="121" />
+        <di:waypoint x="1310" y="121" />
+        <di:waypoint x="1310" y="260" />
+        <di:waypoint x="490" y="260" />
+        <di:waypoint x="490" y="340" />
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="Flow_0fuabjs_di" bpmnElement="Flow_0fuabjs">
-        <di:waypoint x="850" y="121" />
-        <di:waypoint x="959" y="121" />
+        <di:waypoint x="990" y="121" />
+        <di:waypoint x="1089" y="121" />
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="Flow_0cpctye_di" bpmnElement="Flow_0cpctye">
-        <di:waypoint x="630" y="121" />
-        <di:waypoint x="729" y="121" />
+        <di:waypoint x="730" y="121" />
+        <di:waypoint x="869" y="121" />
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="SequenceFlow_0kixzdj_di" bpmnElement="SequenceFlow_0kixzdj">
-        <di:waypoint x="385" y="350" />
-        <di:waypoint x="530" y="350" />
+        <di:waypoint x="540" y="380" />
+        <di:waypoint x="685" y="380" />
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="SequenceFlow_1qv8qw1_di" bpmnElement="SequenceFlow_1qv8qw1">
-        <di:waypoint x="630" y="350" />
-        <di:waypoint x="740" y="350" />
+        <di:waypoint x="785" y="380" />
+        <di:waypoint x="940" y="380" />
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="SequenceFlow_03s744c_di" bpmnElement="SequenceFlow_03s744c">
         <di:waypoint x="214" y="121" />
         <di:waypoint x="285" y="121" />
       </bpmndi:BPMNEdge>
-      <bpmndi:BPMNEdge id="Flow_1032bi1_di" bpmnElement="Flow_1032bi1">
-        <di:waypoint x="840" y="350" />
-        <di:waypoint x="1002" y="350" />
+      <bpmndi:BPMNEdge id="Flow_0046aj5_di" bpmnElement="Flow_0046aj5">
+        <di:waypoint x="515" y="121" />
+        <di:waypoint x="609" y="121" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="553" y="103" width="19" height="14" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNEdge id="Flow_0b2uim4_di" bpmnElement="Flow_0b2uim4">
+        <di:waypoint x="490" y="146" />
+        <di:waypoint x="490" y="340" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="498" y="166" width="14" height="14" />
+        </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNShape id="StartEvent_1nbljfd_di" bpmnElement="StartEvent_1nbljfd">
         <dc:Bounds x="178" y="103" width="36" height="36" />
@@ -155,8 +179,35 @@ runScript.preProcessRequest(execution)</bpmn:script>
           <dc:Bounds x="163" y="146" width="81" height="53" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape id="EndEvent_05h01gx_di" bpmnElement="EndEvent_05h01gx">
+        <dc:Bounds x="1192" y="362" width="36" height="36" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="1200" y="405" width="20" height="14" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="Activity_0nhxd67_di" bpmnElement="Activity_0nhxd67">
-        <dc:Bounds x="740" y="310" width="100" height="80" />
+        <dc:Bounds x="940" y="340" width="100" height="80" />
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape id="ScriptTask_1ssh2l9_di" bpmnElement="ScriptTask_1ssh2l9">
+        <dc:Bounds x="685" y="340" width="100" height="80" />
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape id="Activity_0phv8e5_di" bpmnElement="Activity_0phv8e5">
+        <dc:Bounds x="1089" y="74" width="121" height="94" />
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape id="Activity_0p20esb_di" bpmnElement="Activity_0p20esb">
+        <dc:Bounds x="869" y="74" width="121" height="94" />
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape id="Activity_1tw8eyy_di" bpmnElement="Activity_1tw8eyy">
+        <dc:Bounds x="609" y="74" width="121" height="94" />
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape id="Gateway_1v41rsb_di" bpmnElement="Gateway_1v41rsb" isMarkerVisible="true">
+        <dc:Bounds x="465" y="96" width="50" height="50" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="453" y="73" width="75" height="14" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape id="ScriptTask_19uxoi8_di" bpmnElement="ScriptTask_19uxoi8">
+        <dc:Bounds x="440" y="340" width="100" height="80" />
       </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="SubProcess_1yv9i68_di" bpmnElement="SubProcess_1yv9i68" isExpanded="true">
         <dc:Bounds x="685" y="1080" width="781" height="196" />
@@ -178,27 +229,6 @@ runScript.preProcessRequest(execution)</bpmn:script>
       <bpmndi:BPMNShape id="ScriptTask_1swzdpw_di" bpmnElement="ScriptTask_1swzdpw">
         <dc:Bounds x="979" y="1144" width="100" height="80" />
       </bpmndi:BPMNShape>
-      <bpmndi:BPMNShape id="EndEvent_05h01gx_di" bpmnElement="EndEvent_05h01gx">
-        <dc:Bounds x="1002" y="332" width="36" height="36" />
-        <bpmndi:BPMNLabel>
-          <dc:Bounds x="1010" y="375" width="20" height="14" />
-        </bpmndi:BPMNLabel>
-      </bpmndi:BPMNShape>
-      <bpmndi:BPMNShape id="ScriptTask_1ssh2l9_di" bpmnElement="ScriptTask_1ssh2l9">
-        <dc:Bounds x="530" y="310" width="100" height="80" />
-      </bpmndi:BPMNShape>
-      <bpmndi:BPMNShape id="ScriptTask_19uxoi8_di" bpmnElement="ScriptTask_19uxoi8">
-        <dc:Bounds x="285" y="310" width="100" height="80" />
-      </bpmndi:BPMNShape>
-      <bpmndi:BPMNShape id="Activity_1tw8eyy_di" bpmnElement="Activity_1tw8eyy">
-        <dc:Bounds x="509" y="74" width="121" height="94" />
-      </bpmndi:BPMNShape>
-      <bpmndi:BPMNShape id="Activity_0p20esb_di" bpmnElement="Activity_0p20esb">
-        <dc:Bounds x="729" y="74" width="121" height="94" />
-      </bpmndi:BPMNShape>
-      <bpmndi:BPMNShape id="Activity_0phv8e5_di" bpmnElement="Activity_0phv8e5">
-        <dc:Bounds x="959" y="74" width="121" height="94" />
-      </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="ScriptTask_1tc44ge_di" bpmnElement="ScriptTask_1tc44ge">
         <dc:Bounds x="285" y="81" width="100" height="80" />
       </bpmndi:BPMNShape>
index 9c12200..9b44901 100644 (file)
@@ -193,7 +193,7 @@ nss.prepareDecomposeService(execution)</bpmn:script>
         <camunda:in source="esrInfo" target="esrInfo" />
         <camunda:in source="serviceInfo" target="serviceInfo" />
         <camunda:in source="TNFH_jobId" target="jobId" />
-        <camunda:out source="jobResponse" target="TNFH_jobResponse" />
+        <camunda:out source="responseDescriptor" target="TNFH_jobResponse" />
         <camunda:in source="responseId" target="responseId" />
         <camunda:in source="job_timeout" target="timeout" />
       </bpmn:extensionElements>
@@ -206,7 +206,7 @@ nss.prepareDecomposeService(execution)</bpmn:script>
         <camunda:in source="esrInfo" target="esrInfo" />
         <camunda:in source="serviceInfo" target="serviceInfo" />
         <camunda:in source="TNMH_jobId" target="jobId" />
-        <camunda:out source="jobResponse" target="TNMH_jobResponse" />
+        <camunda:out source="responseDescriptor" target="TNMH_jobResponse" />
         <camunda:in source="responseId" target="responseId" />
         <camunda:in source="job_timeout" target="timeout" />
       </bpmn:extensionElements>
@@ -318,7 +318,7 @@ nss.prepareModifyAccessNssiInputs(execution)</bpmn:script>
         <camunda:in source="esrInfo" target="esrInfo" />
         <camunda:in source="serviceInfo" target="serviceInfo" />
         <camunda:in source="modifyRanNssiJobId" target="jobId" />
-        <camunda:out source="jobResponse" target="jobResponse" />
+        <camunda:out source="responseDescriptor" target="jobResponse" />
         <camunda:in source="responseId" target="responseId" />
         <camunda:in source="job_timeout" target="timeout" />
       </bpmn:extensionElements>
@@ -435,7 +435,7 @@ nss.updateAaiWithRANInstances(execution)</bpmn:script>
     <bpmn:sequenceFlow id="Flow_1exjm0h" sourceRef="Activity_0pa8al6" targetRef="Event_15zn4zi" />
     <bpmn:sequenceFlow id="Flow_0bd6dhi" sourceRef="Activity_0zn4e4n" targetRef="Activity_0vf28ld" />
     <bpmn:sequenceFlow id="Flow_0kcvava" sourceRef="Activity_0vf28ld" targetRef="Event_0u9308h" />
-    <bpmn:scriptTask id="Activity_0vf28ld" name="update AAI relationships">
+    <bpmn:scriptTask id="Activity_0vf28ld" name="update AAI relationships" scriptFormat="groovy">
       <bpmn:incoming>Flow_0bd6dhi</bpmn:incoming>
       <bpmn:outgoing>Flow_0kcvava</bpmn:outgoing>
       <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.*
index 4f83c87..f3bd700 100644 (file)
@@ -164,7 +164,7 @@ css.prepareOofSelection(execution)</bpmn:script>
       <bpmn:incoming>SequenceFlow_0n4xku8</bpmn:incoming>
       <bpmn:outgoing>SequenceFlow_0kixzdj</bpmn:outgoing>
       <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.*
-execution.setVariable("orchestrationStatus", "activated")
+execution.setVariable("orchestrationStatus", "deactivated")
 def runScript = new TnAllocateNssi()
 runScript.updateAAIOrchStatus(execution)</bpmn:script>
     </bpmn:scriptTask>
index fefa022..1f29f81 100644 (file)
@@ -29,7 +29,7 @@ dcsi.createServiceInstance(execution)</bpmn:script>
 def dcsi = new DoCreateTnNssiInstance()
 dcsi.createAllottedResource(execution)</bpmn:script>
     </bpmn:scriptTask>
-    <bpmn:sequenceFlow id="SequenceFlow_17u69c4" sourceRef="ScriptTask_18rzwzb" targetRef="Event_1a9swwa" />
+    <bpmn:sequenceFlow id="SequenceFlow_17u69c4" sourceRef="ScriptTask_18rzwzb" targetRef="Gateway_1cehbyc" />
     <bpmn:intermediateCatchEvent id="Event_0l9vk9p" name="Start SDNC Operation">
       <bpmn:outgoing>Flow_1c8zr59</bpmn:outgoing>
       <bpmn:linkEventDefinition id="LinkEventDefinition_0uwmpn2" name="SdncOperation" />
@@ -67,13 +67,23 @@ dcsi.validateSDNCResponse(execution, response, "allocate")</bpmn:script>
     <bpmn:sequenceFlow id="Flow_1c8zr59" name="" sourceRef="Event_0l9vk9p" targetRef="Activity_0eh82ds" />
     <bpmn:sequenceFlow id="Flow_0pko5tm" name="" sourceRef="Activity_0eh82ds" targetRef="Activity_1fs2182" />
     <bpmn:sequenceFlow id="Flow_11kadz7" name="" sourceRef="Activity_1fs2182" targetRef="Activity_16luyg1" />
-    <bpmn:endEvent id="Event_1rsf7yb">
+    <bpmn:endEvent id="Event_1rsf7yb" name="No">
       <bpmn:incoming>SequenceFlow_1uiz85h</bpmn:incoming>
+      <bpmn:incoming>Flow_07tmxxo</bpmn:incoming>
     </bpmn:endEvent>
     <bpmn:intermediateThrowEvent id="Event_1a9swwa" name="Goto SDNC operation">
-      <bpmn:incoming>SequenceFlow_17u69c4</bpmn:incoming>
+      <bpmn:incoming>Flow_0dp5afv</bpmn:incoming>
       <bpmn:linkEventDefinition id="LinkEventDefinition_1skl6p7" name="SdncOperation" />
     </bpmn:intermediateThrowEvent>
+    <bpmn:exclusiveGateway id="Gateway_1cehbyc" name="Enable SDNC?">
+      <bpmn:incoming>SequenceFlow_17u69c4</bpmn:incoming>
+      <bpmn:outgoing>Flow_0dp5afv</bpmn:outgoing>
+      <bpmn:outgoing>Flow_07tmxxo</bpmn:outgoing>
+    </bpmn:exclusiveGateway>
+    <bpmn:sequenceFlow id="Flow_0dp5afv" name="Yes" sourceRef="Gateway_1cehbyc" targetRef="Event_1a9swwa">
+      <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("enableSdnc" )  == true)}</bpmn:conditionExpression>
+    </bpmn:sequenceFlow>
+    <bpmn:sequenceFlow id="Flow_07tmxxo" name="No" sourceRef="Gateway_1cehbyc" targetRef="Event_1rsf7yb" />
   </bpmn:process>
   <bpmndi:BPMNDiagram id="BPMNDiagram_1">
     <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DoCreateTnNssiInstance">
@@ -91,7 +101,7 @@ dcsi.validateSDNCResponse(execution, response, "allocate")</bpmn:script>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="SequenceFlow_17u69c4_di" bpmnElement="SequenceFlow_17u69c4">
         <di:waypoint x="830" y="129" />
-        <di:waypoint x="982" y="129" />
+        <di:waypoint x="895" y="129" />
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="SequenceFlow_0g5bwvl_di" bpmnElement="SequenceFlow_0g5bwvl">
         <di:waypoint x="600" y="129" />
@@ -118,12 +128,36 @@ dcsi.validateSDNCResponse(execution, response, "allocate")</bpmn:script>
           <dc:Bounds x="266" y="123" width="0" height="12" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
+      <bpmndi:BPMNEdge id="Flow_0dp5afv_di" bpmnElement="Flow_0dp5afv">
+        <di:waypoint x="945" y="129" />
+        <di:waypoint x="1072" y="129" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="1000" y="113" width="19" height="14" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNEdge id="Flow_07tmxxo_di" bpmnElement="Flow_07tmxxo">
+        <di:waypoint x="920" y="154" />
+        <di:waypoint x="920" y="375" />
+        <di:waypoint x="972" y="375" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="929" y="262" width="14" height="14" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNEdge>
       <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="allocateTnNssi_StartEvent">
         <dc:Bounds x="175" y="111" width="36" height="36" />
         <bpmndi:BPMNLabel>
           <dc:Bounds x="153" y="147" width="86" height="27" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape id="ScriptTask_03j6ogo_di" bpmnElement="PreprocessIncomingRequest_task">
+        <dc:Bounds x="310" y="89" width="100" height="80" />
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape id="ScriptTask_1qmmew8_di" bpmnElement="instantiate_NSTask">
+        <dc:Bounds x="500" y="89" width="100" height="80" />
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape id="ScriptTask_18rzwzb_di" bpmnElement="ScriptTask_18rzwzb">
+        <dc:Bounds x="730" y="89" width="100" height="80" />
+      </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="Event_0l9vk9p_di" bpmnElement="Event_0l9vk9p">
         <dc:Bounds x="175" y="357" width="36" height="36" />
         <bpmndi:BPMNLabel>
@@ -141,21 +175,21 @@ dcsi.validateSDNCResponse(execution, response, "allocate")</bpmn:script>
       </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="Event_1rsf7yb_di" bpmnElement="Event_1rsf7yb">
         <dc:Bounds x="972" y="357" width="36" height="36" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="983" y="400" width="14" height="14" />
+        </bpmndi:BPMNLabel>
       </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="Event_1a9swwa_di" bpmnElement="Event_1a9swwa">
-        <dc:Bounds x="982" y="111" width="36" height="36" />
+        <dc:Bounds x="1072" y="111" width="36" height="36" />
         <bpmndi:BPMNLabel>
-          <dc:Bounds x="973" y="154" width="59" height="27" />
+          <dc:Bounds x="1063" y="154" width="59" height="27" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNShape>
-      <bpmndi:BPMNShape id="ScriptTask_18rzwzb_di" bpmnElement="ScriptTask_18rzwzb">
-        <dc:Bounds x="730" y="89" width="100" height="80" />
-      </bpmndi:BPMNShape>
-      <bpmndi:BPMNShape id="ScriptTask_1qmmew8_di" bpmnElement="instantiate_NSTask">
-        <dc:Bounds x="500" y="89" width="100" height="80" />
-      </bpmndi:BPMNShape>
-      <bpmndi:BPMNShape id="ScriptTask_03j6ogo_di" bpmnElement="PreprocessIncomingRequest_task">
-        <dc:Bounds x="310" y="89" width="100" height="80" />
+      <bpmndi:BPMNShape id="Gateway_1cehbyc_di" bpmnElement="Gateway_1cehbyc" isMarkerVisible="true">
+        <dc:Bounds x="895" y="104" width="50" height="50" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="884" y="74" width="75" height="14" />
+        </bpmndi:BPMNLabel>
       </bpmndi:BPMNShape>
     </bpmndi:BPMNPlane>
   </bpmndi:BPMNDiagram>
index a745f7c..85533e7 100644 (file)
@@ -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:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_0884541" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.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:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_0884541" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.4.1">
   <bpmn:process id="DoDeallocateNSSIV1" name="DoDeallocateNSSIV1" isExecutable="true">
     <bpmn:startEvent id="StartEvent_1" name="start">
       <bpmn:outgoing>SequenceFlow_05jfhy6</bpmn:outgoing>
@@ -33,7 +33,7 @@ def dnssi= new DoDeallocateNSSI()
 dnssi.processDecomposition(execution)</bpmn:script>
     </bpmn:scriptTask>
     <bpmn:sequenceFlow id="SequenceFlow_1e7o57n" sourceRef="Task_15ut397" targetRef="Task_0vi4ijv" />
-    <bpmn:scriptTask id="Task_0vi4ijv" name="Send deallocate request to NSSMF" scriptFormat="groovy">
+    <bpmn:scriptTask id="Task_0vi4ijv" name="Send request to NSSMF" scriptFormat="groovy">
       <bpmn:incoming>SequenceFlow_1e7o57n</bpmn:incoming>
       <bpmn:outgoing>SequenceFlow_1wj89r5</bpmn:outgoing>
       <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.*
@@ -53,9 +53,9 @@ def dnssi= new DoDeallocateNSSI()
 dnssi.delSliceProfileFromAAI(execution)</bpmn:script>
     </bpmn:scriptTask>
     <bpmn:endEvent id="EndEvent_1f579t4" name="end">
-      <bpmn:incoming>SequenceFlow_1ii5002</bpmn:incoming>
+      <bpmn:incoming>SequenceFlow_0hyn6ca</bpmn:incoming>
     </bpmn:endEvent>
-    <bpmn:sequenceFlow id="SequenceFlow_1ii5002" sourceRef="Task_13vaezk" targetRef="EndEvent_1f579t4" />
+    <bpmn:sequenceFlow id="SequenceFlow_1ii5002" sourceRef="Task_13vaezk" targetRef="Task_0ocemjg" />
     <bpmn:sequenceFlow id="SequenceFlow_0xq380j" name="yes" sourceRef="ExclusiveGateway_0nhfsui" targetRef="Task_13vaezk">
       <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("isNSSIDeAllocated" )  == true)}</bpmn:conditionExpression>
     </bpmn:sequenceFlow>
@@ -102,7 +102,6 @@ dnssi.prepareUpdateOperationStatus(execution)</bpmn:script>
         <camunda:in source="esrInfo" target="esrInfo" />
         <camunda:in source="serviceInfo" target="serviceInfo" />
         <camunda:in source="jobId" target="jobId" />
-        <camunda:in source="responseId" target="responseId" />
         <camunda:out source="responseDescriptor" target="responseDescriptor" />
       </bpmn:extensionElements>
       <bpmn:incoming>SequenceFlow_0w01l14</bpmn:incoming>
@@ -133,6 +132,14 @@ dnssi.prepareJobStatusRequest(execution)</bpmn:script>
       <bpmn:errorEventDefinition id="ErrorEventDefinition_11pdh1q" errorRef="Error_1o5kb95" />
     </bpmn:endEvent>
     <bpmn:sequenceFlow id="SequenceFlow_1wpbkt9" name="no" sourceRef="ExclusiveGateway_0nhfsui" targetRef="Event_11u9vp2" />
+    <bpmn:sequenceFlow id="SequenceFlow_0hyn6ca" sourceRef="Task_0ocemjg" targetRef="EndEvent_1f579t4" />
+    <bpmn:scriptTask id="Task_0ocemjg" name="Delete Slice Profile Service From AAI" scriptFormat="groovy">
+      <bpmn:incoming>SequenceFlow_1ii5002</bpmn:incoming>
+      <bpmn:outgoing>SequenceFlow_0hyn6ca</bpmn:outgoing>
+      <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.*
+def dnssi= new DoDeallocateNSSI()
+dnssi.delSliceProfileServiceFromAAI(execution)</bpmn:script>
+    </bpmn:scriptTask>
   </bpmn:process>
   <bpmn:error id="Error_1o5kb95" name="MSO Workflow Exception" errorCode="MSOWorkflowException" />
   <bpmndi:BPMNDiagram id="BPMNDiagram_1">
@@ -181,7 +188,7 @@ dnssi.prepareJobStatusRequest(execution)</bpmn:script>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="SequenceFlow_1ii5002_di" bpmnElement="SequenceFlow_1ii5002">
         <di:waypoint x="2040" y="130" />
-        <di:waypoint x="2102" y="130" />
+        <di:waypoint x="2090" y="130" />
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="SequenceFlow_1e7o57n_di" bpmnElement="SequenceFlow_1e7o57n">
         <di:waypoint x="800" y="130" />
@@ -227,9 +234,9 @@ dnssi.prepareJobStatusRequest(execution)</bpmn:script>
         <dc:Bounds x="1940" y="90" width="100" height="80" />
       </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="EndEvent_1f579t4_di" bpmnElement="EndEvent_1f579t4">
-        <dc:Bounds x="2102" y="112" width="36" height="36" />
+        <dc:Bounds x="2272" y="112" width="36" height="36" />
         <bpmndi:BPMNLabel>
-          <dc:Bounds x="2111" y="155" width="19" height="14" />
+          <dc:Bounds x="2281" y="155" width="19" height="14" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="ScriptTask_1dytya8_di" bpmnElement="Task_1vste9s">
@@ -253,6 +260,13 @@ dnssi.prepareJobStatusRequest(execution)</bpmn:script>
       <bpmndi:BPMNShape id="Event_11u9vp2_di" bpmnElement="Event_11u9vp2">
         <dc:Bounds x="1842" y="212" width="36" height="36" />
       </bpmndi:BPMNShape>
+      <bpmndi:BPMNEdge id="SequenceFlow_0hyn6ca_di" bpmnElement="SequenceFlow_0hyn6ca">
+        <di:waypoint x="2190" y="130" />
+        <di:waypoint x="2272" y="130" />
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNShape id="ScriptTask_12dnirp_di" bpmnElement="Task_0ocemjg">
+        <dc:Bounds x="2090" y="90" width="100" height="80" />
+      </bpmndi:BPMNShape>
     </bpmndi:BPMNPlane>
   </bpmndi:BPMNDiagram>
 </bpmn:definitions>
index bd759ca..de83914 100644 (file)
@@ -29,13 +29,13 @@ ex.processJavaException(execution)</bpmn:script>
       <bpmn:incoming>SequenceFlow_1jygjln</bpmn:incoming>
       <bpmn:outgoing>SequenceFlow_1qv8qw1</bpmn:outgoing>
       <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.*
-def runScript = new TnAllocateNssi()
+def runScript = new DoDeallocateTnNssi()
 runScript.prepareUpdateJobStatus(execution,"finished","100","Deallocated TN NSSI successfully")</bpmn:script>
     </bpmn:scriptTask>
     <bpmn:sequenceFlow id="SequenceFlow_03s744c" sourceRef="StartEvent_1nbljfd" targetRef="ScriptTask_1tc44ge" />
     <bpmn:sequenceFlow id="SequenceFlow_1qv8qw1" sourceRef="ScriptTask_1ssh2l9" targetRef="Activity_0rgeefb" />
     <bpmn:scriptTask id="Activity_1tw8eyy" name="PreProcess SDNC Deallocate TN NSSI Request" scriptFormat="groovy">
-      <bpmn:incoming>SequenceFlow_07e12rt</bpmn:incoming>
+      <bpmn:incoming>Flow_0sj0mtu</bpmn:incoming>
       <bpmn:outgoing>Flow_0cpctye</bpmn:outgoing>
       <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.*
 def runScript = new DoDeallocateTnNssi()
@@ -68,6 +68,7 @@ runScript.validateSDNCResponse(execution, response, "deallocate")</bpmn:script>
     </bpmn:scriptTask>
     <bpmn:scriptTask id="Activity_013rjwc" name="Delete Service Instance (TN NSSI) in AAI" scriptFormat="groovy">
       <bpmn:incoming>SequenceFlow_1jdb2oq</bpmn:incoming>
+      <bpmn:incoming>Flow_0dirb5b</bpmn:incoming>
       <bpmn:outgoing>SequenceFlow_1jygjln</bpmn:outgoing>
       <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.*
 def runScript = new DoDeallocateTnNssi()
@@ -81,7 +82,7 @@ runScript.deleteServiceInstance(execution)</bpmn:script>
 def runScript = new DoDeallocateTnNssi()
 runScript.preProcessRequest(execution)</bpmn:script>
     </bpmn:scriptTask>
-    <bpmn:sequenceFlow id="SequenceFlow_07e12rt" sourceRef="ScriptTask_1tc44ge" targetRef="Activity_1tw8eyy" />
+    <bpmn:sequenceFlow id="SequenceFlow_07e12rt" sourceRef="ScriptTask_1tc44ge" targetRef="Gateway_1spi9lo" />
     <bpmn:sequenceFlow id="SequenceFlow_1jygjln" sourceRef="Activity_013rjwc" targetRef="ScriptTask_1ssh2l9" />
     <bpmn:serviceTask id="Activity_0rgeefb" name="Update Resource Operation Status">
       <bpmn:extensionElements>
@@ -106,6 +107,15 @@ runScript.preProcessRequest(execution)</bpmn:script>
       <bpmn:outgoing>Flow_0ca4l8d</bpmn:outgoing>
     </bpmn:serviceTask>
     <bpmn:sequenceFlow id="Flow_0ca4l8d" sourceRef="Activity_0rgeefb" targetRef="EndEvent_05h01gx" />
+    <bpmn:exclusiveGateway id="Gateway_1spi9lo" name="Enable SDNC?">
+      <bpmn:incoming>SequenceFlow_07e12rt</bpmn:incoming>
+      <bpmn:outgoing>Flow_0sj0mtu</bpmn:outgoing>
+      <bpmn:outgoing>Flow_0dirb5b</bpmn:outgoing>
+    </bpmn:exclusiveGateway>
+    <bpmn:sequenceFlow id="Flow_0sj0mtu" name="Yes" sourceRef="Gateway_1spi9lo" targetRef="Activity_1tw8eyy">
+      <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("enableSdnc" )  == true)}</bpmn:conditionExpression>
+    </bpmn:sequenceFlow>
+    <bpmn:sequenceFlow id="Flow_0dirb5b" name="No" sourceRef="Gateway_1spi9lo" targetRef="Activity_013rjwc" />
   </bpmn:process>
   <bpmn:message id="Message_0c4b2r5" name="SliceServiceTask" />
   <bpmn:error id="Error_03akl5v" name="MSOWorkflowException" errorCode="MSOWorkflowException" />
@@ -113,40 +123,54 @@ runScript.preProcessRequest(execution)</bpmn:script>
   <bpmndi:BPMNDiagram id="BPMNDiagram_1">
     <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DoDeallocateTransportNSSI">
       <bpmndi:BPMNEdge id="Flow_0ca4l8d_di" bpmnElement="Flow_0ca4l8d">
-        <di:waypoint x="840" y="350" />
-        <di:waypoint x="1022" y="350" />
+        <di:waypoint x="1030" y="410" />
+        <di:waypoint x="1152" y="410" />
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="Flow_1jygjln_di" bpmnElement="SequenceFlow_1jygjln">
-        <di:waypoint x="360" y="350" />
-        <di:waypoint x="520" y="350" />
+        <di:waypoint x="530" y="410" />
+        <di:waypoint x="660" y="410" />
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="SequenceFlow_07e12rt_di" bpmnElement="SequenceFlow_07e12rt">
         <di:waypoint x="385" y="121" />
-        <di:waypoint x="509" y="121" />
+        <di:waypoint x="455" y="121" />
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="Flow_1jdb2oq_di" bpmnElement="SequenceFlow_1jdb2oq">
-        <di:waypoint x="1080" y="121" />
+        <di:waypoint x="1130" y="121" />
         <di:waypoint x="1220" y="121" />
-        <di:waypoint x="1220" y="230" />
-        <di:waypoint x="310" y="230" />
-        <di:waypoint x="310" y="310" />
+        <di:waypoint x="1220" y="260" />
+        <di:waypoint x="480" y="260" />
+        <di:waypoint x="480" y="370" />
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="Flow_0fuabjs_di" bpmnElement="Flow_0fuabjs">
-        <di:waypoint x="850" y="121" />
-        <di:waypoint x="959" y="121" />
+        <di:waypoint x="910" y="121" />
+        <di:waypoint x="1009" y="121" />
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="Flow_0cpctye_di" bpmnElement="Flow_0cpctye">
-        <di:waypoint x="630" y="121" />
-        <di:waypoint x="729" y="121" />
+        <di:waypoint x="690" y="121" />
+        <di:waypoint x="789" y="121" />
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="SequenceFlow_1qv8qw1_di" bpmnElement="SequenceFlow_1qv8qw1">
-        <di:waypoint x="620" y="350" />
-        <di:waypoint x="740" y="350" />
+        <di:waypoint x="760" y="410" />
+        <di:waypoint x="930" y="410" />
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="SequenceFlow_03s744c_di" bpmnElement="SequenceFlow_03s744c">
         <di:waypoint x="214" y="121" />
         <di:waypoint x="285" y="121" />
       </bpmndi:BPMNEdge>
+      <bpmndi:BPMNEdge id="Flow_0sj0mtu_di" bpmnElement="Flow_0sj0mtu">
+        <di:waypoint x="505" y="121" />
+        <di:waypoint x="569" y="121" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="529" y="103" width="19" height="14" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNEdge id="Flow_0dirb5b_di" bpmnElement="Flow_0dirb5b">
+        <di:waypoint x="480" y="146" />
+        <di:waypoint x="480" y="370" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="483" y="166" width="14" height="14" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNEdge>
       <bpmndi:BPMNShape id="StartEvent_1nbljfd_di" bpmnElement="StartEvent_1nbljfd">
         <dc:Bounds x="178" y="103" width="36" height="36" />
         <bpmndi:BPMNLabel>
@@ -154,17 +178,35 @@ runScript.preProcessRequest(execution)</bpmn:script>
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="ScriptTask_1ssh2l9_di" bpmnElement="ScriptTask_1ssh2l9">
-        <dc:Bounds x="520" y="310" width="100" height="80" />
+        <dc:Bounds x="660" y="370" width="100" height="80" />
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape id="Activity_013rjwc_di" bpmnElement="Activity_013rjwc">
+        <dc:Bounds x="430" y="370" width="100" height="80" />
       </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="Activity_0rgeefb_di" bpmnElement="Activity_0rgeefb">
-        <dc:Bounds x="740" y="310" width="100" height="80" />
+        <dc:Bounds x="930" y="370" width="100" height="80" />
       </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="EndEvent_05h01gx_di" bpmnElement="EndEvent_05h01gx">
-        <dc:Bounds x="1022" y="332" width="36" height="36" />
+        <dc:Bounds x="1152" y="392" width="36" height="36" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="1160" y="435" width="20" height="14" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape id="Activity_1tw8eyy_di" bpmnElement="Activity_1tw8eyy">
+        <dc:Bounds x="569" y="74" width="121" height="94" />
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape id="Gateway_1spi9lo_di" bpmnElement="Gateway_1spi9lo" isMarkerVisible="true">
+        <dc:Bounds x="455" y="96" width="50" height="50" />
         <bpmndi:BPMNLabel>
-          <dc:Bounds x="1030" y="375" width="20" height="14" />
+          <dc:Bounds x="443" y="73" width="75" height="14" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape id="Activity_0p20esb_di" bpmnElement="Activity_0p20esb">
+        <dc:Bounds x="789" y="74" width="121" height="94" />
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape id="Activity_0phv8e5_di" bpmnElement="Activity_0phv8e5">
+        <dc:Bounds x="1009" y="74" width="121" height="94" />
+      </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="SubProcess_1yv9i68_di" bpmnElement="SubProcess_1yv9i68" isExpanded="true">
         <dc:Bounds x="685" y="1080" width="781" height="196" />
       </bpmndi:BPMNShape>
@@ -185,18 +227,6 @@ runScript.preProcessRequest(execution)</bpmn:script>
       <bpmndi:BPMNShape id="ScriptTask_1swzdpw_di" bpmnElement="ScriptTask_1swzdpw">
         <dc:Bounds x="979" y="1144" width="100" height="80" />
       </bpmndi:BPMNShape>
-      <bpmndi:BPMNShape id="Activity_1tw8eyy_di" bpmnElement="Activity_1tw8eyy">
-        <dc:Bounds x="509" y="74" width="121" height="94" />
-      </bpmndi:BPMNShape>
-      <bpmndi:BPMNShape id="Activity_0p20esb_di" bpmnElement="Activity_0p20esb">
-        <dc:Bounds x="729" y="74" width="121" height="94" />
-      </bpmndi:BPMNShape>
-      <bpmndi:BPMNShape id="Activity_0phv8e5_di" bpmnElement="Activity_0phv8e5">
-        <dc:Bounds x="959" y="74" width="121" height="94" />
-      </bpmndi:BPMNShape>
-      <bpmndi:BPMNShape id="Activity_013rjwc_di" bpmnElement="Activity_013rjwc">
-        <dc:Bounds x="260" y="310" width="100" height="80" />
-      </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="ScriptTask_1tc44ge_di" bpmnElement="ScriptTask_1tc44ge">
         <dc:Bounds x="285" y="81" width="100" height="80" />
       </bpmndi:BPMNShape>
index 5510dcd..9edb612 100644 (file)
@@ -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:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_1p1suc9" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.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:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_1p1suc9" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.4.1">
   <bpmn:process id="DoDeleteSliceServiceV1" name="DoDeleteSliceServiceV1" isExecutable="true">
     <bpmn:startEvent id="StartEvent_1" name="start">
       <bpmn:outgoing>SequenceFlow_0ep5het</bpmn:outgoing>
@@ -68,14 +68,14 @@ ddss.parseNextNSSI(execution)</bpmn:script>
     </bpmn:scriptTask>
     <bpmn:sequenceFlow id="SequenceFlow_15z9iio" sourceRef="ScriptTask_159855t" targetRef="ExclusiveGateway_1ogbunu" />
     <bpmn:sequenceFlow id="SequenceFlow_029u1wr" sourceRef="Task_13k9usx" targetRef="Task_1ujnqtj" />
-    <bpmn:scriptTask id="Task_13k9usx" name="Query E2ESlice Serive From AAI" scriptFormat="groovy">
+    <bpmn:scriptTask id="Task_13k9usx" name="Query ServiceProfile From AAI" scriptFormat="groovy">
       <bpmn:incoming>SequenceFlow_0npmman</bpmn:incoming>
       <bpmn:outgoing>SequenceFlow_029u1wr</bpmn:outgoing>
       <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.*
 def ddss= new DoDeleteSliceService()
-ddss.queryE2ESliceSeriveFromAAI(execution)</bpmn:script>
+ddss.queryServiceProfileFromAAI(execution)</bpmn:script>
     </bpmn:scriptTask>
-    <bpmn:callActivity id="Task_1rc7mcw" name="Do Deallocate NSSI " calledElement="DoDeallocateNSSIV1">
+    <bpmn:callActivity id="Task_1rc7mcw" name="Do Deallocate NSSI" calledElement="DoDeallocateNSSIV1">
       <bpmn:extensionElements>
         <camunda:in source="currentNSSI" target="currentNSSI" />
         <camunda:in source="msoRequestId" target="msoRequestId" />
@@ -90,7 +90,7 @@ ddss.queryE2ESliceSeriveFromAAI(execution)</bpmn:script>
       <bpmn:incoming>SequenceFlow_1aa2ek0</bpmn:incoming>
       <bpmn:outgoing>SequenceFlow_1252rbf</bpmn:outgoing>
       <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.*
-def dss= new DeleteSliceService()
+def dss= new DoDeleteSliceService()
 dss.terminateNSIQuery(execution)</bpmn:script>
     </bpmn:scriptTask>
     <bpmn:sequenceFlow id="SequenceFlow_17tvomo" sourceRef="Task_1iomfas" targetRef="Task_1rc7mcw" />
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/AaiResourceIdValidator.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/AaiResourceIdValidator.java
new file mode 100644 (file)
index 0000000..6d90070
--- /dev/null
@@ -0,0 +1,220 @@
+package org.onap.so.bpmn.infrastructure.workflow.tasks;
+
+import java.util.Map;
+import java.util.Optional;
+import org.onap.aai.domain.yang.GenericVnf;
+import org.onap.aai.domain.yang.GenericVnfs;
+import org.onap.aai.domain.yang.L3Network;
+import org.onap.aai.domain.yang.ServiceInstance;
+import org.onap.aai.domain.yang.ServiceInstances;
+import org.onap.aai.domain.yang.VolumeGroup;
+import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder;
+import org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds;
+import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils;
+import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.DuplicateNameException;
+import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.MultipleObjectsFoundException;
+import org.onap.so.serviceinstancebeans.RequestDetails;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+
+@Component
+public class AaiResourceIdValidator {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(AaiResourceIdValidator.class);
+
+    private static final String SERVICE_INSTANCE = "serviceInstance";
+    private static final String NAME_EXISTS_WITH_DIFF_VERSION_ID = "(%s) and different version id (%s)";
+    private static final String WORKFLOW_ACTION_WAS_UNABLE_TO_VERIFY_IF_THE_INSTANCE_NAME_ALREADY_EXIST_IN_AAI =
+            "WorkflowAction was unable to verify if the instance name already exist in AAI.";
+    private static final String NAME_EXISTS_MULTIPLE =
+            "(%s) and multiple combination of model-version-id + service-type + global-customer-id";
+    private static final String NAME_EXISTS_WITH_DIFF_COMBINATION =
+            "(%s) and global-customer-id (%s), service-type (%s), model-version-id (%s)";
+    private static final String NAME_EXISTS_WITH_DIFF_CUSTOMIZATION_ID =
+            "(%s), same parent and different customization id (%s)";
+    private static final String NAME_EXISTS_WITH_DIFF_PARENT = "(%s) id (%s) and different parent relationship";
+
+
+    private final BBInputSetupUtils bbInputSetupUtils;
+
+    public AaiResourceIdValidator(BBInputSetupUtils bbInputSetupUtils) {
+        this.bbInputSetupUtils = bbInputSetupUtils;
+    }
+
+    protected String validateResourceIdInAAI(String generatedResourceId, WorkflowType type, String instanceName,
+            RequestDetails reqDetails, WorkflowResourceIds workflowResourceIds) throws Exception {
+        try {
+            if ("SERVICE".equalsIgnoreCase(type.toString())) {
+                return validateServiceResourceIdInAAI(generatedResourceId, instanceName, reqDetails);
+            } else if ("NETWORK".equalsIgnoreCase(type.toString())) {
+                return validateNetworkResourceIdInAAI(generatedResourceId, instanceName, reqDetails,
+                        workflowResourceIds);
+            } else if ("VNF".equalsIgnoreCase(type.toString())) {
+                return validateVnfResourceIdInAAI(generatedResourceId, instanceName, reqDetails, workflowResourceIds);
+            } else if ("VFMODULE".equalsIgnoreCase(type.toString())) {
+                return validateVfModuleResourceIdInAAI(generatedResourceId, instanceName, reqDetails,
+                        workflowResourceIds);
+            } else if ("VOLUMEGROUP".equalsIgnoreCase(type.toString())) {
+                return validateVolumeGroupResourceIdInAAI(generatedResourceId, instanceName, reqDetails,
+                        workflowResourceIds);
+            } else if ("CONFIGURATION".equalsIgnoreCase(type.toString())) {
+                return validateConfigurationResourceIdInAAI(generatedResourceId, instanceName, reqDetails,
+                        workflowResourceIds);
+            }
+            return generatedResourceId;
+        } catch (DuplicateNameException dne) {
+            throw dne;
+        } catch (Exception ex) {
+            LOGGER.error(WORKFLOW_ACTION_WAS_UNABLE_TO_VERIFY_IF_THE_INSTANCE_NAME_ALREADY_EXIST_IN_AAI, ex);
+            throw new IllegalStateException(
+                    WORKFLOW_ACTION_WAS_UNABLE_TO_VERIFY_IF_THE_INSTANCE_NAME_ALREADY_EXIST_IN_AAI);
+        }
+    }
+
+    protected String validateServiceResourceIdInAAI(String generatedResourceId, String instanceName,
+            RequestDetails reqDetails) throws DuplicateNameException {
+        String globalCustomerId = reqDetails.getSubscriberInfo().getGlobalSubscriberId();
+        String serviceType = reqDetails.getRequestParameters().getSubscriptionServiceType();
+        if (instanceName != null) {
+            Optional<ServiceInstance> serviceInstanceAAI =
+                    bbInputSetupUtils.getAAIServiceInstanceByName(globalCustomerId, serviceType, instanceName);
+            if (serviceInstanceAAI.isPresent()) {
+                if (serviceInstanceAAI.get().getModelVersionId()
+                        .equalsIgnoreCase(reqDetails.getModelInfo().getModelVersionId())) {
+                    return serviceInstanceAAI.get().getServiceInstanceId();
+                } else {
+                    throw new DuplicateNameException(SERVICE_INSTANCE, String.format(NAME_EXISTS_WITH_DIFF_VERSION_ID,
+                            instanceName, reqDetails.getModelInfo().getModelVersionId()));
+                }
+            } else {
+                ServiceInstances aaiServiceInstances =
+                        bbInputSetupUtils.getAAIServiceInstancesGloballyByName(instanceName);
+                if (aaiServiceInstances != null) {
+                    if (aaiServiceInstances.getServiceInstance() != null
+                            && !aaiServiceInstances.getServiceInstance().isEmpty()) {
+                        if (aaiServiceInstances.getServiceInstance().size() > 1) {
+                            throw new DuplicateNameException(SERVICE_INSTANCE,
+                                    String.format(NAME_EXISTS_MULTIPLE, instanceName));
+                        } else {
+                            ServiceInstance si = aaiServiceInstances.getServiceInstance().stream().findFirst().get();
+                            Map<String, String> keys =
+                                    bbInputSetupUtils.getURIKeysFromServiceInstance(si.getServiceInstanceId());
+
+                            throw new DuplicateNameException(SERVICE_INSTANCE, String.format(
+                                    NAME_EXISTS_WITH_DIFF_COMBINATION, instanceName,
+                                    keys.get(AAIFluentTypeBuilder.Types.CUSTOMER.getUriParams().globalCustomerId),
+                                    keys.get(
+                                            AAIFluentTypeBuilder.Types.SERVICE_SUBSCRIPTION.getUriParams().serviceType),
+                                    si.getModelVersionId()));
+                        }
+                    }
+                }
+            }
+        }
+        return generatedResourceId;
+    }
+
+    protected String validateNetworkResourceIdInAAI(String generatedResourceId, String instanceName,
+            RequestDetails reqDetails, WorkflowResourceIds workflowResourceIds)
+            throws DuplicateNameException, MultipleObjectsFoundException {
+        Optional<L3Network> network = bbInputSetupUtils
+                .getRelatedNetworkByNameFromServiceInstance(workflowResourceIds.getServiceInstanceId(), instanceName);
+        if (network.isPresent()) {
+            if (network.get().getModelCustomizationId()
+                    .equalsIgnoreCase(reqDetails.getModelInfo().getModelCustomizationId())) {
+                return network.get().getNetworkId();
+            } else {
+                throw new DuplicateNameException("l3Network", String.format(NAME_EXISTS_WITH_DIFF_CUSTOMIZATION_ID,
+                        instanceName, network.get().getModelCustomizationId()));
+            }
+        }
+        if (bbInputSetupUtils.existsAAINetworksGloballyByName(instanceName)) {
+            throw new DuplicateNameException("l3Network", String.format(NAME_EXISTS_WITH_DIFF_PARENT, instanceName,
+                    workflowResourceIds.getServiceInstanceId()));
+        }
+        return generatedResourceId;
+    }
+
+    protected String validateVnfResourceIdInAAI(String generatedResourceId, String instanceName,
+            RequestDetails reqDetails, WorkflowResourceIds workflowResourceIds) throws DuplicateNameException {
+        Optional<GenericVnf> vnf = bbInputSetupUtils
+                .getRelatedVnfByNameFromServiceInstance(workflowResourceIds.getServiceInstanceId(), instanceName);
+        if (vnf.isPresent()) {
+            if (vnf.get().getModelCustomizationId()
+                    .equalsIgnoreCase(reqDetails.getModelInfo().getModelCustomizationId())) {
+                return vnf.get().getVnfId();
+            } else {
+                throw new DuplicateNameException("generic-vnf", String.format(NAME_EXISTS_WITH_DIFF_CUSTOMIZATION_ID,
+                        instanceName, vnf.get().getModelCustomizationId()));
+            }
+        }
+        GenericVnfs vnfs = bbInputSetupUtils.getAAIVnfsGloballyByName(instanceName);
+        if (vnfs != null) {
+            throw new DuplicateNameException("generic-vnf",
+                    String.format(NAME_EXISTS_WITH_DIFF_PARENT, instanceName, vnfs.getGenericVnf().get(0).getVnfId()));
+        }
+        return generatedResourceId;
+    }
+
+    protected String validateVfModuleResourceIdInAAI(String generatedResourceId, String instanceName,
+            RequestDetails reqDetails, WorkflowResourceIds workflowResourceIds) throws DuplicateNameException {
+        GenericVnf vnf = bbInputSetupUtils.getAAIGenericVnf(workflowResourceIds.getVnfId());
+        if (vnf != null && vnf.getVfModules() != null) {
+            for (org.onap.aai.domain.yang.VfModule vfModule : vnf.getVfModules().getVfModule()) {
+                if (vfModule.getVfModuleName().equalsIgnoreCase(instanceName)) {
+                    if (vfModule.getModelCustomizationId()
+                            .equalsIgnoreCase(reqDetails.getModelInfo().getModelCustomizationId())) {
+                        return vfModule.getVfModuleId();
+                    } else {
+                        throw new DuplicateNameException("vfModule",
+                                String.format(NAME_EXISTS_WITH_DIFF_CUSTOMIZATION_ID, instanceName,
+                                        reqDetails.getModelInfo().getModelCustomizationId()));
+                    }
+                }
+            }
+        }
+        if (bbInputSetupUtils.existsAAIVfModuleGloballyByName(instanceName)) {
+            throw new DuplicateNameException("vfModule", instanceName);
+        }
+        return generatedResourceId;
+    }
+
+    protected String validateVolumeGroupResourceIdInAAI(String generatedResourceId, String instanceName,
+            RequestDetails reqDetails, WorkflowResourceIds workflowResourceIds) throws DuplicateNameException {
+        Optional<VolumeGroup> volumeGroup =
+                bbInputSetupUtils.getRelatedVolumeGroupByNameFromVnf(workflowResourceIds.getVnfId(), instanceName);
+        if (volumeGroup.isPresent()) {
+            if (volumeGroup.get().getVfModuleModelCustomizationId()
+                    .equalsIgnoreCase(reqDetails.getModelInfo().getModelCustomizationId())) {
+                return volumeGroup.get().getVolumeGroupId();
+            } else {
+                throw new DuplicateNameException("volumeGroup", volumeGroup.get().getVolumeGroupName());
+            }
+        }
+        if (bbInputSetupUtils.existsAAIVolumeGroupGloballyByName(instanceName)) {
+            throw new DuplicateNameException("volumeGroup", instanceName);
+        }
+        return generatedResourceId;
+    }
+
+    protected String validateConfigurationResourceIdInAAI(String generatedResourceId, String instanceName,
+            RequestDetails reqDetails, WorkflowResourceIds workflowResourceIds) throws DuplicateNameException {
+        Optional<org.onap.aai.domain.yang.Configuration> configuration =
+                bbInputSetupUtils.getRelatedConfigurationByNameFromServiceInstance(
+                        workflowResourceIds.getServiceInstanceId(), instanceName);
+        if (configuration.isPresent()) {
+            if (configuration.get().getModelCustomizationId()
+                    .equalsIgnoreCase(reqDetails.getModelInfo().getModelCustomizationId())) {
+                return configuration.get().getConfigurationId();
+            } else {
+                throw new DuplicateNameException("configuration", String.format(NAME_EXISTS_WITH_DIFF_CUSTOMIZATION_ID,
+                        instanceName, configuration.get().getConfigurationId()));
+            }
+        }
+        if (bbInputSetupUtils.existsAAIConfigurationGloballyByName(instanceName)) {
+            throw new DuplicateNameException("configuration", instanceName);
+        }
+        return generatedResourceId;
+    }
+}
index 79c846b..7821463 100644 (file)
@@ -31,12 +31,8 @@ import com.fasterxml.jackson.databind.ObjectMapper;
 import org.apache.commons.lang3.SerializationUtils;
 import org.camunda.bpm.engine.delegate.DelegateExecution;
 import org.javatuples.Pair;
-import org.onap.aai.domain.yang.GenericVnf;
-import org.onap.aai.domain.yang.GenericVnfs;
-import org.onap.aai.domain.yang.L3Network;
 import org.onap.aai.domain.yang.Relationship;
 import org.onap.aai.domain.yang.ServiceInstance;
-import org.onap.aai.domain.yang.ServiceInstances;
 import org.onap.aai.domain.yang.Vnfc;
 import org.onap.aai.domain.yang.VolumeGroup;
 import org.onap.aai.domain.yang.VpnBinding;
@@ -58,8 +54,6 @@ import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock;
 import org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds;
 import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetup;
 import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils;
-import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.DuplicateNameException;
-import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.MultipleObjectsFoundException;
 import org.onap.so.client.exception.ExceptionBuilder;
 import org.onap.so.client.orchestration.AAIConfigurationResources;
 import org.onap.so.client.orchestration.AAIEntityNotFoundException;
@@ -104,10 +98,7 @@ import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConst
 public class WorkflowAction {
 
     private static final String SERVICE_INSTANCES = "serviceInstances";
-    private static final String SERVICE_INSTANCE = "serviceInstance";
     private static final String VF_MODULES = "vfModules";
-    private static final String WORKFLOW_ACTION_WAS_UNABLE_TO_VERIFY_IF_THE_INSTANCE_NAME_ALREADY_EXIST_IN_AAI =
-            "WorkflowAction was unable to verify if the instance name already exist in AAI.";
     private static final String VNF_TYPE = "vnfType";
     private static final String SERVICE = "Service";
     private static final String VNF = "Vnf";
@@ -127,14 +118,6 @@ public class WorkflowAction {
     private static final String SERVICE_TYPE_BONDING = "BONDING";
     private static final String CLOUD_OWNER = "DEFAULT";
     private static final Logger logger = LoggerFactory.getLogger(WorkflowAction.class);
-    private static final String NAME_EXISTS_WITH_DIFF_VERSION_ID = "(%s) and different version id (%s)";
-    private static final String NAME_EXISTS_MULTIPLE =
-            "(%s) and multiple combination of model-version-id + service-type + global-customer-id";
-    private static final String NAME_EXISTS_WITH_DIFF_COMBINATION =
-            "(%s) and global-customer-id (%s), service-type (%s), model-version-id (%s)";
-    private static final String NAME_EXISTS_WITH_DIFF_CUSTOMIZATION_ID =
-            "(%s), same parent and different customization id (%s)";
-    private static final String NAME_EXISTS_WITH_DIFF_PARENT = "(%s) id (%s) and different parent relationship";
     private static final String CREATENETWORKBB = "CreateNetworkBB";
     private static final String ACTIVATENETWORKBB = "ActivateNetworkBB";
     private static final String VOLUMEGROUP_DELETE_PATTERN = "(Un|De)(.*)Volume(.*)";
@@ -161,6 +144,8 @@ public class WorkflowAction {
     private Environment environment;
     @Autowired
     private UserParamsServiceTraversal userParamsServiceTraversal;
+    @Autowired
+    private AaiResourceIdValidator aaiResourceIdValidator;
 
     public void setBbInputSetupUtils(BBInputSetupUtils bbInputSetupUtils) {
         this.bbInputSetupUtils = bbInputSetupUtils;
@@ -592,30 +577,32 @@ public class WorkflowAction {
             }
             workflowIdsCopy.setConfigurationId(configuration.getConfigurationId());
             for (OrchestrationFlow orchFlow : result) {
-                if (!isReplace) {
-                    dataObj.getResourceKey().setVfModuleCustomizationId(vfModuleCustomizationUUID);
-                    dataObj.getResourceKey().setVnfCustomizationId(vnfCustomizationUUID);
-                } else {
-                    if (orchFlow.getFlowName().contains("Delete")) {
+                if (!isReplace || (isReplace && (orchFlow.getFlowName().contains("Delete")))) {
+                    if (!isReplace) {
                         dataObj.getResourceKey().setVfModuleCustomizationId(vfModuleCustomizationUUID);
                         dataObj.getResourceKey().setVnfCustomizationId(vnfCustomizationUUID);
                     } else {
-                        dataObj.getResourceKey().setVfModuleCustomizationId(replaceVfModuleCustomizationUUID);
-                        dataObj.getResourceKey().setVnfCustomizationId(replaceVnfModuleCustomizationUUID);
+                        if (orchFlow.getFlowName().contains("Delete")) {
+                            dataObj.getResourceKey().setVfModuleCustomizationId(vfModuleCustomizationUUID);
+                            dataObj.getResourceKey().setVnfCustomizationId(vnfCustomizationUUID);
+                        } else {
+                            dataObj.getResourceKey().setVfModuleCustomizationId(replaceVfModuleCustomizationUUID);
+                            dataObj.getResourceKey().setVnfCustomizationId(replaceVnfModuleCustomizationUUID);
+                        }
                     }
+                    dataObj.getResourceKey().setCvnfModuleCustomizationId(vnfc.getModelCustomizationId());
+                    String vnfcName = vnfc.getVnfcName();
+                    if (vnfcName == null || vnfcName.isEmpty()) {
+                        buildAndThrowException(dataObj.getExecution(), "Exception in create execution list "
+                                + ": VnfcName does not exist or is null while there is a configuration for the vfModule",
+                                new Exception("Vnfc and Configuration do not match"));
+                    }
+                    ExecuteBuildingBlock ebb = buildExecuteBuildingBlock(orchFlow, dataObj.getRequestId(),
+                            dataObj.getResourceKey(), dataObj.getApiVersion(), dataObj.getResourceId(),
+                            dataObj.getRequestAction(), dataObj.isaLaCarte(), dataObj.getVnfType(), workflowIdsCopy,
+                            dataObj.getRequestDetails(), false, null, vnfcName, true, null);
+                    flowsToExecuteConfigs.add(ebb);
                 }
-                dataObj.getResourceKey().setCvnfModuleCustomizationId(vnfc.getModelCustomizationId());
-                String vnfcName = vnfc.getVnfcName();
-                if (vnfcName == null || vnfcName.isEmpty()) {
-                    buildAndThrowException(dataObj.getExecution(), "Exception in create execution list "
-                            + ": VnfcName does not exist or is null while there is a configuration for the vfModule",
-                            new Exception("Vnfc and Configuration do not match"));
-                }
-                ExecuteBuildingBlock ebb = buildExecuteBuildingBlock(orchFlow, dataObj.getRequestId(),
-                        dataObj.getResourceKey(), dataObj.getApiVersion(), dataObj.getResourceId(),
-                        dataObj.getRequestAction(), dataObj.isaLaCarte(), dataObj.getVnfType(), workflowIdsCopy,
-                        dataObj.getRequestDetails(), false, null, vnfcName, true, null);
-                flowsToExecuteConfigs.add(ebb);
             }
         }
         return flowsToExecuteConfigs;
@@ -1261,36 +1248,6 @@ public class WorkflowAction {
         }
     }
 
-    protected String validateResourceIdInAAI(String generatedResourceId, WorkflowType type, String instanceName,
-            RequestDetails reqDetails, WorkflowResourceIds workflowResourceIds) throws Exception {
-        try {
-            if ("SERVICE".equalsIgnoreCase(type.toString())) {
-                return validateServiceResourceIdInAAI(generatedResourceId, instanceName, reqDetails);
-            } else if ("NETWORK".equalsIgnoreCase(type.toString())) {
-                return validateNetworkResourceIdInAAI(generatedResourceId, instanceName, reqDetails,
-                        workflowResourceIds);
-            } else if ("VNF".equalsIgnoreCase(type.toString())) {
-                return validateVnfResourceIdInAAI(generatedResourceId, instanceName, reqDetails, workflowResourceIds);
-            } else if ("VFMODULE".equalsIgnoreCase(type.toString())) {
-                return validateVfModuleResourceIdInAAI(generatedResourceId, instanceName, reqDetails,
-                        workflowResourceIds);
-            } else if ("VOLUMEGROUP".equalsIgnoreCase(type.toString())) {
-                return validateVolumeGroupResourceIdInAAI(generatedResourceId, instanceName, reqDetails,
-                        workflowResourceIds);
-            } else if ("CONFIGURATION".equalsIgnoreCase(type.toString())) {
-                return validateConfigurationResourceIdInAAI(generatedResourceId, instanceName, reqDetails,
-                        workflowResourceIds);
-            }
-            return generatedResourceId;
-        } catch (DuplicateNameException dne) {
-            throw dne;
-        } catch (Exception ex) {
-            logger.error(WORKFLOW_ACTION_WAS_UNABLE_TO_VERIFY_IF_THE_INSTANCE_NAME_ALREADY_EXIST_IN_AAI, ex);
-            throw new IllegalStateException(
-                    WORKFLOW_ACTION_WAS_UNABLE_TO_VERIFY_IF_THE_INSTANCE_NAME_ALREADY_EXIST_IN_AAI);
-        }
-    }
-
     protected String convertTypeFromPlural(String type) {
         if (!type.matches(SUPPORTEDTYPES)) {
             return type;
@@ -1581,152 +1538,6 @@ public class WorkflowAction {
                 && (bbInputSetupUtils.getAAIServiceInstanceById(serviceInstanceId) != null));
     }
 
-    protected String validateServiceResourceIdInAAI(String generatedResourceId, String instanceName,
-            RequestDetails reqDetails) throws DuplicateNameException {
-        String globalCustomerId = reqDetails.getSubscriberInfo().getGlobalSubscriberId();
-        String serviceType = reqDetails.getRequestParameters().getSubscriptionServiceType();
-        if (instanceName != null) {
-            Optional<ServiceInstance> serviceInstanceAAI =
-                    bbInputSetupUtils.getAAIServiceInstanceByName(globalCustomerId, serviceType, instanceName);
-            if (serviceInstanceAAI.isPresent()) {
-                if (serviceInstanceAAI.get().getModelVersionId()
-                        .equalsIgnoreCase(reqDetails.getModelInfo().getModelVersionId())) {
-                    return serviceInstanceAAI.get().getServiceInstanceId();
-                } else {
-                    throw new DuplicateNameException(SERVICE_INSTANCE, String.format(NAME_EXISTS_WITH_DIFF_VERSION_ID,
-                            instanceName, reqDetails.getModelInfo().getModelVersionId()));
-                }
-            } else {
-                ServiceInstances aaiServiceInstances =
-                        bbInputSetupUtils.getAAIServiceInstancesGloballyByName(instanceName);
-                if (aaiServiceInstances != null) {
-                    if (aaiServiceInstances.getServiceInstance() != null
-                            && !aaiServiceInstances.getServiceInstance().isEmpty()) {
-                        if (aaiServiceInstances.getServiceInstance().size() > 1) {
-                            throw new DuplicateNameException(SERVICE_INSTANCE,
-                                    String.format(NAME_EXISTS_MULTIPLE, instanceName));
-                        } else {
-                            ServiceInstance si = aaiServiceInstances.getServiceInstance().stream().findFirst().get();
-                            Map<String, String> keys =
-                                    bbInputSetupUtils.getURIKeysFromServiceInstance(si.getServiceInstanceId());
-
-                            throw new DuplicateNameException(SERVICE_INSTANCE, String.format(
-                                    NAME_EXISTS_WITH_DIFF_COMBINATION, instanceName,
-                                    keys.get(AAIFluentTypeBuilder.Types.CUSTOMER.getUriParams().globalCustomerId),
-                                    keys.get(
-                                            AAIFluentTypeBuilder.Types.SERVICE_SUBSCRIPTION.getUriParams().serviceType),
-                                    si.getModelVersionId()));
-                        }
-                    }
-                }
-            }
-        }
-        return generatedResourceId;
-    }
-
-    protected String validateNetworkResourceIdInAAI(String generatedResourceId, String instanceName,
-            RequestDetails reqDetails, WorkflowResourceIds workflowResourceIds)
-            throws DuplicateNameException, MultipleObjectsFoundException {
-        Optional<L3Network> network = bbInputSetupUtils
-                .getRelatedNetworkByNameFromServiceInstance(workflowResourceIds.getServiceInstanceId(), instanceName);
-        if (network.isPresent()) {
-            if (network.get().getModelCustomizationId()
-                    .equalsIgnoreCase(reqDetails.getModelInfo().getModelCustomizationId())) {
-                return network.get().getNetworkId();
-            } else {
-                throw new DuplicateNameException("l3Network", String.format(NAME_EXISTS_WITH_DIFF_CUSTOMIZATION_ID,
-                        instanceName, network.get().getModelCustomizationId()));
-            }
-        }
-        if (bbInputSetupUtils.existsAAINetworksGloballyByName(instanceName)) {
-            throw new DuplicateNameException("l3Network", String.format(NAME_EXISTS_WITH_DIFF_PARENT, instanceName,
-                    workflowResourceIds.getServiceInstanceId()));
-        }
-        return generatedResourceId;
-    }
-
-    protected String validateVnfResourceIdInAAI(String generatedResourceId, String instanceName,
-            RequestDetails reqDetails, WorkflowResourceIds workflowResourceIds) throws DuplicateNameException {
-        Optional<GenericVnf> vnf = bbInputSetupUtils
-                .getRelatedVnfByNameFromServiceInstance(workflowResourceIds.getServiceInstanceId(), instanceName);
-        if (vnf.isPresent()) {
-            if (vnf.get().getModelCustomizationId()
-                    .equalsIgnoreCase(reqDetails.getModelInfo().getModelCustomizationId())) {
-                return vnf.get().getVnfId();
-            } else {
-                throw new DuplicateNameException("generic-vnf", String.format(NAME_EXISTS_WITH_DIFF_CUSTOMIZATION_ID,
-                        instanceName, vnf.get().getModelCustomizationId()));
-            }
-        }
-        GenericVnfs vnfs = bbInputSetupUtils.getAAIVnfsGloballyByName(instanceName);
-        if (vnfs != null) {
-            throw new DuplicateNameException("generic-vnf",
-                    String.format(NAME_EXISTS_WITH_DIFF_PARENT, instanceName, vnfs.getGenericVnf().get(0).getVnfId()));
-        }
-        return generatedResourceId;
-    }
-
-    protected String validateVfModuleResourceIdInAAI(String generatedResourceId, String instanceName,
-            RequestDetails reqDetails, WorkflowResourceIds workflowResourceIds) throws DuplicateNameException {
-        GenericVnf vnf = bbInputSetupUtils.getAAIGenericVnf(workflowResourceIds.getVnfId());
-        if (vnf != null && vnf.getVfModules() != null) {
-            for (org.onap.aai.domain.yang.VfModule vfModule : vnf.getVfModules().getVfModule()) {
-                if (vfModule.getVfModuleName().equalsIgnoreCase(instanceName)) {
-                    if (vfModule.getModelCustomizationId()
-                            .equalsIgnoreCase(reqDetails.getModelInfo().getModelCustomizationId())) {
-                        return vfModule.getVfModuleId();
-                    } else {
-                        throw new DuplicateNameException("vfModule",
-                                String.format(NAME_EXISTS_WITH_DIFF_CUSTOMIZATION_ID, instanceName,
-                                        reqDetails.getModelInfo().getModelCustomizationId()));
-                    }
-                }
-            }
-        }
-        if (bbInputSetupUtils.existsAAIVfModuleGloballyByName(instanceName)) {
-            throw new DuplicateNameException("vfModule", instanceName);
-        }
-        return generatedResourceId;
-    }
-
-    protected String validateVolumeGroupResourceIdInAAI(String generatedResourceId, String instanceName,
-            RequestDetails reqDetails, WorkflowResourceIds workflowResourceIds) throws DuplicateNameException {
-        Optional<VolumeGroup> volumeGroup =
-                bbInputSetupUtils.getRelatedVolumeGroupByNameFromVnf(workflowResourceIds.getVnfId(), instanceName);
-        if (volumeGroup.isPresent()) {
-            if (volumeGroup.get().getVfModuleModelCustomizationId()
-                    .equalsIgnoreCase(reqDetails.getModelInfo().getModelCustomizationId())) {
-                return volumeGroup.get().getVolumeGroupId();
-            } else {
-                throw new DuplicateNameException("volumeGroup", volumeGroup.get().getVolumeGroupName());
-            }
-        }
-        if (bbInputSetupUtils.existsAAIVolumeGroupGloballyByName(instanceName)) {
-            throw new DuplicateNameException("volumeGroup", instanceName);
-        }
-        return generatedResourceId;
-    }
-
-    protected String validateConfigurationResourceIdInAAI(String generatedResourceId, String instanceName,
-            RequestDetails reqDetails, WorkflowResourceIds workflowResourceIds) throws DuplicateNameException {
-        Optional<org.onap.aai.domain.yang.Configuration> configuration =
-                bbInputSetupUtils.getRelatedConfigurationByNameFromServiceInstance(
-                        workflowResourceIds.getServiceInstanceId(), instanceName);
-        if (configuration.isPresent()) {
-            if (configuration.get().getModelCustomizationId()
-                    .equalsIgnoreCase(reqDetails.getModelInfo().getModelCustomizationId())) {
-                return configuration.get().getConfigurationId();
-            } else {
-                throw new DuplicateNameException("configuration", String.format(NAME_EXISTS_WITH_DIFF_CUSTOMIZATION_ID,
-                        instanceName, configuration.get().getConfigurationId()));
-            }
-        }
-        if (bbInputSetupUtils.existsAAIConfigurationGloballyByName(instanceName)) {
-            throw new DuplicateNameException("configuration", instanceName);
-        }
-        return generatedResourceId;
-    }
-
     protected boolean foundRelated(List<Resource> resourceList) {
         return (containsWorkflowType(resourceList, WorkflowType.VNF)
                 || containsWorkflowType(resourceList, WorkflowType.PNF)
@@ -1767,7 +1578,7 @@ public class WorkflowAction {
             WorkflowResourceIds workflowResourceIds) throws Exception {
         if (resource.isGenerated() && requestAction.equalsIgnoreCase("createInstance")
                 && requestDetails.getRequestInfo().getInstanceName() != null) {
-            return validateResourceIdInAAI(resource.getResourceId(), resource.getResourceType(),
+            return aaiResourceIdValidator.validateResourceIdInAAI(resource.getResourceId(), resource.getResourceType(),
                     requestDetails.getRequestInfo().getInstanceName(), requestDetails, workflowResourceIds);
         } else {
             return resource.getResourceId();
index 554385d..b756772 100644 (file)
@@ -52,6 +52,9 @@ import org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization;
 import org.onap.so.db.catalog.client.CatalogDbClient;
 import org.onap.so.db.request.beans.InfraActiveRequests;
 import org.onap.so.db.request.client.RequestsDbClient;
+import org.onap.so.serviceinstancebeans.ModelType;
+import org.onap.so.serviceinstancebeans.RelatedInstance;
+import org.onap.so.serviceinstancebeans.RelatedInstanceList;
 import org.onap.so.serviceinstancebeans.RequestReferences;
 import org.onap.so.serviceinstancebeans.ServiceInstancesResponse;
 import org.slf4j.Logger;
@@ -437,54 +440,53 @@ public class WorkflowActionBBTasks {
             String vnfId = ebb.getWorkflowResourceIds().getVnfId();
             String vfModuleId = ebb.getResourceId();
             ebb.getWorkflowResourceIds().setVfModuleId(vfModuleId);
-            String serviceModelUUID =
-                    bbInputSetupUtils.getAAIServiceInstanceById(serviceInstanceId).getModelVersionId();
-            String vnfCustomizationUUID = bbInputSetupUtils.getAAIGenericVnf(vnfId).getModelCustomizationId();
-            String vfModuleCustomizationUUID =
-                    bbInputSetupUtils.getAAIVfModule(vnfId, vfModuleId).getModelCustomizationId();
+            String serviceModelUUID = "";
+            String vnfCustomizationUUID = "";
+            String vfModuleCustomizationUUID = "";
+            if (requestAction.equalsIgnoreCase("replaceInstance")
+                    || requestAction.equalsIgnoreCase("replaceInstanceRetainAssignments")) {
+                for (RelatedInstanceList relatedInstList : ebb.getRequestDetails().getRelatedInstanceList()) {
+                    RelatedInstance relatedInstance = relatedInstList.getRelatedInstance();
+                    if (relatedInstance.getModelInfo().getModelType().equals(ModelType.vnf)) {
+                        vnfCustomizationUUID = relatedInstance.getModelInfo().getModelCustomizationId();
+                    }
+                    if (relatedInstance.getModelInfo().getModelType().equals(ModelType.service)) {
+                        serviceModelUUID = relatedInstance.getModelInfo().getModelVersionId();
+                    }
+                }
+                vfModuleCustomizationUUID = ebb.getRequestDetails().getModelInfo().getModelCustomizationId();
+            } else {
+                serviceModelUUID = bbInputSetupUtils.getAAIServiceInstanceById(serviceInstanceId).getModelVersionId();
+                vnfCustomizationUUID = bbInputSetupUtils.getAAIGenericVnf(vnfId).getModelCustomizationId();
+                vfModuleCustomizationUUID =
+                        bbInputSetupUtils.getAAIVfModule(vnfId, vfModuleId).getModelCustomizationId();
+            }
             List<Vnfc> vnfcs = workflowAction.getRelatedResourcesInVfModule(vnfId, vfModuleId, Vnfc.class, Types.VNFC);
             logger.debug("Vnfc Size: {}", vnfcs.size());
             for (Vnfc vnfc : vnfcs) {
                 String modelCustomizationId = vnfc.getModelCustomizationId();
                 logger.debug("Processing Vnfc: {}", modelCustomizationId);
-                if (requestAction.equalsIgnoreCase("replaceInstance")
-                        || requestAction.equalsIgnoreCase("replaceInstanceRetainAssignments")) {
-                    List<ExecuteBuildingBlock> configBBs = flowsToExecute.stream()
-                            .filter(item -> item.getBuildingBlock().getBpmnFlowName().matches(CONFIGURATION_PATTERN))
-                            .collect(Collectors.toList());
-                    if (configBBs != null && configBBs.size() > 0) {
-                        for (ExecuteBuildingBlock bb : configBBs) {
-                            if (bb.getConfigurationResourceKeys() != null) {
-                                bb.getConfigurationResourceKeys().setCvnfcCustomizationUUID(modelCustomizationId);
-                                bb.getConfigurationResourceKeys().setVnfcName(vnfc.getVnfcName());
-                            }
-                        }
-                        execution.setVariable("flowsToExecute", flowsToExecute);
-                        execution.setVariable(COMPLETED, false);
-                    }
+                CvnfcConfigurationCustomization fabricConfig = catalogDbClient.getCvnfcCustomization(serviceModelUUID,
+                        vnfCustomizationUUID, vfModuleCustomizationUUID, modelCustomizationId);
+                if (fabricConfig != null && fabricConfig.getConfigurationResource() != null
+                        && fabricConfig.getConfigurationResource().getToscaNodeType() != null
+                        && fabricConfig.getConfigurationResource().getToscaNodeType().contains(FABRIC_CONFIGURATION)) {
+                    String configurationId = getConfigurationId(vnfc);
+                    ConfigurationResourceKeys configurationResourceKeys = new ConfigurationResourceKeys();
+                    configurationResourceKeys.setCvnfcCustomizationUUID(modelCustomizationId);
+                    configurationResourceKeys.setVfModuleCustomizationUUID(vfModuleCustomizationUUID);
+                    configurationResourceKeys.setVnfResourceCustomizationUUID(vnfCustomizationUUID);
+                    configurationResourceKeys.setVnfcName(vnfc.getVnfcName());
+                    ExecuteBuildingBlock addConfigBB = getExecuteBBForConfig(ADD_FABRIC_CONFIGURATION_BB, ebb,
+                            configurationId, configurationResourceKeys);
+                    flowsToExecute.add(addConfigBB);
+                    flowsToExecute.stream()
+                            .forEach(executeBB -> logger.info("Flows to Execute After Post Processing: {}",
+                                    executeBB.getBuildingBlock().getBpmnFlowName()));
+                    execution.setVariable("flowsToExecute", flowsToExecute);
+                    execution.setVariable(COMPLETED, false);
                 } else {
-                    CvnfcConfigurationCustomization fabricConfig = catalogDbClient.getCvnfcCustomization(
-                            serviceModelUUID, vnfCustomizationUUID, vfModuleCustomizationUUID, modelCustomizationId);
-                    if (fabricConfig != null && fabricConfig.getConfigurationResource() != null
-                            && fabricConfig.getConfigurationResource().getToscaNodeType() != null && fabricConfig
-                                    .getConfigurationResource().getToscaNodeType().contains(FABRIC_CONFIGURATION)) {
-                        String configurationId = getConfigurationId(vnfc);
-                        ConfigurationResourceKeys configurationResourceKeys = new ConfigurationResourceKeys();
-                        configurationResourceKeys.setCvnfcCustomizationUUID(modelCustomizationId);
-                        configurationResourceKeys.setVfModuleCustomizationUUID(vfModuleCustomizationUUID);
-                        configurationResourceKeys.setVnfResourceCustomizationUUID(vnfCustomizationUUID);
-                        configurationResourceKeys.setVnfcName(vnfc.getVnfcName());
-                        ExecuteBuildingBlock addConfigBB = getExecuteBBForConfig(ADD_FABRIC_CONFIGURATION_BB, ebb,
-                                configurationId, configurationResourceKeys);
-                        flowsToExecute.add(addConfigBB);
-                        flowsToExecute.stream()
-                                .forEach(executeBB -> logger.info("Flows to Execute After Post Processing: {}",
-                                        executeBB.getBuildingBlock().getBpmnFlowName()));
-                        execution.setVariable("flowsToExecute", flowsToExecute);
-                        execution.setVariable(COMPLETED, false);
-                    } else {
-                        logger.debug("No cvnfcCustomization found for customizationId: {}", modelCustomizationId);
-                    }
+                    logger.debug("No cvnfcCustomization found for customizationId: {}", modelCustomizationId);
                 }
             }
         } catch (EntityNotFoundException e) {
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/controller/sdnc/prepare/PrepareSdncUpgradePreCheckPnfBBTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/controller/sdnc/prepare/PrepareSdncUpgradePreCheckPnfBBTest.java
new file mode 100644 (file)
index 0000000..0ba1e27
--- /dev/null
@@ -0,0 +1,88 @@
+/*-
+ * ============LICENSE_START=======================================================
+ *  Copyright (C) 2020 Nokia
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.decisionpoint.impl.buildingblock.controller.sdnc.prepare;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.common.DelegateExecutionImpl;
+import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerContext;
+
+public class PrepareSdncUpgradePreCheckPnfBBTest {
+
+    private PrepareSdncUpgradePreCheckPnfBB testedObject;
+
+    @Before
+    public void setup() {
+        testedObject = new PrepareSdncUpgradePreCheckPnfBB();
+    }
+
+    @Test
+    public void understandTrue() {
+        ControllerContext<BuildingBlockExecution> controllerContext =
+                createControllerContext("sdnc", "UpgradePreCheck", "pnf");
+        boolean result = testedObject.understand(controllerContext);
+        assertThat(result).isTrue();
+    }
+
+    @Test
+    public void understandFalse() {
+        ControllerContext<BuildingBlockExecution> controllerContext =
+                createControllerContext("actor1", "action1", "scope1");
+        boolean result = testedObject.understand(controllerContext);
+        assertThat(result).isFalse();
+    }
+
+    @Test
+    public void prepare_jsonWithoutActionPayload() {
+        String payloadWithoutActionArray = "{\"json name\": \"test1\"}";
+        ControllerContext<BuildingBlockExecution> controllerContext =
+                createControllerContext(payloadWithoutActionArray);
+        testedObject.prepare(controllerContext);
+
+        assertThat((String) controllerContext.getExecution().getVariable("payload"))
+                .isEqualTo(payloadWithoutActionArray);
+    }
+
+    private ControllerContext<BuildingBlockExecution> createControllerContext(String actor, String action,
+            String scope) {
+        ControllerContext<BuildingBlockExecution> controllerContext = new ControllerContext<>();
+        controllerContext.setControllerActor(actor);
+        controllerContext.setControllerAction(action);
+        controllerContext.setControllerScope(scope);
+        return controllerContext;
+    }
+
+    private ControllerContext<BuildingBlockExecution> createControllerContext(String payload) {
+        ControllerContext<BuildingBlockExecution> controllerContext = new ControllerContext<>();
+        controllerContext.setExecution(prepareBuildingBlockExecution(payload));
+        return controllerContext;
+    }
+
+    private BuildingBlockExecution prepareBuildingBlockExecution(String payload) {
+        DelegateExecution execution = new DelegateExecutionFake();
+        execution.setVariable("payload", payload);
+        return new DelegateExecutionImpl(execution);
+    }
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/AaiResourceIdValidatorTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/AaiResourceIdValidatorTest.java
new file mode 100644 (file)
index 0000000..ead6c0b
--- /dev/null
@@ -0,0 +1,765 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
+ * Modifications Copyright (c) 2020 Nokia
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.workflow.tasks;
+
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.when;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.aai.domain.yang.GenericVnf;
+import org.onap.aai.domain.yang.GenericVnfs;
+import org.onap.aai.domain.yang.L3Network;
+import org.onap.aai.domain.yang.ServiceInstance;
+import org.onap.aai.domain.yang.ServiceInstances;
+import org.onap.aai.domain.yang.VfModule;
+import org.onap.aai.domain.yang.VfModules;
+import org.onap.aai.domain.yang.VolumeGroup;
+import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder;
+import org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds;
+import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils;
+import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.DuplicateNameException;
+import org.onap.so.serviceinstancebeans.ModelInfo;
+import org.onap.so.serviceinstancebeans.RequestDetails;
+import org.onap.so.serviceinstancebeans.RequestParameters;
+import org.onap.so.serviceinstancebeans.SubscriberInfo;
+
+@RunWith(MockitoJUnitRunner.class)
+public class AaiResourceIdValidatorTest {
+
+    @Mock
+    private BBInputSetupUtils bbInputSetupUtilsMock;
+
+    @InjectMocks
+    private AaiResourceIdValidator testedObject;
+
+    @Rule
+    public ExpectedException expectedException = ExpectedException.none();
+
+    @Test
+    public void validateResourceIdInAAIVnfTest() throws Exception {
+        RequestDetails reqDetails = setupRequestDetails();
+        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
+        workflowResourceIds.setServiceInstanceId("siId123");
+        GenericVnf vnf = new GenericVnf();
+        vnf.setVnfId("id123");
+        vnf.setModelCustomizationId("1234567");
+        Optional<GenericVnf> opVnf = Optional.of(vnf);
+        GenericVnf vnf2 = new GenericVnf();
+        vnf2.setVnfId("id123");
+        vnf2.setModelCustomizationId("222");
+        Optional<GenericVnf> opVnf2 = Optional.of(vnf2);
+        when(bbInputSetupUtilsMock.getRelatedVnfByNameFromServiceInstance("siId123", "vnfName123")).thenReturn(opVnf);
+        when(bbInputSetupUtilsMock.getRelatedVnfByNameFromServiceInstance("siId123", "vnfName222")).thenReturn(opVnf2);
+        String id = testedObject.validateResourceIdInAAI("generatedId123", WorkflowType.VNF, "vnfName123", reqDetails,
+                workflowResourceIds);
+        assertEquals("id123", id);
+        String id2 = testedObject.validateResourceIdInAAI("generatedId123", WorkflowType.VNF, "nameTest", reqDetails,
+                workflowResourceIds);
+        assertEquals("generatedId123", id2);
+
+        this.expectedException.expect(DuplicateNameException.class);
+        this.expectedException.expectMessage(containsString(
+                "generic-vnf with name (vnfName222), same parent and different customization id (222) already exists. The name must be unique."));
+        testedObject.validateResourceIdInAAI("generatedId123", WorkflowType.VNF, "vnfName222", reqDetails,
+                workflowResourceIds);
+    }
+
+    @Test
+    public void validateResourceIdInAAIVnfNotGloballyUniqueTest() throws Exception {
+        RequestDetails reqDetails = setupRequestDetails();
+        GenericVnfs genericVnfs = new GenericVnfs();
+        GenericVnf vnf3 = new GenericVnf();
+        vnf3.setVnfId("id123");
+
+        genericVnfs.getGenericVnf().add(vnf3);
+        when(bbInputSetupUtilsMock.getAAIVnfsGloballyByName("vnfName333")).thenReturn(genericVnfs);
+
+        this.expectedException.expect(DuplicateNameException.class);
+        this.expectedException.expectMessage(containsString(
+                "generic-vnf with name (vnfName333) id (id123) and different parent relationship already exists. The name must be unique."));
+        testedObject.validateResourceIdInAAI("generatedId123", WorkflowType.VNF, "vnfName333", reqDetails,
+                new WorkflowResourceIds());
+    }
+
+    @Test
+    public void validateResourceIdInAAINetworkTest() throws Exception {
+        RequestDetails reqDetails = setupRequestDetails();
+        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
+        workflowResourceIds.setServiceInstanceId("siId123");
+        L3Network network = new L3Network();
+        network.setNetworkId("id123");
+        network.setModelCustomizationId("1234567");
+        Optional<L3Network> opNetwork = Optional.of(network);
+        L3Network network2 = new L3Network();
+        network2.setNetworkId("id123");
+        network2.setModelCustomizationId("222");
+        Optional<L3Network> opNetwork2 = Optional.of(network2);
+
+        when(bbInputSetupUtilsMock.getRelatedNetworkByNameFromServiceInstance("siId123", "name123"))
+                .thenReturn(opNetwork);
+        when(bbInputSetupUtilsMock.getRelatedNetworkByNameFromServiceInstance("siId123", "networkName222"))
+                .thenReturn(opNetwork2);
+        String id = testedObject.validateResourceIdInAAI("generatedId123", WorkflowType.NETWORK, "name123", reqDetails,
+                workflowResourceIds);
+        assertEquals("id123", id);
+        String id2 = testedObject.validateResourceIdInAAI("generatedId123", WorkflowType.NETWORK, "111111", reqDetails,
+                workflowResourceIds);
+        assertEquals("generatedId123", id2);
+
+        this.expectedException.expect(DuplicateNameException.class);
+        this.expectedException.expectMessage(containsString(
+                "l3Network with name (networkName222), same parent and different customization id (222) already exists. The name must be unique."));
+        testedObject.validateResourceIdInAAI("generatedId123", WorkflowType.NETWORK, "networkName222", reqDetails,
+                workflowResourceIds);
+    }
+
+    @Test
+    public void validateNetworkResourceNameExistsInAAITest() throws Exception {
+        RequestDetails reqDetails = setupRequestDetails();
+        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
+        workflowResourceIds.setServiceInstanceId("siId123");
+
+        when(bbInputSetupUtilsMock.existsAAINetworksGloballyByName("networkName333")).thenReturn(true);
+
+        this.expectedException.expect(DuplicateNameException.class);
+        this.expectedException.expectMessage(containsString(
+                "l3Network with name (networkName333) id (siId123) and different parent relationship already exists. The name must be unique."));
+        testedObject.validateResourceIdInAAI("generatedId123", WorkflowType.NETWORK, "networkName333", reqDetails,
+                workflowResourceIds);
+    }
+
+    @Test
+    public void validateResourceIdInAAIVfModuleTest() throws Exception {
+        RequestDetails reqDetails = setupRequestDetails();
+        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
+        workflowResourceIds.setVnfId("id123");
+
+        GenericVnf vnf = new GenericVnf();
+        VfModules vfModules = new VfModules();
+        VfModule vfModule = new VfModule();
+        vfModule.setVfModuleId("id123");
+        vfModule.setVfModuleName("name123");
+        vfModule.setModelCustomizationId("1234567");
+        vfModules.getVfModule().add(vfModule);
+        vnf.setVfModules(vfModules);
+
+        when(bbInputSetupUtilsMock.getAAIGenericVnf("id123")).thenReturn(vnf);
+        String id = testedObject.validateResourceIdInAAI("generatedId123", WorkflowType.VFMODULE, "name123", reqDetails,
+                workflowResourceIds);
+        assertEquals("id123", id);
+
+        GenericVnf vnf1 = new GenericVnf();
+        VfModules vfModules2 = new VfModules();
+        VfModule vfModule2 = new VfModule();
+        vfModule2.setVfModuleName("vFModName222");
+        vfModule2.setModelCustomizationId("222");
+        vfModules2.getVfModule().add(vfModule2);
+        vnf1.setVfModules(vfModules2);
+        workflowResourceIds.setVnfId("id111");
+        when(bbInputSetupUtilsMock.getAAIGenericVnf("id111")).thenReturn(vnf1);
+        String id2 = testedObject.validateResourceIdInAAI("generatedId123", WorkflowType.VFMODULE, "111111", reqDetails,
+                workflowResourceIds);
+        assertEquals("generatedId123", id2);
+
+        this.expectedException.expect(DuplicateNameException.class);
+        this.expectedException.expectMessage(containsString(
+                "vfModule with name (vFModName222), same parent and different customization id (1234567) already exists. The name must be unique."));
+        testedObject.validateResourceIdInAAI("generatedId123", WorkflowType.VFMODULE, "vFModName222", reqDetails,
+                workflowResourceIds);
+    }
+
+    @Test
+    public void validateResourceIdInAAIVfModuleNotGloballyUniqueTest() throws Exception {
+        RequestDetails reqDetails = setupRequestDetails();
+
+        when(bbInputSetupUtilsMock.existsAAIVfModuleGloballyByName("vFModName333")).thenReturn(true);
+        this.expectedException.expect(DuplicateNameException.class);
+        this.expectedException.expectMessage(
+                containsString("vfModule with name vFModName333 already exists. The name must be unique."));
+        testedObject.validateResourceIdInAAI("generatedId123", WorkflowType.VFMODULE, "vFModName333", reqDetails,
+                new WorkflowResourceIds());
+    }
+
+    @Test
+    public void validateResourceIdInAAIVolumeGroupTest() throws Exception {
+        RequestDetails reqDetails = setupRequestDetails();
+        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
+        workflowResourceIds.setVnfId("id123");
+        VolumeGroup volumeGroup = new VolumeGroup();
+        volumeGroup.setVolumeGroupId("id123");
+        volumeGroup.setVolumeGroupName("name123");
+        volumeGroup.setVfModuleModelCustomizationId("1234567");
+        Optional<VolumeGroup> opVolumeGroup = Optional.of(volumeGroup);
+
+        when(bbInputSetupUtilsMock.getRelatedVolumeGroupByNameFromVnf("id123", "name123")).thenReturn(opVolumeGroup);
+        String id = testedObject.validateResourceIdInAAI("generatedId123", WorkflowType.VOLUMEGROUP, "name123",
+                reqDetails, workflowResourceIds);
+        assertEquals("id123", id);
+
+        String id2 = testedObject.validateResourceIdInAAI("generatedId123", WorkflowType.VOLUMEGROUP, "111111",
+                reqDetails, workflowResourceIds);
+        assertEquals("generatedId123", id2);
+    }
+
+
+    @Test
+    public void validateSourceIdInAAIVolumeGroupNotGloballyUniqueTest() throws Exception {
+        RequestDetails reqDetails = setupRequestDetails();
+        when(bbInputSetupUtilsMock.existsAAIVolumeGroupGloballyByName("testVolumeGroup")).thenReturn(true);
+        this.expectedException.expect(DuplicateNameException.class);
+        this.expectedException.expectMessage(
+                containsString("volumeGroup with name testVolumeGroup already exists. The name must be unique."));
+        testedObject.validateResourceIdInAAI("generatedId123", WorkflowType.VOLUMEGROUP, "testVolumeGroup", reqDetails,
+                new WorkflowResourceIds());
+    }
+
+    @Test
+    public void validateResourceIdInAAIConfigurationTest() throws Exception {
+        RequestDetails reqDetails = setupRequestDetails();
+        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
+        workflowResourceIds.setServiceInstanceId("siId123");
+
+        org.onap.aai.domain.yang.Configuration configuration = new org.onap.aai.domain.yang.Configuration();
+        configuration.setConfigurationId("id123");
+        configuration.setModelCustomizationId("1234567");
+        Optional<org.onap.aai.domain.yang.Configuration> opConfiguration = Optional.of(configuration);
+
+        org.onap.aai.domain.yang.Configuration configuration2 = new org.onap.aai.domain.yang.Configuration();
+        configuration2.setConfigurationId("id123");
+        configuration2.setModelCustomizationId("222");
+        Optional<org.onap.aai.domain.yang.Configuration> opConfiguration2 = Optional.of(configuration2);
+
+        when(bbInputSetupUtilsMock.getRelatedConfigurationByNameFromServiceInstance("siId123", "name123"))
+                .thenReturn(opConfiguration);
+        String id = testedObject.validateResourceIdInAAI("generatedId123", WorkflowType.CONFIGURATION, "name123",
+                reqDetails, workflowResourceIds);
+        assertEquals("id123", id);
+
+        String id2 = testedObject.validateResourceIdInAAI("generatedId123", WorkflowType.CONFIGURATION, "111111",
+                reqDetails, workflowResourceIds);
+        assertEquals("generatedId123", id2);
+
+        when(bbInputSetupUtilsMock.getRelatedConfigurationByNameFromServiceInstance("siId123", "name222"))
+                .thenReturn(opConfiguration2);
+        this.expectedException.expect(DuplicateNameException.class);
+        this.expectedException.expectMessage(containsString(
+                "configuration with name (name222), same parent and different customization id (id123) already exists. The name must be unique."));
+        testedObject.validateResourceIdInAAI("generatedId123", WorkflowType.CONFIGURATION, "name222", reqDetails,
+                workflowResourceIds);
+    }
+
+    @Test
+    public void validateResourceIdInAAIConfigurationNotGloballyUniqueTest() throws Exception {
+        RequestDetails reqDetails = setupRequestDetails();
+        when(bbInputSetupUtilsMock.existsAAIConfigurationGloballyByName("testConfig")).thenReturn(true);
+        this.expectedException.expect(DuplicateNameException.class);
+        this.expectedException.expectMessage(
+                containsString("configuration with name testConfig already exists. The name must be unique."));
+        testedObject.validateResourceIdInAAI("generatedId123", WorkflowType.CONFIGURATION, "testConfig", reqDetails,
+                new WorkflowResourceIds());
+    }
+
+    @Test
+    public void validateResourceIdInAAISITest() throws Exception {
+        RequestDetails reqDetails = setupRequestDetails();
+        reqDetails.getModelInfo().setModelVersionId("1234567");
+
+        ServiceInstance si = new ServiceInstance();
+        si.setServiceInstanceId("siId123");
+        si.setModelVersionId("1234567");
+        ServiceInstances serviceInstances = new ServiceInstances();
+        serviceInstances.getServiceInstance().add(si);
+        Optional<ServiceInstance> siOp = Optional.of(si);
+        ServiceInstance si2 = new ServiceInstance();
+        si2.setServiceInstanceId("siId222");
+        si2.setModelVersionId("22222");
+        si2.setServiceInstanceName("siName222");
+        Optional<ServiceInstance> siOp2 = Optional.of(si2);
+        ServiceInstances serviceInstances2 = new ServiceInstances();
+        serviceInstances2.getServiceInstance().add(si2);
+
+        when(bbInputSetupUtilsMock.getAAIServiceInstanceByName("id123", "subServiceType123", "siName123"))
+                .thenReturn(siOp);
+        when(bbInputSetupUtilsMock.getAAIServiceInstanceByName("id123", "subServiceType123", "siName222"))
+                .thenReturn(siOp2);
+        String id = testedObject.validateResourceIdInAAI("generatedId123", WorkflowType.SERVICE, "siName123",
+                reqDetails, new WorkflowResourceIds());
+        assertEquals("siId123", id);
+        String id2 = testedObject.validateResourceIdInAAI("generatedId123", WorkflowType.SERVICE, "111111", reqDetails,
+                new WorkflowResourceIds());
+        assertEquals("generatedId123", id2);
+
+        this.expectedException.expect(DuplicateNameException.class);
+        this.expectedException.expectMessage(containsString(
+                "serviceInstance with name (siName222) and different version id (1234567) already exists. The name must be unique."));
+        testedObject.validateResourceIdInAAI("generatedId123", WorkflowType.SERVICE, "siName222", reqDetails,
+                new WorkflowResourceIds());
+    }
+
+    @Test
+    public void validateResourceIdInAAIMultipleSITest() throws Exception {
+        RequestDetails reqDetails = setupRequestDetails();
+        reqDetails.getModelInfo().setModelVersionId("1234567");
+        ServiceInstance si = new ServiceInstance();
+        ServiceInstances serviceInstances = new ServiceInstances();
+        serviceInstances.getServiceInstance().add(si);
+        ServiceInstance si2 = new ServiceInstance();
+        serviceInstances.getServiceInstance().add(si2);
+        when(bbInputSetupUtilsMock.getAAIServiceInstancesGloballyByName("siName123")).thenReturn(serviceInstances);
+
+        this.expectedException.expect(DuplicateNameException.class);
+        this.expectedException.expectMessage(containsString(
+                "serviceInstance with name (siName123) and multiple combination of model-version-id + service-type + global-customer-id already exists. The name must be unique."));
+        testedObject.validateResourceIdInAAI("generatedId123", WorkflowType.SERVICE, "siName123", reqDetails,
+                new WorkflowResourceIds());
+    }
+
+    @Test
+    public void validateResourceIdInAAISIExistsTest() throws Exception {
+        RequestDetails reqDetails = setupRequestDetails();
+        reqDetails.getModelInfo().setModelVersionId("1234567");
+
+        ServiceInstance si = new ServiceInstance();
+        si.setServiceInstanceId("siId123");
+        si.setModelVersionId("1234567");
+        ServiceInstances serviceInstances = new ServiceInstances();
+        serviceInstances.getServiceInstance().add(si);
+
+        Map<String, String> uriKeys = new HashMap<>();
+        uriKeys.put(AAIFluentTypeBuilder.Types.CUSTOMER.getUriParams().globalCustomerId, "globalCustomerId");
+        uriKeys.put(AAIFluentTypeBuilder.Types.SERVICE_SUBSCRIPTION.getUriParams().serviceType, "serviceType");
+
+        when(bbInputSetupUtilsMock.getAAIServiceInstancesGloballyByName("siName123")).thenReturn(serviceInstances);
+        when(bbInputSetupUtilsMock.getURIKeysFromServiceInstance("siId123")).thenReturn(uriKeys);
+
+        this.expectedException.expect(DuplicateNameException.class);
+        this.expectedException.expectMessage(containsString(
+                "serviceInstance with name (siName123) and global-customer-id (globalCustomerId), service-type (serviceType), model-version-id (1234567) already exists. The name must be unique."));
+        testedObject.validateResourceIdInAAI("generatedId123", WorkflowType.SERVICE, "siName123", reqDetails,
+                new WorkflowResourceIds());
+    }
+
+    @Test
+    public void validateServiceResourceIdInAAINoDupTest() throws Exception {
+        RequestDetails reqDetails = setupRequestDetails();
+        String id = testedObject.validateServiceResourceIdInAAI("generatedId123", "siName123", reqDetails);
+        assertEquals("generatedId123", id);
+    }
+
+    @Test
+    public void validateServiceResourceIdInAAISameModelVersionId() throws Exception {
+        RequestDetails reqDetails = setupRequestDetails();
+        reqDetails.getModelInfo().setModelVersionId("1234567");
+
+        ServiceInstance si = new ServiceInstance();
+        si.setServiceInstanceId("siId123");
+        si.setModelVersionId("1234567");
+        Optional<ServiceInstance> siOp = Optional.of(si);
+
+        when(bbInputSetupUtilsMock.getAAIServiceInstanceByName("id123", "subServiceType123", "siName123"))
+                .thenReturn(siOp);
+        String id = testedObject.validateServiceResourceIdInAAI("generatedId123", "siName123", reqDetails);
+        assertEquals("siId123", id);
+    }
+
+    @Test
+    public void validateServiceResourceIdInAAIDifferentModelVersionId() throws Exception {
+        RequestDetails reqDetails = setupRequestDetails();
+        reqDetails.getModelInfo().setModelVersionId("1234567");
+
+        ServiceInstance si = new ServiceInstance();
+        si.setModelVersionId("9999999");
+        ServiceInstances serviceInstances = new ServiceInstances();
+        serviceInstances.getServiceInstance().add(si);
+        Optional<ServiceInstance> siOp = Optional.of(si);
+
+        when(bbInputSetupUtilsMock.getAAIServiceInstanceByName("id123", "subServiceType123", "siName123"))
+                .thenReturn(siOp);
+
+        this.expectedException.expect(DuplicateNameException.class);
+        this.expectedException.expectMessage(containsString(
+                "serviceInstance with name (siName123) and different version id (1234567) already exists. The name must be unique."));
+
+        String id = testedObject.validateServiceResourceIdInAAI("generatedId123", "siName123", reqDetails);
+        assertEquals("siId123", id);
+    }
+
+    @Test
+    public void validateServiceResourceIdInAAIDuplicateNameTest() throws Exception {
+        RequestDetails reqDetails = setupRequestDetails();
+        ServiceInstance si = new ServiceInstance();
+        si.setModelVersionId("1234567");
+        ServiceInstances serviceInstances = new ServiceInstances();
+        serviceInstances.getServiceInstance().add(si);
+
+        when(bbInputSetupUtilsMock.getAAIServiceInstancesGloballyByName("siName")).thenReturn(serviceInstances);
+
+        this.expectedException.expect(DuplicateNameException.class);
+        this.expectedException.expectMessage(containsString(
+                "serviceInstance with name (siName) and global-customer-id (null), service-type (null), model-version-id (1234567) already exists. The name must be unique."));
+
+        testedObject.validateServiceResourceIdInAAI("generatedId123", "siName", reqDetails);
+    }
+
+    @Test
+    public void validateServiceResourceIdInAAIDuplicateNameMultipleTest() throws Exception {
+        RequestDetails reqDetails = setupRequestDetails();
+        ServiceInstances serviceInstances = new ServiceInstances();
+        serviceInstances.getServiceInstance().add(new ServiceInstance());
+        serviceInstances.getServiceInstance().add(new ServiceInstance());
+
+        when(bbInputSetupUtilsMock.getAAIServiceInstancesGloballyByName("siName")).thenReturn(serviceInstances);
+
+        this.expectedException.expect(DuplicateNameException.class);
+        this.expectedException.expectMessage(containsString(
+                "serviceInstance with name (siName) and multiple combination of model-version-id + service-type + global-customer-id already exists. The name must be unique."));
+
+        testedObject.validateServiceResourceIdInAAI("generatedId123", "siName", reqDetails);
+    }
+
+    @Test
+    public void validateNetworkResourceIdInAAITest() throws Exception {
+        RequestDetails reqDetails = setupRequestDetails();
+        String id = testedObject.validateNetworkResourceIdInAAI("generatedId123", "name123", reqDetails,
+                new WorkflowResourceIds());
+        assertEquals("generatedId123", id);
+    }
+
+    @Test
+    public void validateNetworkResourceIdInAAISameModelCustIdTest() throws Exception {
+        RequestDetails reqDetails = setupRequestDetails();
+        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
+        workflowResourceIds.setServiceInstanceId("siId123");
+        L3Network network = new L3Network();
+        network.setNetworkId("id123");
+        network.setModelCustomizationId("1234567");
+        Optional<L3Network> opNetwork = Optional.of(network);
+
+        when(bbInputSetupUtilsMock.getRelatedNetworkByNameFromServiceInstance("siId123", "name123"))
+                .thenReturn(opNetwork);
+
+        String id = testedObject.validateNetworkResourceIdInAAI("generatedId123", "name123", reqDetails,
+                workflowResourceIds);
+        assertEquals("id123", id);
+    }
+
+    @Test
+    public void validateNetworkResourceIdInAAIDuplicateNameTest() throws Exception {
+        RequestDetails reqDetails = setupRequestDetails();
+        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
+        workflowResourceIds.setServiceInstanceId("siId123");
+        L3Network network = new L3Network();
+        network.setModelCustomizationId("9999999");
+        Optional<L3Network> opNetwork = Optional.of(network);
+
+        when(bbInputSetupUtilsMock.getRelatedNetworkByNameFromServiceInstance("siId123", "name123"))
+                .thenReturn(opNetwork);
+
+        this.expectedException.expect(DuplicateNameException.class);
+        this.expectedException.expectMessage(containsString(
+                "l3Network with name (name123), same parent and different customization id (9999999) already exists. The name must be unique."));
+
+        testedObject.validateNetworkResourceIdInAAI("generatedId123", "name123", reqDetails, workflowResourceIds);
+    }
+
+    @Test
+    public void validateNetworkResourceIdInAAINotGloballyUniqueTest() throws Exception {
+        RequestDetails reqDetails = setupRequestDetails();
+        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
+        workflowResourceIds.setServiceInstanceId("siId123");
+
+        when(bbInputSetupUtilsMock.existsAAINetworksGloballyByName("name123")).thenReturn(true);
+
+        this.expectedException.expect(DuplicateNameException.class);
+        this.expectedException.expectMessage(containsString(
+                "l3Network with name (name123) id (siId123) and different parent relationship already exists. The name must be unique."));
+
+        testedObject.validateNetworkResourceIdInAAI("generatedId123", "name123", reqDetails, workflowResourceIds);
+    }
+
+    @Test
+    public void validateVnfResourceIdInAAITest() throws Exception {
+        RequestDetails reqDetails = setupRequestDetails();
+        String id = testedObject.validateVnfResourceIdInAAI("generatedId123", "vnfName123", reqDetails,
+                new WorkflowResourceIds());
+        assertEquals("generatedId123", id);
+    }
+
+    @Test
+    public void validateVnfResourceIdInAAISameModelCustomizationIdTest() throws Exception {
+        RequestDetails reqDetails = setupRequestDetails();
+        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
+        workflowResourceIds.setServiceInstanceId("siId123");
+
+        GenericVnf vnf = new GenericVnf();
+        vnf.setVnfId("id123");
+        vnf.setModelCustomizationId("1234567");
+        Optional<GenericVnf> opVnf = Optional.of(vnf);
+
+        when(bbInputSetupUtilsMock.getRelatedVnfByNameFromServiceInstance("siId123", "vnfName123")).thenReturn(opVnf);
+        String id = testedObject.validateVnfResourceIdInAAI("generatedId123", "vnfName123", reqDetails,
+                workflowResourceIds);
+        assertEquals("id123", id);
+    }
+
+    @Test
+    public void validateVnfResourceIdInAAIDiffModelCustomizationIdTest() throws Exception {
+        RequestDetails reqDetails = setupRequestDetails();
+        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
+        workflowResourceIds.setServiceInstanceId("siId123");
+        GenericVnf vnf = new GenericVnf();
+        vnf.setModelCustomizationId("9999999");
+        Optional<GenericVnf> opVnf = Optional.of(vnf);
+
+        when(bbInputSetupUtilsMock.getRelatedVnfByNameFromServiceInstance("siId123", "vnfName123")).thenReturn(opVnf);
+
+        this.expectedException.expect(DuplicateNameException.class);
+        this.expectedException.expectMessage(containsString(
+                "generic-vnf with name (vnfName123), same parent and different customization id (9999999) already exists. The name must be unique."));
+
+        testedObject.validateVnfResourceIdInAAI("generatedId123", "vnfName123", reqDetails, workflowResourceIds);
+    }
+
+    @Test
+    public void validateVnfResourceIdInAAINotGloballyUniqueTest() throws Exception {
+        RequestDetails reqDetails = setupRequestDetails();
+        GenericVnf vnf = new GenericVnf();
+        vnf.setVnfId("id123");
+        GenericVnfs genericVnfs = new GenericVnfs();
+        genericVnfs.getGenericVnf().add(vnf);
+
+        when(bbInputSetupUtilsMock.getAAIVnfsGloballyByName("vnfName123")).thenReturn(genericVnfs);
+
+        this.expectedException.expect(DuplicateNameException.class);
+        this.expectedException.expectMessage(containsString(
+                "generic-vnf with name (vnfName123) id (id123) and different parent relationship already exists. The name must be unique."));
+
+        testedObject.validateVnfResourceIdInAAI("generatedId123", "vnfName123", reqDetails, new WorkflowResourceIds());
+    }
+
+    @Test
+    public void validateVfModuleResourceIdTest() throws Exception {
+        RequestDetails reqDetails = setupRequestDetails();
+        String id = testedObject.validateVfModuleResourceIdInAAI("generatedId123", "name123", reqDetails,
+                new WorkflowResourceIds());
+        assertEquals("generatedId123", id);
+    }
+
+    @Test
+    public void validateVfModuleResourceIdSameModelCustIdTest() throws Exception {
+        RequestDetails reqDetails = setupRequestDetails();
+        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
+        workflowResourceIds.setVnfId("vnfId123");
+        VfModules vfModules = new VfModules();
+        VfModule vfModule = new VfModule();
+        vfModule.setVfModuleId("id123");
+        vfModule.setVfModuleName("name123");
+        vfModule.setModelCustomizationId("1234567");
+        vfModules.getVfModule().add(vfModule);
+        GenericVnf vnf = new GenericVnf();
+        vnf.setVfModules(vfModules);
+
+        when(bbInputSetupUtilsMock.getAAIGenericVnf("vnfId123")).thenReturn(vnf);
+
+        String id = testedObject.validateVfModuleResourceIdInAAI("generatedId123", "name123", reqDetails,
+                workflowResourceIds);
+        assertEquals("id123", id);
+    }
+
+    @Test
+    public void validateVfModuleResourceIdDifferentModelCustIdTest() throws Exception {
+        RequestDetails reqDetails = setupRequestDetails();
+        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
+        workflowResourceIds.setVnfId("vnfId123");
+        VfModules vfModules = new VfModules();
+        VfModule vfModule = new VfModule();
+        vfModule.setVfModuleName("name123");
+        vfModule.setModelCustomizationId("9999999");
+        vfModules.getVfModule().add(vfModule);
+        GenericVnf vnf = new GenericVnf();
+        vnf.setVfModules(vfModules);
+
+        when(bbInputSetupUtilsMock.getAAIGenericVnf("vnfId123")).thenReturn(vnf);
+
+        this.expectedException.expect(DuplicateNameException.class);
+        this.expectedException.expectMessage(containsString(
+                "vfModule with name (name123), same parent and different customization id (1234567) already exists. The name must be unique."));
+
+        testedObject.validateVfModuleResourceIdInAAI("generatedId123", "name123", reqDetails, workflowResourceIds);
+    }
+
+    @Test
+    public void validateVfModuleResourceIdNotGloballyUniqueTest() throws Exception {
+        RequestDetails reqDetails = setupRequestDetails();
+        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
+        when(bbInputSetupUtilsMock.existsAAIVfModuleGloballyByName("name123")).thenReturn(true);
+
+        this.expectedException.expect(DuplicateNameException.class);
+        this.expectedException
+                .expectMessage(containsString("vfModule with name name123 already exists. The name must be unique."));
+
+        testedObject.validateVfModuleResourceIdInAAI("generatedId123", "name123", reqDetails, workflowResourceIds);
+    }
+
+    @Test
+    public void validateVolumeGroupResourceIdInAAITest() throws Exception {
+        RequestDetails reqDetails = setupRequestDetails();
+        String id = testedObject.validateVolumeGroupResourceIdInAAI("generatedId123", "name123", reqDetails,
+                new WorkflowResourceIds());
+        assertEquals("generatedId123", id);
+    }
+
+    @Test
+    public void validateVolumeGroupResourceIdInAAISameModelCustIdTest() throws Exception {
+        RequestDetails reqDetails = setupRequestDetails();
+        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
+        workflowResourceIds.setVnfId("vnfId123");
+        VolumeGroup volumeGroup = new VolumeGroup();
+        volumeGroup.setVolumeGroupId("id123");
+        volumeGroup.setVfModuleModelCustomizationId("1234567");
+        Optional<VolumeGroup> opVolumeGroup = Optional.of(volumeGroup);
+
+        when(bbInputSetupUtilsMock.getRelatedVolumeGroupByNameFromVnf("vnfId123", "name123")).thenReturn(opVolumeGroup);
+        String id = testedObject.validateResourceIdInAAI("generatedId123", WorkflowType.VOLUMEGROUP, "name123",
+                reqDetails, workflowResourceIds);
+
+        assertEquals("id123", id);
+    }
+
+    @Test
+    public void validateVolumeGroupResourceIdInAAIDifferentModelCustIdTest() throws Exception {
+        RequestDetails reqDetails = setupRequestDetails();
+        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
+        workflowResourceIds.setVnfId("vnfId123");
+        VolumeGroup volumeGroup = new VolumeGroup();
+        volumeGroup.setVolumeGroupName("name123");
+        volumeGroup.setVfModuleModelCustomizationId("9999999");
+        Optional<VolumeGroup> opVolumeGroup = Optional.of(volumeGroup);
+
+        when(bbInputSetupUtilsMock.getRelatedVolumeGroupByNameFromVnf("vnfId123", "name123")).thenReturn(opVolumeGroup);
+
+        this.expectedException.expect(DuplicateNameException.class);
+        this.expectedException.expectMessage(
+                containsString("volumeGroup with name name123 already exists. The name must be unique."));
+
+        testedObject.validateResourceIdInAAI("generatedId123", WorkflowType.VOLUMEGROUP, "name123", reqDetails,
+                workflowResourceIds);
+    }
+
+    @Test
+    public void validateVolumeGroupResourceIdInAAINotGloballyUniqueTest() throws Exception {
+        RequestDetails reqDetails = setupRequestDetails();
+        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
+        when(bbInputSetupUtilsMock.existsAAIVolumeGroupGloballyByName("name123")).thenReturn(true);
+
+        this.expectedException.expect(DuplicateNameException.class);
+        this.expectedException.expectMessage(
+                containsString("volumeGroup with name name123 already exists. The name must be unique."));
+
+        testedObject.validateResourceIdInAAI("generatedId123", WorkflowType.VOLUMEGROUP, "name123", reqDetails,
+                workflowResourceIds);
+    }
+
+    @Test
+    public void validateConfigurationResourceIdInAAITest() throws Exception {
+        RequestDetails reqDetails = setupRequestDetails();
+        String id = testedObject.validateConfigurationResourceIdInAAI("generatedId123", "name123", reqDetails,
+                new WorkflowResourceIds());
+        assertEquals("generatedId123", id);
+    }
+
+    @Test
+    public void validateConfigurationResourceIdInAAISameModelCustIdTest() throws Exception {
+        RequestDetails reqDetails = setupRequestDetails();
+        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
+        workflowResourceIds.setServiceInstanceId("siId123");
+        org.onap.aai.domain.yang.Configuration configuration = new org.onap.aai.domain.yang.Configuration();
+        configuration.setConfigurationId("id123");
+        configuration.setModelCustomizationId("1234567");
+        Optional<org.onap.aai.domain.yang.Configuration> opConfiguration = Optional.of(configuration);
+
+        when(bbInputSetupUtilsMock.getRelatedConfigurationByNameFromServiceInstance("siId123", "name123"))
+                .thenReturn(opConfiguration);
+
+        String id = testedObject.validateConfigurationResourceIdInAAI("generatedId123", "name123", reqDetails,
+                workflowResourceIds);
+        assertEquals("id123", id);
+    }
+
+    @Test
+    public void validateConfigurationResourceIdInAAIDifferentModelCustIdTest() throws Exception {
+        RequestDetails reqDetails = setupRequestDetails();
+        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
+        workflowResourceIds.setServiceInstanceId("siId123");
+        org.onap.aai.domain.yang.Configuration configuration = new org.onap.aai.domain.yang.Configuration();
+        configuration.setConfigurationId("id123");
+        configuration.setModelCustomizationId("9999999");
+        Optional<org.onap.aai.domain.yang.Configuration> opConfiguration = Optional.of(configuration);
+
+        when(bbInputSetupUtilsMock.getRelatedConfigurationByNameFromServiceInstance("siId123", "name123"))
+                .thenReturn(opConfiguration);
+        this.expectedException.expect(DuplicateNameException.class);
+        this.expectedException.expectMessage(containsString(
+                "configuration with name (name123), same parent and different customization id (id123) already exists. The name must be unique."));
+
+        testedObject.validateConfigurationResourceIdInAAI("generatedId123", "name123", reqDetails, workflowResourceIds);
+    }
+
+    @Test
+    public void validateConfigurationResourceIdInAAINotGloballyUniqueTest() throws Exception {
+        RequestDetails reqDetails = setupRequestDetails();
+        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
+
+        when(bbInputSetupUtilsMock.existsAAIConfigurationGloballyByName("name123")).thenReturn(true);
+        this.expectedException.expect(DuplicateNameException.class);
+        this.expectedException.expectMessage(
+                containsString("configuration with name name123 already exists. The name must be unique."));
+
+        testedObject.validateConfigurationResourceIdInAAI("generatedId123", "name123", reqDetails, workflowResourceIds);
+    }
+
+    private RequestDetails setupRequestDetails() {
+        RequestDetails reqDetails = new RequestDetails();
+        SubscriberInfo subInfo = new SubscriberInfo();
+        subInfo.setGlobalSubscriberId("id123");
+        reqDetails.setSubscriberInfo(subInfo);
+        RequestParameters reqParams = new RequestParameters();
+        reqParams.setSubscriptionServiceType("subServiceType123");
+        reqDetails.setRequestParameters(reqParams);
+        ModelInfo modelInfo = new ModelInfo();
+        modelInfo.setModelCustomizationId("1234567");
+        reqDetails.setModelInfo(modelInfo);
+        return reqDetails;
+    }
+}
index b7529bd..5cd3055 100644 (file)
 
 package org.onap.so.bpmn.infrastructure.workflow.tasks;
 
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyObject;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.isA;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
 import org.camunda.bpm.engine.delegate.BpmnError;
 import org.camunda.bpm.engine.delegate.DelegateExecution;
 import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
@@ -48,31 +64,16 @@ import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock;
 import org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys;
 import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock;
 import org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds;
-import org.onap.so.client.namingservice.NamingRequestObject;
 import org.onap.so.db.catalog.beans.ConfigurationResource;
 import org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization;
 import org.onap.so.db.catalog.beans.VnfResourceCustomization;
 import org.onap.so.db.request.beans.InfraActiveRequests;
 import org.onap.so.serviceinstancebeans.ModelInfo;
+import org.onap.so.serviceinstancebeans.ModelType;
+import org.onap.so.serviceinstancebeans.RelatedInstance;
+import org.onap.so.serviceinstancebeans.RelatedInstanceList;
 import org.onap.so.serviceinstancebeans.RequestDetails;
 import org.springframework.core.env.Environment;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Optional;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyObject;
-import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.ArgumentMatchers.isA;
-import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
 
 public class WorkflowActionBBTasksTest extends BaseTaskTest {
 
@@ -680,7 +681,28 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest {
     @Test
     public void postProcessingExecuteBBActivateVfModuleReplaceInstanceHasConfigurationTest()
             throws CloneNotSupportedException {
-
+        RequestDetails reqDetails = new RequestDetails();
+        RelatedInstanceList[] list = new RelatedInstanceList[2];
+        RelatedInstanceList vnfList = new RelatedInstanceList();
+        RelatedInstanceList serviceList = new RelatedInstanceList();
+        list[0] = vnfList;
+        list[1] = serviceList;
+        RelatedInstance vnfInstance = new RelatedInstance();
+        RelatedInstance serviceInstance = new RelatedInstance();
+        ModelInfo vnfModelInfo = new ModelInfo();
+        vnfModelInfo.setModelType(ModelType.vnf);
+        vnfModelInfo.setModelCustomizationId("1");
+        ModelInfo serviceModelInfo = new ModelInfo();
+        serviceModelInfo.setModelType(ModelType.service);
+        serviceModelInfo.setModelVersionId("1");
+        vnfInstance.setModelInfo(vnfModelInfo);
+        serviceInstance.setModelInfo(serviceModelInfo);
+        reqDetails.setRelatedInstanceList(list);
+        vnfList.setRelatedInstance(vnfInstance);
+        serviceList.setRelatedInstance(serviceInstance);
+        ModelInfo vfModuleInfo = new ModelInfo();
+        vfModuleInfo.setModelCustomizationId("1");
+        reqDetails.setModelInfo(vfModuleInfo);
         BuildingBlock bbAddFabric = new BuildingBlock().setBpmnFlowName("AddFabricConfigurationBB");
         ExecuteBuildingBlock ebbAddFabric = new ExecuteBuildingBlock().setBuildingBlock(bbAddFabric);
         WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
@@ -695,6 +717,7 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest {
         ebbActivateVfModule.setResourceId("1");
         ConfigurationResourceKeys configurationResourceKeys = new ConfigurationResourceKeys();
         ebbAddFabric.setConfigurationResourceKeys(configurationResourceKeys);
+        ebbActivateVfModule.setRequestDetails(reqDetails);
 
         ServiceInstance service = new ServiceInstance();
         service.setServiceInstanceName("name");
@@ -730,7 +753,6 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest {
         prepareDelegateExecution();
         List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
         flowsToExecute.add(ebbActivateVfModule);
-        flowsToExecute.add(ebbAddFabric);
 
         ArgumentCaptor<DelegateExecution> executionCaptor = ArgumentCaptor.forClass(DelegateExecution.class);
         ArgumentCaptor<ExecuteBuildingBlock> bbCaptor = ArgumentCaptor.forClass(ExecuteBuildingBlock.class);
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionExtractResourcesAAITest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionExtractResourcesAAITest.java
new file mode 100644 (file)
index 0000000..35a5bfe
--- /dev/null
@@ -0,0 +1,102 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Modifications Copyright (c) 2020 Nokia
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.workflow.tasks;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Optional;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.aai.domain.yang.VpnBinding;
+import org.onap.aaiclient.client.aai.entities.AAIResultWrapper;
+import org.onap.aaiclient.client.aai.entities.Relationships;
+import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri;
+import org.onap.aaiclient.client.aai.entities.uri.AAISimpleUri;
+import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration;
+import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils;
+
+@RunWith(MockitoJUnitRunner.class)
+public class WorkflowActionExtractResourcesAAITest {
+
+    private static final String CONFIGURATION_ID = "configTestId";
+    private static final String VPN_ID = "vpnTestId";
+
+    @Mock
+    private BBInputSetupUtils bbInputSetupUtils;
+    @InjectMocks
+    private WorkflowActionExtractResourcesAAI testedObject;
+
+    @Test
+    public void extractRelationshipsConfigurationSuccess() {
+        // given
+        Relationships relationships = mock(Relationships.class);
+        when(relationships.getByType(Types.CONFIGURATION)).thenReturn(getConfigurationList());
+        // when
+        Optional<Configuration> resultOpt = testedObject.extractRelationshipsConfiguration(relationships);
+        // then
+        assertThat(resultOpt).isNotEmpty();
+        assertThat(resultOpt.get().getConfigurationId()).isEqualTo(CONFIGURATION_ID);
+    }
+
+    @Test
+    public void extractRelationshipsConfiguration_notFound() {
+        // given
+        Relationships relationships = mock(Relationships.class);
+        when(relationships.getByType(Types.CONFIGURATION)).thenReturn(Collections.emptyList());
+        // when
+        Optional<Configuration> resultOpt = testedObject.extractRelationshipsConfiguration(relationships);
+        // then
+        assertThat(resultOpt).isEmpty();
+    }
+
+    @Test
+    public void extractRelationshipsVpnBindingSuccess() {
+        // given
+        Relationships relationships = mock(Relationships.class);
+        AAIResourceUri aaiResourceUri = mock(AAISimpleUri.class);
+        List<AAIResourceUri> aaiResourceUriList = new ArrayList<>();
+        aaiResourceUriList.add(aaiResourceUri);
+        when(relationships.getRelatedUris(Types.VPN_BINDING)).thenReturn(aaiResourceUriList);
+        AAIResultWrapper aaiResultWrapper = new AAIResultWrapper("{\"vpn-id\" : \"" + VPN_ID + "\"}");
+        when(bbInputSetupUtils.getAAIResourceDepthOne(aaiResourceUri)).thenReturn(aaiResultWrapper);
+        // when
+        Optional<VpnBinding> resultOpt = testedObject.extractRelationshipsVpnBinding(relationships);
+        // then
+        assertThat(resultOpt).isNotEmpty();
+        assertThat(resultOpt.get().getVpnId()).isEqualTo(VPN_ID);
+    }
+
+    private List<AAIResultWrapper> getConfigurationList() {
+        List<AAIResultWrapper> configurations = new ArrayList<>();
+        AAIResultWrapper aaiResultWrapper =
+                new AAIResultWrapper("{\"configuration-id\" : \"" + CONFIGURATION_ID + "\"}");
+        configurations.add(aaiResultWrapper);
+        return configurations;
+    }
+}
index 0a3f74c..c916e09 100644 (file)
@@ -51,9 +51,7 @@ import java.nio.file.Files;
 import java.nio.file.Paths;
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 import java.util.Optional;
 import java.util.UUID;
 import org.camunda.bpm.engine.delegate.BpmnError;
@@ -68,15 +66,10 @@ import org.junit.rules.ExpectedException;
 import org.mockito.InjectMocks;
 import org.mockito.Mock;
 import org.mockito.Spy;
-import org.onap.aai.domain.yang.GenericVnf;
-import org.onap.aai.domain.yang.GenericVnfs;
-import org.onap.aai.domain.yang.L3Network;
 import org.onap.aai.domain.yang.Relationship;
 import org.onap.aai.domain.yang.RelationshipList;
 import org.onap.aai.domain.yang.ServiceInstance;
-import org.onap.aai.domain.yang.ServiceInstances;
 import org.onap.aai.domain.yang.VfModule;
-import org.onap.aai.domain.yang.VfModules;
 import org.onap.aai.domain.yang.VolumeGroup;
 import org.onap.aaiclient.client.aai.entities.AAIResultWrapper;
 import org.onap.aaiclient.client.aai.entities.Relationships;
@@ -108,11 +101,8 @@ import org.onap.so.db.catalog.beans.Service;
 import org.onap.so.db.catalog.beans.VfModuleCustomization;
 import org.onap.so.db.catalog.beans.macro.NorthBoundRequest;
 import org.onap.so.db.catalog.beans.macro.OrchestrationFlow;
-import org.onap.so.serviceinstancebeans.ModelInfo;
 import org.onap.so.serviceinstancebeans.RequestDetails;
-import org.onap.so.serviceinstancebeans.RequestParameters;
 import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
-import org.onap.so.serviceinstancebeans.SubscriberInfo;
 import org.springframework.core.env.Environment;
 
 public class WorkflowActionTest extends BaseTaskTest {
@@ -128,12 +118,13 @@ public class WorkflowActionTest extends BaseTaskTest {
 
     @Mock
     protected Environment environment;
-
     @Mock
     protected UserParamsServiceTraversal userParamsServiceTraversal;
-
+    @Mock
+    private AaiResourceIdValidator aaiResourceIdValidator;
     @InjectMocks
     protected WorkflowAction workflowAction;
+
     private DelegateExecution execution;
 
     @InjectMocks
@@ -242,7 +233,7 @@ public class WorkflowActionTest extends BaseTaskTest {
 
         doThrow(new DuplicateNameException(
                 "serviceInstance with name (instanceName) and different version id (3c40d244-808e-42ca-b09a-256d83d19d0a) already exists. The name must be unique."))
-                        .when(SPY_workflowAction).validateResourceIdInAAI(anyString(), eq(WorkflowType.SERVICE),
+                        .when(aaiResourceIdValidator).validateResourceIdInAAI(anyString(), eq(WorkflowType.SERVICE),
                                 eq("test"), any(RequestDetails.class), any(WorkflowResourceIds.class));
 
         SPY_workflowAction.selectExecutionList(execution);
@@ -1267,8 +1258,8 @@ public class WorkflowActionTest extends BaseTaskTest {
         List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
 
         assertEqualsBulkFlowName(ebbs, "DeleteFabricConfigurationBB", "DeactivateVfModuleBB", "DeleteVfModuleATTBB",
-                "UnassignVFModuleBB", "AssignVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB",
-                "AddFabricConfigurationBB", "ChangeModelVnfBB", "ChangeModelServiceInstanceBB");
+                "UnassignVFModuleBB", "AssignVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB", "ChangeModelVnfBB",
+                "ChangeModelServiceInstanceBB");
     }
 
     @Test
@@ -2022,906 +2013,6 @@ public class WorkflowActionTest extends BaseTaskTest {
         assertNull(x.getVolumeGroupId());
     }
 
-    private RequestDetails setupRequestDetails(String globalSubscriberId, String subscriptionServiceType,
-            String modelCustomizationId) {
-        RequestDetails reqDetails = new RequestDetails();
-        SubscriberInfo subInfo = new SubscriberInfo();
-        subInfo.setGlobalSubscriberId(globalSubscriberId);
-        reqDetails.setSubscriberInfo(subInfo);
-        RequestParameters reqParams = new RequestParameters();
-        reqParams.setSubscriptionServiceType(subscriptionServiceType);
-        reqDetails.setRequestParameters(reqParams);
-        ModelInfo modelInfo = new ModelInfo();
-        modelInfo.setModelCustomizationId(modelCustomizationId);
-        reqDetails.setModelInfo(modelInfo);
-        return reqDetails;
-    }
-
-    @Test
-    public void validateResourceIdInAAIVnfTest() throws Exception {
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
-        workflowResourceIds.setServiceInstanceId("siId123");
-        // Vnf
-        GenericVnf vnf = new GenericVnf();
-        vnf.setVnfId("id123");
-        vnf.setVnfName("vnfName123");
-        vnf.setModelCustomizationId("1234567");
-        Optional<GenericVnf> opVnf = Optional.of(vnf);
-        GenericVnf vnf2 = new GenericVnf();
-        vnf2.setVnfId("id123");
-        vnf2.setVnfName("vnfName222");
-        vnf2.setModelCustomizationId("222");
-        Optional<GenericVnf> opVnf2 = Optional.of(vnf2);
-        when(bbSetupUtils.getRelatedVnfByNameFromServiceInstance("siId123", "vnfName123")).thenReturn(opVnf);
-        when(bbSetupUtils.getRelatedVnfByNameFromServiceInstance("siId123", "vnfName222")).thenReturn(opVnf2);
-        when(bbSetupUtils.getRelatedVnfByNameFromServiceInstance("siId123", "111111")).thenReturn(Optional.empty());
-        String id = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VNF, "vnfName123", reqDetails,
-                workflowResourceIds);
-        assertEquals("id123", id);
-        String id2 = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VNF, "111111", reqDetails,
-                workflowResourceIds);
-        assertEquals("generatedId123", id2);
-
-        this.expectedException.expect(DuplicateNameException.class);
-        this.expectedException.expectMessage(containsString(
-                "generic-vnf with name (vnfName222), same parent and different customization id (222) already exists. The name must be unique."));
-        workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VNF, "vnfName222", reqDetails,
-                workflowResourceIds);
-    }
-
-    @Test
-    public void validateResourceIdInAAIVnfNotGloballyUniqueTest() throws Exception {
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
-        workflowResourceIds.setServiceInstanceId("siId123");
-
-        // Vnf
-        GenericVnfs genericVnfs = new GenericVnfs();
-        GenericVnf vnf3 = new GenericVnf();
-        vnf3.setVnfId("id123");
-        vnf3.setVnfName("vnfName333");
-        genericVnfs.getGenericVnf().add(vnf3);
-        when(bbSetupUtils.getRelatedVnfByNameFromServiceInstance("siId123", "vnfName333")).thenReturn(Optional.empty());
-        when(bbSetupUtils.getAAIVnfsGloballyByName("vnfName333")).thenReturn(genericVnfs);
-
-        this.expectedException.expect(DuplicateNameException.class);
-        this.expectedException.expectMessage(containsString(
-                "generic-vnf with name (vnfName333) id (id123) and different parent relationship already exists. The name must be unique."));
-        workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VNF, "vnfName333", reqDetails,
-                workflowResourceIds);
-    }
-
-    @Test
-    public void validateResourceIdInAAINetworkTest() throws Exception {
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
-        workflowResourceIds.setServiceInstanceId("siId123");
-
-        // Network
-        L3Network network = new L3Network();
-        network.setNetworkId("id123");
-        network.setNetworkName("name123");
-        network.setModelCustomizationId("1234567");
-        workflowResourceIds.setServiceInstanceId("siId123");
-        Optional<L3Network> opNetwork = Optional.of(network);
-        L3Network network2 = new L3Network();
-        network2.setNetworkId("id123");
-        network2.setNetworkName("networkName222");
-        network2.setModelCustomizationId("222");
-        Optional<L3Network> opNetwork2 = Optional.of(network2);
-        when(bbSetupUtils.getRelatedNetworkByNameFromServiceInstance("siId123", "name123")).thenReturn(opNetwork);
-        when(bbSetupUtils.getRelatedNetworkByNameFromServiceInstance("siId123", "networkName222"))
-                .thenReturn(opNetwork2);
-        when(bbSetupUtils.getRelatedNetworkByNameFromServiceInstance("siId123", "111111")).thenReturn(Optional.empty());
-        String id = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.NETWORK, "name123",
-                reqDetails, workflowResourceIds);
-        assertEquals("id123", id);
-        String id2 = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.NETWORK, "111111",
-                reqDetails, workflowResourceIds);
-        assertEquals("generatedId123", id2);
-
-        this.expectedException.expect(DuplicateNameException.class);
-        this.expectedException.expectMessage(containsString(
-                "l3Network with name (networkName222), same parent and different customization id (222) already exists. The name must be unique."));
-        workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.NETWORK, "networkName222", reqDetails,
-                workflowResourceIds);
-    }
-
-    @Test
-    public void validateNetworkResourceNameExistsInAAITest() throws Exception {
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
-        workflowResourceIds.setServiceInstanceId("siId123");
-
-        // Network
-        L3Network network = new L3Network();
-        network.setNetworkId("id123");
-        network.setNetworkName("name123");
-        network.setModelCustomizationId("1234567");
-        workflowResourceIds.setServiceInstanceId("siId123");
-
-        when(bbSetupUtils.getRelatedNetworkByNameFromServiceInstance("networkName333", "111111"))
-                .thenReturn(Optional.empty());
-        when(bbSetupUtils.existsAAINetworksGloballyByName("networkName333")).thenReturn(true);
-
-        this.expectedException.expect(DuplicateNameException.class);
-        this.expectedException.expectMessage(containsString(
-                "l3Network with name (networkName333) id (siId123) and different parent relationship already exists. The name must be unique."));
-        workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.NETWORK, "networkName333", reqDetails,
-                workflowResourceIds);
-    }
-
-    @Test
-    public void validateResourceIdInAAIVfModuleTest() throws Exception {
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
-        workflowResourceIds.setServiceInstanceId("siId123");
-
-        GenericVnf vnf = new GenericVnf();
-        vnf.setVnfId("id123");
-        vnf.setVnfName("vnfName123");
-        vnf.setModelCustomizationId("222");
-
-        // VfModule
-        VfModules vfModules = new VfModules();
-        VfModule vfModule = new VfModule();
-        vfModule.setVfModuleId("id123");
-        vfModule.setVfModuleName("name123");
-        vfModule.setModelCustomizationId("1234567");
-        vfModules.getVfModule().add(vfModule);
-        vnf.setVfModules(vfModules);
-        workflowResourceIds.setVnfId("id123");
-        when(bbSetupUtils.getAAIGenericVnf("id123")).thenReturn(vnf);
-        String id = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VFMODULE, "name123",
-                reqDetails, workflowResourceIds);
-        assertEquals("id123", id);
-
-        GenericVnf vnf1 = new GenericVnf();
-        VfModules vfModules2 = new VfModules();
-        VfModule vfModule2 = new VfModule();
-        vfModule2.setVfModuleId("id123");
-        vfModule2.setVfModuleName("vFModName222");
-        vfModule2.setModelCustomizationId("222");
-        vfModules2.getVfModule().add(vfModule2);
-        vnf1.setVfModules(vfModules2);
-        workflowResourceIds.setVnfId("id111");
-        when(bbSetupUtils.getAAIGenericVnf("id111")).thenReturn(vnf1);
-        String id2 = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VFMODULE, "111111",
-                reqDetails, workflowResourceIds);
-        assertEquals("generatedId123", id2);
-
-        this.expectedException.expect(DuplicateNameException.class);
-        this.expectedException.expectMessage(containsString(
-                "vfModule with name (vFModName222), same parent and different customization id (1234567) already exists. The name must be unique."));
-        workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VFMODULE, "vFModName222", reqDetails,
-                workflowResourceIds);
-    }
-
-    @Test
-    public void validateResourceIdInAAIVfModuleNotGloballyUniqueTest() throws Exception {
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
-        workflowResourceIds.setVnfId("id111");
-
-        GenericVnf vnf1 = new GenericVnf();
-        workflowResourceIds.setVnfId("id111");
-        when(bbSetupUtils.getAAIGenericVnf("id111")).thenReturn(vnf1);
-
-        when(bbSetupUtils.existsAAIVfModuleGloballyByName("vFModName333")).thenReturn(true);
-        this.expectedException.expect(DuplicateNameException.class);
-        this.expectedException.expectMessage(
-                containsString("vfModule with name vFModName333 already exists. The name must be unique."));
-        workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VFMODULE, "vFModName333", reqDetails,
-                workflowResourceIds);
-    }
-
-    @Test
-    public void validateResourceIdInAAIVolumeGroupTest() throws Exception {
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
-        workflowResourceIds.setServiceInstanceId("siId123");
-
-        GenericVnf vnf = new GenericVnf();
-        vnf.setVnfId("id123");
-        vnf.setVnfName("vnfName123");
-        vnf.setModelCustomizationId("1234567");
-
-        GenericVnf vnf2 = new GenericVnf();
-        vnf2.setVnfId("id123");
-        vnf2.setVnfName("vnfName123");
-        vnf2.setModelCustomizationId("222");
-
-        // VolumeGroup
-        VolumeGroup volumeGroup = new VolumeGroup();
-        volumeGroup.setVolumeGroupId("id123");
-        volumeGroup.setVolumeGroupName("name123");
-        volumeGroup.setVfModuleModelCustomizationId("1234567");
-        workflowResourceIds.setVnfId("id123");
-        Optional<VolumeGroup> opVolumeGroup = Optional.of(volumeGroup);
-
-        workflowResourceIds.setVnfId("id123");
-
-        when(bbSetupUtils.getAAIGenericVnf("id123")).thenReturn(vnf);
-        when(bbSetupUtils.getRelatedVolumeGroupByNameFromVnf("id123", "name123")).thenReturn(opVolumeGroup);
-        String id = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VOLUMEGROUP, "name123",
-                reqDetails, workflowResourceIds);
-        assertEquals("id123", id);
-
-        when(bbSetupUtils.getAAIGenericVnf("id123")).thenReturn(vnf2);
-        when(bbSetupUtils.getRelatedVolumeGroupByNameFromVfModule("id123", "id123", "111111"))
-                .thenReturn(opVolumeGroup);
-
-        when(bbSetupUtils.getRelatedVolumeGroupByNameFromVnf("id123", "111111")).thenReturn(Optional.empty());
-        String id2 = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VOLUMEGROUP, "111111",
-                reqDetails, workflowResourceIds);
-        assertEquals("generatedId123", id2);
-    }
-
-    @Test
-    public void validatesourceIdInAAIVolumeGroupNotGloballyUniqueTest() throws Exception {
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
-        workflowResourceIds.setVnfId("id123");
-        GenericVnf vnf = new GenericVnf();
-        vnf.setVnfId("id123");
-        when(bbSetupUtils.getAAIGenericVnf("id123")).thenReturn(vnf);
-        when(bbSetupUtils.getRelatedVolumeGroupByNameFromVnf("id123", "testVolumeGroup")).thenReturn(Optional.empty());
-
-        when(bbSetupUtils.existsAAIVolumeGroupGloballyByName("testVolumeGroup")).thenReturn(true);
-        this.expectedException.expect(DuplicateNameException.class);
-        this.expectedException.expectMessage(
-                containsString("volumeGroup with name testVolumeGroup already exists. The name must be unique."));
-        workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VOLUMEGROUP, "testVolumeGroup",
-                reqDetails, workflowResourceIds);
-    }
-
-    @Test
-    public void validateResourceIdInAAIConfigurationTest() throws Exception {
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
-        workflowResourceIds.setServiceInstanceId("siId123");
-
-        // Configuration
-        org.onap.aai.domain.yang.Configuration configuration = new org.onap.aai.domain.yang.Configuration();
-        configuration.setConfigurationId("id123");
-        configuration.setConfigurationName("name123");
-        configuration.setModelCustomizationId("1234567");
-        Optional<org.onap.aai.domain.yang.Configuration> opConfiguration = Optional.of(configuration);
-
-        org.onap.aai.domain.yang.Configuration configuration2 = new org.onap.aai.domain.yang.Configuration();
-        configuration2.setConfigurationId("id123");
-        configuration2.setConfigurationName("name123");
-        configuration2.setModelCustomizationId("222");
-        Optional<org.onap.aai.domain.yang.Configuration> opConfiguration2 = Optional.of(configuration2);
-
-        workflowResourceIds.setVnfId("id123");
-
-        when(bbSetupUtils.getRelatedConfigurationByNameFromServiceInstance("siId123", "name123"))
-                .thenReturn(opConfiguration);
-        String id = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.CONFIGURATION, "name123",
-                reqDetails, workflowResourceIds);
-        assertEquals("id123", id);
-
-        when(bbSetupUtils.getRelatedConfigurationByNameFromServiceInstance("siId123", "111111"))
-                .thenReturn(Optional.empty());
-        String id2 = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.CONFIGURATION, "111111",
-                reqDetails, workflowResourceIds);
-        assertEquals("generatedId123", id2);
-
-        when(bbSetupUtils.getRelatedConfigurationByNameFromServiceInstance("siId123", "name222"))
-                .thenReturn(opConfiguration2);
-        this.expectedException.expect(DuplicateNameException.class);
-        this.expectedException.expectMessage(containsString(
-                "configuration with name (name222), same parent and different customization id (id123) already exists. The name must be unique."));
-        workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.CONFIGURATION, "name222", reqDetails,
-                workflowResourceIds);
-    }
-
-    @Test
-    public void validateResourceIdInAAIConfigurationNotGloballyUniqueTest() throws Exception {
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
-        workflowResourceIds.setServiceInstanceId("siId123");
-
-        when(bbSetupUtils.getRelatedConfigurationByNameFromServiceInstance("siId123", "testConfig"))
-                .thenReturn(Optional.empty());
-        when(bbSetupUtils.existsAAIConfigurationGloballyByName("testConfig")).thenReturn(true);
-        this.expectedException.expect(DuplicateNameException.class);
-        this.expectedException.expectMessage(
-                containsString("configuration with name testConfig already exists. The name must be unique."));
-        workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.CONFIGURATION, "testConfig", reqDetails,
-                workflowResourceIds);
-    }
-
-    @Test
-    public void validateResourceIdInAAISITest() throws Exception {
-        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
-        workflowResourceIds.setServiceInstanceId("siId123");
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        reqDetails.getModelInfo().setModelVersionId("1234567");
-
-        ServiceInstance si = new ServiceInstance();
-        si.setServiceInstanceId("siId123");
-        si.setModelVersionId("1234567");
-        ServiceInstances serviceInstances = new ServiceInstances();
-        serviceInstances.getServiceInstance().add(si);
-        Optional<ServiceInstance> siOp = Optional.of(si);
-        ServiceInstance si2 = new ServiceInstance();
-        si2.setServiceInstanceId("siId222");
-        si2.setModelVersionId("22222");
-        si2.setServiceInstanceName("siName222");
-        Optional<ServiceInstance> siOp2 = Optional.of(si2);
-        ServiceInstances serviceInstances2 = new ServiceInstances();
-        serviceInstances2.getServiceInstance().add(si2);
-
-        when(bbSetupUtils.getAAIServiceInstanceByName("id123", "subServiceType123", "siName123")).thenReturn(siOp);
-        when(bbSetupUtils.getAAIServiceInstanceByName("id123", "subServiceType123", "siName222")).thenReturn(siOp2);
-        when(bbSetupUtils.getAAIServiceInstanceByName("id123", "subServiceType123", "111111"))
-                .thenReturn(Optional.empty());
-
-        when(bbSetupUtils.getAAIServiceInstancesGloballyByName("siName123")).thenReturn(serviceInstances);
-        String id = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.SERVICE, "siName123",
-                reqDetails, workflowResourceIds);
-        assertEquals("siId123", id);
-        String id2 = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.SERVICE, "111111",
-                reqDetails, workflowResourceIds);
-        assertEquals("generatedId123", id2);
-
-        when(bbSetupUtils.getAAIServiceInstancesGloballyByName("siName222")).thenReturn(serviceInstances2);
-        this.expectedException.expect(DuplicateNameException.class);
-        this.expectedException.expectMessage(containsString(
-                "serviceInstance with name (siName222) and different version id (1234567) already exists. The name must be unique."));
-        workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.SERVICE, "siName222", reqDetails,
-                workflowResourceIds);
-    }
-
-    @Test
-    public void validateResourceIdInAAIMultipleSITest() throws Exception {
-        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
-        workflowResourceIds.setServiceInstanceId("siId123");
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        reqDetails.getModelInfo().setModelVersionId("1234567");
-
-        ServiceInstance si = new ServiceInstance();
-        si.setServiceInstanceId("siId123");
-        si.setModelVersionId("1234567");
-        ServiceInstances serviceInstances = new ServiceInstances();
-        serviceInstances.getServiceInstance().add(si);
-
-        ServiceInstance si2 = new ServiceInstance();
-        si2.setServiceInstanceId("siId222");
-        si2.setModelVersionId("22222");
-        si2.setServiceInstanceName("siName222");
-        serviceInstances.getServiceInstance().add(si2);
-
-        when(bbSetupUtils.getAAIServiceInstanceByName("id123", "subServiceType123", "siId123"))
-                .thenReturn(Optional.empty());
-
-        when(bbSetupUtils.getAAIServiceInstancesGloballyByName("siName123")).thenReturn(serviceInstances);
-
-        this.expectedException.expect(DuplicateNameException.class);
-        this.expectedException.expectMessage(containsString(
-                "serviceInstance with name (siName123) and multiple combination of model-version-id + service-type + global-customer-id already exists. The name must be unique."));
-        workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.SERVICE, "siName123", reqDetails,
-                workflowResourceIds);
-    }
-
-    @Test
-    public void validateResourceIdInAAISIExistsTest() throws Exception {
-        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
-        workflowResourceIds.setServiceInstanceId("siId123");
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        reqDetails.getModelInfo().setModelVersionId("1234567");
-
-        ServiceInstance si = new ServiceInstance();
-        si.setServiceInstanceId("siId123");
-        si.setModelVersionId("1234567");
-        ServiceInstances serviceInstances = new ServiceInstances();
-        serviceInstances.getServiceInstance().add(si);
-
-        when(bbSetupUtils.getAAIServiceInstanceByName("id123", "subServiceType123", "siId123"))
-                .thenReturn(Optional.empty());
-
-        when(bbSetupUtils.getAAIServiceInstancesGloballyByName("siName123")).thenReturn(serviceInstances);
-
-        Map<String, String> uriKeys = new HashMap<>();
-        uriKeys.put(AAIFluentTypeBuilder.Types.CUSTOMER.getUriParams().globalCustomerId, "globalCustomerId");
-        uriKeys.put(AAIFluentTypeBuilder.Types.SERVICE_SUBSCRIPTION.getUriParams().serviceType, "serviceType");
-
-        when(bbSetupUtils.getURIKeysFromServiceInstance("siId123")).thenReturn(uriKeys);
-
-        this.expectedException.expect(DuplicateNameException.class);
-        this.expectedException.expectMessage(containsString(
-                "serviceInstance with name (siName123) and global-customer-id (globalCustomerId), service-type (serviceType), model-version-id (1234567) already exists. The name must be unique."));
-        workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.SERVICE, "siName123", reqDetails,
-                workflowResourceIds);
-    }
-
-    @Test
-    public void validateServiceResourceIdInAAINoDupTest() throws Exception {
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        reqDetails.getModelInfo().setModelVersionId("1234567");
-        when(bbSetupUtils.getAAIServiceInstanceByName("id123", "subServiceType123", "siName123"))
-                .thenReturn(Optional.empty());
-        when(bbSetupUtils.getAAIServiceInstancesGloballyByName("siName123")).thenReturn(null);
-        String id = workflowAction.validateServiceResourceIdInAAI("generatedId123", "siName123", reqDetails);
-        assertEquals("generatedId123", id);
-    }
-
-    @Test
-    public void validateServiceResourceIdInAAISameModelVersionId() throws Exception {
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        reqDetails.getModelInfo().setModelVersionId("1234567");
-
-        ServiceInstance si = new ServiceInstance();
-        si.setServiceInstanceId("siId123");
-        si.setModelVersionId("1234567");
-        Optional<ServiceInstance> siOp = Optional.of(si);
-
-        when(bbSetupUtils.getAAIServiceInstanceByName("id123", "subServiceType123", "siName123")).thenReturn(siOp);
-        String id = workflowAction.validateServiceResourceIdInAAI("generatedId123", "siName123", reqDetails);
-        assertEquals("siId123", id);
-    }
-
-    @Test
-    public void validateServiceResourceIdInAAIDifferentModelVersionId() throws Exception {
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        reqDetails.getModelInfo().setModelVersionId("1234567");
-
-        ServiceInstance si = new ServiceInstance();
-        si.setServiceInstanceId("siId123");
-        si.setModelVersionId("9999999");
-        ServiceInstances serviceInstances = new ServiceInstances();
-        serviceInstances.getServiceInstance().add(si);
-        Optional<ServiceInstance> siOp = Optional.of(si);
-
-        when(bbSetupUtils.getAAIServiceInstanceByName("id123", "subServiceType123", "siName123")).thenReturn(siOp);
-
-        this.expectedException.expect(DuplicateNameException.class);
-        this.expectedException.expectMessage(containsString(
-                "serviceInstance with name (siName123) and different version id (1234567) already exists. The name must be unique."));
-
-        String id = workflowAction.validateServiceResourceIdInAAI("generatedId123", "siName123", reqDetails);
-        assertEquals("siId123", id);
-    }
-
-    @Test
-    public void validateServiceResourceIdInAAIDuplicateNameTest() throws Exception {
-
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        reqDetails.getModelInfo().setModelVersionId("1234567");
-
-        ServiceInstance si = new ServiceInstance();
-        si.setServiceInstanceId("siId123");
-        si.setModelVersionId("1234567");
-
-        ServiceInstances serviceInstances = new ServiceInstances();
-        serviceInstances.getServiceInstance().add(si);
-
-        when(bbSetupUtils.getAAIServiceInstanceByName("id123", "subServiceType123", "siName"))
-                .thenReturn(Optional.empty());
-        when(bbSetupUtils.getAAIServiceInstancesGloballyByName("siName")).thenReturn(serviceInstances);
-
-        this.expectedException.expect(DuplicateNameException.class);
-        this.expectedException.expectMessage(containsString(
-                "serviceInstance with name (siName) and global-customer-id (null), service-type (null), model-version-id (1234567) already exists. The name must be unique."));
-
-        workflowAction.validateServiceResourceIdInAAI("generatedId123", "siName", reqDetails);
-    }
-
-    @Test
-    public void validateServiceResourceIdInAAIDuplicateNameMultipleTest() throws Exception {
-
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        reqDetails.getModelInfo().setModelVersionId("1234567");
-
-        ServiceInstance si = new ServiceInstance();
-        si.setServiceInstanceId("siId123");
-        si.setModelVersionId("1234567");
-
-        ServiceInstance si2 = new ServiceInstance();
-        si2.setServiceInstanceId("siId222");
-        si2.setModelVersionId("22222");
-        si2.setServiceInstanceName("siName222");
-
-        ServiceInstances serviceInstances = new ServiceInstances();
-        serviceInstances.getServiceInstance().add(si);
-        serviceInstances.getServiceInstance().add(si2);
-
-        when(bbSetupUtils.getAAIServiceInstanceByName("id123", "subServiceType123", "siName"))
-                .thenReturn(Optional.empty());
-        when(bbSetupUtils.getAAIServiceInstancesGloballyByName("siName")).thenReturn(serviceInstances);
-
-        this.expectedException.expect(DuplicateNameException.class);
-        this.expectedException.expectMessage(containsString(
-                "serviceInstance with name (siName) and multiple combination of model-version-id + service-type + global-customer-id already exists. The name must be unique."));
-
-        workflowAction.validateServiceResourceIdInAAI("generatedId123", "siName", reqDetails);
-    }
-
-    @Test
-    public void validateNetworkResourceIdInAAITest() throws Exception {
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
-        workflowResourceIds.setServiceInstanceId("siId123");
-
-        when(bbSetupUtils.getRelatedNetworkByNameFromServiceInstance("siId123", "name123"))
-                .thenReturn(Optional.empty());
-        when(bbSetupUtils.existsAAINetworksGloballyByName("name123")).thenReturn(false);
-
-        String id = workflowAction.validateNetworkResourceIdInAAI("generatedId123", "name123", reqDetails,
-                workflowResourceIds);
-        assertEquals("generatedId123", id);
-    }
-
-    @Test
-    public void validateNetworkResourceIdInAAISameModelCustIdTest() throws Exception {
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
-        workflowResourceIds.setServiceInstanceId("siId123");
-
-        L3Network network = new L3Network();
-        network.setNetworkId("id123");
-        network.setNetworkName("name123");
-        network.setModelCustomizationId("1234567");
-        Optional<L3Network> opNetwork = Optional.of(network);
-
-        when(bbSetupUtils.getRelatedNetworkByNameFromServiceInstance("siId123", "name123")).thenReturn(opNetwork);
-
-        String id = workflowAction.validateNetworkResourceIdInAAI("generatedId123", "name123", reqDetails,
-                workflowResourceIds);
-        assertEquals("id123", id);
-    }
-
-    @Test
-    public void validateNetworkResourceIdInAAIDuplicateNameTest() throws Exception {
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
-        workflowResourceIds.setServiceInstanceId("siId123");
-
-        L3Network network = new L3Network();
-        network.setNetworkId("id123");
-        network.setNetworkName("name123");
-        network.setModelCustomizationId("9999999");
-        Optional<L3Network> opNetwork = Optional.of(network);
-
-        when(bbSetupUtils.getRelatedNetworkByNameFromServiceInstance("siId123", "name123")).thenReturn(opNetwork);
-
-        this.expectedException.expect(DuplicateNameException.class);
-        this.expectedException.expectMessage(containsString(
-                "l3Network with name (name123), same parent and different customization id (9999999) already exists. The name must be unique."));
-
-        workflowAction.validateNetworkResourceIdInAAI("generatedId123", "name123", reqDetails, workflowResourceIds);
-    }
-
-    @Test
-    public void validateNetworkResourceIdInAAINotGloballyUniqueTest() throws Exception {
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
-        workflowResourceIds.setServiceInstanceId("siId123");
-
-        when(bbSetupUtils.getRelatedNetworkByNameFromServiceInstance("siId123", "name123"))
-                .thenReturn(Optional.empty());
-        when(bbSetupUtils.existsAAINetworksGloballyByName("name123")).thenReturn(true);
-
-        this.expectedException.expect(DuplicateNameException.class);
-        this.expectedException.expectMessage(containsString(
-                "l3Network with name (name123) id (siId123) and different parent relationship already exists. The name must be unique."));
-
-        workflowAction.validateNetworkResourceIdInAAI("generatedId123", "name123", reqDetails, workflowResourceIds);
-    }
-
-    @Test
-    public void validateVnfResourceIdInAAITest() throws Exception {
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
-        workflowResourceIds.setServiceInstanceId("siId123");
-        when(bbSetupUtils.getRelatedVnfByNameFromServiceInstance("siId123", "vnfName123")).thenReturn(Optional.empty());
-        String id = workflowAction.validateVnfResourceIdInAAI("generatedId123", "vnfName123", reqDetails,
-                workflowResourceIds);
-        assertEquals("generatedId123", id);
-    }
-
-    @Test
-    public void validateVnfResourceIdInAAISameModelCustomizationIdTest() throws Exception {
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
-        workflowResourceIds.setServiceInstanceId("siId123");
-
-        GenericVnf vnf = new GenericVnf();
-        vnf.setVnfId("id123");
-        vnf.setVnfName("vnfName123");
-        vnf.setModelCustomizationId("1234567");
-        Optional<GenericVnf> opVnf = Optional.of(vnf);
-
-        when(bbSetupUtils.getRelatedVnfByNameFromServiceInstance("siId123", "vnfName123")).thenReturn(opVnf);
-        String id = workflowAction.validateVnfResourceIdInAAI("generatedId123", "vnfName123", reqDetails,
-                workflowResourceIds);
-        assertEquals("id123", id);
-    }
-
-    @Test
-    public void validateVnfResourceIdInAAIDiffModelCustomizationIdTest() throws Exception {
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
-        workflowResourceIds.setServiceInstanceId("siId123");
-
-        GenericVnf vnf = new GenericVnf();
-        vnf.setVnfId("id123");
-        vnf.setVnfName("vnfName123");
-        vnf.setModelCustomizationId("9999999");
-        Optional<GenericVnf> opVnf = Optional.of(vnf);
-
-        when(bbSetupUtils.getRelatedVnfByNameFromServiceInstance("siId123", "vnfName123")).thenReturn(opVnf);
-
-        this.expectedException.expect(DuplicateNameException.class);
-        this.expectedException.expectMessage(containsString(
-                "generic-vnf with name (vnfName123), same parent and different customization id (9999999) already exists. The name must be unique."));
-
-        workflowAction.validateVnfResourceIdInAAI("generatedId123", "vnfName123", reqDetails, workflowResourceIds);
-    }
-
-    @Test
-    public void validateVnfResourceIdInAAINotGloballyUniqueTest() throws Exception {
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
-        workflowResourceIds.setServiceInstanceId("siId123");
-
-
-        GenericVnf vnf = new GenericVnf();
-        vnf.setVnfId("id123");
-        vnf.setVnfName("vnfName123");
-        GenericVnfs genericVnfs = new GenericVnfs();
-        genericVnfs.getGenericVnf().add(vnf);
-
-        when(bbSetupUtils.getRelatedVnfByNameFromServiceInstance("siId123", "vnfName123")).thenReturn(Optional.empty());
-        when(bbSetupUtils.getAAIVnfsGloballyByName("vnfName123")).thenReturn(genericVnfs);
-
-        this.expectedException.expect(DuplicateNameException.class);
-        this.expectedException.expectMessage(containsString(
-                "generic-vnf with name (vnfName123) id (id123) and different parent relationship already exists. The name must be unique."));
-
-        workflowAction.validateVnfResourceIdInAAI("generatedId123", "vnfName123", reqDetails, workflowResourceIds);
-    }
-
-    @Test
-    public void validateVfModuleResourceIdTest() throws Exception {
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
-        workflowResourceIds.setVnfId("vnfId123");
-
-        when(bbSetupUtils.getAAIGenericVnf("id123")).thenReturn(null);
-        when(bbSetupUtils.existsAAIVfModuleGloballyByName("name123")).thenReturn(false);
-
-        String id = workflowAction.validateVfModuleResourceIdInAAI("generatedId123", "name123", reqDetails,
-                workflowResourceIds);
-        assertEquals("generatedId123", id);
-    }
-
-    @Test
-    public void validateVfModuleResourceIdSameModelCustIdTest() throws Exception {
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
-        workflowResourceIds.setVnfId("vnfId123");
-
-        VfModules vfModules = new VfModules();
-        VfModule vfModule = new VfModule();
-        vfModule.setVfModuleId("id123");
-        vfModule.setVfModuleName("name123");
-        vfModule.setModelCustomizationId("1234567");
-        vfModules.getVfModule().add(vfModule);
-
-        GenericVnf vnf = new GenericVnf();
-        vnf.setVnfId("id123");
-        vnf.setVnfName("vnfName123");
-        vnf.setVfModules(vfModules);
-
-        when(bbSetupUtils.getAAIGenericVnf("vnfId123")).thenReturn(vnf);
-
-        String id = workflowAction.validateVfModuleResourceIdInAAI("generatedId123", "name123", reqDetails,
-                workflowResourceIds);
-        assertEquals("id123", id);
-    }
-
-    @Test
-    public void validateVfModuleResourceIdDifferentModelCustIdTest() throws Exception {
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
-        workflowResourceIds.setVnfId("vnfId123");
-
-        VfModules vfModules = new VfModules();
-        VfModule vfModule = new VfModule();
-        vfModule.setVfModuleId("id123");
-        vfModule.setVfModuleName("name123");
-        vfModule.setModelCustomizationId("9999999");
-        vfModules.getVfModule().add(vfModule);
-
-        GenericVnf vnf = new GenericVnf();
-        vnf.setVnfId("id123");
-        vnf.setVnfName("vnfName123");
-        vnf.setVfModules(vfModules);
-
-        when(bbSetupUtils.getAAIGenericVnf("vnfId123")).thenReturn(vnf);
-
-        this.expectedException.expect(DuplicateNameException.class);
-        this.expectedException.expectMessage(containsString(
-                "vfModule with name (name123), same parent and different customization id (1234567) already exists. The name must be unique."));
-
-        workflowAction.validateVfModuleResourceIdInAAI("generatedId123", "name123", reqDetails, workflowResourceIds);
-
-    }
-
-    @Test
-    public void validateVfModuleResourceIdNotGloballyUniqueTest() throws Exception {
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
-        workflowResourceIds.setVnfId("vnfId123");
-
-        when(bbSetupUtils.getAAIGenericVnf("id123")).thenReturn(null);
-        when(bbSetupUtils.existsAAIVfModuleGloballyByName("name123")).thenReturn(true);
-
-        this.expectedException.expect(DuplicateNameException.class);
-        this.expectedException
-                .expectMessage(containsString("vfModule with name name123 already exists. The name must be unique."));
-
-        workflowAction.validateVfModuleResourceIdInAAI("generatedId123", "name123", reqDetails, workflowResourceIds);
-    }
-
-    @Test
-    public void validateVolumeGroupResourceIdInAAITest() throws Exception {
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
-        workflowResourceIds.setVnfId("vnfId123");
-
-        when(bbSetupUtils.getRelatedVolumeGroupByNameFromVnf("id123", "name123")).thenReturn(Optional.empty());
-        when(bbSetupUtils.existsAAIVolumeGroupGloballyByName("name123")).thenReturn(false);
-
-        String id = workflowAction.validateVolumeGroupResourceIdInAAI("generatedId123", "name123", reqDetails,
-                workflowResourceIds);
-        assertEquals("generatedId123", id);
-    }
-
-    @Test
-    public void validateVolumeGroupResourceIdInAAISameModelCustIdTest() throws Exception {
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
-        workflowResourceIds.setServiceInstanceId("siId123");
-        workflowResourceIds.setVnfId("vnfId123");
-
-        VolumeGroup volumeGroup = new VolumeGroup();
-        volumeGroup.setVolumeGroupId("id123");
-        volumeGroup.setVolumeGroupName("name123");
-        volumeGroup.setVfModuleModelCustomizationId("1234567");
-
-        Optional<VolumeGroup> opVolumeGroup = Optional.of(volumeGroup);
-
-        when(bbSetupUtils.getRelatedVolumeGroupByNameFromVnf("vnfId123", "name123")).thenReturn(opVolumeGroup);
-        String id = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VOLUMEGROUP, "name123",
-                reqDetails, workflowResourceIds);
-
-        assertEquals("id123", id);
-    }
-
-    @Test
-    public void validateVolumeGroupResourceIdInAAIDifferentModelCustIdTest() throws Exception {
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
-        workflowResourceIds.setServiceInstanceId("siId123");
-        workflowResourceIds.setVnfId("vnfId123");
-
-        VolumeGroup volumeGroup = new VolumeGroup();
-        volumeGroup.setVolumeGroupId("id123");
-        volumeGroup.setVolumeGroupName("name123");
-        volumeGroup.setVfModuleModelCustomizationId("9999999");
-
-        Optional<VolumeGroup> opVolumeGroup = Optional.of(volumeGroup);
-
-        when(bbSetupUtils.getRelatedVolumeGroupByNameFromVnf("vnfId123", "name123")).thenReturn(opVolumeGroup);
-
-        this.expectedException.expect(DuplicateNameException.class);
-        this.expectedException.expectMessage(
-                containsString("volumeGroup with name name123 already exists. The name must be unique."));
-
-        workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VOLUMEGROUP, "name123", reqDetails,
-                workflowResourceIds);
-    }
-
-    @Test
-    public void validateVolumeGroupResourceIdInAAINotGloballyUniqueTest() throws Exception {
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
-        workflowResourceIds.setVnfId("vnfId123");
-
-        when(bbSetupUtils.getRelatedVolumeGroupByNameFromVnf("vnfId123", "name123")).thenReturn(Optional.empty());
-        when(bbSetupUtils.existsAAIVolumeGroupGloballyByName("name123")).thenReturn(true);
-
-        this.expectedException.expect(DuplicateNameException.class);
-        this.expectedException.expectMessage(
-                containsString("volumeGroup with name name123 already exists. The name must be unique."));
-
-        workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VOLUMEGROUP, "name123", reqDetails,
-                workflowResourceIds);
-    }
-
-    @Test
-    public void validateConfigurationResourceIdInAAITest() throws Exception {
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
-        workflowResourceIds.setServiceInstanceId("siId123");
-
-        when(bbSetupUtils.getRelatedConfigurationByNameFromServiceInstance("siId123", "name123"))
-                .thenReturn(Optional.empty());
-        when(bbSetupUtils.existsAAIConfigurationGloballyByName("name123")).thenReturn(false);
-
-        String id = workflowAction.validateConfigurationResourceIdInAAI("generatedId123", "name123", reqDetails,
-                workflowResourceIds);
-        assertEquals("generatedId123", id);
-    }
-
-    @Test
-    public void validateConfigurationResourceIdInAAISameModelCustIdTest() throws Exception {
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
-        workflowResourceIds.setServiceInstanceId("siId123");
-
-        org.onap.aai.domain.yang.Configuration configuration = new org.onap.aai.domain.yang.Configuration();
-        configuration.setConfigurationId("id123");
-        configuration.setConfigurationName("name123");
-        configuration.setModelCustomizationId("1234567");
-        Optional<org.onap.aai.domain.yang.Configuration> opConfiguration = Optional.of(configuration);
-
-        when(bbSetupUtils.getRelatedConfigurationByNameFromServiceInstance("siId123", "name123"))
-                .thenReturn(opConfiguration);
-        when(bbSetupUtils.existsAAIConfigurationGloballyByName("name123")).thenReturn(false);
-
-        String id = workflowAction.validateConfigurationResourceIdInAAI("generatedId123", "name123", reqDetails,
-                workflowResourceIds);
-        assertEquals("id123", id);
-    }
-
-    @Test
-    public void validateConfigurationResourceIdInAAIDifferentModelCustIdTest() throws Exception {
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
-        workflowResourceIds.setServiceInstanceId("siId123");
-
-        org.onap.aai.domain.yang.Configuration configuration = new org.onap.aai.domain.yang.Configuration();
-        configuration.setConfigurationId("id123");
-        configuration.setConfigurationName("name123");
-        configuration.setModelCustomizationId("9999999");
-        Optional<org.onap.aai.domain.yang.Configuration> opConfiguration = Optional.of(configuration);
-
-        when(bbSetupUtils.getRelatedConfigurationByNameFromServiceInstance("siId123", "name123"))
-                .thenReturn(opConfiguration);
-        when(bbSetupUtils.existsAAIConfigurationGloballyByName("name123")).thenReturn(false);
-
-        this.expectedException.expect(DuplicateNameException.class);
-        this.expectedException.expectMessage(containsString(
-                "configuration with name (name123), same parent and different customization id (id123) already exists. The name must be unique."));
-
-        workflowAction.validateConfigurationResourceIdInAAI("generatedId123", "name123", reqDetails,
-                workflowResourceIds);
-    }
-
-    @Test
-    public void validateConfigurationResourceIdInAAINotGloballyUniqueTest() throws Exception {
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
-        workflowResourceIds.setServiceInstanceId("siId123");
-
-        when(bbSetupUtils.getRelatedConfigurationByNameFromServiceInstance("siId123", "name123"))
-                .thenReturn(Optional.empty());
-        when(bbSetupUtils.existsAAIConfigurationGloballyByName("name123")).thenReturn(true);
-
-        this.expectedException.expect(DuplicateNameException.class);
-        this.expectedException.expectMessage(
-                containsString("configuration with name name123 already exists. The name must be unique."));
-
-        workflowAction.validateConfigurationResourceIdInAAI("generatedId123", "name123", reqDetails,
-                workflowResourceIds);
-    }
-
     @Test
     public void handleRuntimeExceptionTest() {
         execution.setVariable("BPMN_javaExpMsg", "test runtime error message");
index 697f2c0..246c61d 100644 (file)
@@ -39,20 +39,22 @@ This setup is overridden by the override.yaml file which is stored in the OOM pr
 Override.yaml file can be edited directly in case of local ONAP setup. This file is loaded into
 container through configmap.
 
-**Note** : If you want to change config stored in override.yaml on working deployment, you have to edit k8s
-configmap. Due to insufficient permissions it is not possible directly in the container. After that pod have 
-to be restarted.
+.. note::
+ If you want to change config stored in override.yaml on working deployment, you have to edit k8s
+ configmap. Due to insufficient permissions it is not possible directly in the container. After that pod have 
+ to be restarted.
 
-**kubectl -n onap edit configmap dev-so-monitoring-app-configmap**
+.. code-block:: bash
+ kubectl -n onap edit configmap dev-so-monitoring-app-configmap
 
 .. image:: ../images/configmap.png
 
 Special care needs to be given to the indentation. Spring needs to be inline with the mso already present and others
 added accordingly.
 
-**Attention! The default setup of the OOM makes SO Monitoring password is being automatically generated during ONAP
-deployment and injected through k8s secret**
-
+.. warning::
+Attention! The default setup of the OOM makes SO Monitoring password is being automatically generated during ONAP
+deployment and injected through k8s secret
 
 2. Setup, retrieve and edit default SO Monitoring password
 ----------------------------------------------------------
@@ -89,19 +91,25 @@ Alternative way (**not recommended**) is to add password entry in the **oom/kube
 
 To retrieve actual password for SO Monitoring on existing ONAP install, run the following command:
 
-**kubectl get secret -n onap dev-so-monitoring-app-user-creds -o json | jq -r .data.password | base64 --decode**
+.. code-block:: bash
+
+ kubectl get secret -n onap dev-so-monitoring-app-user-creds -o json | jq -r .data.password | base64 --decode
 
 .. image:: ../images/so-monitoring-password.png
 
 To change actual password on existing ONAP install, **dev-so-monitoring-app-user-creds** secret has to be modified.
 
-**kubectl edit secret -n onap dev-so-monitoring-app-user-creds**
+.. code-block:: bash
+
+ kubectl edit secret -n onap dev-so-monitoring-app-user-creds
 
 .. image:: ../images/so-monitoring-secret.png
 
 Edit password entry, which has to be given in base64 form. Base64 form of password can be obtained by running:
 
-**echo 'YOUR_PASSWORD' | base64**
+.. code-block:: bash
+ echo 'YOUR_PASSWORD' | base64
 
 .. image:: ../images/so-monitorring-base64-password.png
 
@@ -113,11 +121,13 @@ Once, password was edited, pod has to be restarted.
 
 Identify the external port which is mapped to SO Monitoring using the following command. The default port is 30224 :
 
-**sudo kubectl -n onap get svc | grep so-monitoring**
+.. code-block:: bash
+
+ sudo kubectl -n onap get svc | grep so-monitoring
 
 .. image:: ../images/nodemap.png
 
-Then access the UI of SO Monitoring, for example by  https://<IP>:30224/ 
+Then access the UI of SO Monitoring, by default https://<k8s-worker-ip>:30224/
 
 .. image:: ../images/ui.png
 
@@ -131,6 +141,8 @@ In order to make the service only reachable from within the cluster, ClusterIP s
 
 Command used to edit the service configuration of SO Monitoring is:
 
-**sudo kubectl edit svc so-monitoring -n onap**
+.. code-block:: bash
+
+ sudo kubectl edit svc so-monitoring -n onap
 
 .. image:: ../images/nodeport.png
index d823b40..de12fc4 100644 (file)
@@ -190,7 +190,8 @@ Quick Links:
 
 **Known Issues**
 *  `SO-3403 <https://jira.onap.org/browse/SO-3403>`_ - The functionality of the SO cnf-adapter will be tested further and will be delivered by the Guilin Maintenance Release as a 1.7.11 patch.
-*   `SO-3237 <https://jira.onap.org/browse/SO-SO-3237>`_ - Exposed HTTP port. 
+*  `SO-3237 <https://jira.onap.org/browse/SO-SO-3237>`_ - Exposed HTTP port. 
+*  `SO-3414 <https://jira.onap.org/browse/SO-SO-3414>`_ - Search Query does not contain get model data for vFW closed loop. 
 
 
 **Upgrade Notes**
index d1c9742..d532103 100644 (file)
@@ -93,7 +93,7 @@
               <destination>${project.build.directory}/generated-sources</destination>
               <destinationClasspath>org.onap.aaiclient.client.generated.fluentbuilders</destinationClasspath>
               <builderName>AAIFluentTypeBuilder</builderName>
-              <swaggerLocation>${project.build.directory}/swagger/onap/aai_swagger_yaml/aai_swagger_v21.yaml</swaggerLocation>
+              <swaggerLocation>${project.build.directory}/swagger/onap/aai_swagger_yaml/aai_swagger_LATEST.yaml</swaggerLocation>
               <singularBuilderClass>org.onap.aaiclient.client.aai.entities.uri.AAIFluentSingleType</singularBuilderClass>
               <pluralBuilderClass>org.onap.aaiclient.client.aai.entities.uri.AAIFluentPluralType</pluralBuilderClass>
               <topLevelBuilderClass>org.onap.aaiclient.client.aai.entities.uri.AAIFluentTopLevelType</topLevelBuilderClass>
index 343e888..5dbe915 100644 (file)
@@ -42,9 +42,13 @@ import org.onap.aaiclient.client.graphinventory.entities.uri.HttpAwareUri;
 import org.onap.aaiclient.client.graphinventory.exceptions.GraphInventoryMultipleItemsException;
 import org.onap.so.client.RestClient;
 import org.onap.so.client.RestProperties;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public abstract class GraphInventoryResourcesClient<Self, Uri extends GraphInventoryResourceUri<?, ?>, SingleUri extends GraphInventorySingleResourceUri<?, ?, ?, ?, ?, ?>, PluralUri extends GraphInventoryPluralResourceUri<?, ?>, EdgeLabel extends GraphInventoryEdgeLabel, Wrapper extends GraphInventoryResultWrapper, TransactionalClient, SingleTransactionClient> {
 
+    private static final Logger logger = LoggerFactory.getLogger(GraphInventoryResourcesClient.class);
+
     protected GraphInventoryClient client;
 
     protected GraphInventoryResourcesClient(GraphInventoryClient client) {
@@ -147,6 +151,27 @@ public abstract class GraphInventoryResourcesClient<Self, Uri extends GraphInven
         String resourceVersion = (String) result.get("resource-version");
         giRC = client.createClient(clone.resourceVersion(resourceVersion));
         giRC.delete();
+
+    }
+
+    /**
+     * Deletes object from GraphInventory only if exists. Automatically handles resource-version.
+     * 
+     * @param uri
+     * @return
+     */
+    public void deleteIfExists(SingleUri uri) {
+        GraphInventorySingleResourceUri<?, ?, ?, ?, ?, ?> clone = (SingleUri) uri.clone();
+        RestClient giRC = client.createClient(clone);
+        Optional<Map<String, Object>> result = giRC.get(new GenericType<Map<String, Object>>() {});
+        if (result.isPresent()) {
+            String resourceVersion = (String) result.get().get("resource-version");
+            giRC = client.createClient(clone.resourceVersion(resourceVersion));
+            giRC.delete();
+        } else {
+            logger.warn(clone.build() + " already does not exist in " + client.getGraphDBName()
+                    + " therefore delete call not executed");
+        }
     }
 
     /**
index 36ba1f3..03fd0ac 100644 (file)
@@ -107,6 +107,27 @@ public class AAIResourcesClientTest {
         client.delete(path);
     }
 
+    @Test
+    public void verifyDeleteIfExists() {
+        AAIResourceUri path = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("test2"));
+        wireMockRule.stubFor(get(urlPathEqualTo("/aai/" + AAIVersion.LATEST + path.build()))
+                .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(404)));
+        AAIResourcesClient client = aaiClient;
+        client.deleteIfExists(path);
+    }
+
+    @Test
+    public void verifyDeleteIfExists_exists() {
+        AAIResourceUri path = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("test2"));
+        wireMockRule.stubFor(get(urlPathEqualTo("/aai/" + AAIVersion.LATEST + path.build()))
+                .willReturn(aResponse().withHeader("Content-Type", "application/json")
+                        .withBodyFile("aai/resources/mockObject.json").withStatus(200)));
+        wireMockRule.stubFor(delete(urlPathEqualTo("/aai/" + AAIVersion.LATEST + path.build()))
+                .withQueryParam("resource-version", equalTo("1234")).willReturn(aResponse().withStatus(204)));
+        AAIResourcesClient client = aaiClient;
+        client.deleteIfExists(path);
+    }
+
     @Test
     public void verifyBasicAuth() {
         AAIResourceUri path = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("test3"));
index ec09af8..fc42d9c 100644 (file)
@@ -1,6 +1,10 @@
 package org.onap.graphinventory.generate;
 
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
 import java.util.ArrayList;
+import java.util.Comparator;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
@@ -26,6 +30,9 @@ public class SwaggerConverter {
     }
 
     public Map<String, ObjectType> getDoc(String swaggerLocation) throws JsonProcessingException {
+
+
+        swaggerLocation = processLocation(swaggerLocation);
         Swagger swagger = new SwaggerParser().read(swaggerLocation);
 
         Map<String, Path> paths = swagger.getPaths().entrySet().stream()
@@ -168,4 +175,19 @@ public class SwaggerConverter {
 
         return output;
     }
+
+    private String processLocation(String swaggerLocation) {
+
+        java.nio.file.Path path = Paths.get(swaggerLocation);
+        try {
+            return Files.list(path.getParent())
+                    .filter(it -> it.getFileName().toString()
+                            .matches(path.getFileName().toString().replaceFirst("LATEST", "v\\\\\\d+")))
+                    .sorted(Comparator.reverseOrder()).map(it -> it.toString()).findFirst().orElseGet(null);
+        } catch (IOException e) {
+            log.error(e);
+        }
+
+        return null;
+    }
 }
index fd8c273..11f2d4b 100644 (file)
@@ -1200,6 +1200,7 @@ CREATE TABLE IF NOT EXISTS `pnf_resource_customization` (
   `CDS_BLUEPRINT_NAME` varchar(200) DEFAULT NULL,
   `CDS_BLUEPRINT_VERSION` varchar(20) DEFAULT NULL,
   `CONTROLLER_ACTOR` varchar(200) DEFAULT NULL,
+  `DEFAULT_SOFTWARE_VERSION` varchar(4000) DEFAULT NULL,
   PRIMARY KEY (`MODEL_CUSTOMIZATION_UUID`),
   KEY `fk_pnf_resource_customization__pnf_resource1_idx` (`PNF_RESOURCE_MODEL_UUID`),
   CONSTRAINT `fk_pnf_resource_customization__pnf_resource1` FOREIGN KEY (`PNF_RESOURCE_MODEL_UUID`) REFERENCES `pnf_resource` (`MODEL_UUID`) ON DELETE CASCADE ON UPDATE CASCADE
index 61b0b11..63ee35c 100644 (file)
 
 package org.onap.so.db.catalog.beans;
 
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.openpojo.business.annotation.BusinessKey;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
 import java.util.Date;
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.ToStringBuilder;
-import org.apache.commons.lang3.builder.ToStringStyle;
 import javax.persistence.Column;
 import javax.persistence.Entity;
 import javax.persistence.EnumType;
@@ -36,6 +30,12 @@ import javax.persistence.PrePersist;
 import javax.persistence.Table;
 import javax.persistence.Temporal;
 import javax.persistence.TemporalType;
+import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.openpojo.business.annotation.BusinessKey;
 import uk.co.blackpepper.bowman.annotation.RemoteResource;
 
 /**
@@ -74,6 +74,11 @@ public class CloudIdentity {
     @Column(name = "PROJECT_DOMAIN_NAME")
     private String projectDomainName;
 
+    @JsonProperty("admin_project_domain_name ")
+    @BusinessKey
+    @Column(name = "ADMIN_PROJECT_DOMAIN_NAME")
+    private String adminProjectDomainName;
+
     @JsonProperty("user_domain_name")
     @BusinessKey
     @Column(name = "USER_DOMAIN_NAME")
@@ -245,6 +250,14 @@ public class CloudIdentity {
         this.projectDomainName = projectDomainName;
     }
 
+    public String getAdminProjectDomainName() {
+        return adminProjectDomainName;
+    }
+
+    public void setAdminProjectDomainName(String adminProjectDomainName) {
+        this.adminProjectDomainName = adminProjectDomainName;
+    }
+
     public String getUserDomainName() {
         return userDomainName;
     }
@@ -267,6 +280,7 @@ public class CloudIdentity {
         cloudIdentityCopy.identityServerType = this.identityServerType;
         cloudIdentityCopy.identityAuthenticationType = this.identityAuthenticationType;
         cloudIdentityCopy.projectDomainName = this.projectDomainName;
+        cloudIdentityCopy.adminProjectDomainName = this.adminProjectDomainName;
         cloudIdentityCopy.userDomainName = this.userDomainName;
 
         return cloudIdentityCopy;
@@ -279,7 +293,8 @@ public class CloudIdentity {
                 .append("projectDomain", getProjectDomainName()).append("userDomain", getUserDomainName())
                 .append("adminTenant", getAdminTenant()).append("memberRole", getMemberRole())
                 .append("tenantMetadata", getTenantMetadata()).append("identityServerType", getIdentityServerType())
-                .append("identityAuthenticationType", getIdentityAuthenticationType()).toString();
+                .append("identityAuthenticationType", getIdentityAuthenticationType())
+                .append("adminProjectDomainName", getAdminProjectDomainName()).toString();
     }
 
     @Override
@@ -299,7 +314,8 @@ public class CloudIdentity {
                 .append(getMemberRole(), castOther.getMemberRole())
                 .append(getTenantMetadata(), castOther.getTenantMetadata())
                 .append(getIdentityServerType(), castOther.getIdentityServerType())
-                .append(getIdentityAuthenticationType(), castOther.getIdentityAuthenticationType()).isEquals();
+                .append(getIdentityAuthenticationType(), castOther.getIdentityAuthenticationType())
+                .append(getAdminProjectDomainName(), castOther.getAdminProjectDomainName()).isEquals();
     }
 
     @Override
@@ -307,6 +323,7 @@ public class CloudIdentity {
         return new HashCodeBuilder(1, 31).append(getId()).append(getIdentityUrl()).append(getMsoId())
                 .append(getMsoPass()).append(getProjectDomainName()).append(getUserDomainName())
                 .append(getAdminTenant()).append(getMemberRole()).append(getTenantMetadata())
-                .append(getIdentityServerType()).append(getIdentityAuthenticationType()).toHashCode();
+                .append(getIdentityServerType()).append(getIdentityAuthenticationType())
+                .append(getAdminProjectDomainName()).toHashCode();
     }
 }
index 2e4623d..122a20f 100644 (file)
@@ -88,6 +88,9 @@ public class PnfResourceCustomization implements Serializable {
     @Column(name = "CONTROLLER_ACTOR")
     private String controllerActor;
 
+    @Column(name = "DEFAULT_SOFTWARE_VERSION")
+    private String defaultSoftwareVersion;
+
     @Override
     public String toString() {
         return new ToStringBuilder(this).append("modelCustomizationUUID", modelCustomizationUUID)
@@ -95,7 +98,8 @@ public class PnfResourceCustomization implements Serializable {
                 .append("nfFunction", nfFunction).append("nfType", nfType).append("nfRole", nfRole)
                 .append("nfNamingCode", nfNamingCode).append("multiStageDesign", multiStageDesign)
                 .append("pnfResources", pnfResources).append("blueprintName", blueprintName)
-                .append("blueprintVersion", blueprintVersion).append("controllerActor", controllerActor).toString();
+                .append("blueprintVersion", blueprintVersion).append("controllerActor", controllerActor)
+                .append("defaultSoftwareVersion", defaultSoftwareVersion).toString();
     }
 
     @Override
@@ -234,4 +238,12 @@ public class PnfResourceCustomization implements Serializable {
     public void setControllerActor(String controllerActor) {
         this.controllerActor = controllerActor;
     }
+
+    public String getDefaultSoftwareVersion() {
+        return defaultSoftwareVersion;
+    }
+
+    public void setDefaultSoftwareVersion(String defaultSoftwareVersion) {
+        this.defaultSoftwareVersion = defaultSoftwareVersion;
+    }
 }
index ef90dd6..91cfb00 100644 (file)
@@ -47,6 +47,7 @@ import org.onap.so.db.catalog.beans.HomingInstance;
 import org.onap.so.db.catalog.beans.InstanceGroup;
 import org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization;
 import org.onap.so.db.catalog.beans.NetworkRecipe;
+import org.onap.so.db.catalog.beans.NetworkResource;
 import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
 import org.onap.so.db.catalog.beans.OrchestrationAction;
 import org.onap.so.db.catalog.beans.OrchestrationStatus;
@@ -98,6 +99,7 @@ public class CatalogDbClient {
     private static final String RAINY_DAY_HANDLER_MACRO = "/rainy_day_handler_macro";
     private static final String NORTHBOUND_REQUEST_REF_LOOKUP = "/northbound_request_ref_lookup";
     private static final String NETWORK_RESOURCE_CUSTOMIZATION = "/networkResourceCustomization";
+    private static final String NETWORK_RESOURCE = "/networkResource";
     private static final String COLLECTION_RESOURCE_INSTANCE_GROUP_CUSTOMIZATION =
             "/collectionResourceInstanceGroupCustomization";
     private static final String VNFC_INSTANCE_GROUP_CUSTOMIZATION = "/vnfcInstanceGroupCustomization";
@@ -223,6 +225,7 @@ public class CatalogDbClient {
     private String vnfResourceURI;
     private String networkCollectionResourceCustomizationURI;
     private String networkResourceCustomizationURI;
+    private String networkResourceURI;
     private String collectionNetworkResourceCustomizationURI;
     private String instanceGroupURI;
     private String cloudifyManagerURI;
@@ -375,6 +378,7 @@ public class CatalogDbClient {
         networkCollectionResourceCustomizationURI =
                 endpoint + NETWORK_COLLECTION_RESOURCE_CUSTOMIZATION + URI_SEPARATOR;
         networkResourceCustomizationURI = endpoint + NETWORK_RESOURCE_CUSTOMIZATION + URI_SEPARATOR;
+        networkResourceURI = endpoint + NETWORK_RESOURCE + SEARCH;
         collectionNetworkResourceCustomizationURI =
                 endpoint + COLLECTION_NETWORK_RESOURCE_CUSTOMIZATION + URI_SEPARATOR;
         instanceGroupURI = endpoint + INSTANCE_GROUP + URI_SEPARATOR;
@@ -607,6 +611,25 @@ public class CatalogDbClient {
         return networkResourceCustomization;
     }
 
+    public NetworkResource getNetworkResourceByModelName(String networkType) {
+        if (Strings.isNullOrEmpty(networkType)) {
+            throw new EntityNotFoundException("networkType passed as Null or Empty String");
+        }
+        try {
+            HttpEntity<?> entity = getHttpEntity();
+            return restTemplate.exchange(
+                    UriBuilder.fromUri(networkResourceURI + "/findFirstByModelNameOrderByModelVersionDesc")
+                            .queryParam("modelName", networkType).build(),
+                    HttpMethod.GET, entity, NetworkResource.class).getBody();
+        } catch (HttpClientErrorException e) {
+            if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) {
+                throw new EntityNotFoundException("Unable to find NetworkResource By networkType " + networkType);
+            }
+            throw e;
+        }
+    }
+
+
 
     public BuildingBlockDetail getBuildingBlockDetail(String buildingBlockName) {
         BuildingBlockDetail buildingBlockDetail =
index 42d107c..30f3df7 100644 (file)
@@ -23,6 +23,7 @@ package org.onap.so.db.catalog.data.repository;
 import org.onap.so.db.catalog.beans.NetworkResource;
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.Query;
+import org.springframework.data.repository.query.Param;
 import org.springframework.data.rest.core.annotation.RepositoryRestResource;
 import org.springframework.stereotype.Repository;
 
@@ -38,7 +39,7 @@ public interface NetworkResourceRepository extends JpaRepository<NetworkResource
      */
     @Query(value = "SELECT * FROM network_resource WHERE MODEL_NAME = ?1 ORDER BY INET_ATON(SUBSTRING_INDEX(CONCAT(MODEL_VERSION,'.0.0.0'),'.',4)) DESC LIMIT 1;",
             nativeQuery = true)
-    NetworkResource findFirstByModelNameOrderByModelVersionDesc(String modelName);
+    NetworkResource findFirstByModelNameOrderByModelVersionDesc(@Param("modelName") String modelName);
 
     NetworkResource findResourceByModelUUID(String modelUUID);
 
index 68f272c..335c49e 100644 (file)
@@ -1204,6 +1204,7 @@ CREATE TABLE IF NOT EXISTS `pnf_resource_customization` (
   `CDS_BLUEPRINT_VERSION` varchar(20) DEFAULT NULL,
   `SKIP_POST_INSTANTIATION_CONFIGURATION` boolean default true,
   `CONTROLLER_ACTOR` varchar(200) DEFAULT NULL,
+  `DEFAULT_SOFTWARE_VERSION` varchar(4000) DEFAULT NULL,
   PRIMARY KEY (`MODEL_CUSTOMIZATION_UUID`),
   KEY `fk_pnf_resource_customization__pnf_resource1_idx` (`PNF_RESOURCE_MODEL_UUID`),
   CONSTRAINT `fk_pnf_resource_customization__pnf_resource1` FOREIGN KEY (`PNF_RESOURCE_MODEL_UUID`) REFERENCES `pnf_resource` (`MODEL_UUID`) ON DELETE CASCADE ON UPDATE CASCADE