List of usage examples for org.apache.commons.collections4 MapUtils isEmpty
public static boolean isEmpty(final Map<?, ?> map)
From source file:org.openecomp.sdc.validation.impl.validators.EcompGuideLineValidator.java
private void validateResourceTypeIsForbidden(String fileName, HeatOrchestrationTemplate heatOrchestrationTemplate, GlobalValidationContext globalContext) { if (MapUtils.isEmpty(heatOrchestrationTemplate.getResources())) { return;/* w ww .j a v a2 s . c o m*/ } heatOrchestrationTemplate.getResources().entrySet().stream().filter( entry -> ForbiddenHeatResourceTypes.findByForbiddenHeatResource(entry.getValue().getType()) != null) .filter(entry -> ForbiddenHeatResourceTypes.findByForbiddenHeatResource(entry.getValue().getType()) .equals(ForbiddenHeatResourceTypes.HEAT_FLOATING_IP_TYPE)) .forEach(entry -> globalContext.addMessage(fileName, ErrorLevel.WARNING, ErrorMessagesFormatBuilder.getErrorWithParameters( Messages.FLOATING_IP_NOT_IN_USE.getErrorMessage(), entry.getKey()))); }
From source file:org.openecomp.sdc.validation.impl.validators.EcompGuideLineValidator.java
private void validateFixedIpsNamingConvention(String fileName, HeatOrchestrationTemplate heatOrchestrationTemplate, GlobalValidationContext globalContext) { if (MapUtils.isEmpty(heatOrchestrationTemplate.getResources())) { return;//from w ww . ja v a 2 s . c o m } heatOrchestrationTemplate.getResources().entrySet().stream() .filter(entry -> HeatResourcesTypes.findByHeatResource(entry.getValue().getType()) != null) .filter(entry -> HeatResourcesTypes.findByHeatResource(entry.getValue().getType()) .equals(HeatResourcesTypes.NEUTRON_PORT_RESOURCE_TYPE)) .forEach(entry -> checkNeutronPortFixedIpsName(fileName, entry, globalContext)); }
From source file:org.openecomp.sdc.validation.impl.validators.EcompGuideLineValidator.java
private void validateImageAndFlavorFromNovaServer(String fileName, Map.Entry<String, Resource> resourceEntry, GlobalValidationContext globalContext) { if (MapUtils.isEmpty(resourceEntry.getValue().getProperties())) { return;/* w w w . j ava 2 s. co m*/ } String[] imageOrFlavorAsParameters = new String[] { "image", "flavor" }; Map<String, Object> propertiesMap = resourceEntry.getValue().getProperties(); for (String imageOrFlavor : imageOrFlavorAsParameters) { checkImageAndFlavorNames(fileName, imageOrFlavor, resourceEntry.getKey(), propertiesMap, globalContext); } }
From source file:org.openecomp.sdc.validation.impl.validators.EcompGuideLineValidator.java
@SuppressWarnings("unchecked") private void checkNeutronPortFixedIpsName(String fileName, Map.Entry<String, Resource> resourceEntry, GlobalValidationContext globalContext) { String[] regexList = new String[] { "[^_]+_[^_]+_ips", "[^_]+_[^_]+_v6_ips", "[^_]+_[^_]+_ip_(\\d+)", "[^_]+_[^_]+_v6_ip_(\\d+)" }; if (MapUtils.isEmpty(resourceEntry.getValue().getProperties())) { return;//w w w. j ava2 s. com } Map<String, Object> propertiesMap = resourceEntry.getValue().getProperties(); Object fixedIps = propertiesMap.get("fixed_ips"); if (Objects.nonNull(fixedIps) && fixedIps instanceof List) { List<Object> fixedIpsList = (List<Object>) fixedIps; for (Object fixedIpsObject : fixedIpsList) { Map.Entry<String, Object> fixedIpsEntry = ((Map<String, Object>) fixedIpsObject).entrySet() .iterator().next(); if (Objects.nonNull(fixedIpsEntry)) { if (fixedIpsEntry.getValue() instanceof Map) { String fixedIpsName = getWantedNameFromPropertyValueGetParam(fixedIpsEntry.getValue()); if (Objects.nonNull(fixedIpsName)) { if (!evalPattern(fixedIpsName, regexList)) { globalContext.addMessage(fileName, ErrorLevel.WARNING, ErrorMessagesFormatBuilder.getErrorWithParameters( Messages.FIXED_IPS_NOT_ALIGNED_WITH_GUIDE_LINES.getErrorMessage(), resourceEntry.getKey())); } } } else { globalContext.addMessage(fileName, ErrorLevel.WARNING, ErrorMessagesFormatBuilder.getErrorWithParameters( Messages.MISSING_GET_PARAM.getErrorMessage(), "fixed_ips", resourceEntry.getKey())); } } } } }
From source file:org.openecomp.sdc.validation.impl.validators.EcompGuideLineValidator.java
private void validateNovaServerNamingConvention(String fileName, String envFileName, Map.Entry<String, Resource> resourceEntry, GlobalValidationContext globalContext) { if (MapUtils.isEmpty(resourceEntry.getValue().getProperties())) { return;/*from w w w . ja va 2 s. c o m*/ } checkIfNovaNameByGuidelines(fileName, envFileName, resourceEntry, globalContext); }
From source file:org.openecomp.sdc.validation.impl.validators.EcompGuideLineValidator.java
private void checkIfNovaNameByGuidelines(String fileName, String envFileName, Map.Entry<String, Resource> resourceEntry, GlobalValidationContext globalContext) { if (MapUtils.isEmpty(resourceEntry.getValue().getProperties())) { return;// w w w. j a v a 2s . co m } Object novaServerName = resourceEntry.getValue().getProperties().get("name"); Map novaNameMap; String novaName; if (Objects.nonNull(novaServerName)) { if (novaServerName instanceof Map) { novaNameMap = (Map) novaServerName; Object novaNameGetParam = novaNameMap .get(ResourceReferenceFunctions.GET_PARAM.getFunction()) == null ? null : novaNameMap.get(ResourceReferenceFunctions.GET_PARAM.getFunction()); if (Objects.nonNull(novaNameGetParam)) { checkNovaNameGetParamValueMap(fileName, novaNameGetParam, resourceEntry, globalContext); novaName = novaNameGetParam instanceof List ? (String) ((List) novaNameGetParam).get(0) : (String) novaNameGetParam; checkIfNovaNameParameterInEnvIsStringOrList(fileName, envFileName, resourceEntry, novaName, globalContext); } } else { globalContext.addMessage(fileName, ErrorLevel.WARNING, ErrorMessagesFormatBuilder.getErrorWithParameters( Messages.MISSING_GET_PARAM.getErrorMessage(), "nova server name", resourceEntry.getKey())); } } }
From source file:org.openecomp.sdc.validation.impl.validators.EcompGuideLineValidator.java
private void validateNovaServerAvailabilityZoneName(String fileName, Map.Entry<String, Resource> resourceEntry, GlobalValidationContext globalContext) { String[] regexList = new String[] { "availability_zone_(\\d+)" }; if (MapUtils.isEmpty(resourceEntry.getValue().getProperties())) { return;//from w w w.j a v a2 s . c o m } Object availabilityZoneMap = resourceEntry.getValue().getProperties().containsKey("availability_zone") ? resourceEntry.getValue().getProperties().get("availability_zone") : null; if (Objects.nonNull(availabilityZoneMap)) { if (availabilityZoneMap instanceof Map) { String availabilityZoneName = getWantedNameFromPropertyValueGetParam(availabilityZoneMap); if (availabilityZoneName != null) { if (!evalPattern(availabilityZoneName, regexList)) { globalContext.addMessage(fileName, ErrorLevel.WARNING, ErrorMessagesFormatBuilder.getErrorWithParameters( Messages.AVAILABILITY_ZONE_NOT_ALIGNED_WITH_GUIDE_LINES.getErrorMessage(), resourceEntry.getKey())); } } } else { globalContext.addMessage(fileName, ErrorLevel.WARNING, ErrorMessagesFormatBuilder.getErrorWithParameters( Messages.MISSING_GET_PARAM.getErrorMessage(), "availability_zone", resourceEntry.getKey())); } } }
From source file:org.openecomp.sdc.vendorsoftwareproduct.impl.VendorSoftwareProductManagerImpl.java
private Map<String, List<ErrorMessage>> validateUploadData(UploadDataEntity uploadData) throws IOException { if (uploadData == null || uploadData.getContentData() == null) { return null; }//w ww . ja v a 2s .c om FileContentHandler fileContentMap = VendorSoftwareProductUtils .loadUploadFileContent(uploadData.getContentData().array()); ValidationManager validationManager = ValidationManagerUtil.initValidationManager(fileContentMap); Map<String, List<ErrorMessage>> validationErrors = validationManager.validate(); return MapUtils.isEmpty(MessageContainerUtil.getMessageByLevel(ErrorLevel.ERROR, validationErrors)) ? null : validationErrors; }
From source file:org.openecomp.sdc.vendorsoftwareproduct.services.CompositionDataExtractor.java
private static Map<String, List<String>> getComputeToPortsConnection( Map<String, NodeTemplate> portNodeTemplates) { Map<String, List<String>> computeToPortConnection = new HashMap<>(); if (MapUtils.isEmpty(portNodeTemplates)) { return computeToPortConnection; }//from w w w . j a v a 2s .com for (String portId : portNodeTemplates.keySet()) { List<RequirementAssignment> bindingRequirementsToCompute = toscaAnalyzerService .getRequirements(portNodeTemplates.get(portId), ToscaConstants.BINDING_REQUIREMENT_ID); for (RequirementAssignment bindingRequirementToCompute : bindingRequirementsToCompute) { computeToPortConnection.putIfAbsent(bindingRequirementToCompute.getNode(), new ArrayList<>()); computeToPortConnection.get(bindingRequirementToCompute.getNode()).add(portId); } } return computeToPortConnection; }
From source file:org.openecomp.sdc.vendorsoftwareproduct.services.CompositionDataExtractor.java
private static void extractComponents(ServiceTemplate serviceTemplate, ToscaServiceModel toscaServiceModel, ExtractCompositionDataContext context) { Map<String, NodeTemplate> computeNodeTemplates = toscaAnalyzerService .getNodeTemplatesByType(serviceTemplate, ToscaNodeType.COMPUTE.getDisplayName(), toscaServiceModel); if (MapUtils.isEmpty(computeNodeTemplates)) { return;/*from w w w. ja v a2 s .c o m*/ } Map<String, NodeTemplate> portNodeTemplates = toscaAnalyzerService.getNodeTemplatesByType(serviceTemplate, ToscaNodeType.NETWORK_PORT.getDisplayName(), toscaServiceModel); Map<String, List<String>> computeToPortsConnection = getComputeToPortsConnection(portNodeTemplates); Map<String, List<String>> computesGroupedByType = getNodeTemplatesGroupedByType(computeNodeTemplates); computesGroupedByType.keySet().stream() .filter(nodeType -> !context.getCreatedComponents().contains(nodeType)) .forEach(nodeType -> extractComponent(serviceTemplate, computeToPortsConnection, computesGroupedByType, nodeType, context)); }