From a3b0c74345d2dbf981d49493ef498e28e867a144 Mon Sep 17 00:00:00 2001 From: "Plummer, Brittany" Date: Thu, 4 Jun 2020 12:52:07 -0400 Subject: mso to add validation for vf module instantiation Updated validator to accept action on validate Added VnfInServiceValidator and unit tests Issue-ID: SO-2975 Signed-off-by: Benjamin, Max (mb388a) Change-Id: I5e1d7a40dab6a447588cac55edade5e2823e7dac --- .../apihandlerinfra/infra/rest/validators/NetworkDeleteValidator.java | 2 +- .../so/apihandlerinfra/infra/rest/validators/RequestValidator.java | 2 +- .../infra/rest/validators/RequestValidatorListenerRunner.java | 4 ++-- .../infra/rest/validators/ServiceInstanceDeleteValidator.java | 2 +- .../so/apihandlerinfra/infra/rest/validators/VnfDeleteValidator.java | 2 +- .../infra/rest/validators/VolumeGroupDeleteValidator.java | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) (limited to 'mso-api-handlers/mso-api-handler-infra/src/main/java') diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/NetworkDeleteValidator.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/NetworkDeleteValidator.java index 89c5cbed9b..c875764b7b 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/NetworkDeleteValidator.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/NetworkDeleteValidator.java @@ -25,7 +25,7 @@ public class NetworkDeleteValidator implements RequestValidator { @Override public Optional validate(Map instanceIdMap, ServiceInstancesRequest request, - Map queryParams) { + Map queryParams, Actions action) { if (aaiDataRetrieval.isNetworkRelatedToModules(instanceIdMap.get("networkInstanceId"))) { return Optional.of("Cannot delete network it is still related to existing vf-modules"); } else { diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/RequestValidator.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/RequestValidator.java index 50938e6826..dc6d01ea8a 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/RequestValidator.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/RequestValidator.java @@ -39,5 +39,5 @@ public interface RequestValidator { public Optional validate(Map instanceIdMap, ServiceInstancesRequest request, - Map queryParams); + Map queryParams, Actions action); } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/RequestValidatorListenerRunner.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/RequestValidatorListenerRunner.java index 3aba39b501..7ab761aeef 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/RequestValidatorListenerRunner.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/RequestValidatorListenerRunner.java @@ -73,8 +73,8 @@ public class RequestValidatorListenerRunner extends ListenerRunner { filterListeners(validators, (item -> item.shouldRunFor(requestURI, request, action))); List>> results = new ArrayList<>(); - filtered.forEach(item -> results - .add(new Pair<>(item.getClass().getName(), item.validate(instanceIdMap, request, queryParams)))); + filtered.forEach(item -> results.add( + new Pair<>(item.getClass().getName(), item.validate(instanceIdMap, request, queryParams, action)))); return results.stream().filter(item -> item.getValue1().isPresent()).collect(Collectors.toList()); } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/ServiceInstanceDeleteValidator.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/ServiceInstanceDeleteValidator.java index 843d94ce6c..74dbf579c0 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/ServiceInstanceDeleteValidator.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/ServiceInstanceDeleteValidator.java @@ -34,7 +34,7 @@ public class ServiceInstanceDeleteValidator implements RequestValidator { @Override public Optional validate(Map instanceIdMap, ServiceInstancesRequest request, - Map queryParams) { + Map queryParams, Actions action) { if (aaiDataRetrieval.isServiceRelatedToGenericVnf(instanceIdMap.get("serviceInstanceId"))) { return Optional.of("Cannot delete service it is still related to existing vf-modules"); } else if (aaiDataRetrieval.isServiceRelatedToNetworks(instanceIdMap.get("serviceInstanceId"))) { diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/VnfDeleteValidator.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/VnfDeleteValidator.java index a48fca8d0f..44bab7e087 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/VnfDeleteValidator.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/VnfDeleteValidator.java @@ -24,7 +24,7 @@ public class VnfDeleteValidator implements RequestValidator { @Override public Optional validate(Map instanceIdMap, ServiceInstancesRequest request, - Map queryParams) { + Map queryParams, Actions action) { final Optional volumeGroupIds = aaiDataRetrieval.getVolumeGroupIdsByVnfId(instanceIdMap.get("vnfInstanceId")); final Optional vfModuleIds = aaiDataRetrieval.getVfModuleIdsByVnfId(instanceIdMap.get("vnfInstanceId")); 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 e3598af31d..550db19af4 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 @@ -24,7 +24,7 @@ public class VolumeGroupDeleteValidator implements RequestValidator { @Override public Optional validate(Map instanceIdMap, ServiceInstancesRequest request, - Map queryParams) { + Map queryParams, Actions action) { if (aaiDataRetrieval.isVolumeGroupRelatedToVFModule(instanceIdMap.get("volumeGroupInstanceId"))) { return Optional.of("Cannot delete volume group it is related to existing vf-modules"); } else { -- cgit 1.2.3-korg