continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From car...@apache.org
Subject svn commit: r440829 - in /maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/main/java/org/apache/maven/continuum/security/acegi: AcegiContinuum.java AclEventHandler.java
Date Wed, 06 Sep 2006 18:53:56 GMT
Author: carlos
Date: Wed Sep  6 11:53:55 2006
New Revision: 440829

URL: http://svn.apache.org/viewvc?view=rev&rev=440829
Log:
Add ACL deletion code

Modified:
    maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/main/java/org/apache/maven/continuum/security/acegi/AcegiContinuum.java
    maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/main/java/org/apache/maven/continuum/security/acegi/AclEventHandler.java

Modified: maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/main/java/org/apache/maven/continuum/security/acegi/AcegiContinuum.java
URL: http://svn.apache.org/viewvc/maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/main/java/org/apache/maven/continuum/security/acegi/AcegiContinuum.java?view=diff&rev=440829&r1=440828&r2=440829
==============================================================================
--- maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/main/java/org/apache/maven/continuum/security/acegi/AcegiContinuum.java
(original)
+++ maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/main/java/org/apache/maven/continuum/security/acegi/AcegiContinuum.java
Wed Sep  6 11:53:55 2006
@@ -1059,6 +1059,7 @@
         throws ContinuumException
     {
         getContinuum().removeProjectGroup( projectGroupId );
+        getAclEventHandler().afterDeleteProjectGroup( projectGroupId );
     }
 
 }

Modified: maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/main/java/org/apache/maven/continuum/security/acegi/AclEventHandler.java
URL: http://svn.apache.org/viewvc/maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/main/java/org/apache/maven/continuum/security/acegi/AclEventHandler.java?view=diff&rev=440829&r1=440828&r2=440829
==============================================================================
--- maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/main/java/org/apache/maven/continuum/security/acegi/AclEventHandler.java
(original)
+++ maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/main/java/org/apache/maven/continuum/security/acegi/AclEventHandler.java
Wed Sep  6 11:53:55 2006
@@ -52,6 +52,11 @@
         return aclDao;
     }
 
+    /**
+     * Create ACLs for new {@link ProjectGroup} and {@link Project}s
+     * 
+     * @param result
+     */
     public void afterAddProject( ContinuumProjectBuildingResult result )
     {
         List projectGroups = result.getProjectGroups();
@@ -70,6 +75,18 @@
     }
 
     /**
+     * Delete {@link ProjectGroup} ACLs
+     * 
+     * @TODO should this cascade delete all the children ACLs ?
+     * 
+     * @param projectGroupId
+     */
+    public void afterDeleteProjectGroup( int projectGroupId )
+    {
+        getAclDao().delete( createProjectGroupObjectIdentity( projectGroupId ) );
+    }
+
+    /**
      * Call this method when new {@link ProjectGroup}s are created.
      * 
      * @param projectGroups
@@ -93,8 +110,7 @@
     {
         User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
         SimpleAclEntry aclEntry = new SimpleAclEntry();
-        aclEntry.setAclObjectIdentity( new NamedEntityObjectIdentity( projectGroup.getClass().getName(),
Integer
-            .toString( projectGroup.getId() ) ) );
+        aclEntry.setAclObjectIdentity( createProjectGroupObjectIdentity( projectGroup.getId()
) );
         aclEntry.setRecipient( user.getUsername() );
         aclEntry.setAclObjectParentIdentity( AclInitializer.PARENT_PROJECT_GROUP_ACL_ID );
         aclEntry.addPermission( SimpleAclEntry.ADMINISTRATION );
@@ -124,13 +140,25 @@
      */
     private void createNewProjectACL( Project project, ProjectGroup projectGroup )
     {
-        NamedEntityObjectIdentity projectGroupIdentity = new NamedEntityObjectIdentity( ProjectGroup.class.getName(),
-                                                                                        Integer.toString(
projectGroup
-                                                                                        
   .getId() ) );
+        NamedEntityObjectIdentity projectGroupIdentity = createProjectGroupObjectIdentity(
projectGroup.getId() );
         SimpleAclEntry aclEntry = new SimpleAclEntry();
-        aclEntry.setAclObjectIdentity( new NamedEntityObjectIdentity( Project.class.getName(),
Integer
-            .toString( project.getId() ) ) );
+        aclEntry.setAclObjectIdentity( createProjectObjectIdentity( project.getId() ) );
         aclEntry.setAclObjectParentIdentity( projectGroupIdentity );
         getAclDao().create( aclEntry );
+    }
+
+    private NamedEntityObjectIdentity createProjectObjectIdentity( int projectId )
+    {
+        return createObjectIdentity( Project.class, projectId );
+    }
+
+    private NamedEntityObjectIdentity createProjectGroupObjectIdentity( int projectGroupId
)
+    {
+        return createObjectIdentity( ProjectGroup.class, projectGroupId );
+    }
+
+    private NamedEntityObjectIdentity createObjectIdentity( Class clazz, int id )
+    {
+        return new NamedEntityObjectIdentity( clazz.getName(), Integer.toString( id ) );
     }
 }



Mime
View raw message