summaryrefslogtreecommitdiffstats
path: root/mso-api-handlers/mso-api-handler-infra/src
diff options
context:
space:
mode:
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra/src')
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java25
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/AAIDataRetrieval.java79
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/BpmnRequestBuilder.java14
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/VolumeGroupDeleteValidator.java3
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelper.java26
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java5
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/AAIDataRetrievalTest.java20
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/BpmnRequestBuilderTest.java19
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/validator/VolumeGroupDeleteValidatorTest.java20
9 files changed, 122 insertions, 89 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java
index c7692cb2cc..b09d676b57 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java
@@ -23,7 +23,12 @@
package org.onap.so.apihandlerinfra;
import java.io.IOException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.UUID;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
@@ -34,14 +39,13 @@ import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
-import org.onap.so.apihandlerinfra.e2eserviceinstancebeans.*;
+import org.apache.http.HttpStatus;
+import org.json.JSONObject;
import org.onap.aai.domain.yang.v16.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;
-import org.apache.http.HttpStatus;
-import org.json.JSONObject;
+import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder;
import org.onap.logging.filter.base.ErrorCode;
import org.onap.so.apihandler.camundabeans.CamundaResponse;
import org.onap.so.apihandler.common.CamundaClient;
@@ -53,6 +57,7 @@ import org.onap.so.apihandlerinfra.e2eserviceinstancebeans.CompareModelsRequest;
import org.onap.so.apihandlerinfra.e2eserviceinstancebeans.E2EServiceInstanceDeleteRequest;
import org.onap.so.apihandlerinfra.e2eserviceinstancebeans.E2EServiceInstanceRequest;
import org.onap.so.apihandlerinfra.e2eserviceinstancebeans.E2EServiceInstanceScaleRequest;
+import org.onap.so.apihandlerinfra.e2eserviceinstancebeans.E2ESliceServiceActivateRequest;
import org.onap.so.apihandlerinfra.e2eserviceinstancebeans.GetE2EServiceInstanceResponse;
import org.onap.so.apihandlerinfra.exceptions.ApiException;
import org.onap.so.apihandlerinfra.exceptions.BPMNFailureException;
@@ -380,8 +385,9 @@ public class E2EServiceInstances {
// TODO Get the service template model version uuid from AAI.
String modelVersionId = null;
AAIResourcesClient client = new AAIResourcesClient();
- AAIResourceUri url = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,
- e2eActReq.getGlobalSubscriberId(), e2eActReq.getServiceType(), instanceIdMap.get(SERVICE_ID));
+ AAIResourceUri url = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business()
+ .customer(e2eActReq.getGlobalSubscriberId()).serviceSubscription(e2eActReq.getServiceType())
+ .serviceInstance(instanceIdMap.get(SERVICE_ID)));
Optional<ServiceInstance> serviceInstanceOpt = client.get(ServiceInstance.class, url);
if (serviceInstanceOpt.isPresent()) {
modelVersionId = serviceInstanceOpt.get().getModelVersionId();
@@ -469,8 +475,9 @@ public class E2EServiceInstances {
// TODO Get the service template model version uuid from AAI.
String modelVersionId = null;
AAIResourcesClient client = new AAIResourcesClient();
- AAIResourceUri url = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,
- e2eDelReq.getGlobalSubscriberId(), e2eDelReq.getServiceType(), instanceIdMap.get(SERVICE_ID));
+ AAIResourceUri url = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business()
+ .customer(e2eDelReq.getGlobalSubscriberId()).serviceSubscription(e2eDelReq.getServiceType())
+ .serviceInstance(instanceIdMap.get(SERVICE_ID)));
Optional<ServiceInstance> serviceInstanceOpt = client.get(ServiceInstance.class, url);
if (serviceInstanceOpt.isPresent()) {
modelVersionId = serviceInstanceOpt.get().getModelVersionId();
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/AAIDataRetrieval.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/AAIDataRetrieval.java
index 70de94a3ef..d8ad82c17d 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/AAIDataRetrieval.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/AAIDataRetrieval.java
@@ -1,7 +1,6 @@
package org.onap.so.apihandlerinfra.infra.rest;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
@@ -15,14 +14,13 @@ import org.onap.aai.domain.yang.VfModule;
import org.onap.aai.domain.yang.VfModules;
import org.onap.aai.domain.yang.VolumeGroup;
import org.onap.aai.domain.yang.VolumeGroups;
-import org.onap.so.apihandlerinfra.infra.rest.exception.AAIEntityNotFound;
import org.onap.aaiclient.client.aai.AAIDSLQueryClient;
-import org.onap.aaiclient.client.aai.AAIObjectPlurals;
-import org.onap.aaiclient.client.aai.AAIObjectType;
import org.onap.aaiclient.client.aai.AAIResourcesClient;
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.AAIUriFactory;
+import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder;
+import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types;
import org.onap.aaiclient.client.graphinventory.entities.DSLQuery;
import org.onap.aaiclient.client.graphinventory.entities.DSLQueryBuilder;
import org.onap.aaiclient.client.graphinventory.entities.DSLStartNode;
@@ -30,6 +28,8 @@ import org.onap.aaiclient.client.graphinventory.entities.Node;
import org.onap.aaiclient.client.graphinventory.entities.Start;
import org.onap.aaiclient.client.graphinventory.entities.TraversalBuilder;
import org.onap.aaiclient.client.graphinventory.entities.__;
+import org.onap.so.apihandlerinfra.infra.rest.exception.AAIEntityNotFound;
+import org.onap.so.serviceinstancebeans.CloudConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
@@ -48,7 +48,7 @@ public class AAIDataRetrieval {
public ServiceInstance getServiceInstance(String serviceInstanceId) {
return this.getAaiResourcesClient()
.get(ServiceInstance.class,
- AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId))
+ AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstanceId)))
.orElseGet(() -> {
logger.debug("No Service Instance found in A&AI ServiceInstanceId: {}", serviceInstanceId);
return null;
@@ -57,7 +57,9 @@ public class AAIDataRetrieval {
public VfModule getAAIVfModule(String vnfId, String vfModuleId) {
return this.getAaiResourcesClient()
- .get(VfModule.class, AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId))
+ .get(VfModule.class,
+ AAIUriFactory.createResourceUri(
+ AAIFluentTypeBuilder.network().genericVnf(vnfId).vfModule(vfModuleId)))
.orElseGet(() -> {
logger.debug("No Vf Module found in A&AI VnfId: {}" + ", VfModuleId: {}", vnfId, vfModuleId);
return null;
@@ -66,7 +68,8 @@ public class AAIDataRetrieval {
public GenericVnf getGenericVnf(String vnfId) {
return this.getAaiResourcesClient()
- .get(GenericVnf.class, AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId))
+ .get(GenericVnf.class,
+ AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId)))
.orElseGet(() -> {
logger.debug("No Generic VNF found in A&AI VnfId: {}", vnfId);
return null;
@@ -74,9 +77,9 @@ public class AAIDataRetrieval {
}
public VolumeGroup getVolumeGroup(String vnfId, String volumeGroupId) throws AAIEntityNotFound {
- AAIResultWrapper wrapper =
- this.getAaiResourcesClient().get(AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)
- .relatedTo(AAIObjectType.VOLUME_GROUP, volumeGroupId));
+ AAIResultWrapper wrapper = this.getAaiResourcesClient()
+ .get(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId))
+ .relatedTo(Types.VOLUME_GROUP.getFragment(volumeGroupId)));
Optional<VolumeGroup> volume = wrapper.asBean(VolumeGroup.class);
if (volume.isPresent()) {
return volume.get();
@@ -88,7 +91,8 @@ public class AAIDataRetrieval {
public L3Network getNetwork(String networkId) {
return this.getAaiResourcesClient()
- .get(L3Network.class, AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId))
+ .get(L3Network.class,
+ AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().l3Network(networkId)))
.orElseGet(() -> {
logger.debug("No Network found in A&AI NetworkId: {}", networkId);
return null;
@@ -96,51 +100,57 @@ public class AAIDataRetrieval {
}
- public boolean isVolumeGroupRelatedToVFModule(String volumeGroupId) {
- return this.getAaiResourcesClient().exists(AAIUriFactory
- .createResourceUri(AAIObjectType.VOLUME_GROUP, volumeGroupId).relatedTo(AAIObjectPlurals.VF_MODULE));
+ public boolean isVolumeGroupRelatedToVFModule(CloudConfiguration cloudConfig, String volumeGroupId) {
+ return this.getAaiResourcesClient()
+ .exists(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure()
+ .cloudRegion(cloudConfig.getCloudOwner(), cloudConfig.getLcpCloudRegionId())
+ .volumeGroup(volumeGroupId)).relatedTo(Types.VF_MODULES.getFragment()));
}
public boolean isVnfRelatedToVolumes(String vnfId) {
- return this.getAaiResourcesClient().exists(AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)
- .relatedTo(AAIObjectPlurals.VOLUME_GROUP));
+ return this.getAaiResourcesClient()
+ .exists(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId))
+ .relatedTo(Types.VOLUME_GROUPS.getFragment()));
}
public boolean isNetworkRelatedToModules(String networkId) {
- return this.getAaiResourcesClient().exists(AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId)
- .relatedTo(AAIObjectPlurals.VF_MODULE));
+ return this.getAaiResourcesClient()
+ .exists(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().l3Network(networkId))
+ .relatedTo(Types.VF_MODULES.getFragment()));
}
public boolean isServiceRelatedToNetworks(String serviceInstanceId) {
return this.getAaiResourcesClient()
- .exists(AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId)
- .relatedTo(AAIObjectPlurals.L3_NETWORK));
+ .exists(AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstanceId))
+ .relatedTo(Types.L3_NETWORKS.getFragment()));
}
public boolean isServiceRelatedToGenericVnf(String serviceInstanceId) {
return this.getAaiResourcesClient()
- .exists(AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId)
- .relatedTo(AAIObjectPlurals.GENERIC_VNF));
+ .exists(AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstanceId))
+ .relatedTo(Types.GENERIC_VNFS.getFragment()));
}
public boolean isServiceRelatedToConfiguration(String serviceInstanceId) {
return this.getAaiResourcesClient()
- .exists(AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId)
- .relatedTo(AAIObjectPlurals.CONFIGURATION));
+ .exists(AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstanceId))
+ .relatedTo(Types.CONFIGURATIONS.getFragment()));
}
public Service getService(String serviceId) {
return this.getAaiResourcesClient()
- .get(Service.class, AAIUriFactory.createResourceUri(AAIObjectType.SERVICE, serviceId)).orElseGet(() -> {
+ .get(Service.class,
+ AAIUriFactory
+ .createResourceUri(AAIFluentTypeBuilder.serviceDesignAndCreation().service(serviceId)))
+ .orElseGet(() -> {
logger.debug("No Service found in A&AI ServiceId: {}", serviceId);
return null;
});
}
public Tenant getTenant(String cloudOwner, String cloudRegion, String tenantId) {
- return this.getAaiResourcesClient()
- .get(Tenant.class,
- AAIUriFactory.createResourceUri(AAIObjectType.TENANT, cloudOwner, cloudRegion, tenantId))
+ return this.getAaiResourcesClient().get(Tenant.class, AAIUriFactory.createResourceUri(
+ AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudOwner, cloudRegion).tenant(tenantId)))
.orElseGet(() -> {
logger.debug("No Tenant found in A&AI TenantId: {}", tenantId);
return null;
@@ -148,9 +158,9 @@ public class AAIDataRetrieval {
}
public List<LInterface> getLinterfacesOfVnf(String vnfId) {
- DSLStartNode startNode = new DSLStartNode(AAIObjectType.GENERIC_VNF, __.key("vnf-id", vnfId));
- DSLQueryBuilder<Start, Node> builder = TraversalBuilder.fragment(startNode)
- .to(__.node(AAIObjectType.VSERVER).to(__.node(AAIObjectType.L_INTERFACE).output()));
+ DSLStartNode startNode = new DSLStartNode(Types.GENERIC_VNF, __.key("vnf-id", vnfId));
+ DSLQueryBuilder<Start, Node> builder =
+ TraversalBuilder.fragment(startNode).to(__.node(Types.VSERVER).to(__.node(Types.L_INTERFACE).output()));
List<LInterface> linterfaces =
getAAIDSLQueryClient().querySingleResource(new DSLQuery(builder.build()), LInterface.class);
return linterfaces;
@@ -176,7 +186,8 @@ public class AAIDataRetrieval {
public List<VfModule> getVfModulesOfVnf(String vnfId) {
List<VfModule> vfModuleList = new ArrayList<VfModule>();
- AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.VF_MODULE, vnfId);
+ AAIPluralResourceUri uri =
+ AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId).vfModules());
Optional<VfModules> vfModules = getAaiResourcesClient().get(VfModules.class, uri);
if (!vfModules.isPresent() || vfModules.get().getVfModule().isEmpty()) {
logger.debug("No VfModules attached to Vnf in AAI : {}", vnfId);
@@ -198,8 +209,8 @@ public class AAIDataRetrieval {
public List<VolumeGroup> getVolumeGroupsOfVnf(String vnfId) {
List<VolumeGroup> volumeGroupList = new ArrayList<VolumeGroup>();
- AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)
- .relatedTo(AAIObjectPlurals.VOLUME_GROUP);
+ AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId))
+ .relatedTo(Types.VOLUME_GROUPS.getFragment());
Optional<VolumeGroups> volumeGroups = getAaiResourcesClient().get(VolumeGroups.class, uri);
if (!volumeGroups.isPresent() || volumeGroups.get().getVolumeGroup().isEmpty()) {
logger.debug("No VolumeGroups attached to Vnf in AAI : {}", vnfId);
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/BpmnRequestBuilder.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/BpmnRequestBuilder.java
index 6e7947bb58..edf17f363b 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/BpmnRequestBuilder.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/BpmnRequestBuilder.java
@@ -29,9 +29,9 @@ import org.onap.aai.domain.yang.L3Network;
import org.onap.aai.domain.yang.ServiceInstance;
import org.onap.aai.domain.yang.VfModule;
import org.onap.aai.domain.yang.VolumeGroup;
-import org.onap.aaiclient.client.aai.AAIObjectType;
import org.onap.aaiclient.client.aai.entities.AAIResultWrapper;
import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder;
+import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types;
import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.onap.so.apihandlerinfra.infra.rest.exception.AAIEntityNotFound;
import org.onap.so.apihandlerinfra.infra.rest.exception.CloudConfigurationNotFoundException;
@@ -278,13 +278,13 @@ public class BpmnRequestBuilder {
String cloudOwner = null;
String lcpRegionId = null;
if (relationshipsOpt.isPresent()) {
- tenantId = relationshipsOpt.get().getRelatedUris(AAIObjectType.TENANT).stream().findFirst()
+ tenantId = relationshipsOpt.get().getRelatedUris(Types.TENANT).stream().findFirst()
.map(item -> item.getURIKeys().get(AAIFluentTypeBuilder.Types.TENANT.getUriParams().tenantId))
.orElse(null);
- cloudOwner = relationshipsOpt.get().getRelatedUris(AAIObjectType.TENANT).stream().findFirst().map(
+ cloudOwner = relationshipsOpt.get().getRelatedUris(Types.TENANT).stream().findFirst().map(
item -> item.getURIKeys().get(AAIFluentTypeBuilder.Types.CLOUD_REGION.getUriParams().cloudOwner))
.orElse(null);
- lcpRegionId = relationshipsOpt.get().getRelatedUris(AAIObjectType.TENANT).stream().findFirst().map(
+ lcpRegionId = relationshipsOpt.get().getRelatedUris(Types.TENANT).stream().findFirst().map(
item -> item.getURIKeys().get(AAIFluentTypeBuilder.Types.CLOUD_REGION.getUriParams().cloudRegionId))
.orElse(null);
}
@@ -323,13 +323,13 @@ public class BpmnRequestBuilder {
String cloudOwner = null;
String lcpRegionId = null;
if (relationshipsOpt.isPresent()) {
- tenantId = relationshipsOpt.get().getRelatedUris(AAIObjectType.TENANT).stream().findFirst()
+ tenantId = relationshipsOpt.get().getRelatedUris(Types.TENANT).stream().findFirst()
.map(item -> item.getURIKeys().get(AAIFluentTypeBuilder.Types.TENANT.getUriParams().tenantId))
.orElse(null);
- cloudOwner = relationshipsOpt.get().getRelatedUris(AAIObjectType.TENANT).stream().findFirst().map(
+ cloudOwner = relationshipsOpt.get().getRelatedUris(Types.TENANT).stream().findFirst().map(
item -> item.getURIKeys().get(AAIFluentTypeBuilder.Types.CLOUD_REGION.getUriParams().cloudOwner))
.orElse(null);
- lcpRegionId = relationshipsOpt.get().getRelatedUris(AAIObjectType.TENANT).stream().findFirst().map(
+ lcpRegionId = relationshipsOpt.get().getRelatedUris(Types.TENANT).stream().findFirst().map(
item -> item.getURIKeys().get(AAIFluentTypeBuilder.Types.CLOUD_REGION.getUriParams().cloudRegionId))
.orElse(null);
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/VolumeGroupDeleteValidator.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/VolumeGroupDeleteValidator.java
index 550db19af4..3640baa942 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/VolumeGroupDeleteValidator.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/VolumeGroupDeleteValidator.java
@@ -25,7 +25,8 @@ public class VolumeGroupDeleteValidator implements RequestValidator {
@Override
public Optional<String> validate(Map<String, String> instanceIdMap, ServiceInstancesRequest request,
Map<String, String> queryParams, Actions action) {
- if (aaiDataRetrieval.isVolumeGroupRelatedToVFModule(instanceIdMap.get("volumeGroupInstanceId"))) {
+ if (aaiDataRetrieval.isVolumeGroupRelatedToVFModule(request.getRequestDetails().getCloudConfiguration(),
+ instanceIdMap.get("volumeGroupInstanceId"))) {
return Optional.of("Cannot delete volume group it is related to existing vf-modules");
} else {
return Optional.empty();
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelper.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelper.java
index a28298f859..33fe9d8ae9 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelper.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelper.java
@@ -27,13 +27,13 @@ import java.io.StringWriter;
import java.util.Map;
import javax.ws.rs.NotFoundException;
import org.onap.aai.domain.yang.OperationalEnvironment;
-import org.onap.so.apihandlerinfra.tenantisolation.exceptions.AAIClientCallFailed;
-import org.onap.aaiclient.client.aai.AAIObjectType;
import org.onap.aaiclient.client.aai.AAIResourcesClient;
import org.onap.aaiclient.client.aai.entities.AAIResultWrapper;
import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri;
import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory;
+import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder;
import org.onap.aaiclient.client.graphinventory.entities.uri.Depth;
+import org.onap.so.apihandlerinfra.tenantisolation.exceptions.AAIClientCallFailed;
import org.springframework.stereotype.Component;
@@ -50,7 +50,8 @@ public class AAIClientHelper {
*/
public AAIResultWrapper getAaiOperationalEnvironment(String id) {
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.OPERATIONAL_ENVIRONMENT, id);
+ AAIResourceUri uri =
+ AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().operationalEnvironment(id));
uri.depth(Depth.ZERO);
AAIResourcesClient client = this.getClient();
return client.get(uri, NotFoundException.class);
@@ -65,7 +66,8 @@ public class AAIClientHelper {
*/
public void updateAaiOperationalEnvironment(String id, OperationalEnvironment aaiRequest) {
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.OPERATIONAL_ENVIRONMENT, id);
+ AAIResourceUri uri =
+ AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().operationalEnvironment(id));
AAIResourcesClient client = this.getClient();
client.update(uri, aaiRequest);
@@ -75,8 +77,8 @@ public class AAIClientHelper {
public void updateAaiOperationalEnvironment(String operationalEnvironmentId, Map<String, String> payload)
throws AAIClientCallFailed {
try {
- AAIResourceUri uri =
- AAIUriFactory.createResourceUri(AAIObjectType.OPERATIONAL_ENVIRONMENT, operationalEnvironmentId);
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(
+ AAIFluentTypeBuilder.cloudInfrastructure().operationalEnvironment(operationalEnvironmentId));
AAIResourcesClient aaiClient = this.getClient();
aaiClient.update(uri, payload);
} catch (Exception ex) {
@@ -92,8 +94,8 @@ public class AAIClientHelper {
*/
public void createOperationalEnvironment(OperationalEnvironment operationalEnvironment) {
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.OPERATIONAL_ENVIRONMENT,
- operationalEnvironment.getOperationalEnvironmentId());
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure()
+ .operationalEnvironment(operationalEnvironment.getOperationalEnvironmentId()));
AAIResourcesClient client = this.getClient();
client.create(uri, operationalEnvironment);
}
@@ -107,10 +109,10 @@ public class AAIClientHelper {
*/
public void createRelationship(String managingEcompOperationalEnvironmentId, String vnfOperationalEnvironmentId) {
- AAIResourceUri ecompEnvUri = AAIUriFactory.createResourceUri(AAIObjectType.OPERATIONAL_ENVIRONMENT,
- managingEcompOperationalEnvironmentId);
- AAIResourceUri vnfEnvUri =
- AAIUriFactory.createResourceUri(AAIObjectType.OPERATIONAL_ENVIRONMENT, vnfOperationalEnvironmentId);
+ AAIResourceUri ecompEnvUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure()
+ .operationalEnvironment(managingEcompOperationalEnvironmentId));
+ AAIResourceUri vnfEnvUri = AAIUriFactory.createResourceUri(
+ AAIFluentTypeBuilder.cloudInfrastructure().operationalEnvironment(vnfOperationalEnvironmentId));
AAIResourcesClient client = this.getClient();
client.connect(vnfEnvUri, ecompEnvUri);
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java
index d4c66f62e4..42d5af7feb 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java
@@ -26,11 +26,11 @@ import javax.ws.rs.core.Response;
import org.apache.http.HttpStatus;
import org.json.JSONObject;
import org.onap.aai.domain.yang.OperationalEnvironment;
-import org.onap.aaiclient.client.aai.AAIObjectType;
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.generated.fluentbuilders.AAIFluentTypeBuilder;
+import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types;
import org.onap.logging.filter.base.ErrorCode;
import org.onap.so.apihandler.common.ErrorNumbers;
import org.onap.so.apihandlerinfra.exceptions.ApiException;
@@ -94,8 +94,7 @@ public class ActivateVnfOperationalEnvironment {
Optional<Relationships> optRelationships = wrapper.getRelationships();
if (optRelationships.isPresent()) {
Relationships relationships = optRelationships.get();
- List<AAIResourceUri> operationalEnvironments =
- relationships.getRelatedAAIUris(AAIObjectType.OPERATIONAL_ENVIRONMENT);
+ List<AAIResourceUri> operationalEnvironments = relationships.getRelatedUris(Types.OPERATIONAL_ENVIRONMENT);
if (!operationalEnvironments.isEmpty()) {
ecompOperationalEnvironmentId = operationalEnvironments.get(0).getURIKeys().get(
AAIFluentTypeBuilder.Types.OPERATIONAL_ENVIRONMENT.getUriParams().operationalEnvironmentId);
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/AAIDataRetrievalTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/AAIDataRetrievalTest.java
index 9d5d80592d..61ac542810 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/AAIDataRetrievalTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/AAIDataRetrievalTest.java
@@ -24,22 +24,20 @@ import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.doReturn;
import java.util.List;
import java.util.Optional;
-import org.junit.Before;
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.GenericVnf;
import org.onap.aai.domain.yang.VfModule;
import org.onap.aai.domain.yang.VfModules;
import org.onap.aai.domain.yang.VolumeGroup;
import org.onap.aai.domain.yang.VolumeGroups;
-import org.onap.aaiclient.client.aai.AAIObjectPlurals;
-import org.onap.aaiclient.client.aai.AAIObjectType;
import org.onap.aaiclient.client.aai.AAIResourcesClient;
import org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri;
import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory;
+import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder;
+import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types;
@RunWith(MockitoJUnitRunner.class)
public class AAIDataRetrievalTest {
@@ -52,7 +50,8 @@ public class AAIDataRetrievalTest {
@Test
public void getVfModulesOfVnfTest() {
VfModules vfModules = getVfModules();
- AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.VF_MODULE, "vnfId");
+ AAIPluralResourceUri uri =
+ AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("vnfId").vfModules());
doReturn(Optional.of(vfModules)).when(aaiResourcesClient).get(VfModules.class, uri);
List<VfModule> vfModulesList = aaiDataRetrieval.getVfModulesOfVnf("vnfId");
assertEquals("vfm1", vfModulesList.get(0).getVfModuleId());
@@ -64,7 +63,8 @@ public class AAIDataRetrievalTest {
@Test
public void getVfModulesOfVnfWhenNoneTest() {
VfModules vfModules = new VfModules();
- AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.VF_MODULE, "vnfId");
+ AAIPluralResourceUri uri =
+ AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("vnfId").vfModules());
doReturn(Optional.of(vfModules)).when(aaiResourcesClient).get(VfModules.class, uri);
List<VfModule> vfModulesList = aaiDataRetrieval.getVfModulesOfVnf("vnfId");
assertEquals(true, vfModulesList.isEmpty());
@@ -76,8 +76,8 @@ public class AAIDataRetrievalTest {
@Test
public void getVolumeGroupsOfVnfTest() throws Exception {
VolumeGroups volumeGroups = getVolumeGroups();
- AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "vnfId")
- .relatedTo(AAIObjectPlurals.VOLUME_GROUP);
+ AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("vnfId"))
+ .relatedTo(Types.VOLUME_GROUPS.getFragment());
doReturn(Optional.of(volumeGroups)).when(aaiResourcesClient).get(VolumeGroups.class, uri);
List<VolumeGroup> volumeGroupList = aaiDataRetrieval.getVolumeGroupsOfVnf("vnfId");
assertEquals("vg1", volumeGroupList.get(0).getVolumeGroupId());
@@ -88,8 +88,8 @@ public class AAIDataRetrievalTest {
@Test
public void getVolumeGroupsOfVnfWhenNoneTest() throws Exception {
VolumeGroups volumeGroups = new VolumeGroups();
- AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "vnfId")
- .relatedTo(AAIObjectPlurals.VOLUME_GROUP);
+ AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("vnfId"))
+ .relatedTo(Types.VOLUME_GROUPS.getFragment());
doReturn(Optional.of(volumeGroups)).when(aaiResourcesClient).get(VolumeGroups.class, uri);
List<VolumeGroup> volumeGroupList = aaiDataRetrieval.getVolumeGroupsOfVnf("vnfId");
assertEquals(true, volumeGroupList.isEmpty());
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/BpmnRequestBuilderTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/BpmnRequestBuilderTest.java
index 389ff28dbd..912c026203 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/BpmnRequestBuilderTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/BpmnRequestBuilderTest.java
@@ -41,10 +41,11 @@ import org.onap.aai.domain.yang.GenericVnf;
import org.onap.aai.domain.yang.ServiceInstance;
import org.onap.aai.domain.yang.VfModule;
import org.onap.aai.domain.yang.VolumeGroup;
-import org.onap.aaiclient.client.aai.AAIObjectType;
import org.onap.aaiclient.client.aai.AAIResourcesClient;
import org.onap.aaiclient.client.aai.entities.AAIResultWrapper;
import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory;
+import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder;
+import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types;
import org.onap.aaiclient.client.graphinventory.GraphInventoryCommonObjectMapperProvider;
import org.onap.so.constants.Status;
import org.onap.so.db.request.client.RequestsDbClient;
@@ -104,7 +105,7 @@ public class BpmnRequestBuilderTest {
GenericVnf vnf = provider.getMapper().readValue(new File(RESOURCE_PATH + "Vnf.json"), GenericVnf.class);
doReturn(Optional.of(vnf)).when(aaiResourcesClient).get(GenericVnf.class,
- AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "vnfId"));
+ AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("vnfId")));
ServiceInstancesRequest expectedRequest =
mapper.readValue(new File(RESOURCE_PATH + "ExpectedVnfRequest.json"), ServiceInstancesRequest.class);
@@ -117,11 +118,11 @@ public class BpmnRequestBuilderTest {
GenericVnf vnf = provider.getMapper().readValue(new File(RESOURCE_PATH + "Vnf.json"), GenericVnf.class);
doReturn(Optional.of(vnf)).when(aaiResourcesClient).get(GenericVnf.class,
- AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "vnfId"));
+ AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("vnfId")));
VfModule vfModule = provider.getMapper().readValue(new File(RESOURCE_PATH + "VfModule.json"), VfModule.class);
- doReturn(Optional.of(vfModule)).when(aaiResourcesClient).get(VfModule.class,
- AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, "vnfId", "vfModuleId"));
+ doReturn(Optional.of(vfModule)).when(aaiResourcesClient).get(VfModule.class, AAIUriFactory
+ .createResourceUri(AAIFluentTypeBuilder.network().genericVnf("vnfId").vfModule("vfModuleId")));
ServiceInstancesRequest expectedRequest = mapper
.readValue(new File(RESOURCE_PATH + "ExpectedVfModuleRequest.json"), ServiceInstancesRequest.class);
@@ -135,13 +136,13 @@ public class BpmnRequestBuilderTest {
GenericVnf vnf = provider.getMapper().readValue(new File(RESOURCE_PATH + "Vnf.json"), GenericVnf.class);
doReturn(Optional.of(vnf)).when(aaiResourcesClient).get(GenericVnf.class,
- AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "vnfId"));
+ AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("vnfId")));
VolumeGroup volumeGroup =
provider.getMapper().readValue(new File(RESOURCE_PATH + "VolumeGroup.json"), VolumeGroup.class);
AAIResultWrapper wrapper = new AAIResultWrapper(volumeGroup);
doReturn(wrapper).when(aaiResourcesClient)
- .get(AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "vnfId")
- .relatedTo(AAIObjectType.VOLUME_GROUP, "volumeGroupId"));
+ .get(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("vnfId"))
+ .relatedTo(Types.VOLUME_GROUP.getFragment("volumeGroupId")));
ServiceInstancesRequest expectedRequest = mapper
.readValue(new File(RESOURCE_PATH + "ExpectedVolumeGroupRequest.json"), ServiceInstancesRequest.class);
@@ -157,7 +158,7 @@ public class BpmnRequestBuilderTest {
GenericVnf vnf = provider.getMapper().readValue(new File(RESOURCE_PATH + "Vnf.json"), GenericVnf.class);
doReturn(Optional.of(vnf)).when(aaiResourcesClient).get(GenericVnf.class,
- AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId));
+ AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId)));
CloudConfiguration result = reqBuilder.getCloudConfigurationVfModuleReplace(vnfId, vfModuleId);
assertEquals("0422ffb57ba042c0800a29dc85ca70f8", result.getTenantId());
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/validator/VolumeGroupDeleteValidatorTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/validator/VolumeGroupDeleteValidatorTest.java
index 7aa12a61a6..1023408088 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/validator/VolumeGroupDeleteValidatorTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/validator/VolumeGroupDeleteValidatorTest.java
@@ -1,6 +1,8 @@
package org.onap.so.apihandlerinfra.infra.rest.validator;
import static org.junit.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.when;
import java.util.HashMap;
import java.util.Map;
@@ -14,6 +16,8 @@ import org.mockito.junit.MockitoJUnitRunner;
import org.onap.so.apihandlerinfra.Action;
import org.onap.so.apihandlerinfra.infra.rest.AAIDataRetrieval;
import org.onap.so.apihandlerinfra.infra.rest.validators.VolumeGroupDeleteValidator;
+import org.onap.so.serviceinstancebeans.CloudConfiguration;
+import org.onap.so.serviceinstancebeans.RequestDetails;
import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
@@ -53,16 +57,24 @@ public class VolumeGroupDeleteValidatorTest {
@Test
public void validateSuccessTest() {
instanceIdMap.put("volumeGroupInstanceId", "1");
- when(aaiDataRetrieval.isVolumeGroupRelatedToVFModule("1")).thenReturn(false);
- Optional<String> result = volumeGroupDeleteValidator.validate(instanceIdMap, null, null, null);
+ ServiceInstancesRequest request = new ServiceInstancesRequest();
+ RequestDetails details = new RequestDetails();
+ details.setCloudConfiguration(new CloudConfiguration());
+ request.setRequestDetails(details);
+ when(aaiDataRetrieval.isVolumeGroupRelatedToVFModule(any(CloudConfiguration.class), eq("1"))).thenReturn(false);
+ Optional<String> result = volumeGroupDeleteValidator.validate(instanceIdMap, request, null, null);
assertEquals(false, result.isPresent());
}
@Test
public void validateFailureVnfTest() {
instanceIdMap.put("volumeGroupInstanceId", "1");
- when(aaiDataRetrieval.isVolumeGroupRelatedToVFModule("1")).thenReturn(true);
- Optional<String> result = volumeGroupDeleteValidator.validate(instanceIdMap, null, null, null);
+ ServiceInstancesRequest request = new ServiceInstancesRequest();
+ RequestDetails details = new RequestDetails();
+ details.setCloudConfiguration(new CloudConfiguration());
+ request.setRequestDetails(details);
+ when(aaiDataRetrieval.isVolumeGroupRelatedToVFModule(any(CloudConfiguration.class), eq("1"))).thenReturn(true);
+ Optional<String> result = volumeGroupDeleteValidator.validate(instanceIdMap, request, null, null);
assertEquals(true, result.isPresent());
}