String role = it.next();
// recover groups
Enumeration<Group> groups = r.getGroupsAssignedTo(new Role(role));
Set<Group> groupsToRole = new HashSet<Group>();
for (; groups.hasMoreElements();) {
Group gp = groups.nextElement();
groupsToRole.add(new Group(gp.getName()));
addRoleToPrincipal(gp, role);
}
this.roleToGroup.put(role, groupsToRole);
// recover principles
Enumeration<Principal> users = r.getUsersAssignedTo(new Role(role));
Set<Principal> usersToRole = new HashSet<Principal>();
for (; users.hasMoreElements();) {
PrincipalImpl gp = (PrincipalImpl) users.nextElement();
usersToRole.add(new PrincipalImpl(gp.getName()));
addRoleToPrincipal(gp, role);
}
this.roleToPrincipal.put(role, usersToRole);
}
}