diff options
author | Max Benjamin <max.benjamin@att.com> | 2019-06-15 14:08:46 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-06-15 14:08:46 +0000 |
commit | c12bd8acf7bbc266b14851b50728e9d24d53b5b8 (patch) | |
tree | 9245f612d2a50bf6a25a99ba979e70f1a6b7a6de /bpmn/so-bpmn-tasks/src/main/java | |
parent | b619a05033211171ac61dd658282bc2cf1be77d9 (diff) | |
parent | 3fea528d612cf90c57510f66dc0d0b42b607e6d5 (diff) |
Merge "Validate names before writing to A&AI"
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/main/java')
4 files changed, 43 insertions, 0 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 524098bcb7..57dbec3ad7 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 @@ -323,9 +323,13 @@ public class AAICreateTasks { */ public void createNetwork(BuildingBlockExecution execution) { try { + Boolean alaCarte = execution.getVariable(A_LA_CARTE); 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())) { + throw new DuplicateNameException("l3Network", l3network.getNetworkName()); + } // set default to false. ToBe updated by SDNC l3network.setIsBoundToVpn(false); // define is bound to vpn flag as true if NEUTRON_NETWORK_TYPE is PROVIDER @@ -376,11 +380,16 @@ public class AAICreateTasks { */ public void createNetworkCollectionInstanceGroup(BuildingBlockExecution execution) { try { + Boolean alaCarte = execution.getVariable(A_LA_CARTE); ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID); 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 + && aaiInstanceGroupResources.checkInstanceGroupNameInUse(instanceGroup.getInstanceGroupName())) { + throw new DuplicateNameException("instance-group", instanceGroup.getInstanceGroupName()); + } // put shell in AAI aaiNetworkResources.createNetworkInstanceGroup(instanceGroup); } catch (Exception ex) { @@ -497,7 +506,12 @@ public class AAICreateTasks { public void createConfiguration(BuildingBlockExecution execution) { try { + Boolean alaCarte = execution.getVariable(A_LA_CARTE); Configuration configuration = extractPojosForBB.extractByKey(execution, ResourceKey.CONFIGURATION_ID); + if (alaCarte != null && alaCarte + && aaiConfigurationResources.checkConfigurationNameInUse(configuration.getConfigurationName())) { + throw new DuplicateNameException("configuration", configuration.getConfigurationName()); + } aaiConfigurationResources.createConfiguration(configuration); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); @@ -506,9 +520,14 @@ public class AAICreateTasks { public void createInstanceGroupVnf(BuildingBlockExecution execution) { try { + Boolean alaCarte = execution.getVariable(A_LA_CARTE); ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID); InstanceGroup instanceGroup = extractPojosForBB.extractByKey(execution, ResourceKey.INSTANCE_GROUP_ID); + if (alaCarte != null && alaCarte + && aaiInstanceGroupResources.checkInstanceGroupNameInUse(instanceGroup.getInstanceGroupName())) { + throw new DuplicateNameException("instance-group", instanceGroup.getInstanceGroupName()); + } aaiInstanceGroupResources.createInstanceGroupandConnectServiceInstance(instanceGroup, serviceInstance); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIConfigurationResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIConfigurationResources.java index 9eee0e607d..867d80a4ea 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIConfigurationResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIConfigurationResources.java @@ -24,6 +24,7 @@ import java.util.Optional; import javax.ws.rs.core.UriBuilder; import org.onap.so.bpmn.common.InjectionHelper; import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; +import org.onap.so.client.aai.AAIObjectPlurals; import org.onap.so.client.aai.AAIObjectType; import org.onap.so.client.aai.entities.AAIEdgeLabel; import org.onap.so.client.aai.entities.uri.AAIResourceUri; @@ -237,4 +238,11 @@ public class AAIConfigurationResources { aaiConfiguration.setOrchestrationStatus(orchestrationStatus.name()); injectionHelper.getAaiClient().update(aaiResourceUri, aaiConfiguration); } + + public boolean checkConfigurationNameInUse(String configurationName) { + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.CONFIGURATION) + .queryParam("configuration-name", configurationName); + return injectionHelper.getAaiClient().exists(uri); + } + } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIInstanceGroupResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIInstanceGroupResources.java index c48593037a..296d052315 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIInstanceGroupResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIInstanceGroupResources.java @@ -25,6 +25,7 @@ import org.onap.so.bpmn.common.InjectionHelper; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.client.aai.AAIObjectPlurals; import org.onap.so.client.aai.AAIObjectType; import org.onap.so.client.aai.entities.AAIEdgeLabel; import org.onap.so.client.aai.entities.uri.AAIResourceUri; @@ -84,4 +85,11 @@ public class AAIInstanceGroupResources { injectionHelper.getAaiClient().createIfNotExists(instanceGroupUri, Optional.of(aaiInstanceGroup)) .connect(instanceGroupUri, serviceInstanceURI); } + + public boolean checkInstanceGroupNameInUse(String instanceGroupName) { + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.INSTANCE_GROUP) + .queryParam("instance-group-name", instanceGroupName); + return injectionHelper.getAaiClient().exists(uri); + } + } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAINetworkResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAINetworkResources.java index b936551549..bc702c9fb4 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAINetworkResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAINetworkResources.java @@ -32,6 +32,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet; +import org.onap.so.client.aai.AAIObjectPlurals; import org.onap.so.client.aai.AAIObjectType; import org.onap.so.client.aai.entities.AAIEdgeLabel; import org.onap.so.client.aai.entities.AAIResultWrapper; @@ -206,4 +207,11 @@ public class AAINetworkResources { AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, networkPolicyId); injectionHelper.getAaiClient().delete(networkPolicyURI); } + + public boolean checkNetworkNameInUse(String networkName) { + AAIResourceUri uri = + AAIUriFactory.createResourceUri(AAIObjectPlurals.L3_NETWORK).queryParam("network-name", networkName); + return injectionHelper.getAaiClient().exists(uri); + } + } |