diff options
author | eleonorali <eleonoral@amdocs.com> | 2018-08-06 11:25:37 +0300 |
---|---|---|
committer | Avi Gaffa <avi.gaffa@amdocs.com> | 2018-08-06 11:46:15 +0000 |
commit | b503f5b618a0c14b91714bb32de69f0957ab1f03 (patch) | |
tree | df9d751581d67645fc6f86fe4039c8ea43deab3a /openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main | |
parent | aa8057fa429db6852a86ad217a641bb2bf12123c (diff) |
Add HEAT validation for generated artifacts
Add heat validation for generated artifacts,
like vendor-license-model.xml, vf-license-model.xml, HEAT.meta
Change-Id: Ie256b19679b5aebea1290f6b3f67692dfad5e980
Issue-ID: SDC-1600
Signed-off-by: eleonorali <eleonoral@amdocs.com>
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main')
-rw-r--r-- | openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/HeatValidator.java | 81 |
1 files changed, 56 insertions, 25 deletions
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 af3b503479..ae289f9178 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 @@ -53,24 +53,37 @@ import org.openecomp.sdc.validation.impl.util.HeatValidationService; import org.openecomp.sdc.validation.util.ValidationUtil; public class HeatValidator implements Validator { - private static final Logger LOGGER = LoggerFactory.getLogger(HeatValidator.class); - private static final ErrorMessageCode ERROR_CODE_HOT_1 = new ErrorMessageCode("HOT1"); - private static final ErrorMessageCode ERROR_CODE_HOT_2 = new ErrorMessageCode("HOT2"); - private static final ErrorMessageCode ERROR_CODE_HOT_3 = new ErrorMessageCode("HOT3"); - private static final ErrorMessageCode ERROR_CODE_HOT_4 = new ErrorMessageCode("HOT4"); - private static final ErrorMessageCode ERROR_CODE_HOT_5 = new ErrorMessageCode("HOT5"); - private static final ErrorMessageCode ERROR_CODE_HOT_6 = new ErrorMessageCode("HOT6"); - private static final ErrorMessageCode ERROR_CODE_HOT_7 = new ErrorMessageCode("HOT7"); - private static final ErrorMessageCode ERROR_CODE_HOT_8 = new ErrorMessageCode("HOT8"); - private static final ErrorMessageCode ERROR_CODE_HOT_9 = new ErrorMessageCode("HOT9"); - private static final ErrorMessageCode ERROR_CODE_HOT_10 = new ErrorMessageCode("HOT10"); - private static final ErrorMessageCode ERROR_CODE_HOT_11 = new ErrorMessageCode("HOT11"); - private static final ErrorMessageCode ERROR_CODE_HOT_12 = new ErrorMessageCode("HOT12"); - private static final ErrorMessageCode ERROR_CODE_HOT_13 = new ErrorMessageCode("HOT13"); - private static final ErrorMessageCode ERROR_CODE_HOT_14 = new ErrorMessageCode("HOT14"); - private static final ErrorMessageCode ERROR_CODE_HOT_15 = new ErrorMessageCode("HOT15"); - private static final ErrorMessageCode ERROR_CODE_HOT_16 = new ErrorMessageCode("HOT16"); - private static final ErrorMessageCode ERROR_CODE_HOT_17 = new ErrorMessageCode("HOT17"); + private static final Logger LOGGER = LoggerFactory.getLogger(HeatValidator.class); + private static final ErrorMessageCode ERROR_CODE_HOT_1 = new ErrorMessageCode("HOT1"); + private static final ErrorMessageCode ERROR_CODE_HOT_2 = new ErrorMessageCode("HOT2"); + private static final ErrorMessageCode ERROR_CODE_HOT_3 = new ErrorMessageCode("HOT3"); + private static final ErrorMessageCode ERROR_CODE_HOT_4 = new ErrorMessageCode("HOT4"); + private static final ErrorMessageCode ERROR_CODE_HOT_5 = new ErrorMessageCode("HOT5"); + private static final ErrorMessageCode ERROR_CODE_HOT_6 = new ErrorMessageCode("HOT6"); + private static final ErrorMessageCode ERROR_CODE_HOT_7 = new ErrorMessageCode("HOT7"); + private static final ErrorMessageCode ERROR_CODE_HOT_8 = new ErrorMessageCode("HOT8"); + private static final ErrorMessageCode ERROR_CODE_HOT_9 = new ErrorMessageCode("HOT9"); + private static final ErrorMessageCode ERROR_CODE_HOT_10 = new ErrorMessageCode("HOT10"); + private static final ErrorMessageCode ERROR_CODE_HOT_11 = new ErrorMessageCode("HOT11"); + private static final ErrorMessageCode ERROR_CODE_HOT_12 = new ErrorMessageCode("HOT12"); + private static final ErrorMessageCode ERROR_CODE_HOT_13 = new ErrorMessageCode("HOT13"); + private static final ErrorMessageCode ERROR_CODE_HOT_14 = new ErrorMessageCode("HOT14"); + private static final ErrorMessageCode ERROR_CODE_HOT_15 = new ErrorMessageCode("HOT15"); + private static final ErrorMessageCode ERROR_CODE_HOT_16 = new ErrorMessageCode("HOT16"); + private static final ErrorMessageCode ERROR_CODE_HOT_17 = new ErrorMessageCode("HOT17"); + + private static final ErrorMessageCode ERROR_CODE_HOT_18 = new ErrorMessageCode("HOT18"); + + // The Artifacts generated by SDC - not allowed to be in HEAT + static final String VF_LICENSE_MODEL_XML = "vf-license-model.xml"; + static final String VENDOR_LICENSE_MODEL_XML = "vendor-license-model.xml"; + static final String HEAT_META = "HEAT.meta"; + + private static final Set<String> GENERATED_ARTIFACTS; + + static { + GENERATED_ARTIFACTS = getGeneratedArtifactNames(); + } private static void validateAllRequiredArtifactsExist(String fileName, HeatOrchestrationTemplate @@ -494,16 +507,34 @@ public class HeatValidator implements Validator { fileName).getFile(), artifacts, globalContext)); - Set<String> manifestArtifacts = ManifestUtil.getArtifacts(manifestContent); - globalContext.getFiles().stream() - .filter(fileName -> isManifestArtifact(manifestArtifacts, fileName) - && isNotArtifact(artifacts, fileName)) - .forEach(fileName -> globalContext.addMessage(fileName, ErrorLevel.WARNING, - ErrorMessagesFormatBuilder + globalContext.getFiles().stream().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()))); + Messages.ARTIFACT_FILE_NOT_REFERENCED.getErrorMessage())); + + validateGeneratedArtifact(fileName, globalContext); + + }); + } + + private void validateGeneratedArtifact(String fileName, GlobalValidationContext globalContext) { + if (GENERATED_ARTIFACTS.contains(fileName)) { + globalContext.addMessage(fileName, ErrorLevel.ERROR, ErrorMessagesFormatBuilder + .getErrorWithParameters(ERROR_CODE_HOT_18, + Messages.GENERATED_ARTIFACT_IN_USE.getErrorMessage(), fileName)); + } + } + + private static Set<String> getGeneratedArtifactNames() { + Set<String> predefinedArtifactNames = new HashSet<>(); + predefinedArtifactNames.add(VF_LICENSE_MODEL_XML); + predefinedArtifactNames.add(VENDOR_LICENSE_MODEL_XML); + predefinedArtifactNames.add(HEAT_META); + return predefinedArtifactNames; } private boolean isManifestArtifact(Set<String> manifestArtifacts, String fileName) { |