summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main
diff options
context:
space:
mode:
authormojahidi <mojahidul.islam@amdocs.com>2017-11-21 11:38:41 +0530
committermojahidi <mojahidul.islam@amdocs.com>2017-11-21 11:38:54 +0530
commit7bd878afa02d188e687a6958ae999807c2106392 (patch)
tree386429ce3dfa9bc95c766118b0aa54968289c9fd /openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main
parent66ed5840294585b55bc632944f19b859d389b3d2 (diff)
ContrailNetworkPolicy ResourceValidator
This task is about updating error messages with error codes for ContrailNetworkPolicyResourceValidator Change-Id: Ia011acd6c82b5fee5fdfd0bca27ef527d4b3b039 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')
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/heatresource/ContrailNetworkPolicyResourceValidator.java55
1 files changed, 29 insertions, 26 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/heatresource/ContrailNetworkPolicyResourceValidator.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/heatresource/ContrailNetworkPolicyResourceValidator.java
index 8ca5e69061..8aa5714f2c 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/heatresource/ContrailNetworkPolicyResourceValidator.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/heatresource/ContrailNetworkPolicyResourceValidator.java
@@ -1,6 +1,7 @@
package org.openecomp.sdc.validation.impl.validators.heatresource;
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;
@@ -23,12 +24,14 @@ import java.util.Map;
*/
public class ContrailNetworkPolicyResourceValidator implements ResourceValidator {
private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
+ private static final ErrorMessageCode ERROR_CODE_HNP1 = new ErrorMessageCode("HNP1");
+ private static final ErrorMessageCode ERROR_CODE_HNP2 = new ErrorMessageCode("HNP2");
@Override
public void validate(String fileName, Map.Entry<String, Resource> resourceEntry,
GlobalValidationContext globalContext, ValidationContext validationContext) {
- validateNetworkPolicyIsUsed
- (fileName, resourceEntry, globalContext, (HeatResourceValidationContext)validationContext);
+ validateNetworkPolicyIsUsed(fileName, resourceEntry, globalContext,
+ (HeatResourceValidationContext) validationContext);
}
@@ -39,25 +42,25 @@ public class ContrailNetworkPolicyResourceValidator implements ResourceValidator
mdcDataDebugMessage.debugEntryMessage("file", fileName);
Map<String, Map<String, List<String>>> referencedNetworkAttachPoliciesResources =
- validationContext.getFileLevelResourceDependencies()
- .get(HeatResourcesTypes.CONTRAIL_NETWORK_RULE_RESOURCE_TYPE.getHeatResource());
+ validationContext.getFileLevelResourceDependencies()
+ .get(HeatResourcesTypes.CONTRAIL_NETWORK_RULE_RESOURCE_TYPE.getHeatResource());
if (MapUtils.isEmpty(referencedNetworkAttachPoliciesResources)) {
globalContext
- .addMessage(
- fileName,
- ErrorLevel.WARNING,
- ErrorMessagesFormatBuilder
- .getErrorWithParameters(
- Messages.RESOURCE_NOT_IN_USE.getErrorMessage(),
- ValidatorConstants.Network_Policy, resourceEntry.getKey()),
- LoggerTragetServiceName.VALIDATE_ATTACH_POLICY_IN_USE,
- LoggerErrorDescription.NETWORK_ATTACH_POLICY_NOT_IN_USE);
+ .addMessage(
+ fileName,
+ ErrorLevel.WARNING,
+ ErrorMessagesFormatBuilder
+ .getErrorWithParameters(ERROR_CODE_HNP1,
+ Messages.RESOURCE_NOT_IN_USE.getErrorMessage(),
+ ValidatorConstants.Network_Policy, resourceEntry.getKey()),
+ LoggerTragetServiceName.VALIDATE_ATTACH_POLICY_IN_USE,
+ LoggerErrorDescription.NETWORK_ATTACH_POLICY_NOT_IN_USE);
return;
}
- handleNetworkAttachPolicyReferences
- (fileName, resourceEntry, referencedNetworkAttachPoliciesResources, globalContext);
+ handleNetworkAttachPolicyReferences(fileName, resourceEntry,
+ referencedNetworkAttachPoliciesResources, globalContext);
mdcDataDebugMessage.debugExitMessage("file", fileName);
@@ -69,23 +72,23 @@ public class ContrailNetworkPolicyResourceValidator implements ResourceValidator
GlobalValidationContext globalContext) {
Map<String, List<String>> resourcesPointingToCurrNetworkAttachPolicy =
- pointedNetworkAttachPolicies.get(resourceEntry.getKey());
+ pointedNetworkAttachPolicies.get(resourceEntry.getKey());
if (isNetworkAttachPolicyNotInUse(resourcesPointingToCurrNetworkAttachPolicy)) {
globalContext
- .addMessage(
- fileName,
- ErrorLevel.WARNING,
- ErrorMessagesFormatBuilder
- .getErrorWithParameters(
- Messages.RESOURCE_NOT_IN_USE.getErrorMessage(),
- ValidatorConstants.Network_Policy, resourceEntry.getKey()),
- LoggerTragetServiceName.VALIDATE_ATTACH_POLICY_IN_USE,
- LoggerErrorDescription.NETWORK_ATTACH_POLICY_NOT_IN_USE);
+ .addMessage(
+ fileName,
+ ErrorLevel.WARNING,
+ ErrorMessagesFormatBuilder
+ .getErrorWithParameters(ERROR_CODE_HNP2,
+ Messages.RESOURCE_NOT_IN_USE.getErrorMessage(),
+ ValidatorConstants.Network_Policy, resourceEntry.getKey()),
+ LoggerTragetServiceName.VALIDATE_ATTACH_POLICY_IN_USE,
+ LoggerErrorDescription.NETWORK_ATTACH_POLICY_NOT_IN_USE);
}
}
private static boolean isNetworkAttachPolicyNotInUse(
- Map<String, List<String>> resourcesPointingToCurrNetworkAttachPolicy) {
+ Map<String, List<String>> resourcesPointingToCurrNetworkAttachPolicy) {
return MapUtils.isEmpty(resourcesPointingToCurrNetworkAttachPolicy);
}