summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java
diff options
context:
space:
mode:
authormojahidi <mojahidul.islam@amdocs.com>2017-11-22 18:46:42 +0530
committermojahidi <mojahidul.islam@amdocs.com>2017-11-22 18:46:52 +0530
commit7bc86774af4b54478aa00e3554b1a6c868d983dc (patch)
tree0606c7160472b7892c61825fb56939a7d7f17bc5 /openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java
parent49817938ed3fcfb62b43954eaa361ff2289f1715 (diff)
NovaServerGroupResourceValidator
This task is about updating error messages with error codes for NovaServerGroupResourceValidator Change-Id: I72efa7954e846a094268dbda4399bea9c841305d 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/heatresource/NovaServerGroupResourceValidator.java74
1 files changed, 39 insertions, 35 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/NovaServerGroupResourceValidator.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/heatresource/NovaServerGroupResourceValidator.java
index f56d941ba4..a9cbbe565e 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/heatresource/NovaServerGroupResourceValidator.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/heatresource/NovaServerGroupResourceValidator.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;
@@ -25,12 +26,15 @@ import java.util.Objects;
*/
public class NovaServerGroupResourceValidator implements ResourceValidator {
private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
+ private static final ErrorMessageCode ERROR_CODE_HNG1 = new ErrorMessageCode("HNG1");
+ private static final ErrorMessageCode ERROR_CODE_HNG2 = new ErrorMessageCode("HNG2");
+ private static final ErrorMessageCode ERROR_CODE_HNG3 = new ErrorMessageCode("HNG3");
public void validate(String fileName, Map.Entry<String, Resource> resourceEntry,
GlobalValidationContext globalContext, ValidationContext validationContext) {
validateNovaServerGroupPolicy(fileName, resourceEntry, globalContext);
- validateServerGroupIsUsed
- (fileName, resourceEntry, globalContext, (HeatResourceValidationContext) validationContext);
+ validateServerGroupIsUsed(fileName, resourceEntry, globalContext,
+ (HeatResourceValidationContext) validationContext);
}
@SuppressWarnings("unchecked")
@@ -42,7 +46,7 @@ public class NovaServerGroupResourceValidator implements ResourceValidator {
Resource resource = resourceEntry.getValue();
Object policies =
- resource.getProperties() == null ? null : resource.getProperties().get("policies");
+ resource.getProperties() == null ? null : resource.getProperties().get("policies");
if (Objects.nonNull(policies) && policies instanceof List) {
List<Object> policiesList = (List<Object>) policies;
@@ -50,17 +54,19 @@ public class NovaServerGroupResourceValidator implements ResourceValidator {
Object policy = policiesList.get(0);
if (!isGivenPolicyValid(policy)) {
globalContext.addMessage(fileName, ErrorLevel.ERROR, ErrorMessagesFormatBuilder
- .getErrorWithParameters(Messages.WRONG_POLICY_IN_SERVER_GROUP.getErrorMessage(),
- resourceEntry.getKey()),
- LoggerTragetServiceName.VALIDATE_NOVA_SEVER_GROUP_POLICY,
- LoggerErrorDescription.WRONG_POLICY_SERVER_GROUP);
+ .getErrorWithParameters(
+ ERROR_CODE_HNG1, Messages.WRONG_POLICY_IN_SERVER_GROUP.getErrorMessage(),
+ resourceEntry.getKey()),
+ LoggerTragetServiceName.VALIDATE_NOVA_SEVER_GROUP_POLICY,
+ LoggerErrorDescription.WRONG_POLICY_SERVER_GROUP);
}
} else {
globalContext.addMessage(fileName, ErrorLevel.ERROR, ErrorMessagesFormatBuilder
- .getErrorWithParameters(Messages.WRONG_POLICY_IN_SERVER_GROUP.getErrorMessage(),
- resourceEntry.getKey()),
- LoggerTragetServiceName.VALIDATE_NOVA_SEVER_GROUP_POLICY,
- LoggerErrorDescription.WRONG_POLICY_SERVER_GROUP);
+ .getErrorWithParameters(ERROR_CODE_HNG1,
+ Messages.WRONG_POLICY_IN_SERVER_GROUP.getErrorMessage(),
+ resourceEntry.getKey()),
+ LoggerTragetServiceName.VALIDATE_NOVA_SEVER_GROUP_POLICY,
+ LoggerErrorDescription.WRONG_POLICY_SERVER_GROUP);
}
}
@@ -83,45 +89,43 @@ public class NovaServerGroupResourceValidator implements ResourceValidator {
HeatResourceValidationContext validationContext) {
Map<String, Map<String, List<String>>> pointedServerGroups =
- validationContext.getFileLevelResourceDependencies().get(HeatResourcesTypes
- .NOVA_SERVER_GROUP_RESOURCE_TYPE.getHeatResource());
+ validationContext.getFileLevelResourceDependencies().get(HeatResourcesTypes
+ .NOVA_SERVER_GROUP_RESOURCE_TYPE.getHeatResource());
if (MapUtils.isEmpty(pointedServerGroups)) {
globalContext
- .addMessage(
- fileName,
- ErrorLevel.WARNING,
- ErrorMessagesFormatBuilder
- .getErrorWithParameters(
- Messages.RESOURCE_NOT_IN_USE.getErrorMessage(),
- ValidatorConstants.Server_Group, resourceEntry.getKey()),
- LoggerTragetServiceName.VALIDATE_ALL_SERVER_GROUP_OR_SECURITY_GROUP_IN_USE,
- LoggerErrorDescription.SERVER_GROUP_SECURITY_GROUP_NOT_IN_USE);
+ .addMessage(
+ fileName,
+ ErrorLevel.WARNING,
+ ErrorMessagesFormatBuilder
+ .getErrorWithParameters(
+ ERROR_CODE_HNG2, Messages.RESOURCE_NOT_IN_USE.getErrorMessage(),
+ ValidatorConstants.Server_Group, resourceEntry.getKey()),
+ LoggerTragetServiceName.VALIDATE_ALL_SERVER_GROUP_OR_SECURITY_GROUP_IN_USE,
+ LoggerErrorDescription.SERVER_GROUP_SECURITY_GROUP_NOT_IN_USE);
return;
}
handleServerGroupReferences(fileName, resourceEntry, pointedServerGroups, globalContext);
-
-
}
private void handleServerGroupReferences(String fileName, Map.Entry<String, Resource>
- resourceEntry, Map<String, Map<String, List<String>>> pointedServerGroups,
+ resourceEntry, Map<String, Map<String, List<String>>> pointedServerGroups,
GlobalValidationContext globalContext) {
Map<String, List<String>> resourcesPointingToCurrServerGroup =
- pointedServerGroups.get(resourceEntry.getKey());
+ pointedServerGroups.get(resourceEntry.getKey());
if (MapUtils.isEmpty(resourcesPointingToCurrServerGroup)) {
globalContext
- .addMessage(
- fileName,
- ErrorLevel.WARNING,
- ErrorMessagesFormatBuilder
- .getErrorWithParameters(
- Messages.RESOURCE_NOT_IN_USE.getErrorMessage(),
- ValidatorConstants.Server_Group, resourceEntry.getKey()),
- LoggerTragetServiceName.VALIDATE_ALL_SERVER_GROUP_OR_SECURITY_GROUP_IN_USE,
- LoggerErrorDescription.SERVER_GROUP_SECURITY_GROUP_NOT_IN_USE);
+ .addMessage(
+ fileName,
+ ErrorLevel.WARNING,
+ ErrorMessagesFormatBuilder
+ .getErrorWithParameters(
+ ERROR_CODE_HNG3, Messages.RESOURCE_NOT_IN_USE.getErrorMessage(),
+ ValidatorConstants.Server_Group, resourceEntry.getKey()),
+ LoggerTragetServiceName.VALIDATE_ALL_SERVER_GROUP_OR_SECURITY_GROUP_IN_USE,
+ LoggerErrorDescription.SERVER_GROUP_SECURITY_GROUP_NOT_IN_USE);
}
}