diff options
author | mojahidi <mojahidul.islam@amdocs.com> | 2017-11-20 18:11:32 +0530 |
---|---|---|
committer | mojahidi <mojahidul.islam@amdocs.com> | 2017-11-20 18:13:45 +0530 |
commit | 56d40d922c89b9837560c4ca739cafeef566287c (patch) | |
tree | 59f3982e8b28b3a41cd7a025269fce8b1ee5b15a /openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java | |
parent | 914f3a5f952e0799b6fb05788d30562464384a13 (diff) |
Naming Convetion validators
This task is about updating error messages with error codes for ContrailServiceInstanceNamingConventionValidator validator
Change-Id: Ibb113f809ad0d68f4a4104dd35ba14d32e262f0d
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')
1 files changed, 21 insertions, 19 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/namingconvention/ContrailServiceInstanceNamingConventionValidator.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/namingconvention/ContrailServiceInstanceNamingConventionValidator.java index 957658e8cc..51a174f9fa 100644 --- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/namingconvention/ContrailServiceInstanceNamingConventionValidator.java +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/namingconvention/ContrailServiceInstanceNamingConventionValidator.java @@ -1,6 +1,7 @@ package org.openecomp.sdc.validation.impl.validators.namingconvention; 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; @@ -22,6 +23,8 @@ import static java.util.Objects.nonNull; */ public class ContrailServiceInstanceNamingConventionValidator implements ResourceValidator { private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage(); + private static final ErrorMessageCode ERROR_CODE_NSI1 = new ErrorMessageCode("NSI1"); + private static final ErrorMessageCode ERROR_CODE_NSI2 = new ErrorMessageCode("NSI2"); @Override public void validate(String fileName, Map.Entry<String, Resource> resourceEntry, @@ -37,45 +40,44 @@ public class ContrailServiceInstanceNamingConventionValidator implements Resourc mdcDataDebugMessage.debugEntryMessage("file", fileName); String[] regexList = new String[]{"availability_zone_(\\d+)"}; - if (MapUtils.isEmpty(resourceEntry.getValue().getProperties())) { mdcDataDebugMessage.debugExitMessage("file", fileName); return; } Object availabilityZoneMap = - resourceEntry.getValue().getProperties().containsKey("availability_zone") ? resourceEntry - .getValue().getProperties().get("availability_zone") : null; + resourceEntry.getValue().getProperties().containsKey("availability_zone") ? resourceEntry + .getValue().getProperties().get("availability_zone") : null; if (nonNull(availabilityZoneMap)) { if (availabilityZoneMap instanceof Map) { String availabilityZoneName = ValidationUtil.getWantedNameFromPropertyValueGetParam - (availabilityZoneMap); + (availabilityZoneMap); if (availabilityZoneName != null) { if (!ValidationUtil.evalPattern(availabilityZoneName, regexList)) { globalContext.addMessage( - fileName, - ErrorLevel.WARNING, ErrorMessagesFormatBuilder.getErrorWithParameters( - Messages.PARAMETER_NAME_NOT_ALIGNED_WITH_GUIDELINES.getErrorMessage(), - ValidationUtil.getMessagePartAccordingToResourceType(resourceEntry), - "Availability Zone", - availabilityZoneName, resourceEntry.getKey()), - LoggerTragetServiceName.VALIDATE_AVAILABILITY_ZONE_NAME, - LoggerErrorDescription.NAME_NOT_ALIGNED_WITH_GUIDELINES); + fileName, + ErrorLevel.WARNING, ErrorMessagesFormatBuilder.getErrorWithParameters(ERROR_CODE_NSI1, + Messages.PARAMETER_NAME_NOT_ALIGNED_WITH_GUIDELINES.getErrorMessage(), + ValidationUtil.getMessagePartAccordingToResourceType(resourceEntry), + "Availability Zone", + availabilityZoneName, resourceEntry.getKey()), + LoggerTragetServiceName.VALIDATE_AVAILABILITY_ZONE_NAME, + LoggerErrorDescription.NAME_NOT_ALIGNED_WITH_GUIDELINES); } } } else { globalContext.addMessage( - fileName, - ErrorLevel.WARNING, ErrorMessagesFormatBuilder - .getErrorWithParameters(Messages.MISSING_GET_PARAM.getErrorMessage(), - "availability_zone", resourceEntry.getKey()), - LoggerTragetServiceName.VALIDATE_AVAILABILITY_ZONE_NAME, - LoggerErrorDescription.MISSING_GET_PARAM); + fileName, + ErrorLevel.WARNING, ErrorMessagesFormatBuilder + .getErrorWithParameters(ERROR_CODE_NSI2, Messages.MISSING_GET_PARAM.getErrorMessage(), + "availability_zone", resourceEntry.getKey()), + LoggerTragetServiceName.VALIDATE_AVAILABILITY_ZONE_NAME, + LoggerErrorDescription.MISSING_GET_PARAM); } } mdcDataDebugMessage.debugExitMessage("file", fileName); } -} +}
\ No newline at end of file |