* @return the collection of groups that can be selected
*/
public static Groups buildSelectableGroups(RequestContext context) {
IdentityAdapter idAdapter = context.newIdentityAdapter();
IdentityConfiguration idConfig = context.getIdentityConfiguration();
Groups selectableGroups = null;
User user = context.getUser();
RoleSet roles = user.getAuthenticationStatus().getAuthenticatedRoles();
boolean bIsAdministrator = roles.hasRole("gptAdministrator");
try {
if (bIsAdministrator) {
User selectableUser = new User();
selectableUser.setDistinguishedName("*");
idAdapter.readUserGroups(selectableUser);
selectableGroups = selectableUser.getGroups();
} else {
selectableGroups = user.getGroups();
}
Groups mgmtGroups = idConfig.getMetadataManagementGroups();
if ((mgmtGroups != null) && (mgmtGroups.size() > 0)) {
for (Group mgmtGroup : mgmtGroups.values()) {
boolean bAdd = bIsAdministrator;
if ((selectableGroups != null)
&& selectableGroups.containsKey(mgmtGroup.getKey())) {