diff options
author | Sangalang, Felix <felix.sangalang@att.com> | 2019-06-16 12:00:36 -0400 |
---|---|---|
committer | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2019-06-16 12:00:42 -0400 |
commit | 9990df8b87bdc0d3de175b8d56fc6920595e3129 (patch) | |
tree | 9e4b1ad5ff695c365846ee3c1790aecbbe8328e4 /bpmn/so-bpmn-tasks/src/main/java | |
parent | c12bd8acf7bbc266b14851b50728e9d24d53b5b8 (diff) |
Validate ServiceInstance name using createNodesUri
Validate ServiceInstance name using createNodesUri.
Change-Id: I5194dd933dc98064888250bc9a38e6ee9716fc01
Issue-ID: SO-2024
Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/main/java')
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); + } } |