Class SystemPropertyAttributeNameValidator
java.lang.Object
org.broadleafcommerce.openadmin.server.service.persistence.validation.ValidationConfigurationBasedPropertyValidator
org.broadleafcommerce.admin.persistence.validation.SystemPropertyAttributeNameValidator
- All Implemented Interfaces:
PropertyValidator
@Component("blSystemPropertyAttributeNameValidator")
public class SystemPropertyAttributeNameValidator
extends ValidationConfigurationBasedPropertyValidator
Validates that a SystemProperty's AttributeName field does not contain a reserved key word surrounded by ".".
AttributeNames such as "should.not.fail" will be converted to "should__not__fail" by JSCompatibilityHelper.
This will later lead to a Thymeleaf exception when it attempts to process #fields.hasErrors('fields[should__not__fail].value')
in entityForm.html.
- Author:
- Chris Kittrell (ckittrell)
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
containsOnlyLettersNumbersPeriodsDashes
(String attributeName) protected boolean
containsWhiteSpace
(String attributeName) protected PropertyValidationResult
createContainsReservedKeywordsValidationResult
(Set<String> containedReservedKeywords) protected PropertyValidationResult
protected String
protected String
removeFirstAndLastPieces
(List<String> attributeNamePieces) Remove the first & last elements since we know they cannot be surrounded by "."retrieveContainedReservedKeywords
(String attributeName) validate
(Entity entity, Serializable instance, Map<String, FieldMetadata> entityFieldMetadata, Map<String, String> validationConfiguration, BasicFieldMetadata propertyMetadata, String propertyName, String value) Validates a property for an entityMethods inherited from class org.broadleafcommerce.openadmin.server.service.persistence.validation.ValidationConfigurationBasedPropertyValidator
validateInternal
-
Field Details
-
LOG
protected static final org.apache.commons.logging.Log LOG
-
-
Constructor Details
-
SystemPropertyAttributeNameValidator
public SystemPropertyAttributeNameValidator()
-
-
Method Details
-
validate
public PropertyValidationResult validate(Entity entity, Serializable instance, Map<String, FieldMetadata> entityFieldMetadata, Map<String, String> validationConfiguration, BasicFieldMetadata propertyMetadata, String propertyName, String value) Description copied from interface:PropertyValidator
Validates a property for an entity- Specified by:
validate
in interfacePropertyValidator
- Overrides:
validate
in classValidationConfigurationBasedPropertyValidator
- Parameters:
entity
- Entity DTO of the entity attempting to saveinstance
- actual object representation of entity. This can be cast to entity interfaces (like Sku or Product)entityFieldMetadata
- complete field metadata for all properties in entityvalidationConfiguration
- the map represented by the set ofConfigurationItem
for aValidationConfiguration
on a property. This map could be null if thisPropertyValidator
is being invoked outside of the context of a particular property (like a global validator)propertyMetadata
-BasicFieldMetadata
corresponding to the property that is being validpropertyName
- the property name of the value attempting to be saved (could be a sub-entity obtained via dot notation like 'defaultSku.name')value
- the value attempted to be saved- Returns:
- true if this passes validation, false otherwise.
-
containsWhiteSpace
-
containsOnlyLettersNumbersPeriodsDashes
-
retrieveContainedReservedKeywords
-
removeFirstAndLastPieces
Remove the first & last elements since we know they cannot be surrounded by "." -
createDisallowedCharactersValidationResult
-
getDisallowedCharactersErrorMesssage
-
createContainsReservedKeywordsValidationResult
protected PropertyValidationResult createContainsReservedKeywordsValidationResult(Set<String> containedReservedKeywords) -
getReservedWordErrorMessage
-