From b6379cce2e96293cdc00fc3633a0295b55d6f40c Mon Sep 17 00:00:00 2001 From: vempo Date: Wed, 7 Nov 2018 18:48:04 +0200 Subject: Removed dead and duplicate code in onboarding Change-Id: I2ca0f1a4b00938838213ba2d615ab72c80d6dda3 Issue-ID: SDC-1903 Signed-off-by: vempo --- .../validation/impl/validators/HeatValidator.java | 38 +----------------- .../heatresource/NeutronPortResourceValidator.java | 45 ---------------------- 2 files changed, 2 insertions(+), 81 deletions(-) (limited to 'openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main') diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/HeatValidator.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/HeatValidator.java index ae289f9178..5fb2953b6a 100644 --- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/HeatValidator.java +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/HeatValidator.java @@ -24,7 +24,6 @@ import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.Set; - import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.MapUtils; import org.onap.sdc.tosca.services.YamlUtil; @@ -39,7 +38,6 @@ import org.openecomp.sdc.heat.datatypes.manifest.ManifestContent; import org.openecomp.sdc.heat.datatypes.model.Environment; import org.openecomp.sdc.heat.datatypes.model.HeatOrchestrationTemplate; import org.openecomp.sdc.heat.datatypes.model.HeatPseudoParameters; -import org.openecomp.sdc.heat.datatypes.model.HeatResourcesTypes; import org.openecomp.sdc.heat.datatypes.model.Output; import org.openecomp.sdc.heat.datatypes.model.Parameter; import org.openecomp.sdc.heat.datatypes.model.Resource; @@ -282,7 +280,7 @@ public class HeatValidator implements Validator { globalContext) { for (Output output : outputMap.values()) { Object outputValue = output.getValue(); - if (outputValue != null && outputValue instanceof Map) { + if (outputValue instanceof Map) { Map outputValueMap = (Map) outputValue; List getAttrValue = (List) outputValueMap.get( @@ -423,7 +421,7 @@ public class HeatValidator implements Validator { globalContext) { Map parametersMap = heatOrchestrationTemplate.getParameters(); - if (parametersMap != null && MapUtils.isNotEmpty(parametersMap)) { + if (MapUtils.isNotEmpty(parametersMap)) { for (Map.Entry parameterEntry : parametersMap.entrySet()) { validateParameterEntryForParameterDefaultTypeAlignWithType(parameterEntry, fileName, globalContext); @@ -629,36 +627,4 @@ public class HeatValidator implements Validator { "The heat file does not contain any resources")); } } - - - @SuppressWarnings("unchecked") - private void getSecurityGroupsReferencedResourcesFromOutputs( - Set securityGroupsNamesFromOutputsMap, Map outputMap, - Map resourceMap) { - if (MapUtils.isNotEmpty(outputMap)) { - for (Map.Entry outputEntry : outputMap.entrySet()) { - - validateOutputEntryForGetSecurityGroupsReferencedResourcesFromOutputs(outputEntry, - resourceMap, securityGroupsNamesFromOutputsMap); - - } - } - } - private void validateOutputEntryForGetSecurityGroupsReferencedResourcesFromOutputs( - Map.Entry outputEntry, - Map resourceMap, Set securityGroupsNamesFromOutputsMap){ - Object outputValue = outputEntry.getValue().getValue(); - if (Objects.nonNull(outputValue) && outputValue instanceof Map) { - String resourceName = (String) ((Map) outputValue) - .get(ResourceReferenceFunctions.GET_RESOURCE.getFunction()); - if (Objects.nonNull(resourceName)) { - Resource resource = resourceMap.get(resourceName); - if (Objects.nonNull(resource) && resource.getType().equals( - HeatResourcesTypes.NEUTRON_SECURITY_GROUP_RESOURCE_TYPE.getHeatResource())) { - securityGroupsNamesFromOutputsMap.add(outputEntry.getKey()); - } - } - } - } - } diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/heatresource/NeutronPortResourceValidator.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/heatresource/NeutronPortResourceValidator.java index b11a287a41..a21173a6b2 100644 --- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/heatresource/NeutronPortResourceValidator.java +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/heatresource/NeutronPortResourceValidator.java @@ -17,12 +17,8 @@ package org.openecomp.sdc.validation.impl.validators.heatresource; import java.util.ArrayList; -import java.util.Collection; import java.util.List; import java.util.Map; -import java.util.Objects; -import java.util.Set; - import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.MapUtils; import org.openecomp.core.validation.ErrorMessageCode; @@ -32,8 +28,6 @@ import org.openecomp.sdc.common.errors.Messages; import org.openecomp.sdc.datatypes.error.ErrorLevel; import org.openecomp.sdc.heat.datatypes.model.HeatResourcesTypes; import org.openecomp.sdc.heat.datatypes.model.Resource; -import org.openecomp.sdc.heat.datatypes.model.ResourceReferenceFunctions; -import org.openecomp.sdc.heat.services.HeatStructureUtil; import org.openecomp.sdc.validation.ResourceValidator; import org.openecomp.sdc.validation.ValidationContext; import org.openecomp.sdc.validation.type.HeatResourceValidationContext; @@ -125,43 +119,4 @@ public class NeutronPortResourceValidator implements ResourceValidator { return CollectionUtils.isNotEmpty(pointingNovaServers) && pointingNovaServers.size() > 1; } - - @SuppressWarnings("unchecked") - private static void validateAllSecurityGroupsAreUsed(String filename, - Map.Entry resourceEntry, - List securityGroupResourceNameList, - GlobalValidationContext globalContext) { - Map propertiesMap = resourceEntry.getValue().getProperties(); - - if (MapUtils.isEmpty(propertiesMap)) { - return; - } - - Object securityGroupsValue = propertiesMap.get("security_groups"); - - if (Objects.isNull(securityGroupsValue)) { - return; - } - - if (securityGroupsValue instanceof List) { - List securityGroupsListFromCurrResource = - (List) propertiesMap.get("security_groups"); - for (Object securityGroup : securityGroupsListFromCurrResource) { - removeSecurityGroupNamesFromListByGivenFunction(filename, - ResourceReferenceFunctions.GET_RESOURCE.getFunction(), securityGroup, - securityGroupResourceNameList, globalContext); - } - } - } - - private static void removeSecurityGroupNamesFromListByGivenFunction(String filename, - String functionName, - Object securityGroup, - Collection - securityGroupResourceNameList, - GlobalValidationContext globalContext) { - Set securityGroupsNamesFromFunction = HeatStructureUtil - .getReferencedValuesByFunctionName(filename, functionName, securityGroup, globalContext); - securityGroupsNamesFromFunction.forEach(securityGroupResourceNameList::remove); - } } -- cgit 1.2.3-korg