jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r344339 - in /incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core: PathMap.java lock/LockManagerImpl.java observation/EventStateCollection.java
Date Tue, 15 Nov 2005 09:56:19 GMT
Author: stefan
Date: Tue Nov 15 01:56:14 2005
New Revision: 344339

URL: http://svn.apache.org/viewcvs?rev=344339&view=rev
Log:
JCR-230 persistent locks persist even after removing the locked node

Modified:
    incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/PathMap.java
    incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java
    incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/EventStateCollection.java

Modified: incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/PathMap.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/PathMap.java?rev=344339&r1=344338&r2=344339&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/PathMap.java
(original)
+++ incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/PathMap.java
Tue Nov 15 01:56:14 2005
@@ -193,7 +193,7 @@
                     for (int i = index; i < list.size(); i++) {
                         Element element = (Element) list.get(i);
                         if (element != null) {
-                            element.index++;
+                            element.index = element.getNormalizedIndex() + 1;
                         }
                     }
                     list.add(index, null);

Modified: incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java?rev=344339&r1=344338&r2=344339&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java
(original)
+++ incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java
Tue Nov 15 01:56:14 2005
@@ -83,7 +83,7 @@
     private final Object contentMonitor = new Object();
 
     /**
-     * Name space resolver
+     * Namespace resolver
      */
     private final NamespaceResolver nsResolver;
 
@@ -119,13 +119,7 @@
      * Close this lock manager. Writes back all changes.
      */
     public void close() {
-        try {
-            save();
-        } catch (IOException e) {
-            log.warn("I/O error while saving locks to '"
-                    + locksFile.getPath() + "': " + e.getMessage());
-            log.debug("Root cause: ", e);
-        }
+        save();
     }
 
     /**
@@ -180,7 +174,7 @@
     /**
      * Write locks to locks file
      */
-    private void save() throws IOException {
+    private void save() {
         final ArrayList list = new ArrayList();
 
         lockMap.traverse(new PathMap.ElementVisitor() {
@@ -202,6 +196,10 @@
                 writer.write(info.lockToken.toString());
                 writer.newLine();
             }
+        } catch (IOException e) {
+            log.warn("I/O error while saving locks to '"
+                    + locksFile.getPath() + "': " + e.getMessage());
+            log.debug("Root cause: ", e);
         } finally {
             if (writer != null) {
                 try {
@@ -257,6 +255,9 @@
                 session.addLockToken(info.lockToken.toString(), false);
                 lockMap.put(path, info);
                 lock = new LockImpl(info, node);
+
+                // persist lockMap
+                save();
             }
 
             // add properties to content
@@ -300,6 +301,9 @@
 
                     // set live flag to false
                     info.setLive(false);
+
+                    // persist lockMap
+                    save();
                 }
 
                 // remove properties in content
@@ -316,7 +320,7 @@
 
     }
 
-    //-----------------------------------------------------------< LockManager >
+    //----------------------------------------------------------< LockManager >
 
     /**
      * {@inheritDoc}

Modified: incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/EventStateCollection.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/EventStateCollection.java?rev=344339&r1=344338&r2=344339&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/EventStateCollection.java
(original)
+++ incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/EventStateCollection.java
Tue Nov 15 01:56:14 2005
@@ -109,6 +109,17 @@
                 new ChangeLogBasedHierarchyMgr(rootNodeUUID, provider, changes,
                         session.getNamespaceResolver());
 
+        /**
+         * Important:
+         * Do NOT change the sequence of events generated unless there's
+         * a very good reason for it! Some internal SynchronousEventListener
+         * implementations depend on the order of the events fired.
+         * LockManagerImpl for example expects that for any given path a
+         * childNodeRemoved event is fired before a childNodeAdded event.  
+         */
+
+        // 1. modified items
+
         for (Iterator it = changes.modifiedStates(); it.hasNext();) {
             ItemState state = (ItemState) it.next();
             if (state.isNode()) {
@@ -289,6 +300,48 @@
                         session));
             }
         }
+
+        // 2. removed items
+
+        for (Iterator it = changes.deletedStates(); it.hasNext();) {
+            ItemState state = (ItemState) it.next();
+            if (state.isNode()) {
+                // node deleted
+                NodeState n = (NodeState) state;
+                NodeState parent = (NodeState) provider.getItemState(new NodeId(n.getParentUUID()));
+                NodeTypeImpl nodeType = getNodeType(parent, session);
+                Set mixins = parent.getMixinTypeNames();
+                Path path = getZombiePath(state.getId(), hmgr);
+                events.add(EventState.childNodeRemoved(n.getParentUUID(),
+                        getParent(path),
+                        n.getUUID(),
+                        path.getNameElement(),
+                        nodeType,
+                        mixins,
+                        session));
+            } else {
+                // property removed
+                // only create an event if node still exists
+                try {
+                    NodeState n = (NodeState) changes.get(new NodeId(state.getParentUUID()));
+                    // node state exists -> only property removed
+                    NodeTypeImpl nodeType = getNodeType(n, session);
+                    Set mixins = n.getMixinTypeNames();
+                    Path path = getZombiePath(state.getId(), hmgr);
+                    events.add(EventState.propertyRemoved(state.getParentUUID(),
+                            getParent(path),
+                            path.getNameElement(),
+                            nodeType,
+                            mixins,
+                            session));
+                } catch (NoSuchItemStateException e) {
+                    // node removed as well -> do not create an event
+                }
+            }
+        }
+
+        // 3. added items
+
         for (Iterator it = changes.addedStates(); it.hasNext();) {
             ItemState state = (ItemState) it.next();
             if (state.isNode()) {
@@ -324,42 +377,6 @@
                         nodeType,
                         mixins,
                         session));
-            }
-        }
-        for (Iterator it = changes.deletedStates(); it.hasNext();) {
-            ItemState state = (ItemState) it.next();
-            if (state.isNode()) {
-                // node deleted
-                NodeState n = (NodeState) state;
-                NodeState parent = (NodeState) provider.getItemState(new NodeId(n.getParentUUID()));
-                NodeTypeImpl nodeType = getNodeType(parent, session);
-                Set mixins = parent.getMixinTypeNames();
-                Path path = getZombiePath(state.getId(), hmgr);
-                events.add(EventState.childNodeRemoved(n.getParentUUID(),
-                        getParent(path),
-                        n.getUUID(),
-                        path.getNameElement(),
-                        nodeType,
-                        mixins,
-                        session));
-            } else {
-                // property removed
-                // only create an event if node still exists
-                try {
-                    NodeState n = (NodeState) changes.get(new NodeId(state.getParentUUID()));
-                    // node state exists -> only property removed
-                    NodeTypeImpl nodeType = getNodeType(n, session);
-                    Set mixins = n.getMixinTypeNames();
-                    Path path = getZombiePath(state.getId(), hmgr);
-                    events.add(EventState.propertyRemoved(state.getParentUUID(),
-                            getParent(path),
-                            path.getNameElement(),
-                            nodeType,
-                            mixins,
-                            session));
-                } catch (NoSuchItemStateException e) {
-                    // node removed as well -> do not create an event
-                }
             }
         }
     }



Mime
View raw message