public List<User> searchUsers(final UsersSearchCriteria searchCriteria, final int firstResult, final int maxResults, final String sortProperty, final boolean ascending){
final String searchTerm = searchCriteria != null? searchCriteria.getSearchTerm() : null;
final List<User> users = userManager.search(searchTerm);
if(StringUtils.isNotEmpty(sortProperty)) {
log.debug(String.format("Sorting usersList by property='%s', ascending='%s'", sortProperty, ascending));
Collections.sort(users, new PropertyComparator(sortProperty, true, ascending));
}
final int fromIndex = Math.min(firstResult, users.size());
final int toIndex = Math.min(fromIndex + maxResults, users.size());
log.debug(String.format("searchUsers(%d,%d) %d-%d [%d]", firstResult, maxResults, fromIndex, toIndex, users.size()));
return users.subList(fromIndex, toIndex);