jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1132993 - /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/acl/EntryCollector.java
Date Tue, 07 Jun 2011 13:14:25 GMT
Author: angela
Date: Tue Jun  7 13:14:24 2011
New Revision: 1132993

URL: http://svn.apache.org/viewvc?rev=1132993&view=rev
Log:
minor improvement: change log level to warn and test for node existence before calling Session.getNodeByIdentifier

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/acl/EntryCollector.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/acl/EntryCollector.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/acl/EntryCollector.java?rev=1132993&r1=1132992&r2=1132993&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/acl/EntryCollector.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/acl/EntryCollector.java
Tue Jun  7 13:14:24 2011
@@ -283,7 +283,7 @@ public class EntryCollector extends Acce
                     }
                 } catch (RepositoryException e) {
                     // should not get here
-                    log.error("Failed to process ACL event: " + event, e);
+                    log.warn("Failed to process ACL event: " + event, e);
                 }
             }
         }
@@ -299,21 +299,25 @@ public class EntryCollector extends Acce
         }
 
         private void siftNodeAdded(String identifier) throws RepositoryException {
-            NodeImpl n = (NodeImpl) session.getNodeByIdentifier(identifier);
-            if (n.isNodeType(EntryCollector.NT_REP_ACL)) {
-                // a new ACL was added -> use the added node to update
-                // the cache.
-                addModification(
-                        accessControlledIdFromAclNode(n),
-                        AccessControlObserver.POLICY_ADDED);
-            } else if (n.isNodeType(EntryCollector.NT_REP_ACE)) {
-                // a new ACE was added -> use the parent node (acl)
-                // to update the cache.
-                addModification(
-                        accessControlledIdFromAceNode(n),
-                        AccessControlObserver.POLICY_MODIFIED);
-            } /* else: some other node added below an access controlled
-               parent node -> not interested. */
+            if (session.nodeExists(getIdentifierPath(identifier))) {
+                NodeImpl n = (NodeImpl) session.getNodeByIdentifier(identifier);
+                if (n.isNodeType(EntryCollector.NT_REP_ACL)) {
+                    // a new ACL was added -> use the added node to update
+                    // the cache.
+                    addModification(
+                            accessControlledIdFromAclNode(n),
+                            AccessControlObserver.POLICY_ADDED);
+                } else if (n.isNodeType(EntryCollector.NT_REP_ACE)) {
+                    // a new ACE was added -> use the parent node (acl)
+                    // to update the cache.
+                    addModification(
+                            accessControlledIdFromAceNode(n),
+                            AccessControlObserver.POLICY_MODIFIED);
+                } /* else: some other node added below an access controlled
+                     parent node -> not interested. */
+            } else {
+                log.debug("Cannot process NODE_ADDED event. Node {} doesn't exist (anymore).",
identifier);
+            }
         }
 
         private void siftNodeRemoved(String path) throws RepositoryException {
@@ -343,15 +347,19 @@ public class EntryCollector extends Acce
         }
 
         private void siftPropertyChanged(String identifier) throws RepositoryException {
-            // test if the changed prop belongs to an ACE
-            NodeImpl parent = (NodeImpl) session.getNodeByIdentifier(identifier);
-            if (parent.isNodeType(EntryCollector.NT_REP_ACE)) {
-                addModification(
-                        accessControlledIdFromAceNode(parent),
-                        AccessControlObserver.POLICY_MODIFIED);
-            } /* some other property below an access controlled node
+            if (session.nodeExists(getIdentifierPath(identifier))) {
+                // test if the changed prop belongs to an ACE
+                NodeImpl parent = (NodeImpl) session.getNodeByIdentifier(identifier);
+                if (parent.isNodeType(EntryCollector.NT_REP_ACE)) {
+                    addModification(
+                            accessControlledIdFromAceNode(parent),
+                            AccessControlObserver.POLICY_MODIFIED);
+                } /* some other property below an access controlled node
                  changed -> not interested. (NOTE: rep:ACL doesn't
                  define any properties. */
+            } else {
+                log.debug("Cannot process PROPERTY_CHANGED event. Node {} doesn't exist (anymore).",
identifier);
+            }
         }
 
         private NodeId accessControlledIdFromAclNode(Node aclNode) throws RepositoryException
{
@@ -369,5 +377,11 @@ public class EntryCollector extends Acce
             }
             modMap.put(accessControllNodeId, modType);
         }
+
+        private static String getIdentifierPath(String identifier) {
+            StringBuilder sb = new StringBuilder();
+            sb.append('[').append(identifier).append(']');
+            return sb.toString();
+        }
     }
 }
\ No newline at end of file



Mime
View raw message