continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r478759 - in /maven/continuum/trunk/continuum-webapp/src/main: java/org/apache/maven/continuum/web/action/ java/org/apache/maven/continuum/web/bean/ webapp/WEB-INF/jsp/
Date Fri, 24 Nov 2006 04:00:55 GMT
Author: brett
Date: Thu Nov 23 20:00:53 2006
New Revision: 478759

URL: http://svn.apache.org/viewvc?view=rev&rev=478759
Log:
[CONTINUUM-1010] Add ability to view list of users with permissions to a project group.
Submitted by: Lester Ecarma

Added:
    maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/bean/
    maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/bean/ProjectGroupUserBean.java
  (with props)
Modified:
    maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectGroupAction.java
    maven/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectGroupMembers.jsp

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=478759&r1=478758&r2=478759
==============================================================================
--- 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
Thu Nov 23 20:00:53 2006
@@ -16,8 +16,24 @@
  * limitations under the License.
  */
 
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
 import org.apache.maven.continuum.model.project.ProjectGroup;
+import org.apache.maven.continuum.web.bean.ProjectGroupUserBean;
 import org.apache.maven.continuum.ContinuumException;
+import org.codehaus.plexus.security.rbac.RBACManager;
+import org.codehaus.plexus.security.rbac.RbacManagerException;
+import org.codehaus.plexus.security.rbac.RbacObjectNotFoundException;
+import org.codehaus.plexus.security.rbac.Role;
+import org.codehaus.plexus.security.user.User;
+import org.codehaus.plexus.security.user.UserManager;
+import org.codehaus.plexus.util.StringUtils;
 
 /**
  * ProjectGroupAction:
@@ -32,11 +48,37 @@
 public class ProjectGroupAction
     extends ContinuumConfirmAction
 {
+    private final static Map FILTER_CRITERIA = new HashMap();
+    static
+    {
+        FILTER_CRITERIA.put( "username", "Username contains" );
+        FILTER_CRITERIA.put( "fullName", "Name contains" );
+        FILTER_CRITERIA.put( "email", "Email contains" );
+    }
+    
+    /**
+     * @plexus.requirement
+     */
+    private UserManager manager;
+
+    /**
+     * @plexus.requirement
+     */
+    private RBACManager rbac;
+
     private int projectGroupId;
 
     private ProjectGroup projectGroup;
 
     private boolean confirmed;
+    
+    private List projectGroupUsers;
+    
+    private String filterProperty;
+    
+    private String filterKey;
+    
+    private boolean ascending = true;
 
     public String summary()
         throws ContinuumException
@@ -49,7 +91,11 @@
     public String members()
         throws ContinuumException
     {
-        return summary();
+        projectGroup = getContinuum().getProjectGroup( projectGroupId );
+
+        populateProjectGroupUsers( projectGroup );
+        
+        return SUCCESS;
     }
 
     public String buildDefinitions()
@@ -88,7 +134,81 @@
         return SUCCESS;
     }
 
-
+    private void populateProjectGroupUsers( ProjectGroup group ) 
+    {
+        List users;
+        
+        if ( StringUtils.isEmpty( filterKey ) )
+        {
+            users = manager.getUsers( ascending );
+        }
+        else
+        {
+            users = findUsers( filterProperty, filterKey, ascending );
+        }
+        
+        projectGroupUsers = new ArrayList();
+        
+        for ( Iterator i = users.iterator(); i.hasNext(); )
+        {
+            ProjectGroupUserBean pgUser = new ProjectGroupUserBean();
+            
+            User user = (User) i.next();
+            
+            pgUser.setUser( user );
+            
+            pgUser.setProjectGroup( group );
+            
+            try
+            {
+                Collection effectiveRoles = rbac.getEffectivelyAssignedRoles( user.getUsername()
);
+                for ( Iterator j = effectiveRoles.iterator(); j.hasNext(); )
+                {
+                    Role role = (Role) j.next();
+                    if( role.getName().indexOf( projectGroup.getName() ) > -1 )
+                    {
+                        pgUser.setRoles( effectiveRoles );
+                        projectGroupUsers.add( pgUser );
+                        break;
+                    }
+                }
+                
+            }
+            catch ( RbacObjectNotFoundException e )
+            {
+                pgUser.setRoles( Collections.EMPTY_LIST );
+            }
+            catch ( RbacManagerException e )
+            {
+                pgUser.setRoles( Collections.EMPTY_LIST );
+            }
+        }
+    }
+    
+    private List findUsers( String searchProperty, String searchKey, boolean orderAscending
)
+    {
+        List users = null;
+            
+        if ( "username".equals( searchProperty ) )
+        {
+            users = manager.findUsersByUsernameKey( searchKey, orderAscending );
+        }
+        else if ( "fullName".equals( getFilterProperty() ) )
+        {
+            users = manager.findUsersByFullNameKey( searchKey, orderAscending );
+        }
+        else if ( "email".equals( getFilterProperty() ) )
+        {
+            users = manager.findUsersByEmailKey( searchKey, orderAscending );
+        }
+        else
+        {
+            users = Collections.EMPTY_LIST;
+        }
+        
+        return users;
+    }
+    
     public int getProjectGroupId()
     {
         return projectGroupId;
@@ -118,4 +238,45 @@
     {
         this.confirmed = confirmed;
     }
+
+    public List getProjectGroupUsers()
+    {
+        return projectGroupUsers;
+    }
+
+    public boolean isAscending()
+    {
+        return ascending;
+    }
+
+    public void setAscending( boolean ascending )
+    {
+        this.ascending = ascending;
+    }
+
+    public String getFilterKey()
+    {
+        return filterKey;
+    }
+
+    public void setFilterKey( String filterKey )
+    {
+        this.filterKey = filterKey;
+    }
+
+    public String getFilterProperty()
+    {
+        return filterProperty;
+    }
+
+    public void setFilterProperty( String filterProperty )
+    {
+        this.filterProperty = filterProperty;
+    }
+
+    public Map getCriteria()
+    {
+        return FILTER_CRITERIA;
+    }
+    
 }

Added: 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=auto&rev=478759
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/bean/ProjectGroupUserBean.java
(added)
+++ maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/bean/ProjectGroupUserBean.java
Thu Nov 23 20:00:53 2006
@@ -0,0 +1,118 @@
+package org.apache.maven.continuum.web.bean;
+
+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;
+
+public class ProjectGroupUserBean
+{
+    public static final String ROLE_ADMINISTRATOR = "Group Project Administrator";
+    
+    public static final String ROLE_DEVELOPER = "Project Developer";
+    
+    public static final String ROLE_USER = "Project User";
+    
+    private User user;
+    
+    private ProjectGroup projectGroup;
+    
+    private Collection roles;
+    
+    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;
+    }
+
+    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;
+    }
+
+    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;
+    }
+
+    public ProjectGroup getProjectGroup()
+    {
+        return projectGroup;
+    }
+
+    public void setProjectGroup( ProjectGroup projectGroup )
+    {
+        this.projectGroup = projectGroup;
+    }
+
+    public void addRole( String role )
+    {
+        roles.add( role );
+    }
+    
+    public Collection getRoles()
+    {
+        return roles;
+    }
+
+    public void setRoles( Collection roles )
+    {
+        this.roles = roles;
+    }
+
+    public User getUser()
+    {
+        return user;
+    }
+
+    public void setUser( User user )
+    {
+        this.user = user;
+    }
+    
+    public String getUsername()
+    {
+        return user.getUsername();
+    }
+    
+    public String getUserFullName()
+    {
+        return user.getFullName();
+    }
+    
+    public String toString()
+    {
+        return user.getUsername() + ": " + roles + ": "+(isAdministrator()?"A":"-") + (isDeveloper()?"D":"-")
+ (isUser()?"U":"-"); 
+    }
+
+}

Propchange: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/bean/ProjectGroupUserBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: maven/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectGroupMembers.jsp
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectGroupMembers.jsp?view=diff&rev=478759&r1=478758&r2=478759
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectGroupMembers.jsp
(original)
+++ maven/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectGroupMembers.jsp
Thu Nov 23 20:00:53 2006
@@ -87,6 +87,90 @@
         </ec:column>
       </ec:row>
     </ec:table>
+    
+  <pss:ifAuthorized permission="continuum-manage-users">
+  <h3>Users</h3>
+    
+  <ww:form action="projectGroupMembers" theme="xhtml" method="post">
+    <ww:hidden name="ascending" />
+    <ww:hidden name="projectGroupId" />
+    <tr>
+      <td nowrap="true">
+        <table cellpadding="0" cellspacing="0">               
+          <ww:select label="User search"
+               list="criteria"
+               name="filterProperty"
+               value="filterProperty" />
+        </table>
+      </td>               
+      <td>
+        <table cellpadding="0" cellspacing="0">
+          <ww:textfield name="filterKey" />
+        </table>
+      </td>  
+      <td colspan="2" align="right">
+        <table cellpadding="0" cellspacing="0">
+          <ww:submit value="Search"/>
+        </table>
+      </td>
+    </tr>             
+  </ww:form>
+
+  <hr/>
+  
+  <table class="securityTable" border="1" cellspacing="0" cellpadding="2" width="80%">
+    <thead>
+      <tr>
+        <th nowrap="true">
+          <ww:form id="sortlist" name="sortlist" action="projectGroupMembers" theme="xhtml"
method="post">
+            <ww:if test="${ascending}">
+              <ww:a href="javascript: sortlist.submit()"><img src="<ww:url value='/images/icon_sortdown.gif'/>"
title="<ww:text name='Sort descending'/>" border="0"></ww:a> Username
+            </ww:if>
+            <ww:else>
+              <ww:a href="javascript: sortlist.submit()"><img src="<ww:url value='/images/icon_sortup.gif'/>"
title="<ww:text name='Sort ascending'/>" border="0"></ww:a> Username
+            </ww:else>
+            <ww:hidden name="ascending" value="${!ascending}"/>
+            <ww:hidden name="projectGroupId" />
+            <ww:hidden name="filterProperty" />
+            <ww:hidden name="filterKey" />
+          </ww:form>
+        </th>   
+        <th>Full Name</th>
+        <th>Administrator</th>
+        <th>Developer</th>
+        <th>User</th>
+      </tr>
+    </thead>
+    <tbody>
+      <ww:iterator value="projectGroupUsers">
+        <tr>
+          <td>
+            <ww:property value="username"/>
+          </td>
+          <td>
+            <ww:property value="userFullName"/>
+          </td>
+          <td>
+            <ww:if test="${administrator}">
+              <img src="<ww:url value='/images/icon_success_sml.gif'/>" border="0">
+            </ww:if>
+          </td>
+          <td>
+            <ww:if test="${developer}">
+              <img src="<ww:url value='/images/icon_success_sml.gif'/>" border="0">
+            </ww:if>
+          </td>
+          <td>
+            <ww:if test="${user}">
+              <img src="<ww:url value='/images/icon_success_sml.gif'/>" border="0">
+            </ww:if>
+          </td>
+        </tr>
+      </ww:iterator>
+    </tbody>
+  </table>
+  </pss:ifAuthorized>
+  
   </div>
   </body>
 </ww:i18n>



Mime
View raw message