From fa36daa658a50d9ca2e57cae649d63c0e9e2882a Mon Sep 17 00:00:00 2001 From: "Smokowski, Steven" Date: Thu, 15 Aug 2019 21:40:16 -0400 Subject: Initial commit of validation framework to APIH Move ListenerRunner to common location Adjust request params name, update junit tests Update validations to work properly Properly escape period for the string split Issue-ID: SO-2232 Signed-off-by: Benjamin, Max (mb388a) Change-Id: Ia468cf7062cccf30e28afeb7a5cddc37ceb2e002 --- .../so/apihandlerinfra/RequestHandlerUtils.java | 21 +----- .../onap/so/apihandlerinfra/ServiceInstances.java | 13 ++++ .../infra/rest/AAIDataRetrieval.java | 85 +++++++++++++++++++++ .../infra/rest/BpmnRequestBuilder.java | 88 +++------------------- .../infra/rest/validators/RequestValidator.java | 40 ++++++++++ .../validators/RequestValidatorListenerRunner.java | 80 ++++++++++++++++++++ .../validation/PlatformLOBValidation.java | 3 +- .../validation/ProjectOwningEntityValidation.java | 4 +- 8 files changed, 237 insertions(+), 97 deletions(-) create mode 100644 mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/AAIDataRetrieval.java create mode 100644 mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/RequestValidator.java create mode 100644 mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/RequestValidatorListenerRunner.java (limited to 'mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap') diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java index b6f3f82ab1..2fddfd9a95 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java @@ -479,24 +479,11 @@ public class RequestHandlerUtils extends AbstractRestHandler { boolean isAlaCarte, Actions action) throws IOException { ObjectMapper mapper = new ObjectMapper(); mapper.setSerializationInclusion(Include.NON_NULL); - if (msoRawRequest != null) { - ServiceInstancesRequest sir = mapper.readValue(msoRawRequest, ServiceInstancesRequest.class); - if (serviceInstRequest != null && serviceInstRequest.getRequestDetails() != null - && serviceInstRequest.getRequestDetails().getRequestParameters() != null) { - if (!isAlaCarte && Action.createInstance.equals(action)) { - sir.getRequestDetails() - .setCloudConfiguration(serviceInstRequest.getRequestDetails().getCloudConfiguration()); - sir.getRequestDetails().getRequestParameters().setUserParams( - serviceInstRequest.getRequestDetails().getRequestParameters().getUserParams()); - } - sir.getRequestDetails().getRequestParameters() - .setUsePreload(serviceInstRequest.getRequestDetails().getRequestParameters().getUsePreload()); - } - - logger.debug("Value as string: {}", mapper.writeValueAsString(sir)); - return mapper.writeValueAsString(sir); + if (serviceInstRequest != null) { + return mapper.writeValueAsString(serviceInstRequest); + } else { + return msoRawRequest; } - return null; } public Optional retrieveModelName(RequestParameters requestParams) { diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java index 5b827d9cf8..b1d38983ec 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java @@ -51,6 +51,7 @@ import org.onap.so.apihandlerinfra.exceptions.RecipeNotFoundException; import org.onap.so.apihandlerinfra.exceptions.RequestDbFailureException; import org.onap.so.apihandlerinfra.exceptions.ValidateException; import org.onap.so.apihandlerinfra.infra.rest.handler.AbstractRestHandler; +import org.onap.so.apihandlerinfra.infra.rest.validators.RequestValidatorListenerRunner; import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo; import org.onap.so.constants.Status; import org.onap.so.db.catalog.beans.NetworkResource; @@ -124,6 +125,9 @@ public class ServiceInstances extends AbstractRestHandler { @Autowired private RequestHandlerUtils requestHandlerUtils; + @Autowired + private RequestValidatorListenerRunner requestValidatorListenerRunner; + @POST @Path("/{version:[vV][5-7]}/serviceInstances") @Consumes(MediaType.APPLICATION_JSON) @@ -764,6 +768,13 @@ public class ServiceInstances extends AbstractRestHandler { public Response serviceInstances(String requestJSON, Actions action, HashMap instanceIdMap, String version, String requestId, String requestUri) throws ApiException { + return serviceInstances(requestJSON, action, instanceIdMap, version, requestId, requestUri, null); + + } + + public Response serviceInstances(String requestJSON, Actions action, HashMap instanceIdMap, + String version, String requestId, String requestUri, HashMap queryParams) + throws ApiException { String serviceInstanceId; Boolean aLaCarte = null; ServiceInstancesRequest sir; @@ -771,6 +782,8 @@ public class ServiceInstances extends AbstractRestHandler { sir = requestHandlerUtils.convertJsonToServiceInstanceRequest(requestJSON, action, requestId, requestUri); action = handleReplaceInstance(action, sir); + requestValidatorListenerRunner.runValidations(requestUri, instanceIdMap, sir, queryParams); + String requestScope = requestHandlerUtils.deriveRequestScope(action, sir, requestUri); InfraActiveRequests currentActiveReq = msoRequest.createRequestObject(sir, action, requestId, Status.IN_PROGRESS, requestJSON, requestScope); 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 new file mode 100644 index 0000000000..344e5438c9 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/AAIDataRetrieval.java @@ -0,0 +1,85 @@ +package org.onap.so.apihandlerinfra.infra.rest; + +import java.util.Optional; +import org.onap.aai.domain.yang.GenericVnf; +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.so.apihandlerinfra.infra.rest.exception.AAIEntityNotFound; +import org.onap.so.client.aai.AAIObjectType; +import org.onap.so.client.aai.AAIResourcesClient; +import org.onap.so.client.aai.entities.AAIResultWrapper; +import org.onap.so.client.aai.entities.uri.AAIUriFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +@Component +public class AAIDataRetrieval { + + private static final String VF_MODULE_NOT_FOUND_IN_INVENTORY_VNF_ID = "VF Module Not Found In Inventory, VnfId: "; + + private AAIResourcesClient aaiResourcesClient; + + private static final Logger logger = LoggerFactory.getLogger(AAIDataRetrieval.class); + + public ServiceInstance getServiceInstance(String serviceInstanceId) { + return this.getAaiResourcesClient() + .get(ServiceInstance.class, + AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId)) + .orElseGet(() -> { + logger.debug("No Service Instance found in A&AI ServiceInstanceId: {}", serviceInstanceId); + return null; + }); + } + + + public VfModule getAAIVfModule(String vnfId, String vfModuleId) { + return this.getAaiResourcesClient() + .get(VfModule.class, AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId)) + .orElseGet(() -> { + logger.debug("No Vf Module found in A&AI VnfId: {}" + ", VfModuleId: {}", vnfId, vfModuleId); + return null; + }); + } + + public GenericVnf getGenericVnf(String vnfId) { + return this.getAaiResourcesClient() + .get(GenericVnf.class, AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)) + .orElseGet(() -> { + logger.debug("No Generic VNF found in A&AI VnfId: {}", vnfId); + return null; + }); + } + + 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)); + Optional volume = wrapper.asBean(VolumeGroup.class); + if (volume.isPresent()) { + return volume.get(); + } else { + logger.debug("No VolumeGroup in A&AI found: {}", vnfId); + return null; + } + } + + public L3Network getNetwork(String networkId) { + return this.getAaiResourcesClient() + .get(L3Network.class, AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId)) + .orElseGet(() -> { + logger.debug("No Network found in A&AI NetworkId: {}", networkId); + return null; + }); + } + + protected AAIResourcesClient getAaiResourcesClient() { + if (aaiResourcesClient == null) { + aaiResourcesClient = new AAIResourcesClient(); + } + return aaiResourcesClient; + } + +} 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 bb5b4edfe4..ee2bb586cf 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 @@ -33,10 +33,7 @@ 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; import org.onap.so.client.aai.AAIObjectType; -import org.onap.so.client.aai.AAIResourcesClient; import org.onap.so.client.aai.entities.AAIResultWrapper; -import org.onap.so.client.aai.entities.uri.AAIResourceUri; -import org.onap.so.client.aai.entities.uri.AAIUriFactory; import org.onap.so.constants.Status; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.client.RequestsDbClient; @@ -75,17 +72,19 @@ public class BpmnRequestBuilder { @Autowired private RequestsDbClient infraActiveRequestsClient; + @Autowired + private AAIDataRetrieval aaiDataRet; + private ObjectMapper mapper = new ObjectMapper(); - private AAIResourcesClient aaiResourcesClient; public ServiceInstancesRequest buildVFModuleDeleteRequest(String vnfId, String vfModuleId, ModelType modelType) throws AAIEntityNotFound { - GenericVnf vnf = getGenericVnf(vnfId); + GenericVnf vnf = aaiDataRet.getGenericVnf(vnfId); if (vnf == null) { throw new AAIEntityNotFound(GENERIC_VNF_NOT_FOUND_IN_INVENTORY_VNF_ID + vnfId); } - VfModule vfModule = getAAIVfModule(vnfId, vfModuleId); + VfModule vfModule = aaiDataRet.getAAIVfModule(vnfId, vfModuleId); if (vfModule == null) { throw new AAIEntityNotFound(VF_MODULE_NOT_FOUND_IN_INVENTORY_VNF_ID + vnfId + " vfModuleId: " + vfModuleId); } @@ -94,11 +93,11 @@ public class BpmnRequestBuilder { public ServiceInstancesRequest buildVolumeGroupDeleteRequest(String vnfId, String volumeGroupId) throws AAIEntityNotFound { - GenericVnf vnf = getGenericVnf(vnfId); + GenericVnf vnf = aaiDataRet.getGenericVnf(vnfId); if (vnf == null) { throw new AAIEntityNotFound(GENERIC_VNF_NOT_FOUND_IN_INVENTORY_VNF_ID + vnfId); } - VolumeGroup volumeGroup = getVolumeGroup(vnfId, volumeGroupId); + VolumeGroup volumeGroup = aaiDataRet.getVolumeGroup(vnfId, volumeGroupId); if (volumeGroup == null) { throw new AAIEntityNotFound( VF_MODULE_NOT_FOUND_IN_INVENTORY_VNF_ID + vnfId + " volumeGroupId: " + volumeGroupId); @@ -107,7 +106,7 @@ public class BpmnRequestBuilder { } public ServiceInstancesRequest buildServiceDeleteRequest(String serviceInstanceId) throws AAIEntityNotFound { - ServiceInstance serviceInstance = getServiceInstance(serviceInstanceId); + ServiceInstance serviceInstance = aaiDataRet.getServiceInstance(serviceInstanceId); if (serviceInstance == null) { throw new AAIEntityNotFound( "ServiceInstance Not Found In Inventory, ServiceInstanceId: " + serviceInstanceId); @@ -116,7 +115,7 @@ public class BpmnRequestBuilder { } public ServiceInstancesRequest buildVnfDeleteRequest(String vnfId) throws AAIEntityNotFound { - GenericVnf vnf = getGenericVnf(vnfId); + GenericVnf vnf = aaiDataRet.getGenericVnf(vnfId); if (vnf == null) { throw new AAIEntityNotFound(GENERIC_VNF_NOT_FOUND_IN_INVENTORY_VNF_ID + vnfId); } @@ -124,7 +123,7 @@ public class BpmnRequestBuilder { } public ServiceInstancesRequest buildNetworkDeleteRequest(String networkId) throws AAIEntityNotFound { - L3Network network = getNetwork(networkId); + L3Network network = aaiDataRet.getNetwork(networkId); if (network == null) { throw new AAIEntityNotFound("Network Not Found In Inventory, NetworkId: " + networkId); } @@ -407,72 +406,5 @@ public class BpmnRequestBuilder { return requestParams; } - public VfModule getAAIVfModule(String vnfId, String vfModuleId) { - return this.getAaiResourcesClient() - .get(VfModule.class, AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId)) - .orElseGet(() -> { - logger.debug("No Vf Module found in A&AI VnfId: {}" + ", VfModuleId: {}", vnfId, vfModuleId); - return null; - }); - } - - public GenericVnf getGenericVnf(String vnfId) { - return this.getAaiResourcesClient() - .get(GenericVnf.class, AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)) - .orElseGet(() -> { - logger.debug("No Generic VNF found in A&AI VnfId: {}", vnfId); - return null; - }); - } - - public VolumeGroup getVolumeGroup(String vnfId, String volumeGroupId) throws AAIEntityNotFound { - GenericVnf vnf = getGenericVnf(vnfId); - AAIResultWrapper wrapper = new AAIResultWrapper(vnf); - List listVserverWrapper; - Optional volumeGroupURI; - if (wrapper.getRelationships().isPresent()) { - listVserverWrapper = wrapper.getRelationships().get().getRelatedUris(AAIObjectType.VOLUME_GROUP); - volumeGroupURI = listVserverWrapper.stream() - .filter(resourceURI -> resourceURI.getURIKeys().get("volume-group-id").equals(volumeGroupId)) - .findFirst(); - } else { - throw new AAIEntityNotFound( - VF_MODULE_NOT_FOUND_IN_INVENTORY_VNF_ID + vnfId + " volumeGroupId: " + volumeGroupId); - } - return this.getAaiResourcesClient().get(VolumeGroup.class, volumeGroupURI.get()).orElseGet(() -> { - logger.debug("No VolumeGroup in A&AI found: {}", vnfId); - return null; - }); - } - - public ServiceInstance getServiceInstance(String serviceInstanceId) { - return this.getAaiResourcesClient() - .get(ServiceInstance.class, - AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId)) - .orElseGet(() -> { - logger.debug("No Service Instance found in A&AI ServiceInstanceId: {}", serviceInstanceId); - return null; - }); - } - - public L3Network getNetwork(String networkId) { - return this.getAaiResourcesClient() - .get(L3Network.class, AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId)) - .orElseGet(() -> { - logger.debug("No Network found in A&AI NetworkId: {}", networkId); - return null; - }); - } - - public AAIResourcesClient getAaiResourcesClient() { - if (aaiResourcesClient == null) { - aaiResourcesClient = new AAIResourcesClient(); - } - return aaiResourcesClient; - } - - public void setAaiResourcesClient(AAIResourcesClient aaiResourcesClient) { - this.aaiResourcesClient = aaiResourcesClient; - } } 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 new file mode 100644 index 0000000000..4aa60152dd --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/RequestValidator.java @@ -0,0 +1,40 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.apihandlerinfra.infra.rest.validators; + +import java.util.Map; +import java.util.Optional; +import org.onap.so.serviceinstancebeans.ServiceInstancesRequest; + +public interface RequestValidator { + + + /** + * Should this validator run for given request + * + * @return + */ + public boolean shouldRunFor(String uri, ServiceInstancesRequest request); + + + public Optional validate(Map instanceIdMap, ServiceInstancesRequest request, + Map queryParams); +} 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 new file mode 100644 index 0000000000..d689c6b7a5 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/RequestValidatorListenerRunner.java @@ -0,0 +1,80 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.apihandlerinfra.infra.rest.validators; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.stream.Collectors; +import javax.annotation.PostConstruct; +import org.javatuples.Pair; +import org.onap.so.apihandlerinfra.exceptions.ApiException; +import org.onap.so.apihandlerinfra.exceptions.ValidateException; +import org.onap.so.listener.ListenerRunner; +import org.onap.so.serviceinstancebeans.ServiceInstancesRequest; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +@Component +public class RequestValidatorListenerRunner extends ListenerRunner { + + private static Logger logger = LoggerFactory.getLogger(RequestValidatorListenerRunner.class); + + protected List requestValidators; + + @PostConstruct + protected void init() { + requestValidators = new ArrayList<>( + Optional.ofNullable(context.getBeansOfType(RequestValidator.class)).orElse(new HashMap<>()).values()); + } + + public boolean runValidations(String requestURI, Map instanceIdMap, ServiceInstancesRequest request, + Map queryParams) throws ApiException { + logger.info("Running local validations"); + List>> results = + runValidations(requestValidators, instanceIdMap, request, queryParams, requestURI); + if (!results.isEmpty()) { + throw new ValidateException("Failed Validations:\n" + + results.stream().map(item -> String.format("%s: %s", item.getValue0(), item.getValue1().get())) + .collect(Collectors.joining("\n")), + 400); + } + + return true; + } + + protected List>> runValidations(List validators, + Map instanceIdMap, ServiceInstancesRequest request, Map queryParams, + String requestURI) { + + List filtered = + filterListeners(validators, (item -> item.shouldRunFor(requestURI, request))); + + List>> results = new ArrayList<>(); + filtered.forEach(item -> results + .add(new Pair<>(item.getClass().getName(), item.validate(instanceIdMap, request, queryParams)))); + + 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/validation/PlatformLOBValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/PlatformLOBValidation.java index 71405b0f63..20be2b5a8b 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/PlatformLOBValidation.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/PlatformLOBValidation.java @@ -43,7 +43,8 @@ public class PlatformLOBValidation implements ValidationRule { platform = info.getSir().getRequestDetails().getPlatform(); lineOfBusiness = info.getSir().getRequestDetails().getLineOfBusiness(); - if (reqVersion >= 5 && requestScope.equalsIgnoreCase(ModelType.vnf.name()) && action == Action.createInstance) { + if (reqVersion >= 5 && requestScope.equalsIgnoreCase(ModelType.vnf.name()) && action == Action.createInstance + && !info.getReqParameters().getEnforceValidNfValues()) { if (reqVersion > 5 && platform == null) { throw new ValidationException("platform"); } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ProjectOwningEntityValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ProjectOwningEntityValidation.java index 584269715a..cebbd6389c 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ProjectOwningEntityValidation.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ProjectOwningEntityValidation.java @@ -41,10 +41,12 @@ public class ProjectOwningEntityValidation implements ValidationRule { String requestScope = info.getRequestScope(); Actions action = info.getAction(); + project = info.getSir().getRequestDetails().getProject(); owningEntity = info.getSir().getRequestDetails().getOwningEntity(); if (reqVersion >= 5 && requestScope.equalsIgnoreCase(ModelType.service.name()) - && action == Action.createInstance || action == Action.assignInstance) { + && !info.getReqParameters().getEnforceValidNfValues() && action == Action.createInstance + || action == Action.assignInstance) { if (reqVersion > 5 && owningEntity == null) { throw new ValidationException("owningEntity"); } -- cgit 1.2.3-korg