Class NamedQueryDataValidator

java.lang.Object
de.hybris.platform.cmsfacades.namedquery.validator.NamedQueryDataValidator
All Implemented Interfaces:
org.springframework.validation.Validator

public class NamedQueryDataValidator extends Object implements org.springframework.validation.Validator
Validates DTO for executing named query.

Rules:

  • namedQuery not null
  • namedQuery exists
  • pageSize > 0, if provided
  • pageSize <= ${cmswebservices.media.namedquery.max.pagesize}, if provided
  • currentPage >= 0, if provided
  • sort formatting, if sort provided
  • sort parameter names, if sort provided
  • sort directions, if sort provided
  • params not null
  • params formatting
  • params parameter names

  • Field Details

  • Constructor Details

    • NamedQueryDataValidator

      public NamedQueryDataValidator()
  • Method Details

    • supports

      public boolean supports(Class<?> clazz)
      Specified by:
      supports in interface org.springframework.validation.Validator
    • validate

      public void validate(Object obj, org.springframework.validation.Errors errors)
      Specified by:
      validate in interface org.springframework.validation.Validator
    • getValidParameterNames

      protected Set<String> getValidParameterNames(Class<?> queryType)
      Get valid parameters names as the attributes of the named query's query type.
      Parameters:
      queryType - - the class representing the type of query
      Returns:
      list of valid params
    • validateSortPair

      protected void validateSortPair(String sortPair, Set<String> validParamNames, org.springframework.validation.Errors errors)
      Validate the parameter name and sort direction of a single sortPair.

      Expected Format: {paramName}:{sortDirection}
      Example: code:ASC

      Parameters:
      sortPair -
      errors -
    • validateParamPair

      protected void validateParamPair(String paramPair, Set<String> validParamNames, org.springframework.validation.Errors errors)
      Validate the parameter name of a single paramPair.

      Expected Format: {paramName}:{paramValue}
      Example: code:banner

      Parameters:
      paramPair -
      validParamNames -
      errors -
    • validSortDirection

      protected boolean validSortDirection(String direction)
      Check whether the sort direction provided matches a valid enum value from SortDirection.
      Parameters:
      direction -
      Returns:
      true if the sort direction is valid, false otherwise
    • getMaxPageSize

      protected int getMaxPageSize()
    • setMaxPageSize

      public void setMaxPageSize(int maxPageSize)
    • getNamedQueryExistsPredicate

      protected Predicate<String> getNamedQueryExistsPredicate()
    • setNamedQueryExistsPredicate

      public void setNamedQueryExistsPredicate(Predicate<String> namedQueryExistsPredicate)