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 Details

    • LOG

      protected static final org.apache.commons.logging.Log LOG
    • URI_PATTERN

      protected static final Pattern URI_PATTERN
    • ERROR_KEY_BEGIN_WITH_SLASH

      protected String ERROR_KEY_BEGIN_WITH_SLASH
    • ERROR_KEY_CANNOT_END_WITH_SLASH

      protected String ERROR_KEY_CANNOT_END_WITH_SLASH
    • ERROR_KEY_CANNOT_CONTAIN_SPACES

      protected String ERROR_KEY_CANNOT_CONTAIN_SPACES
    • ERROR_KEY_CANNOT_CONTAIN_SPECIAL_CHARACTERS

      protected String ERROR_KEY_CANNOT_CONTAIN_SPECIAL_CHARACTERS
    • succeedForNullValues

      protected boolean succeedForNullValues
      Denotes 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

      public boolean isFullUrl(String url)
    • 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 interface PropertyValidator
      Overrides:
      validate in class ValidationConfigurationBasedPropertyValidator
      Parameters:
      entity - Entity DTO of the entity attempting to save
      instance - actual object representation of entity. This can be cast to entity interfaces (like Sku or Product)
      entityFieldMetadata - complete field metadata for all properties in entity
      validationConfiguration - the map represented by the set of ConfigurationItem for a ValidationConfiguration on a property. This map could be null if this PropertyValidator is being invoked outside of the context of a particular property (like a global validator)
      propertyMetadata - BasicFieldMetadata corresponding to the property that is being valid
      propertyName - 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)