From 66ed5840294585b55bc632944f19b859d389b3d2 Mon Sep 17 00:00:00 2001 From: Abhai Singh Date: Mon, 20 Nov 2017 18:27:50 +0530 Subject: Adding error codes to HEAT Validator Added error code to SharedResourceGuideLineValidator Issue-Id :SDC-572 Change-Id: I20c014a1aeb488788bc1faeb05a89ff920258275 Signed-off-by: Abhai Singh --- .../sdc/validation/util/ValidationUtil.java | 43 ++-------------------- 1 file changed, 3 insertions(+), 40 deletions(-) (limited to 'openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk') diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/src/main/java/org/openecomp/sdc/validation/util/ValidationUtil.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/src/main/java/org/openecomp/sdc/validation/util/ValidationUtil.java index 217ff857f6..d9e0351578 100644 --- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/src/main/java/org/openecomp/sdc/validation/util/ValidationUtil.java +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/src/main/java/org/openecomp/sdc/validation/util/ValidationUtil.java @@ -2,7 +2,6 @@ package org.openecomp.sdc.validation.util; import org.apache.commons.collections4.CollectionUtils; -import org.openecomp.core.utilities.CommonMethods; import org.openecomp.core.utilities.json.JsonUtil; import org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder; import org.openecomp.core.validation.types.GlobalValidationContext; @@ -16,7 +15,6 @@ 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.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; @@ -229,8 +227,9 @@ public class ValidationUtil { } } catch (Exception exception) { globalContext.addMessage(fileName, ErrorLevel.ERROR, ErrorMessagesFormatBuilder - .getErrorWithParameters(Messages.INVALID_HEAT_FORMAT_REASON.getErrorMessage(), - getParserExceptionReason(exception)), + .getErrorWithParameters(globalContext.getMessageCode(), + Messages.INVALID_HEAT_FORMAT_REASON.getErrorMessage() + , getParserExceptionReason(exception)), LoggerTragetServiceName.VALIDATE_HEAT_FORMAT, LoggerErrorDescription.INVALID_HEAT_FORMAT); mdcDataDebugMessage.debugExitMessage("file", fileName); @@ -240,41 +239,5 @@ public class ValidationUtil { return heatOrchestrationTemplate; } - public static Set validateManifest(ManifestContent manifestContent, - GlobalValidationContext globalContext) { - - mdcDataDebugMessage.debugEntryMessage("file", SdcCommon.MANIFEST_NAME); - - Set baseFiles = ManifestUtil.getBaseFiles(manifestContent); - if (baseFiles == null || baseFiles.size() == 0) { - globalContext.addMessage( - SdcCommon.MANIFEST_NAME, - ErrorLevel.WARNING, - ErrorMessagesFormatBuilder - .getErrorWithParameters(Messages.MISSIN_BASE_HEAT_FILE.getErrorMessage()), - LoggerTragetServiceName.VALIDATE_BASE_FILE, - LoggerErrorDescription.MISSING_BASE_HEAT); - } else if (baseFiles.size() > 1) { - String baseFileList = getElementListAsString(baseFiles); - globalContext.addMessage( - SdcCommon.MANIFEST_NAME, - ErrorLevel.WARNING, - ErrorMessagesFormatBuilder - .getErrorWithParameters(Messages.MULTI_BASE_HEAT_FILE.getErrorMessage(), - baseFileList), - LoggerTragetServiceName.VALIDATE_BASE_FILE, - LoggerErrorDescription.MULTI_BASE_HEAT); - } - - mdcDataDebugMessage.debugExitMessage("file", SdcCommon.MANIFEST_NAME); - return baseFiles; - } - - private static String getElementListAsString(Set elementCollection) { - - return "[" - + CommonMethods.collectionToCommaSeparatedString(elementCollection) - + "]"; - } } -- cgit 1.2.3-korg