From 1520c9b3f95bd2b9c96a89a8cd4b292d78e57ff3 Mon Sep 17 00:00:00 2001 From: "Gamboa, Gilbert" Date: Thu, 6 Jun 2019 15:55:45 -0400 Subject: vrfvalidation exceptions not getting logged Remove unused imports in VrfValidation class Check for null AAI network and vpn-bindings. Do not catch exceptions in WorkflowAction.traverseVrfCondifuration. Propagate exceptions and let calling method selectExecutionList() handle exceptions. Change-Id: I26adfdb351cee6dc111f496901558340b8152a2a Issue-ID: SO-1988 Signed-off-by: Benjamin, Max (mb388a) --- .../workflow/tasks/VrfValidation.java | 19 +++++++--- .../workflow/tasks/WorkflowAction.java | 42 +++++++++++----------- 2 files changed, 34 insertions(+), 27 deletions(-) (limited to 'bpmn/so-bpmn-tasks/src/main/java/org') diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/VrfValidation.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/VrfValidation.java index 6e410e9880..9092b68491 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/VrfValidation.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/VrfValidation.java @@ -8,7 +8,6 @@ import org.onap.so.client.aai.AAIObjectType; import org.onap.so.client.aai.entities.AAIResultWrapper; import org.onap.so.client.aai.entities.uri.AAIResourceUri; import org.onap.so.db.catalog.beans.ConfigurationResourceCustomization; -import org.onap.so.db.catalog.beans.ServiceProxyResourceCustomization; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -54,11 +53,14 @@ public class VrfValidation { return null; } - protected void aaiVpnBindingValidation(org.onap.aai.domain.yang.VpnBinding aaiVpnBinding) + protected void aaiVpnBindingValidation(String relatedVpnId, org.onap.aai.domain.yang.VpnBinding aaiVpnBinding) throws VrfBondingServiceException { - if (aaiVpnBinding == null || !aaiVpnBinding.getVpnType().equalsIgnoreCase("SERVICE-INFRASTRUCTURE")) { - throw new VrfBondingServiceException("VpnBinding: " + aaiVpnBinding.getVpnId() - + " does not have service type of BONDING and doesn not have service role of INFRASTRUCTURE-VPN"); + if (aaiVpnBinding == null) { + throw new VrfBondingServiceException("The infrastructure vpn " + relatedVpnId + " does not exist in A&AI."); + } else if (aaiVpnBinding.getVpnType() != null + && !aaiVpnBinding.getVpnType().equalsIgnoreCase("SERVICE-INFRASTRUCTURE")) { + throw new VrfBondingServiceException( + "VpnBinding: " + relatedVpnId + " does not have a vpn type of SERVICE-INFRASTRUCTURE."); } } @@ -84,6 +86,13 @@ public class VrfValidation { } } + protected void aaiNetworkValidation(String relatedNetworkid, org.onap.aai.domain.yang.L3Network aaiLocalNetwork) + throws VrfBondingServiceException { + if (aaiLocalNetwork == null) { + throw new VrfBondingServiceException("The local network " + relatedNetworkid + " does not exist in A&AI."); + } + } + protected void aaiSubnetValidation(org.onap.aai.domain.yang.L3Network aaiLocalNetwork) throws VrfBondingServiceException { if (aaiLocalNetwork.getSubnets() == null || aaiLocalNetwork.getSubnets().getSubnet() == null) { diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java index 73b0b5483e..4958e123fb 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java @@ -368,7 +368,7 @@ public class WorkflowAction { execution.setVariable("isRollbackComplete", false); } catch (Exception ex) { - buildAndThrowException(execution, "Exception in create execution list " + ex.getMessage(), ex); + buildAndThrowException(execution, "Exception in create execution list. " + ex.getMessage(), ex); } } @@ -623,7 +623,8 @@ public class WorkflowAction { } protected void traverseCatalogDbService(DelegateExecution execution, ServiceInstancesRequest sIRequest, - List resourceCounter, List> aaiResourceIds) { + List resourceCounter, List> aaiResourceIds) + throws JsonProcessingException, VrfBondingServiceException { String modelUUID = sIRequest.getRequestDetails().getModelInfo().getModelVersionId(); org.onap.so.db.catalog.beans.Service service = catalogDbClient.getServiceByID(modelUUID); if (service == null) { @@ -646,27 +647,24 @@ public class WorkflowAction { protected void traverseVrfConfiguration(DelegateExecution execution, List> aaiResourceIds, List resourceCounter, org.onap.so.db.catalog.beans.Service service, RelatedInstance relatedVpnBinding, - RelatedInstance relatedLocalNetwork) { - try { - org.onap.aai.domain.yang.L3Network aaiLocalNetwork = - bbInputSetupUtils.getAAIL3Network(relatedLocalNetwork.getInstanceId()); - vrfValidation.vrfServiceValidation(service); - vrfValidation.vrfCatalogDbChecks(service); - vrfValidation - .aaiVpnBindingValidation(bbInputSetupUtils.getAAIVpnBinding(relatedVpnBinding.getInstanceId())); - vrfValidation.aaiSubnetValidation(aaiLocalNetwork); - vrfValidation.aaiAggregateRouteValidation(aaiLocalNetwork); - vrfValidation.aaiRouteTargetValidation(aaiLocalNetwork); - String existingAAIVrfConfiguration = getExistingAAIVrfConfiguration(relatedVpnBinding, aaiLocalNetwork); - if (existingAAIVrfConfiguration != null) { - aaiResourceIds - .add(new Pair(WorkflowType.CONFIGURATION, existingAAIVrfConfiguration)); - } - resourceCounter.add(new Resource(WorkflowType.CONFIGURATION, - service.getConfigurationCustomizations().get(0).getModelCustomizationUUID(), false)); - } catch (VrfBondingServiceException | JsonProcessingException e) { - buildAndThrowException(execution, e.getMessage()); + RelatedInstance relatedLocalNetwork) throws VrfBondingServiceException, JsonProcessingException { + org.onap.aai.domain.yang.L3Network aaiLocalNetwork = + bbInputSetupUtils.getAAIL3Network(relatedLocalNetwork.getInstanceId()); + vrfValidation.vrfServiceValidation(service); + vrfValidation.vrfCatalogDbChecks(service); + vrfValidation.aaiVpnBindingValidation(relatedVpnBinding.getInstanceId(), + bbInputSetupUtils.getAAIVpnBinding(relatedVpnBinding.getInstanceId())); + vrfValidation.aaiNetworkValidation(relatedLocalNetwork.getInstanceId(), aaiLocalNetwork); + vrfValidation.aaiSubnetValidation(aaiLocalNetwork); + vrfValidation.aaiAggregateRouteValidation(aaiLocalNetwork); + vrfValidation.aaiRouteTargetValidation(aaiLocalNetwork); + String existingAAIVrfConfiguration = getExistingAAIVrfConfiguration(relatedVpnBinding, aaiLocalNetwork); + if (existingAAIVrfConfiguration != null) { + aaiResourceIds.add(new Pair(WorkflowType.CONFIGURATION, existingAAIVrfConfiguration)); } + resourceCounter.add(new Resource(WorkflowType.CONFIGURATION, + service.getConfigurationCustomizations().get(0).getModelCustomizationUUID(), false)); + } protected String getExistingAAIVrfConfiguration(RelatedInstance relatedVpnBinding, -- cgit 1.2.3-korg