summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java')
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/util/HeatValidationService.java16
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/ContrailValidator.java6
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/ForbiddenResourceGuideLineValidator.java2
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/HeatResourceValidator.java35
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/HeatValidator.java290
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/ManifestValidator.java2
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/NamingConventionGuideLineValidator.java2
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/SharedResourceGuideLineValidator.java10
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/YamlValidator.java4
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/heatresource/NovaServerResourceValidator.java2
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/namingconvention/NovaServerNamingConventionGuideLineValidator.java4
11 files changed, 193 insertions, 180 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/util/HeatValidationService.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/util/HeatValidationService.java
index 90750a48ec..e437892758 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/util/HeatValidationService.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/util/HeatValidationService.java
@@ -17,13 +17,15 @@
package org.openecomp.sdc.validation.impl.util;
import org.apache.commons.collections4.CollectionUtils;
-import org.openecomp.sdc.heat.datatypes.model.*;
-import org.openecomp.sdc.tosca.services.YamlUtil;
import org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder;
import org.openecomp.core.validation.types.GlobalValidationContext;
import org.openecomp.sdc.common.errors.Messages;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
import org.openecomp.sdc.heat.datatypes.DefinedHeatParameterTypes;
+import org.openecomp.sdc.heat.datatypes.model.Environment;
+import org.openecomp.sdc.heat.datatypes.model.HeatOrchestrationTemplate;
+import org.openecomp.sdc.heat.datatypes.model.Parameter;
+import org.openecomp.sdc.heat.datatypes.model.Resource;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
@@ -32,10 +34,18 @@ import org.openecomp.sdc.logging.types.LoggerConstants;
import org.openecomp.sdc.logging.types.LoggerErrorCode;
import org.openecomp.sdc.logging.types.LoggerErrorDescription;
import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
+import org.openecomp.sdc.tosca.services.YamlUtil;
import org.openecomp.sdc.validation.impl.validators.HeatValidator;
import java.io.InputStream;
-import java.util.*;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Set;
public class HeatValidationService {
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/ContrailValidator.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/ContrailValidator.java
index 5045c80d11..eb23930216 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/ContrailValidator.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/ContrailValidator.java
@@ -22,9 +22,7 @@ package org.openecomp.sdc.validation.impl.validators;
import org.apache.commons.collections4.MapUtils;
import org.openecomp.core.validation.ErrorMessageCode;
-import org.openecomp.sdc.tosca.services.YamlUtil;
import org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder;
-import org.openecomp.sdc.validation.Validator;
import org.openecomp.core.validation.types.GlobalValidationContext;
import org.openecomp.sdc.common.errors.Messages;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
@@ -39,6 +37,8 @@ import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
import org.openecomp.sdc.logging.types.LoggerErrorDescription;
import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
+import org.openecomp.sdc.tosca.services.YamlUtil;
+import org.openecomp.sdc.validation.Validator;
import org.openecomp.sdc.validation.tos.ContrailResourcesMappingTo;
import org.openecomp.sdc.validation.util.ValidationUtil;
@@ -62,7 +62,7 @@ public class ContrailValidator implements Validator {
ManifestContent manifestContent;
try {
- manifestContent = ValidationUtil.checkValidationPreCondition(globalContext);
+ manifestContent = ValidationUtil.validateManifest(globalContext);
} catch (Exception exception) {
logger.debug("",exception);
return;
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/ForbiddenResourceGuideLineValidator.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/ForbiddenResourceGuideLineValidator.java
index 2dad766c45..2107825c6c 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/ForbiddenResourceGuideLineValidator.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/ForbiddenResourceGuideLineValidator.java
@@ -63,7 +63,7 @@ public class ForbiddenResourceGuideLineValidator implements Validator {
public void validate(GlobalValidationContext globalContext) {
ManifestContent manifestContent;
try {
- manifestContent = ValidationUtil.checkValidationPreCondition(globalContext);
+ manifestContent = ValidationUtil.validateManifest(globalContext);
} catch (Exception exception) {
log.debug("",exception);
return;
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/HeatResourceValidator.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/HeatResourceValidator.java
index 10cfe352f6..89e96efa36 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/HeatResourceValidator.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/HeatResourceValidator.java
@@ -14,7 +14,6 @@ import org.openecomp.sdc.heat.services.HeatStructureUtil;
import org.openecomp.sdc.heat.services.manifest.ManifestUtil;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
-import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
import org.openecomp.sdc.validation.ValidationContext;
import org.openecomp.sdc.validation.base.ResourceBaseValidator;
import org.openecomp.sdc.validation.type.ConfigConstants;
@@ -31,8 +30,7 @@ import java.util.Objects;
import java.util.Set;
public class HeatResourceValidator extends ResourceBaseValidator {
- public static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
- private static Logger logger = (Logger) LoggerFactory.getLogger(ResourceBaseValidator.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(ResourceBaseValidator.class);
private static final ErrorMessageCode ERROR_CODE_HTR_1 = new ErrorMessageCode("HTR1");
@Override
@@ -42,14 +40,14 @@ public class HeatResourceValidator extends ResourceBaseValidator {
@Override
public ValidationContext createValidationContext(String fileName,
- String envFileName,
- HeatOrchestrationTemplate heatOrchestrationTemplate,
- GlobalValidationContext globalContext) {
+ String envFileName,
+ HeatOrchestrationTemplate heatOrchestrationTemplate,
+ GlobalValidationContext globalContext) {
ManifestContent manifestContent = new ManifestContent();
try {
- manifestContent = ValidationUtil.checkValidationPreCondition(globalContext);
+ manifestContent = ValidationUtil.validateManifest(globalContext);
} catch (Exception exception) {
- logger.debug("",exception);
+ LOGGER.debug("", exception);
}
Set<String> baseFiles = ManifestUtil.getBaseFiles(manifestContent);
String baseFileName = CollectionUtils.isEmpty(baseFiles) ? null : baseFiles.iterator().next();
@@ -58,7 +56,7 @@ public class HeatResourceValidator extends ResourceBaseValidator {
ValidationUtil.checkHeatOrchestrationPreCondition(baseFileName, globalContext);
Set<String> securityGroupsNamesFromBaseFileOutputs = baseFileName == null ? new HashSet<>()
: checkForBaseFilePortsExistenceAndReturnSecurityGroupNamesFromOutputsIfNot
- (baseFileName, baseHot, globalContext);
+ (baseHot);
Map<String, Resource> resourcesMap =
heatOrchestrationTemplate.getResources() == null ? new HashMap<>()
@@ -86,7 +84,7 @@ public class HeatResourceValidator extends ResourceBaseValidator {
GlobalValidationContext globalContext) {
initTypeRelationsMapFromResourcesMap
- (fileName, resourceMap, securityGroupsNamesFromBaseFileOutputs,
+ (fileName, resourceMap,
typeToPointingResourcesMap, globalContext);
initTypeRelationsMapFromOutputsMap
@@ -133,13 +131,13 @@ public class HeatResourceValidator extends ResourceBaseValidator {
private void initTypeRelationsMapFromResourcesMap(String fileName,
Map<String, Resource> resourceMap,
- Set<String> securityGroupsNamesFromBaseFileOutputs,
Map<String, Map<String, Map<String, List<String>>>> typeToPointingResourcesMap,
GlobalValidationContext globalContext) {
for (Map.Entry<String, Resource> resourceEntry : resourceMap.entrySet()) {
Resource pointingResource = resourceEntry.getValue();
Map<String, Object> properties =
- pointingResource.getProperties() == null ? new HashMap<>() : pointingResource.getProperties();
+ pointingResource.getProperties() == null ? new HashMap<>()
+ : pointingResource.getProperties();
Set<String> referencedResourcesByGetResource =
getResourcesIdsPointedByCurrentResource(fileName, ResourceReferenceFunctions.GET_RESOURCE,
@@ -231,9 +229,9 @@ public class HeatResourceValidator extends ResourceBaseValidator {
(pointingResourceType, new ArrayList<>());
}
- private Set<String> handleGetAttrBetweenResources(Map<String, Object> properties){
+ private Set<String> handleGetAttrBetweenResources(Map<String, Object> properties) {
Set<String> referencedResourcesByGetAttr = new HashSet<>();
- for(Map.Entry<String, Object> proprtyEntry : properties.entrySet()){
+ for (Map.Entry<String, Object> proprtyEntry : properties.entrySet()) {
referencedResourcesByGetAttr.addAll(getGetAttrReferencesInCaseOfContrail(proprtyEntry
.getValue()));
}
@@ -242,7 +240,7 @@ public class HeatResourceValidator extends ResourceBaseValidator {
}
- private Set<String> getGetAttrReferencesInCaseOfContrail(Object propertyValue){
+ private Set<String> getGetAttrReferencesInCaseOfContrail(Object propertyValue) {
Object value;
Set<String> getAttrReferences = new HashSet<>();
@@ -255,11 +253,11 @@ public class HeatResourceValidator extends ResourceBaseValidator {
getAttrReferences.add((String) ((List) value).get(0));
return getAttrReferences;
} else {
- logger.warn("invalid format of 'get_attr' function - " + propertyValue.toString());
+ LOGGER.warn("invalid format of 'get_attr' function - " + propertyValue.toString());
}
}
}
- }else {
+ } else {
Collection<Object> valCollection = ((Map) propertyValue).values();
for (Object entryValue : valCollection) {
getAttrReferences.addAll(getGetAttrReferencesInCaseOfContrail(entryValue));
@@ -294,8 +292,7 @@ public class HeatResourceValidator extends ResourceBaseValidator {
}
private Set<String> checkForBaseFilePortsExistenceAndReturnSecurityGroupNamesFromOutputsIfNot(
- String baseFileName, HeatOrchestrationTemplate heatOrchestrationTemplate,
- GlobalValidationContext globalContext) {
+ HeatOrchestrationTemplate heatOrchestrationTemplate) {
Set<String> securityGroupsNamesFromOutputsMap = new HashSet<>();
if (heatOrchestrationTemplate != null) {
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 da87a13eb4..8064c6f20a 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
@@ -23,11 +23,6 @@ package org.openecomp.sdc.validation.impl.validators;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.openecomp.core.validation.ErrorMessageCode;
-import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage;
-import org.openecomp.sdc.logging.types.LoggerConstants;
-import org.openecomp.sdc.logging.types.LoggerErrorCode;
-import org.openecomp.sdc.tosca.services.YamlUtil;
-import org.openecomp.sdc.validation.Validator;
import org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder;
import org.openecomp.core.validation.types.GlobalValidationContext;
import org.openecomp.sdc.common.errors.Messages;
@@ -48,13 +43,24 @@ import org.openecomp.sdc.heat.services.manifest.ManifestUtil;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
+import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage;
+import org.openecomp.sdc.logging.types.LoggerConstants;
+import org.openecomp.sdc.logging.types.LoggerErrorCode;
import org.openecomp.sdc.logging.types.LoggerErrorDescription;
import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
+import org.openecomp.sdc.tosca.services.YamlUtil;
+import org.openecomp.sdc.validation.Validator;
import org.openecomp.sdc.validation.impl.util.HeatValidationService;
import org.openecomp.sdc.validation.util.ValidationUtil;
import java.io.InputStream;
-import java.util.*;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Set;
public class HeatValidator implements Validator {
public static final MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
@@ -126,91 +132,91 @@ public class HeatValidator implements Validator {
: heatOrchestrationTemplate.getResources().values();
Collection<Output> outputsValues = heatOrchestrationTemplate.getOutputs() == null ? null
: heatOrchestrationTemplate.getOutputs().values();
- checkResourceExistenceFromResourcesMap(fileName, resourcesNames, resourcesValues,
- globalContext);
- checkResourceExistenceFromResourcesMap(fileName, resourcesNames, outputsValues,
- globalContext);
+ checkResourceExistenceFromResourcesMap(fileName, resourcesNames, resourcesValues,
+ globalContext);
+ checkResourceExistenceFromResourcesMap(fileName, resourcesNames, outputsValues,
+ globalContext);
mdcDataDebugMessage.debugExitMessage("file", fileName);
}
- private static void checkResourceExistenceFromResourcesMap(String fileName,
- Set<String> resourcesNames,
- Collection<?> valuesToSearchIn,
- GlobalValidationContext globalContext) {
-
- mdcDataDebugMessage.debugEntryMessage("file", fileName);
-
- if (CollectionUtils.isNotEmpty(valuesToSearchIn)) {
- for (Object value : valuesToSearchIn) {
- if (value instanceof Resource) {
- extractResourceProperty(fileName, resourcesNames, globalContext, (Resource) value);
- } else if (value instanceof Output) {
- Output output = (Output) value;
- Object outputsValue = output.getValue();
- handleReferencedResources(fileName, outputsValue, resourcesNames,
- globalContext);
- }
- }
+ private static void checkResourceExistenceFromResourcesMap(String fileName,
+ Set<String> resourcesNames,
+ Collection<?> valuesToSearchIn,
+ GlobalValidationContext globalContext) {
+
+ mdcDataDebugMessage.debugEntryMessage("file", fileName);
+
+ if (CollectionUtils.isNotEmpty(valuesToSearchIn)) {
+ for (Object value : valuesToSearchIn) {
+ if (value instanceof Resource) {
+ extractResourceProperty(fileName, resourcesNames, globalContext, (Resource) value);
+ } else if (value instanceof Output) {
+ Output output = (Output) value;
+ Object outputsValue = output.getValue();
+ handleReferencedResources(fileName, outputsValue, resourcesNames,
+ globalContext);
}
+ }
}
+ }
private static void extractResourceProperty(String fileName, Set<String> resourcesNames,
GlobalValidationContext globalContext,
Resource value) {
Resource resource = value;
Collection<Object> resourcePropertiesValues =
- resource.getProperties() == null ? null : resource.getProperties()
- .values();
+ resource.getProperties() == null ? null : resource.getProperties()
+ .values();
if (CollectionUtils.isNotEmpty(resourcePropertiesValues)) {
- for (Object propertyValue : resourcePropertiesValues) {
- handleReferencedResources(fileName, propertyValue, resourcesNames,
- globalContext);
- }
+ for (Object propertyValue : resourcePropertiesValues) {
+ handleReferencedResources(fileName, propertyValue, resourcesNames,
+ globalContext);
+ }
}
}
private static void handleReferencedResources(String fileName, Object valueToSearchReferencesIn,
- Set<String> resourcesNames,
- GlobalValidationContext globalContext) {
-
-
- mdcDataDebugMessage.debugEntryMessage("file", fileName);
- globalContext.setMessageCode(ERROR_CODE_HOT_13);
- Set<String> referencedResourcesNames = HeatStructureUtil
- .getReferencedValuesByFunctionName(fileName,
- ResourceReferenceFunctions.GET_RESOURCE.getFunction(),
- valueToSearchReferencesIn, globalContext);
- if (CollectionUtils.isNotEmpty(referencedResourcesNames)) {
- checkIfResourceReferenceExist(fileName, resourcesNames, referencedResourcesNames,
- globalContext);
- }
+ Set<String> resourcesNames,
+ GlobalValidationContext globalContext) {
+
- mdcDataDebugMessage.debugExitMessage("file", fileName);
+ mdcDataDebugMessage.debugEntryMessage("file", fileName);
+ globalContext.setMessageCode(ERROR_CODE_HOT_13);
+ Set<String> referencedResourcesNames = HeatStructureUtil
+ .getReferencedValuesByFunctionName(fileName,
+ ResourceReferenceFunctions.GET_RESOURCE.getFunction(),
+ valueToSearchReferencesIn, globalContext);
+ if (CollectionUtils.isNotEmpty(referencedResourcesNames)) {
+ checkIfResourceReferenceExist(fileName, resourcesNames, referencedResourcesNames,
+ globalContext);
}
- private static void checkIfResourceReferenceExist(String fileName,
- Set<String> referencedResourcesNames,
- Set<String> referencedResources,
- GlobalValidationContext globalContext) {
+ mdcDataDebugMessage.debugExitMessage("file", fileName);
+ }
+ private static void checkIfResourceReferenceExist(String fileName,
+ Set<String> referencedResourcesNames,
+ Set<String> referencedResources,
+ GlobalValidationContext globalContext) {
- mdcDataDebugMessage.debugEntryMessage("file", fileName);
- referencedResources.stream()
- .filter(referencedResource -> !referencedResourcesNames.contains(referencedResource))
- .forEach(referencedResource -> {
- globalContext.addMessage(fileName,
- ErrorLevel.ERROR, ErrorMessagesFormatBuilder
- .getErrorWithParameters(ERROR_CODE_HOT_16,Messages
- .REFERENCED_RESOURCE_NOT_FOUND.getErrorMessage(), referencedResource),
- LoggerTragetServiceName.VALIDATE_RESOURCE_REFERENCE_EXISTENCE,
- LoggerErrorDescription.RESOURCE_NOT_FOUND);
- });
+ mdcDataDebugMessage.debugEntryMessage("file", fileName);
- mdcDataDebugMessage.debugExitMessage("file", fileName);
- }
+ referencedResources.stream()
+ .filter(referencedResource -> !referencedResourcesNames.contains(referencedResource))
+ .forEach(referencedResource -> {
+ globalContext.addMessage(fileName,
+ ErrorLevel.ERROR, ErrorMessagesFormatBuilder
+ .getErrorWithParameters(ERROR_CODE_HOT_16,Messages
+ .REFERENCED_RESOURCE_NOT_FOUND.getErrorMessage(), referencedResource),
+ LoggerTragetServiceName.VALIDATE_RESOURCE_REFERENCE_EXISTENCE,
+ LoggerErrorDescription.RESOURCE_NOT_FOUND);
+ });
+
+ mdcDataDebugMessage.debugExitMessage("file", fileName);
+ }
/* validation 16 */
@@ -294,79 +300,79 @@ public class HeatValidator implements Validator {
mdcDataDebugMessage.debugExitMessage("file", fileName);
}
- private static void loopOverOutputMapAndValidateGetAttrFromNested(String fileName,
- Map<String, Output> outputMap,
- HeatOrchestrationTemplate
- heatOrchestrationTemplate,
- GlobalValidationContext
- globalContext) {
- for (Output output : outputMap.values()) {
- Object outputValue = output.getValue();
- if (outputValue != null && outputValue instanceof Map) {
- Map<String, Object> outputValueMap = (Map<String, Object>) outputValue;
- List<String> getAttrValue =
- (List<String>) outputValueMap.get(
- ResourceReferenceFunctions.GET_ATTR.getFunction());
- if (!CollectionUtils.isEmpty(getAttrValue)) {
- String resourceName = getAttrValue.get(0);
- Object attNameObject = getAttrValue.get(1);
- if (!(attNameObject instanceof String)) {
- return;
- }
- String attName = getAttrValue.get(1);
- String resourceType =
- getResourceTypeFromResourcesMap(resourceName, heatOrchestrationTemplate);
-
- if (Objects.nonNull(resourceType)
- && HeatValidationService.isNestedResource(resourceType)) {
- handleGetAttrNestedResource(fileName, globalContext, resourceName, attName,
- resourceType);
- }
- }
- }
- }
- }
-
- private static void handleGetAttrNestedResource(String fileName,
- GlobalValidationContext globalContext,
- String resourceName, String attName,
- String resourceType) {
- Map<String, Output> nestedOutputMap;
- HeatOrchestrationTemplate nestedHeatOrchestrationTemplate;
- try {
- Optional<InputStream> fileContent = globalContext.getFileContent(resourceType);
- if (fileContent.isPresent()) {
- nestedHeatOrchestrationTemplate =
- new YamlUtil().yamlToObject(fileContent.get(), HeatOrchestrationTemplate.class);
- } else {
- MdcDataErrorMessage
- .createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_API,
- LoggerTragetServiceName.VALIDATE_GET_ATTR_FROM_NESTED,
- ErrorLevel.ERROR.name(), LoggerErrorCode.DATA_ERROR.getErrorCode(),
- LoggerErrorDescription.EMPTY_FILE);
- throw new Exception("The file '" + resourceType + "' has no content");
- }
- } catch (Exception exception) {
- logger.debug("",exception);
+ private static void loopOverOutputMapAndValidateGetAttrFromNested(String fileName,
+ Map<String, Output> outputMap,
+ HeatOrchestrationTemplate
+ heatOrchestrationTemplate,
+ GlobalValidationContext
+ globalContext) {
+ for (Output output : outputMap.values()) {
+ Object outputValue = output.getValue();
+ if (outputValue != null && outputValue instanceof Map) {
+ Map<String, Object> outputValueMap = (Map<String, Object>) outputValue;
+ List<String> getAttrValue =
+ (List<String>) outputValueMap.get(
+ ResourceReferenceFunctions.GET_ATTR.getFunction());
+ if (!CollectionUtils.isEmpty(getAttrValue)) {
+ String resourceName = getAttrValue.get(0);
+ Object attNameObject = getAttrValue.get(1);
+ if (!(attNameObject instanceof String)) {
return;
+ }
+ String attName = getAttrValue.get(1);
+ String resourceType =
+ getResourceTypeFromResourcesMap(resourceName, heatOrchestrationTemplate);
+
+ if (Objects.nonNull(resourceType)
+ && HeatValidationService.isNestedResource(resourceType)) {
+ handleGetAttrNestedResource(fileName, globalContext, resourceName, attName,
+ resourceType);
+ }
}
- nestedOutputMap = nestedHeatOrchestrationTemplate.getOutputs();
+ }
+ }
+ }
- if (MapUtils.isEmpty(nestedOutputMap) || !nestedOutputMap.containsKey(attName)) {
- globalContext.addMessage(fileName, ErrorLevel.ERROR, ErrorMessagesFormatBuilder
- .getErrorWithParameters(ERROR_CODE_HOT_17,Messages.
- GET_ATTR_NOT_FOUND.getErrorMessage(),
- attName, resourceName),
- LoggerTragetServiceName.VALIDATE_GET_ATTR_FROM_NESTED,
- LoggerErrorDescription.GET_ATTR_NOT_FOUND);
- }
+ private static void handleGetAttrNestedResource(String fileName,
+ GlobalValidationContext globalContext,
+ String resourceName, String attName,
+ String resourceType) {
+ Map<String, Output> nestedOutputMap;
+ HeatOrchestrationTemplate nestedHeatOrchestrationTemplate;
+ try {
+ Optional<InputStream> fileContent = globalContext.getFileContent(resourceType);
+ if (fileContent.isPresent()) {
+ nestedHeatOrchestrationTemplate =
+ new YamlUtil().yamlToObject(fileContent.get(), HeatOrchestrationTemplate.class);
+ } else {
+ MdcDataErrorMessage
+ .createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_API,
+ LoggerTragetServiceName.VALIDATE_GET_ATTR_FROM_NESTED,
+ ErrorLevel.ERROR.name(), LoggerErrorCode.DATA_ERROR.getErrorCode(),
+ LoggerErrorDescription.EMPTY_FILE);
+ throw new Exception("The file '" + resourceType + "' has no content");
+ }
+ } catch (Exception exception) {
+ logger.debug("",exception);
+ return;
}
+ nestedOutputMap = nestedHeatOrchestrationTemplate.getOutputs();
- private static String getResourceTypeFromResourcesMap(String resourceName,
- HeatOrchestrationTemplate
- heatOrchestrationTemplate) {
- return heatOrchestrationTemplate.getResources().get(resourceName).getType();
+ if (MapUtils.isEmpty(nestedOutputMap) || !nestedOutputMap.containsKey(attName)) {
+ globalContext.addMessage(fileName, ErrorLevel.ERROR, ErrorMessagesFormatBuilder
+ .getErrorWithParameters(ERROR_CODE_HOT_17,Messages.
+ GET_ATTR_NOT_FOUND.getErrorMessage(),
+ attName, resourceName),
+ LoggerTragetServiceName.VALIDATE_GET_ATTR_FROM_NESTED,
+ LoggerErrorDescription.GET_ATTR_NOT_FOUND);
}
+ }
+
+ private static String getResourceTypeFromResourcesMap(String resourceName,
+ HeatOrchestrationTemplate
+ heatOrchestrationTemplate) {
+ return heatOrchestrationTemplate.getResources().get(resourceName).getType();
+ }
/* validation 17 + */
private static void validateEnvFile(String fileName, String envFileName,
@@ -416,7 +422,7 @@ public class HeatValidator implements Validator {
if (parametersNames != null && !parametersNames.contains(envParameter)) {
globalContext.addMessage(envFile, ErrorLevel.ERROR, ErrorMessagesFormatBuilder
.getErrorWithParameters(
- ERROR_CODE_HOT_3,Messages.
+ ERROR_CODE_HOT_3,Messages.
ENV_INCLUDES_PARAMETER_NOT_IN_HEAT.getErrorMessage(), envFile,
envParameter), LoggerTragetServiceName.VALIDATE_ENV_FILE,
LoggerErrorDescription.ENV_PARAMETER_NOT_IN_HEAT);
@@ -459,7 +465,7 @@ public class HeatValidator implements Validator {
if (!isValueMatchDefault) {
globalContext.addMessage(fileName, ErrorLevel.ERROR, ErrorMessagesFormatBuilder
.getErrorWithParameters(
- ERROR_CODE_HOT_4,Messages.
+ ERROR_CODE_HOT_4,Messages.
PARAMETER_DEFAULT_VALUE_NOT_ALIGN_WITH_TYPE.getErrorMessage(),
parameterEntry.getKey(), parameterType),
LoggerTragetServiceName.VALIDATE_PARAMTER_DEFAULT_MATCH_TYPE,
@@ -495,7 +501,7 @@ public class HeatValidator implements Validator {
.isValueIsFromGivenType(parameterEnvValue, parameterType)) {
globalContext.addMessage(envFile, ErrorLevel.ERROR, ErrorMessagesFormatBuilder
.getErrorWithParameters(
- ERROR_CODE_HOT_5,Messages.
+ ERROR_CODE_HOT_5,Messages.
PARAMETER_ENV_VALUE_NOT_ALIGN_WITH_TYPE.getErrorMessage(),
parameterName), LoggerTragetServiceName.VALIDATE_ENV_PARAMETER_MATCH_TYPE,
LoggerErrorDescription.PARAMETER_DEFAULT_VALUE_NOT_ALIGNED_WITH_TYPE);
@@ -513,7 +519,7 @@ public class HeatValidator implements Validator {
mdcDataDebugMessage.debugEntryMessage(null, null);
ManifestContent manifestContent;
try {
- manifestContent = ValidationUtil.checkValidationPreCondition(globalContext);
+ manifestContent = ValidationUtil.validateManifest(globalContext);
} catch (Exception exception) {
logger.debug("",exception);
return;
@@ -546,9 +552,9 @@ public class HeatValidator implements Validator {
.filter(fileName -> isManifestArtifact(manifestArtifacts, fileName) &&
isNotArtifact(artifacts, fileName))
.forEach(fileName -> globalContext.addMessage(fileName, ErrorLevel.WARNING,
- ErrorMessagesFormatBuilder
- .getErrorWithParameters(ERROR_CODE_HOT_11,
- Messages.ARTIFACT_FILE_NOT_REFERENCED.getErrorMessage()),
+ ErrorMessagesFormatBuilder
+ .getErrorWithParameters(ERROR_CODE_HOT_11,
+ Messages.ARTIFACT_FILE_NOT_REFERENCED.getErrorMessage()),
LoggerTragetServiceName.CHECK_FOR_ORPHAN_ARTIFACTS,
LoggerErrorDescription.ARTIFACT_NOT_REFERENCED));
@@ -567,10 +573,10 @@ public class HeatValidator implements Validator {
private void validate(String fileName, String envFileName, String baseFileName,
Set<String> artifacts, Set<String> securityGroupsNamesFromBaseFileOutputs,
GlobalValidationContext globalContext) {
- globalContext.setMessageCode(ERROR_CODE_HOT_12);
+ globalContext.setMessageCode(ERROR_CODE_HOT_12);
HeatOrchestrationTemplate
heatOrchestrationTemplate = ValidationUtil.checkHeatOrchestrationPreCondition(
- fileName, globalContext);
+ fileName, globalContext);
if (heatOrchestrationTemplate != null) {
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/ManifestValidator.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/ManifestValidator.java
index 2ad2f9afb4..e3a35af6dc 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/ManifestValidator.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/ManifestValidator.java
@@ -22,7 +22,6 @@ package org.openecomp.sdc.validation.impl.validators;
import org.openecomp.core.utilities.json.JsonUtil;
import org.openecomp.core.validation.ErrorMessageCode;
-import org.openecomp.sdc.validation.Validator;
import org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder;
import org.openecomp.core.validation.types.GlobalValidationContext;
import org.openecomp.sdc.common.errors.Messages;
@@ -38,6 +37,7 @@ import org.openecomp.sdc.logging.types.LoggerConstants;
import org.openecomp.sdc.logging.types.LoggerErrorCode;
import org.openecomp.sdc.logging.types.LoggerErrorDescription;
import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
+import org.openecomp.sdc.validation.Validator;
import java.io.InputStream;
import java.util.ArrayList;
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/NamingConventionGuideLineValidator.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/NamingConventionGuideLineValidator.java
index 724b7e4735..43e8e9404f 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/NamingConventionGuideLineValidator.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/NamingConventionGuideLineValidator.java
@@ -1,8 +1,8 @@
package org.openecomp.sdc.validation.impl.validators;
-import org.openecomp.sdc.validation.ValidationContext;
import org.openecomp.core.validation.types.GlobalValidationContext;
import org.openecomp.sdc.heat.datatypes.model.HeatOrchestrationTemplate;
+import org.openecomp.sdc.validation.ValidationContext;
import org.openecomp.sdc.validation.base.ResourceBaseValidator;
import org.openecomp.sdc.validation.type.ConfigConstants;
import org.openecomp.sdc.validation.type.NamingConventionValidationContext;
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/SharedResourceGuideLineValidator.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/SharedResourceGuideLineValidator.java
index 424f8d3517..fb7d6a2c97 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/SharedResourceGuideLineValidator.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/SharedResourceGuideLineValidator.java
@@ -3,13 +3,10 @@ package org.openecomp.sdc.validation.impl.validators;
import org.apache.commons.collections4.CollectionUtils;
import org.openecomp.core.utilities.CommonMethods;
import org.openecomp.core.validation.ErrorMessageCode;
-import org.openecomp.sdc.common.utils.SdcCommon;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
-import org.openecomp.sdc.validation.Validator;
import org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder;
import org.openecomp.core.validation.types.GlobalValidationContext;
import org.openecomp.sdc.common.errors.Messages;
+import org.openecomp.sdc.common.utils.SdcCommon;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
import org.openecomp.sdc.heat.datatypes.manifest.FileData;
import org.openecomp.sdc.heat.datatypes.manifest.ManifestContent;
@@ -18,9 +15,12 @@ import org.openecomp.sdc.heat.datatypes.model.HeatResourcesTypes;
import org.openecomp.sdc.heat.datatypes.model.ResourceReferenceFunctions;
import org.openecomp.sdc.heat.services.HeatStructureUtil;
import org.openecomp.sdc.heat.services.manifest.ManifestUtil;
+import org.openecomp.sdc.logging.api.Logger;
+import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
import org.openecomp.sdc.logging.types.LoggerErrorDescription;
import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
+import org.openecomp.sdc.validation.Validator;
import org.openecomp.sdc.validation.util.ValidationUtil;
import java.util.HashSet;
@@ -44,7 +44,7 @@ public class SharedResourceGuideLineValidator implements Validator {
public void validate(GlobalValidationContext globalContext) {
ManifestContent manifestContent;
try {
- manifestContent = ValidationUtil.checkValidationPreCondition(globalContext);
+ manifestContent = ValidationUtil.validateManifest(globalContext);
} catch (Exception exception) {
log.debug("",exception);
return;
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/YamlValidator.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/YamlValidator.java
index c0468f8b5a..ab2e427f23 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/YamlValidator.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/YamlValidator.java
@@ -21,8 +21,6 @@
package org.openecomp.sdc.validation.impl.validators;
import org.openecomp.core.validation.ErrorMessageCode;
-import org.openecomp.sdc.tosca.services.YamlUtil;
-import org.openecomp.sdc.validation.Validator;
import org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder;
import org.openecomp.core.validation.types.GlobalValidationContext;
import org.openecomp.sdc.common.errors.Messages;
@@ -32,6 +30,8 @@ import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
import org.openecomp.sdc.logging.types.LoggerErrorDescription;
import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
+import org.openecomp.sdc.tosca.services.YamlUtil;
+import org.openecomp.sdc.validation.Validator;
import org.openecomp.sdc.validation.impl.util.YamlValidatorUtil;
import java.io.InputStream;
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/heatresource/NovaServerResourceValidator.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/heatresource/NovaServerResourceValidator.java
index 9c9f4bcdc0..33d20d5714 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/heatresource/NovaServerResourceValidator.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/heatresource/NovaServerResourceValidator.java
@@ -2,7 +2,6 @@ package org.openecomp.sdc.validation.impl.validators.heatresource;
import org.apache.commons.collections4.MapUtils;
import org.openecomp.core.validation.ErrorMessageCode;
-import org.openecomp.sdc.validation.ResourceValidator;
import org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder;
import org.openecomp.core.validation.types.GlobalValidationContext;
import org.openecomp.sdc.common.errors.Messages;
@@ -15,6 +14,7 @@ import org.openecomp.sdc.heat.datatypes.model.ResourceReferenceFunctions;
import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
import org.openecomp.sdc.logging.types.LoggerErrorDescription;
import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
+import org.openecomp.sdc.validation.ResourceValidator;
import org.openecomp.sdc.validation.ValidationContext;
import org.openecomp.sdc.validation.type.HeatResourceValidationContext;
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/namingconvention/NovaServerNamingConventionGuideLineValidator.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/namingconvention/NovaServerNamingConventionGuideLineValidator.java
index b98b6d6600..795bdf0f9f 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/namingconvention/NovaServerNamingConventionGuideLineValidator.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/namingconvention/NovaServerNamingConventionGuideLineValidator.java
@@ -1,7 +1,5 @@
package org.openecomp.sdc.validation.impl.validators.namingconvention;
-import static java.util.Objects.nonNull;
-
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
@@ -36,6 +34,8 @@ import java.util.Map;
import java.util.Objects;
import java.util.TreeMap;
+import static java.util.Objects.nonNull;
+
public class NovaServerNamingConventionGuideLineValidator implements ResourceValidator {
private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
private static final ErrorMessageCode ERROR_CODE_NNS1 = new ErrorMessageCode("NNS1");