jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dpfis...@apache.org
Subject svn commit: r368735 - in /incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core: ItemImpl.java state/SessionItemStateManager.java
Date Fri, 13 Jan 2006 14:24:27 GMT
Author: dpfister
Date: Fri Jan 13 06:24:19 2006
New Revision: 368735

URL: http://svn.apache.org/viewcvs?rev=368735&view=rev
Log:
Restore of transient items after a unsuccessful save() failed when same item
was already in attic space.

Modified:
    incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/ItemImpl.java
    incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java

Modified: incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/ItemImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/ItemImpl.java?rev=368735&r1=368734&r2=368735&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/ItemImpl.java
(original)
+++ incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/ItemImpl.java
Fri Jan 13 06:24:19 2006
@@ -688,7 +688,24 @@
         // walk through list of transient states and reapply transient changes
         while (iter.hasNext()) {
             ItemState itemState = (ItemState) iter.next();
-            ItemImpl item = itemMgr.getItem(itemState.getId());
+            ItemId id = itemState.getId();
+            ItemImpl item;
+
+            if (stateMgr.isItemStateInAttic(id)) {
+                // If an item has been removed and then again created, the
+                // item is lost after persistTransientItems() and the
+                // TransientItemStateManager will bark because of a deleted
+                // state in its attic. We therefore have to forge a new item
+                // instance ourself.
+                if (itemState.isNode()) {
+                    item = itemMgr.createNodeInstance((NodeState) itemState);
+                } else {
+                    item = itemMgr.createPropertyInstance((PropertyState) itemState);
+                }
+                itemState.setStatus(ItemState.STATUS_NEW);
+            } else {
+                item = itemMgr.getItem(id);
+            }
             if (!item.isTransient()) {
                 // reapply transient changes (i.e. undo effect of item.makePersistent())
                 if (item.isNode()) {

Modified: incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java?rev=368735&r1=368734&r2=368735&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java
(original)
+++ incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java
Fri Jan 13 06:24:19 2006
@@ -582,6 +582,18 @@
         return resultIter;
     }
 
+    /**
+     * Return a flag indicating whether the specified item is in the transient
+     * item state manager's attic space.
+     *
+     * @param id item id
+     * @return <code>true</code> if the item state is in the attic space;
+     *         <code>false</code> otherwise
+     */
+    public boolean isItemStateInAttic(ItemId id) {
+        return transientStateMgr.getAttic().hasItemState(id);
+    }
+
     //------< methods for creating & discarding transient ItemState instances >
     /**
      * @param uuid



Mime
View raw message