Class UriPropertyValidator
java.lang.Object
org.broadleafcommerce.openadmin.server.service.persistence.validation.ValidationConfigurationBasedPropertyValidator
org.broadleafcommerce.openadmin.server.service.persistence.validation.UriPropertyValidator
- All Implemented Interfaces:
PropertyValidator
@Component("blUriPropertyValidator")
public class UriPropertyValidator
extends ValidationConfigurationBasedPropertyValidator
Validates a field as being a valid URI to ensure compatibility with Broadleaf handlers including
PageHandler, ProductHandler, and CategoryHandlers.
Component can be overridden with the following properties:
This component was introduced instead of using RegEx because most site have simple url needs and BLC out of box simply requires that the URL start with a / and use valid url characters.
Replace if needed for your implementation.
- Author:
- Brian Polster
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanprotected booleanprotected booleanbooleanbooleanvoidsetSucceedForNullValues(boolean succeedForNullValues) 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 -
URI_PATTERN
-
ERROR_KEY_BEGIN_WITH_SLASH
-
ERROR_KEY_CANNOT_END_WITH_SLASH
-
ERROR_KEY_CANNOT_CONTAIN_SPACES
-
ERROR_KEY_CANNOT_CONTAIN_SPECIAL_CHARACTERS
-
succeedForNullValues
protected boolean succeedForNullValuesDenotes what should occur when this validator encounters a null value to validate against. Default behavior is to allow them, which means that this validator will always return true with null values
-
-
Constructor Details
-
UriPropertyValidator
public UriPropertyValidator()
-
-
Method Details
-
getIgnoreFullUrls
protected boolean getIgnoreFullUrls() -
getRequireLeadingSlash
protected boolean getRequireLeadingSlash() -
getAllowTrailingSlash
protected boolean getAllowTrailingSlash() -
isFullUrl
-
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:PropertyValidatorValidates a property for an entity- Specified by:
validatein interfacePropertyValidator- Overrides:
validatein 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 ofConfigurationItemfor aValidationConfigurationon a property. This map could be null if thisPropertyValidatoris being invoked outside of the context of a particular property (like a global validator)propertyMetadata-BasicFieldMetadatacorresponding 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.
-
isSucceedForNullValues
public boolean isSucceedForNullValues() -
setSucceedForNullValues
public void setSucceedForNullValues(boolean succeedForNullValues)
-