continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r661400 - in /continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action: ContinuumActionSupport.java ProjectGroupAction.java
Date Thu, 29 May 2008 16:56:44 GMT
Author: evenisse
Date: Thu May 29 09:56:44 2008
New Revision: 661400

URL: http://svn.apache.org/viewvc?rev=661400&view=rev
Log:
Fix some NPE with LDAP integration and improve a lot performance on the members page

Modified:
    continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ContinuumActionSupport.java
    continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectGroupAction.java

Modified: continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ContinuumActionSupport.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ContinuumActionSupport.java?rev=661400&r1=661399&r2=661400&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ContinuumActionSupport.java
(original)
+++ continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ContinuumActionSupport.java
Thu May 29 09:56:44 2008
@@ -505,7 +505,7 @@
      *
      * @return the security system
      */
-    private SecuritySystem getSecuritySystem()
+    protected SecuritySystem getSecuritySystem()
     {
         return securitySystem;
     }

Modified: continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectGroupAction.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectGroupAction.java?rev=661400&r1=661399&r2=661400&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectGroupAction.java
(original)
+++ continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectGroupAction.java
Thu May 29 09:56:44 2008
@@ -32,10 +32,10 @@
 import org.codehaus.plexus.redback.rbac.RbacManagerException;
 import org.codehaus.plexus.redback.rbac.RbacObjectNotFoundException;
 import org.codehaus.plexus.redback.rbac.Role;
+import org.codehaus.plexus.redback.rbac.UserAssignment;
 import org.codehaus.plexus.redback.role.RoleManager;
 import org.codehaus.plexus.redback.role.RoleManagerException;
 import org.codehaus.plexus.redback.users.User;
-import org.codehaus.plexus.redback.users.UserManager;
 import org.codehaus.plexus.util.StringUtils;
 
 import java.util.ArrayList;
@@ -67,11 +67,6 @@
     }
 
     /**
-     * @plexus.requirement role-hint="configurable"
-     */
-    private UserManager manager;
-
-    /**
      * @plexus.requirement role-hint="cached"
      */
     private RBACManager rbac;
@@ -533,25 +528,49 @@
 
     private void populateProjectGroupUsers( ProjectGroup group )
     {
-        List users;
+        List<User> users = new ArrayList<User>();
 
-        if ( StringUtils.isEmpty( filterKey ) )
+        try
         {
-            // REVIEW: for caching in the user manager
-            users = manager.getUsers( ascending );
+            List<Role> roles = rbac.getAllRoles();
+            List<String> roleNames = new ArrayList<String>();
+            for ( Role r : roles )
+            {
+                if ( r.getName().indexOf( projectGroup.getName() ) > -1 )
+                {
+                    roleNames.add( r.getName() );
+                }
+            }
+            List<UserAssignment> userAssignments = rbac.getUserAssignmentsForRoles(
roleNames );
+            for ( UserAssignment ua : userAssignments )
+            {
+                User u = getSecuritySystem().getUserManager().findUser( ua.getPrincipal()
);
+                if ( u != null )
+                {
+                    users.add( u );
+                }
+            }
         }
-        else
+        catch ( Exception e )
+        {
+            getLogger().error( "Can't get the users list", e );
+        }
+
+        if ( !StringUtils.isEmpty( filterKey ) )
         {
-            users = findUsers( filterProperty, filterKey, ascending );
+            users = findUsers( users, filterProperty, filterKey, ascending );
         }
 
         projectGroupUsers = new ArrayList();
 
-        for ( Iterator i = users.iterator(); i.hasNext(); )
+        if ( users == null )
         {
-            ProjectGroupUserBean pgUser = new ProjectGroupUserBean();
+            return;
+        }
 
-            User user = (User) i.next();
+        for ( User user : users )
+        {
+            ProjectGroupUserBean pgUser = new ProjectGroupUserBean();
 
             pgUser.setUser( user );
 
@@ -584,28 +603,47 @@
         }
     }
 
-    private List findUsers( String searchProperty, String searchKey, boolean orderAscending
)
+    private List<User> findUsers( List<User> users, String searchProperty, String
searchKey, boolean orderAscending )
     {
-        List users = null;
-
-        if ( "username".equals( searchProperty ) )
-        {
-            users = manager.findUsersByUsernameKey( searchKey, orderAscending );
-        }
-        else if ( "fullName".equals( getFilterProperty() ) )
+        List<User> userList = new ArrayList<User>();
+        for ( User user : users )
         {
-            users = manager.findUsersByFullNameKey( searchKey, orderAscending );
-        }
-        else if ( "email".equals( getFilterProperty() ) )
-        {
-            users = manager.findUsersByEmailKey( searchKey, orderAscending );
-        }
-        else
-        {
-            users = Collections.EMPTY_LIST;
+            if ( "username".equals( searchProperty ) )
+            {
+                String username = user.getUsername();
+                if ( username != null )
+                {
+                    if ( username.toLowerCase().indexOf( searchKey.toLowerCase() ) >=
0 )
+                    {
+                        userList.add( user );
+                    }
+                }
+            }
+            else if ( "fullName".equals( searchProperty ) )
+            {
+                String fullname = user.getFullName();
+                if ( fullname != null )
+                {
+                    if ( fullname.toLowerCase().indexOf( searchKey.toLowerCase() ) >=
0 )
+                    {
+                        userList.add( user );
+                    }
+                }
+            }
+            else if ( "email".equals( searchProperty ) )
+            {
+                String email = user.getEmail();
+                if ( email != null )
+                {
+                    if ( email.toLowerCase().indexOf( searchKey.toLowerCase() ) >= 0 )
+                    {
+                        userList.add( user );
+                    }
+                }
+            }
         }
 
-        return users;
+        return userList;
     }
 
     public int getProjectGroupId()



Mime
View raw message