public static final void validateSearchCriteria ( SearchCriteriaBean criteria ) throws InvalidSearchCriteriaException { if ( criteria . getPaging ( ) != null ) { if ( criteria . getPaging ( ) . getPage ( ) < 1 ) { throw new InvalidSearchCriteriaException ( Messages . i18n . format ( "SearchCriteriaUtil.MissingPage" ) ) ; //$NON-NLS-1$ } if ( criteria . getPaging ( ) . getPageSize ( ) < 1 ) { throw new InvalidSearchCriteriaException ( Messages . i18n . format ( "SearchCriteriaUtil.MissingPageSize" ) ) ; //$NON-NLS-1$ } } int count = 1 ; for ( SearchCriteriaFilterBean filter : criteria . getFilters ( ) ) { if ( filter . getName ( ) == null || filter . getName ( ) . trim ( ) . length ( ) == 0 ) { throw new InvalidSearchCriteriaException ( Messages . i18n . format ( "SearchCriteriaUtil.MissingSearchFilterName" , count ) ) ; //$NON-NLS-1$ } if ( filter . getValue ( ) == null || filter . getValue ( ) . trim ( ) . length ( ) == 0 ) { throw new InvalidSearchCriteriaException ( Messages . i18n . format ( "SearchCriteriaUtil.MissingSearchFilterValue" , count ) ) ; //$NON-NLS-1$ } if ( filter . getOperator ( ) == null || ! validOperators . contains ( filter . getOperator ( ) ) ) { throw new InvalidSearchCriteriaException ( Messages . i18n . format ( "SearchCriteriaUtil.MissingSearchFilterOperator" , count ) ) ; //$NON-NLS-1$ } count ++ ; } if ( criteria . getOrderBy ( ) != null && ( criteria . getOrderBy ( ) . getName ( ) == null || criteria . getOrderBy ( ) . getName ( ) . trim ( ) . length ( ) == 0 ) ) { throw new InvalidSearchCriteriaException ( Messages . i18n . format ( "SearchCriteriaUtil.MissingOrderByName" ) ) ; //$NON-NLS-1$ } }
Validates that the search criteria bean is complete and makes sense .