jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r783346 - in /jackrabbit/trunk/jackrabbit-core/src: main/java/org/apache/jackrabbit/core/security/user/ main/resources/org/apache/jackrabbit/core/nodetype/ test/java/org/apache/jackrabbit/api/security/user/
Date Wed, 10 Jun 2009 13:06:47 GMT
Author: angela
Date: Wed Jun 10 13:06:47 2009
New Revision: 783346

URL: http://svn.apache.org/viewvc?rev=783346&view=rev
Log:
JCR-2135: UserManagement: make membership a weakreferences

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/AuthorizableImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/GroupImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/nodetype/builtin_nodetypes.cnd
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/GroupTest.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/AuthorizableImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/AuthorizableImpl.java?rev=783346&r1=783345&r2=783346&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/AuthorizableImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/AuthorizableImpl.java
Wed Jun 10 13:06:47 2009
@@ -39,6 +39,7 @@
 import javax.jcr.PropertyIterator;
 import javax.jcr.RepositoryException;
 import javax.jcr.Value;
+import javax.jcr.ItemNotFoundException;
 import javax.jcr.nodetype.ConstraintViolationException;
 import javax.jcr.nodetype.PropertyDefinition;
 import java.security.Principal;
@@ -304,8 +305,7 @@
     boolean addToGroup(GroupImpl group) throws RepositoryException {
         try {
             Value[] values;
-            // TODO: replace by weak-refs
-            Value added = getSession().getValueFactory().createValue(group.getNode());
+            Value added = getSession().getValueFactory().createValue(group.getNode(), true);
             NodeImpl node = getNode();
             if (node.hasProperty(P_GROUPS)) {
                 Value[] old = node.getProperty(P_GROUPS).getValues();
@@ -364,10 +364,16 @@
         }
         Value[] refs = node.getProperty(P_GROUPS).getValues();
         for (int i = 0; i < refs.length; i++) {
-            NodeImpl groupNode = (NodeImpl) getSession().getNodeByUUID(refs[i].getString());
-            Group group = GroupImpl.create(groupNode, userManager);
-            if (groups.add(group) && includedIndirect) {
-                ((AuthorizableImpl) group).collectMembership(groups, true);
+            try {
+                NodeImpl groupNode = (NodeImpl) getSession().getNodeByUUID(refs[i].getString());
+                Group group = GroupImpl.create(groupNode, userManager);
+                if (groups.add(group) && includedIndirect) {
+                    ((AuthorizableImpl) group).collectMembership(groups, true);
+                }
+            } catch (ItemNotFoundException e) {
+                // groupNode doesn't exist any more
+                log.warn("Group node referenced by " + getID() + " doesn't exist -> Ignored
from membership list.");
+                // TODO: ev. clean up list of group memberships
             }
         }
     }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/GroupImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/GroupImpl.java?rev=783346&r1=783345&r2=783346&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/GroupImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/GroupImpl.java
Wed Jun 10 13:06:47 2009
@@ -168,8 +168,7 @@
      * @throws RepositoryException If an error occurs while collecting the members.
      */
     private Collection getMembers(boolean includeIndirect) throws RepositoryException {
-        // TODO: replace by weak-refs
-        PropertyIterator itr = getNode().getReferences();
+        PropertyIterator itr = getNode().getWeakReferences();
         Collection members = new HashSet((int) itr.getSize());
         while (itr.hasNext()) {
             NodeImpl n = (NodeImpl) itr.nextProperty().getParent();

Modified: jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/nodetype/builtin_nodetypes.cnd
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/nodetype/builtin_nodetypes.cnd?rev=783346&r1=783345&r2=783346&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/nodetype/builtin_nodetypes.cnd
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/nodetype/builtin_nodetypes.cnd
Wed Jun 10 13:06:47 2009
@@ -252,7 +252,7 @@
   + * (rep:AuthorizableFolder) = rep:AuthorizableFolder protected version
   - rep:principalName (string) protected mandatory
   - rep:referees (string) protected multiple
-  - rep:groups (reference) protected multiple < 'rep:Group'
+  - rep:groups (weakreference) protected multiple < 'rep:Group'
   - * (undefined)
   - * (undefined) multiple
 

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/GroupTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/GroupTest.java?rev=783346&r1=783345&r2=783346&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/GroupTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/GroupTest.java
Wed Jun 10 13:06:47 2009
@@ -279,14 +279,12 @@
     }
 
     /**
-     * TODO: uncomment once membership-relation is stored as weak ref.
      * Removing a GroupImpl must be possible even if there are still existing
      * members present.
      *
      * @throws RepositoryException
      * @throws NotExecutableException
      */
-    /*
     public void testRemoveGroupIfMemberExist() throws RepositoryException, NotExecutableException
{
         User auth = getTestUser(superuser);
         String newGroupId = null;
@@ -306,5 +304,4 @@
             }
         }
     }
-    */
 }
\ No newline at end of file



Mime
View raw message