1 package com.att.sdc.validation.impl.validators;
3 import com.att.sdc.validation.datatypes.AttLoggerErrorDescription;
4 import com.att.sdc.validation.datatypes.AttLoggerTargetServiceName;
5 import com.att.sdc.validation.datatypes.AttValetGroupTypeValues;
6 import com.att.sdc.validation.messages.Messages;
7 import org.apache.commons.collections4.MapUtils;
8 import org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder;
9 import org.openecomp.core.validation.types.GlobalValidationContext;
10 import org.openecomp.sdc.datatypes.error.ErrorLevel;
11 import org.openecomp.sdc.heat.datatypes.model.Resource;
12 import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
13 import org.openecomp.sdc.validation.ResourceValidator;
14 import org.openecomp.sdc.validation.ValidationContext;
17 import java.util.Objects;
20 * Created by TALIO on 2/26/2017.
22 public class AttValetGroupAssignmentResourceValidator implements ResourceValidator {
23 private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
26 public void validate(String fileName, Map.Entry<String, Resource> resourceEntry,
27 GlobalValidationContext globalContext, ValidationContext validationContext) {
28 mdcDataDebugMessage.debugEntryMessage("file", fileName);
30 Resource resource = resourceEntry.getValue();
32 Map<String, Object> propertiesMap = resource.getProperties();
33 if (MapUtils.isEmpty(propertiesMap)) {
37 Object groupTypeValue = propertiesMap.get("group_type");
38 if (Objects.isNull(groupTypeValue)) {
42 validateGroupTypeValue(fileName, resourceEntry.getKey(), groupTypeValue, globalContext);
43 mdcDataDebugMessage.debugExitMessage("file", fileName);
46 private static void validateGroupTypeValue(String fileName, String resourceId,
47 Object groupTypeValue,
48 GlobalValidationContext globalContext) {
49 mdcDataDebugMessage.debugEntryMessage("file", fileName);
51 if (!AttValetGroupTypeValues.isGroupTypeValid(groupTypeValue)) {
52 globalContext.addMessage(fileName, ErrorLevel.WARNING, ErrorMessagesFormatBuilder
53 .getErrorWithParameters(Messages.UNEXPECTED_GROUP_TYPE_ATT_VALET.getErrorMessage(),
54 resourceId), AttLoggerTargetServiceName.VALIDATE_ATT_VALET_TYPE,
55 AttLoggerErrorDescription.ATT_VALET_IN_USE);
58 mdcDataDebugMessage.debugExitMessage("file", fileName);