/** * Sets the modifiable list of root groups. This method clears the current * list and adds all entries in the parameter list. * * @param rootGroups * A list of root groups. */ public void setRootGroups(List<Group> rootGroups) { synchronized (getRootGroups()) { if (rootGroups != getRootGroups()) { getRootGroups().clear(); if (rootGroups != null) { getRootGroups().addAll(rootGroups); } } } }
/** * Finds the set of groups where a given user is a member. * * @param user * The member user. * @param inheritOnly * Indicates if only the ancestors groups that have their * "inheritRoles" property enabled should be added. * @return The set of groups. */ public Set<Group> findGroups(User user, boolean inheritOnly) { Set<Group> result = new HashSet<Group>(); List<Group> stack; // Recursively find user groups for (Group group : getRootGroups()) { stack = new ArrayList<Group>(); addGroups(user, result, group, stack, inheritOnly); } return result; }