[jboss-jira] [JBoss JIRA] Assigned: (JBPORTAL-1707) New UserModule/RoleModule finders
Boleslaw Dawidowicz (JIRA)
jira-events at lists.jboss.org
Wed Oct 3 04:51:03 EDT 2007
[ http://jira.jboss.com/jira/browse/JBPORTAL-1707?page=all ]
Boleslaw Dawidowicz reassigned JBPORTAL-1707:
---------------------------------------------
Assignee: Boleslaw Dawidowicz (was: Julien Viet)
> New UserModule/RoleModule finders
> ---------------------------------
>
> Key: JBPORTAL-1707
> URL: http://jira.jboss.com/jira/browse/JBPORTAL-1707
> Project: JBoss Portal
> Issue Type: Feature Request
> Security Level: Public(Everyone can see)
> Components: Portal Security
> Affects Versions: 2.6.1 Final
> Reporter: Andrew Oliver
> Assigned To: Boleslaw Dawidowicz
>
> While working with clients using the portal API some efficiency issues with regards to finders have become apparent:
> It is presently possible to find users having a role by calling MembershipModule.getUsers(role). However it is not possible to get a list of users with a set of roles, a list of users who do NOT have a role or set of roles. (there are ways in both HQL and LDAP to construct each type of query). I suggest something similar to hibernate conditions.
> MembershipModule.getUsers().addCondition(
> Condition.and(
> Condition.not(roleSet), Condition.with(roleSet)
> )
> )
> this would result in roughly:
> from Users where roles in (:roleSet) and roles not in (:roleSet2)
> and something like
> (& (|(role=roleName)(role=roleName) )
> (&(!role=roleName)(!role=roleName) )
> )
> in LDAP
> the attribute name can be based on the type. As it stands you have to do something like:
> try {
> Role roleApproved = rolemodule.findRoleByName("approved");
> Role roleUsers = rolemodule.findRoleByName("User");
> //todo create transient wrapper set.
> Set users = membership.getUsers(roleUsers);
> dirtyStinkyHackToGetAroundPortalAPIBugACO(users);
> System.err.println("Total number of users with User Role : " + users.size() );
> Set temp = new HashSet();
> temp = dirtyStinkyHackToGetAroundPortalAPIBugACO(users); //because the hibernate set doesn't have removeall
> users = temp;
> Set usersApproved = membership.getUsers(roleApproved);
> System.err.println("number of users with approved role: "+usersApproved.size());
> users.removeAll(usersApproved);
> System.err.println("Total number of users with User Role and NO approved role : " + users.size() );
> Map profiles = profiles(users);
> response.setRenderParameter("op", "new");
> request.getPortletSession().setAttribute("users", users);
> request.getPortletSession().setAttribute("profiles", profiles);
> } catch (IdentityException e) {
> //todo type this and catch it up higher to make a
> //smarter error message
> throw new RuntimeException(e);
> }
> private Map profiles(Set users) throws IdentityException {
> Iterator i = users.iterator();
> Map retval = new HashMap();
> while(i.hasNext()) {
> User user = (User) i.next();
> retval.put(user, profileModule.getProperties(user));
> }
> return retval;
> }
>
> private Set dirtyStinkyHackToGetAroundPortalAPIBugACO(Set users) {
> Iterator i = users.iterator();
> Set retval = new HashSet();
> while(i.hasNext()) {
> User u = (User)i.next();
> u.getUserName();
> retval.add(u);
> }
> return retval;
> }
> Just to get the list of users who DONT have the "approved" role. For our immediate needs:
> UserModule.getUsersWithout(role) would work...until next time.
> -Andy
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jboss-jira
mailing list