aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/MSOCommonBPMN
diff options
context:
space:
mode:
authorLukasz Muszkieta <lukasz.muszkieta@nokia.com>2020-02-25 14:18:22 +0000
committerGerrit Code Review <gerrit@onap.org>2020-02-25 14:18:22 +0000
commit7acc80b895555184f4fc011d32dd509e10e4e1ac (patch)
tree1fe4813915d01d43c1db42e49097f5d20e188e9e /bpmn/MSOCommonBPMN
parent2f497888bfcc70a6982843454e346c46ee02ce78 (diff)
parentb40da4a8dff7c148ddfa3b29802e072449d7419d (diff)
Merge "Lower code duplication of AaiClient calls in BBInputSetupUtils"
Diffstat (limited to 'bpmn/MSOCommonBPMN')
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java58
1 files changed, 14 insertions, 44 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java
index ec7b613727..e004e10cf0 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java
@@ -24,6 +24,7 @@ package org.onap.so.bpmn.servicedecomposition.tasks;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Optional;
@@ -398,68 +399,37 @@ public class BBInputSetupUtils {
}
public Configuration getAAIConfiguration(String configurationId) {
- return this.injectionHelper.getAaiClient()
- .get(Configuration.class,
- AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, configurationId).depth(Depth.ONE))
- .orElseGet(() -> {
- logger.debug("No Configuration matched by id");
- return null;
- });
+ return this.getConcreteAAIResource(Configuration.class, AAIObjectType.CONFIGURATION, configurationId);
}
public GenericVnf getAAIGenericVnf(String vnfId) {
-
- return this.injectionHelper.getAaiClient()
- .get(GenericVnf.class,
- AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId).depth(Depth.ONE))
- .orElseGet(() -> {
- logger.debug("No Generic Vnf matched by id");
- return null;
- });
+ return getConcreteAAIResource(GenericVnf.class, AAIObjectType.GENERIC_VNF, vnfId);
}
public VpnBinding getAAIVpnBinding(String vpnBindingId) {
-
- return this.injectionHelper.getAaiClient()
- .get(VpnBinding.class,
- AAIUriFactory.createResourceUri(AAIObjectType.VPN_BINDING, vpnBindingId).depth(Depth.ONE))
- .orElseGet(() -> {
- logger.debug("No VpnBinding matched by id");
- return null;
- });
+ return getConcreteAAIResource(VpnBinding.class, AAIObjectType.VPN_BINDING, vpnBindingId);
}
public VolumeGroup getAAIVolumeGroup(String cloudOwnerId, String cloudRegionId, String volumeGroupId) {
- return this.injectionHelper.getAaiClient()
- .get(VolumeGroup.class, AAIUriFactory
- .createResourceUri(AAIObjectType.VOLUME_GROUP, cloudOwnerId, cloudRegionId, volumeGroupId)
- .depth(Depth.ONE))
- .orElseGet(() -> {
- logger.debug("No Generic Vnf matched by id");
- return null;
- });
+ return getConcreteAAIResource(VolumeGroup.class, AAIObjectType.VOLUME_GROUP, cloudOwnerId, cloudRegionId,
+ volumeGroupId);
}
public VfModule getAAIVfModule(String vnfId, String vfModuleId) {
- return this.injectionHelper.getAaiClient()
- .get(VfModule.class,
- AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId).depth(Depth.ONE))
- .orElseGet(() -> {
- logger.debug("No Generic Vnf matched by id");
- return null;
- });
+ return getConcreteAAIResource(VfModule.class, AAIObjectType.VF_MODULE, vnfId, vfModuleId);
}
public L3Network getAAIL3Network(String networkId) {
+ return getConcreteAAIResource(L3Network.class, AAIObjectType.L3_NETWORK, networkId);
+ }
- return this.injectionHelper.getAaiClient()
- .get(L3Network.class,
- AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId).depth(Depth.ONE))
- .orElseGet(() -> {
- logger.debug("No Generic Vnf matched by id");
+ private <T> T getConcreteAAIResource(Class<T> clazz, AAIObjectType objectType, Object... ids) {
+ return injectionHelper.getAaiClient()
+ .get(clazz, AAIUriFactory.createResourceUri(objectType, ids).depth(Depth.ONE)).orElseGet(() -> {
+ logger.debug("No resource of type: {} matched by ids: {}", objectType.typeName(),
+ Arrays.toString(ids));
return null;
});
-
}
public Optional<ServiceInstance> getRelatedServiceInstanceFromInstanceGroup(String instanceGroupId)