You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by dp...@apache.org on 2008/03/19 11:56:52 UTC

svn commit: r638783 - /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java

Author: dpfister
Date: Wed Mar 19 03:56:38 2008
New Revision: 638783

URL: http://svn.apache.org/viewvc?rev=638783&view=rev
Log:
JCR-1487 - Transient states should be persisted in depth-first traversal order

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java?rev=638783&r1=638782&r2=638783&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java Wed Mar 19 03:56:38 2008
@@ -299,7 +299,9 @@
 
     /**
      * Builds a list of transient (i.e. new or modified) item states that are
-     * within the scope of <code>this.{@link #save()}</code>.
+     * within the scope of <code>this.{@link #save()}</code>. The collection
+     * returned is ordered depth-first, i.e. the item itself (if transient)
+     * comes last.
      *
      * @return list of transient item states
      * @throws InvalidItemStateException
@@ -311,45 +313,6 @@
         ArrayList dirty = new ArrayList();
         ItemState transientState;
 
-        // fail-fast test: check status of this item's state
-        if (isTransient()) {
-            String msg;
-            switch (state.getStatus()) {
-                case ItemState.STATUS_EXISTING_MODIFIED:
-                    // add this item's state to the list
-                    dirty.add(state);
-                    break;
-
-                case ItemState.STATUS_NEW:
-                    msg = safeGetJCRPath() + ": cannot save a new item.";
-                    log.debug(msg);
-                    throw new RepositoryException(msg);
-
-                case ItemState.STATUS_STALE_MODIFIED:
-                    msg = safeGetJCRPath()
-                        + ": the item cannot be saved because it has been modified externally.";
-                    log.debug(msg);
-                    throw new InvalidItemStateException(msg);
-
-                case ItemState.STATUS_STALE_DESTROYED:
-                    msg = safeGetJCRPath()
-                        + ": the item cannot be saved because it has been deleted externally.";
-                    log.debug(msg);
-                    throw new InvalidItemStateException(msg);
-
-                case ItemState.STATUS_UNDEFINED:
-                    msg = safeGetJCRPath()
-                        + ": the item cannot be saved; it seems to have been removed externally.";
-                    log.debug(msg);
-                    throw new InvalidItemStateException(msg);
-
-                default:
-                    log.debug("unexpected state status (" + state.getStatus() + ")");
-                    // ignore
-                    break;
-            }
-        }
-
         if (isNode()) {
             // build list of 'new' or 'modified' descendants
             Iterator iter = stateMgr.getDescendantTransientItemStates((NodeId) id);
@@ -389,6 +352,45 @@
                 }
             }
         }
+        // fail-fast test: check status of this item's state
+        if (isTransient()) {
+            String msg;
+            switch (state.getStatus()) {
+                case ItemState.STATUS_EXISTING_MODIFIED:
+                    // add this item's state to the list
+                    dirty.add(state);
+                    break;
+
+                case ItemState.STATUS_NEW:
+                    msg = safeGetJCRPath() + ": cannot save a new item.";
+                    log.debug(msg);
+                    throw new RepositoryException(msg);
+
+                case ItemState.STATUS_STALE_MODIFIED:
+                    msg = safeGetJCRPath()
+                        + ": the item cannot be saved because it has been modified externally.";
+                    log.debug(msg);
+                    throw new InvalidItemStateException(msg);
+
+                case ItemState.STATUS_STALE_DESTROYED:
+                    msg = safeGetJCRPath()
+                        + ": the item cannot be saved because it has been deleted externally.";
+                    log.debug(msg);
+                    throw new InvalidItemStateException(msg);
+
+                case ItemState.STATUS_UNDEFINED:
+                    msg = safeGetJCRPath()
+                        + ": the item cannot be saved; it seems to have been removed externally.";
+                    log.debug(msg);
+                    throw new InvalidItemStateException(msg);
+
+                default:
+                    log.debug("unexpected state status (" + state.getStatus() + ")");
+                    // ignore
+                    break;
+            }
+        }
+
         return dirty;
     }