summaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/main')
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java13
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIServiceInstanceResources.java5
2 files changed, 14 insertions, 4 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java
index 57dbec3ad7..e3540ecc58 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java
@@ -107,8 +107,12 @@ public class AAICreateTasks {
public void createServiceInstance(BuildingBlockExecution execution) {
try {
+ Boolean alaCarte = execution.getVariable(A_LA_CARTE);
ServiceInstance serviceInstance =
extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ if (Boolean.TRUE.equals(alaCarte) && aaiSIResources.checkInstanceServiceNameInUse(serviceInstance)) {
+ throw new DuplicateNameException("service-instance", serviceInstance.getServiceInstanceName());
+ }
Customer customer = execution.getGeneralBuildingBlock().getCustomer();
aaiSIResources.createServiceInstance(serviceInstance, customer);
} catch (Exception ex) {
@@ -327,7 +331,8 @@ public class AAICreateTasks {
ServiceInstance serviceInstance =
extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
- if (alaCarte != null && alaCarte && aaiNetworkResources.checkNetworkNameInUse(l3network.getNetworkName())) {
+ if (Boolean.TRUE.equals(alaCarte)
+ && aaiNetworkResources.checkNetworkNameInUse(l3network.getNetworkName())) {
throw new DuplicateNameException("l3Network", l3network.getNetworkName());
}
// set default to false. ToBe updated by SDNC
@@ -386,7 +391,7 @@ public class AAICreateTasks {
InstanceGroup instanceGroup = serviceInstance.getCollection().getInstanceGroup();
// set name generated for NetworkCollection/NetworkCollectionInstanceGroup in previous step of the BB flow
instanceGroup.setInstanceGroupName(execution.getVariable(NETWORK_COLLECTION_NAME));
- if (alaCarte != null && alaCarte
+ if (Boolean.TRUE.equals(alaCarte)
&& aaiInstanceGroupResources.checkInstanceGroupNameInUse(instanceGroup.getInstanceGroupName())) {
throw new DuplicateNameException("instance-group", instanceGroup.getInstanceGroupName());
}
@@ -508,7 +513,7 @@ public class AAICreateTasks {
try {
Boolean alaCarte = execution.getVariable(A_LA_CARTE);
Configuration configuration = extractPojosForBB.extractByKey(execution, ResourceKey.CONFIGURATION_ID);
- if (alaCarte != null && alaCarte
+ if (Boolean.TRUE.equals(alaCarte)
&& aaiConfigurationResources.checkConfigurationNameInUse(configuration.getConfigurationName())) {
throw new DuplicateNameException("configuration", configuration.getConfigurationName());
}
@@ -524,7 +529,7 @@ public class AAICreateTasks {
ServiceInstance serviceInstance =
extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
InstanceGroup instanceGroup = extractPojosForBB.extractByKey(execution, ResourceKey.INSTANCE_GROUP_ID);
- if (alaCarte != null && alaCarte
+ if (Boolean.TRUE.equals(alaCarte)
&& aaiInstanceGroupResources.checkInstanceGroupNameInUse(instanceGroup.getInstanceGroupName())) {
throw new DuplicateNameException("instance-group", instanceGroup.getInstanceGroupName());
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIServiceInstanceResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIServiceInstanceResources.java
index f84afbe4a2..c41f3fa56c 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIServiceInstanceResources.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIServiceInstanceResources.java
@@ -157,5 +157,10 @@ public class AAIServiceInstanceResources {
injectionHelper.getAaiClient().update(serviceInstanceURI, aaiServiceInstance);
}
+ public boolean checkInstanceServiceNameInUse(ServiceInstance serviceInstance) {
+ AAIResourceUri uriSI = AAIUriFactory.createNodesUri(AAIObjectPlurals.SERVICE_INSTANCE)
+ .queryParam("service-instance-name", serviceInstance.getServiceInstanceName());
+ return injectionHelper.getAaiClient().exists(uriSI);
+ }
}