diff options
author | mojahidi <mojahidul.islam@amdocs.com> | 2017-11-22 17:52:37 +0530 |
---|---|---|
committer | mojahidi <mojahidul.islam@amdocs.com> | 2017-11-22 17:56:28 +0530 |
commit | dd537b2c409c580efd98d887a61c50f7f53458c5 (patch) | |
tree | d8207b57fb889d0f8f9f46c92cbd8c97ff2b24b5 /openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java | |
parent | b110b94fe9ab62393b8c1ec64320668c7222bc6a (diff) |
ForbiddenResourceGuideLine Validator
This task is about updating error messages with error codes for ForbiddenResourceGuideLine
Change-Id: Id692b43e05443dc1313b51533e685dd3c7ad6ca6
Issue-ID: SDC-572
Signed-off-by: mojahidi <mojahidul.islam@amdocs.com>
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/validators/ForbiddenResourceGuideLineValidator.java | 25 |
1 files changed, 14 insertions, 11 deletions
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 569f2bb760..2dad766c45 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 @@ -1,6 +1,7 @@ package org.openecomp.sdc.validation.impl.validators; import org.apache.commons.collections4.MapUtils; +import org.openecomp.core.validation.ErrorMessageCode; import org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder; import org.openecomp.core.validation.types.GlobalValidationContext; import org.openecomp.sdc.common.errors.Messages; @@ -29,6 +30,9 @@ import java.util.Set; public class ForbiddenResourceGuideLineValidator implements Validator { private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage(); private static Set<String> forbiddenResources = new HashSet<>(); + private static final ErrorMessageCode ERROR_CODE_FRG_1 = new ErrorMessageCode("FRG1"); + private static final ErrorMessageCode ERROR_CODE_FRG_2 = new ErrorMessageCode("FRG2"); + private static final ErrorMessageCode ERROR_CODE_FRG_3 = new ErrorMessageCode("FRG3"); private final Logger log = (Logger) LoggerFactory.getLogger(this.getClass().getName()); @@ -40,10 +44,6 @@ public class ForbiddenResourceGuideLineValidator implements Validator { forbiddenResourcesMap.entrySet().stream() .filter(entry -> isResourceEnabled(entry.getValue().get("enable"))) .forEach(entry -> forbiddenResources.add(entry.getKey())); - - - - } private boolean isResourceEnabled(Object enableValue){ @@ -78,8 +78,10 @@ public class ForbiddenResourceGuideLineValidator implements Validator { } private void validate(String fileName, GlobalValidationContext globalContext) { + globalContext.setMessageCode(ERROR_CODE_FRG_3); HeatOrchestrationTemplate - heatOrchestrationTemplate = ValidationUtil.checkHeatOrchestrationPreCondition(fileName, globalContext); + heatOrchestrationTemplate = ValidationUtil.checkHeatOrchestrationPreCondition( + fileName, globalContext); if (heatOrchestrationTemplate == null) { return; } @@ -103,18 +105,19 @@ public class ForbiddenResourceGuideLineValidator implements Validator { String resourceType = resourceEntry.getValue().getType(); if (Objects.isNull(resourceType)) { globalContext.addMessage(fileName, ErrorLevel.WARNING, ErrorMessagesFormatBuilder - .getErrorWithParameters(Messages.INVALID_RESOURCE_TYPE.getErrorMessage(), "null", + .getErrorWithParameters(ERROR_CODE_FRG_1, + Messages.INVALID_RESOURCE_TYPE.getErrorMessage(),"null", resourceEntry.getKey()), LoggerTragetServiceName.VALIDATE_RESOURCE_TYPE, LoggerErrorDescription.INVALID_RESOURCE_TYPE); } else { - if(isResourceForbidden(resourceType)){ - globalContext.addMessage( + if (isResourceForbidden(resourceType)){ + globalContext.addMessage( fileName, ErrorLevel.WARNING, ErrorMessagesFormatBuilder - .getErrorWithParameters(Messages.FORBIDDEN_RESOURCE_IN_USE.getErrorMessage(), - resourceType, - resourceEntry.getKey()), + .getErrorWithParameters(ERROR_CODE_FRG_2, Messages.FORBIDDEN_RESOURCE_IN_USE + .getErrorMessage(), + resourceType, resourceEntry.getKey()), LoggerTragetServiceName.VALIDATE_FORBIDDEN_RESOURCE, LoggerErrorDescription.FLOATING_IP_IN_USE); } |