public ListAccess<User> findUsersByGroupId(String groupId, UserStatus userStatus) throws Exception {
if (log.isTraceEnabled()) {
Tools.logMethodIn(log, LogLevel.TRACE, "findUsersByGroupId", new Object[] { groupId, userStatus });
}
UserQueryBuilder qb = service_.getIdentitySession().createUserQueryBuilder();
org.picketlink.idm.api.Group jbidGroup = null;
try {
jbidGroup = orgService.getJBIDMGroup(groupId);
} catch (Exception e) {
handleException("Cannot obtain group: " + groupId + "; ", e);
}
//As test case supposed, we should return empty list instead of Exception if group is not exist.
if(jbidGroup == null) {
return new ListAccess<User>() {
public User[] load(int index, int length) throws Exception {
if(index > 0 || length > 0) {
throw new IndexOutOfBoundsException("Try to access an empty list");
}
return new User[0];
}
public int getSize() throws Exception {
return 0;
}
};
}
qb.addRelatedGroup(jbidGroup);
switch (userStatus) {
case DISABLED:
if (filterDisabledUsersInQueries()) {
qb = addEnabledUserFilter(qb);