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 Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected intgetValidParameterNames(Class<?> queryType) Get valid parameters names as the attributes of the named query's query type.voidsetMaxPageSize(int maxPageSize) voidsetNamedQueryExistsPredicate(Predicate<String> namedQueryExistsPredicate) booleanvoidprotected voidvalidateParamPair(String paramPair, Set<String> validParamNames, org.springframework.validation.Errors errors) Validate the parameter name of a single paramPair.protected voidvalidateSortPair(String sortPair, Set<String> validParamNames, org.springframework.validation.Errors errors) Validate the parameter name and sort direction of a single sortPair.protected booleanvalidSortDirection(String direction) Check whether the sort direction provided matches a valid enum value fromSortDirection.
-
Field Details
-
PARAMETER_LENGTH
public static final int PARAMETER_LENGTH- See Also:
-
-
Constructor Details
-
NamedQueryDataValidator
public NamedQueryDataValidator()
-
-
Method Details
-
supports
- Specified by:
supportsin interfaceorg.springframework.validation.Validator
-
validate
- Specified by:
validatein interfaceorg.springframework.validation.Validator
-
getValidParameterNames
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
Check whether the sort direction provided matches a valid enum value fromSortDirection.- Parameters:
direction-- Returns:
trueif the sort direction is valid,falseotherwise
-
getMaxPageSize
protected int getMaxPageSize() -
setMaxPageSize
public void setMaxPageSize(int maxPageSize) -
getNamedQueryExistsPredicate
-
setNamedQueryExistsPredicate
-