jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dpfis...@apache.org
Subject svn commit: r161276 - incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
Date Thu, 14 Apr 2005 13:24:30 GMT
Author: dpfister
Date: Thu Apr 14 06:24:30 2005
New Revision: 161276

URL: http://svn.apache.org/viewcvs?view=rev&rev=161276
Log:
JCR-108
- Reload shared states from persistent storage, if PersistenceManager#store operation fails

Modified:
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java?view=diff&r1=161275&r2=161276
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
Thu Apr 14 06:24:30 2005
@@ -390,6 +390,21 @@
     }
 
     /**
+     * Load item state from persistent storage.
+     * @param id item id
+     * @return item state
+     */
+    private ItemState loadItemState(ItemId id)
+            throws NoSuchItemStateException, ItemStateException {
+
+        if (id.denotesNode()) {
+            return persistMgr.load((NodeId) id);
+        } else {
+            return persistMgr.load((PropertyId) id);
+        }
+    }
+
+    /**
      * Store modifications registered in a <code>ChangeLog</code>. The items
      * contained in the <tt>ChangeLog</tt> are not states returned by this
      * item state manager but rather must be reconnected to items provided
@@ -493,11 +508,36 @@
         } finally {
 
             /**
-             * If some store operation was unsuccessful, we have to restore
-             * the original state of all items in the local change log.
+             * If some store operation was unsuccessful, we have to reload
+             * the state of modified and deleted items from persistent
+             * storage.
              */
             if (!succeeded) {
                 local.disconnect();
+
+                iter = shared.modifiedStates();
+                while (iter.hasNext()) {
+                    ItemState state = (ItemState) iter.next();
+                    try {
+                        state.copy(loadItemState(state.getId()));
+                    } catch (ItemStateException e) {
+                        state.discard();
+                    }
+                }
+                iter = shared.deletedStates();
+                while (iter.hasNext()) {
+                    ItemState state = (ItemState) iter.next();
+                    try {
+                        state.copy(loadItemState(state.getId()));
+                    } catch (ItemStateException e) {
+                        state.discard();
+                    }
+                }
+                iter = shared.addedStates();
+                while (iter.hasNext()) {
+                    ItemState state = (ItemState) iter.next();
+                    state.discard();
+                }
             }
         }
 



Mime
View raw message