continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmcconn...@apache.org
Subject svn commit: r508551 - in /maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web: action/ProjectGroupAction.java bean/ProjectGroupUserBean.java
Date Fri, 16 Feb 2007 19:57:35 GMT
Author: jmcconnell
Date: Fri Feb 16 11:57:34 2007
New Revision: 508551

URL: http://svn.apache.org/viewvc?view=rev&rev=508551
Log:
sped up the pg user bean a little bit and verified the use of the correct cache in the members
page

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

Modified: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectGroupAction.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectGroupAction.java?view=diff&rev=508551&r1=508550&r2=508551
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectGroupAction.java
(original)
+++ maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectGroupAction.java
Fri Feb 16 11:57:34 2007
@@ -375,6 +375,7 @@
             try
             {
                 Collection effectiveRoles = rbac.getEffectivelyAssignedRoles( user.getUsername()
);
+
                 for ( Iterator j = effectiveRoles.iterator(); j.hasNext(); )
                 {
                     Role role = (Role) j.next();
@@ -385,7 +386,6 @@
                         break;
                     }
                 }
-
             }
             catch ( RbacObjectNotFoundException e )
             {

Modified: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/bean/ProjectGroupUserBean.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/bean/ProjectGroupUserBean.java?view=diff&rev=508551&r1=508550&r2=508551
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/bean/ProjectGroupUserBean.java
(original)
+++ maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/bean/ProjectGroupUserBean.java
Fri Feb 16 11:57:34 2007
@@ -19,12 +19,12 @@
  * under the License.
  */
 
-import java.util.Collection;
-import java.util.Iterator;
-
 import org.apache.maven.continuum.model.project.ProjectGroup;
-import org.codehaus.plexus.security.rbac.Role;
 import org.codehaus.plexus.security.user.User;
+import org.codehaus.plexus.security.rbac.Role;
+
+import java.util.Collection;
+import java.util.Iterator;
 
 public class ProjectGroupUserBean
 {
@@ -39,49 +39,29 @@
     private ProjectGroup projectGroup;
     
     private Collection roles;
+
+    /*
+     * these booleans should be set on the addition of roles to this bean, see setRoles and
addRole 
+     */
+    boolean isAdministrator = false;
+
+    boolean isDeveloper = false;
+
+    boolean isUser = false;
     
     public boolean isAdministrator()
     {
-        for ( Iterator i = roles.iterator(); i.hasNext(); )
-        {
-            Role role = (Role) i.next();
-            if ( role.getName().indexOf( ROLE_ADMINISTRATOR ) > -1 )
-            {
-                return true;
-            }
-        }
-        
-        return false;
+       return isAdministrator;
     }
 
     public boolean isDeveloper()
     {
-        for ( Iterator i = roles.iterator(); i.hasNext(); )
-        {
-            Role role = (Role) i.next();
-            if ( role.getName().indexOf( projectGroup.getName() ) > -1 && 
-                 role.getName().indexOf( ROLE_DEVELOPER ) > -1 )
-            {
-                return true;
-            }
-        }
-        
-        return false;
+       return isDeveloper;
     }
 
     public boolean isUser()
     {
-        for ( Iterator i = roles.iterator(); i.hasNext(); )
-        {
-            Role role = (Role) i.next();
-            if ( role.getName().indexOf( projectGroup.getName() ) > -1 && 
-                 role.getName().indexOf( ROLE_USER ) > -1 )
-            {
-                return true;
-            }
-        }
-        
-        return false;
+       return isUser;
     }
 
     public ProjectGroup getProjectGroup()
@@ -97,6 +77,21 @@
     public void addRole( String role )
     {
         roles.add( role );
+
+        if ( role.indexOf( ROLE_ADMINISTRATOR ) != -1 )
+        {
+            isAdministrator = true;
+        }
+
+        if ( role.indexOf( ROLE_DEVELOPER ) != -1 )
+        {
+            isDeveloper = true;
+        }
+
+        if ( role.indexOf( ROLE_USER ) != -1 )
+        {
+            isUser = true;
+        }        
     }
     
     public Collection getRoles()
@@ -107,6 +102,26 @@
     public void setRoles( Collection roles )
     {
         this.roles = roles;
+
+        for ( Iterator i = roles.iterator(); i.hasNext(); )
+        {
+            Role role = (Role)i.next();
+
+            if ( role.getName().indexOf( ROLE_ADMINISTRATOR ) != -1 )
+            {
+                isAdministrator = true;
+            }
+
+            if ( role.getName().indexOf( ROLE_DEVELOPER ) != -1 )
+            {
+                isDeveloper = true;
+            }
+
+            if ( role.getName().indexOf( ROLE_USER ) != -1 )
+            {
+                isUser = true;
+            }
+        }
     }
 
     public User getUser()



Mime
View raw message