if (fullResults != null) {
// If we already have fullResults (all pages) we can simply sublist them
roles = fullResults.subList(index, index + length);
} else {
// Decide if use paginated query or skip pagination and obtain full results
IdentitySearchCriteria crit = usePaginatedQuery ? new IdentitySearchCriteriaImpl().page(index, length) : new IdentitySearchCriteriaImpl().page(0, size);
crit.sort(SortOrder.ASCENDING);
if (group != null) {
roles = new LinkedList<Role>(getIDMService().getIdentitySession().getRoleManager().findRoles(group, null, crit));
} else if (user != null) {
roles = new LinkedList<Role>(getIDMService().getIdentitySession().getRoleManager().findRoles(user, null, crit));