You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by ju...@apache.org on 2008/04/22 03:08:27 UTC

svn commit: r650340 - /jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java

Author: jukka
Date: Mon Apr 21 18:08:23 2008
New Revision: 650340

URL: http://svn.apache.org/viewvc?rev=650340&view=rev
Log:
1.4: Merged revision 638783 (JCR-1487)

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

Modified: jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java?rev=650340&r1=650339&r2=650340&view=diff
==============================================================================
--- jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java (original)
+++ jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java Mon Apr 21 18:08:23 2008
@@ -298,7 +298,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
@@ -310,6 +312,45 @@
         ArrayList dirty = new ArrayList();
         ItemState transientState;
 
+        if (isNode()) {
+            // build list of 'new' or 'modified' descendants
+            Iterator iter = stateMgr.getDescendantTransientItemStates((NodeId) id);
+            while (iter.hasNext()) {
+                transientState = (ItemState) iter.next();
+                // fail-fast test: check status of transient state
+                String msg;
+                switch (transientState.getStatus()) {
+                    case ItemState.STATUS_NEW:
+                    case ItemState.STATUS_EXISTING_MODIFIED:
+                        // add modified state to the list
+                        dirty.add(transientState);
+                        break;
+
+                    case ItemState.STATUS_STALE_MODIFIED:
+                        msg = transientState.getId()
+                            + ": the item cannot be saved because it has been modified externally.";
+                        log.debug(msg);
+                        throw new InvalidItemStateException(msg);
+
+                    case ItemState.STATUS_STALE_DESTROYED:
+                        msg = transientState.getId()
+                            + ": 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 (" + transientState.getStatus() + ")");
+                        // ignore
+                        break;
+                }
+            }
+        }
         // fail-fast test: check status of this item's state
         if (isTransient()) {
             switch (state.getStatus()) {
@@ -357,50 +398,6 @@
             }
         }
 
-        if (isNode()) {
-            // build list of 'new' or 'modified' descendants
-            Iterator iter = stateMgr.getDescendantTransientItemStates((NodeId) id);
-            while (iter.hasNext()) {
-                transientState = (ItemState) iter.next();
-                // fail-fast test: check status of transient state
-                switch (transientState.getStatus()) {
-                    case ItemState.STATUS_NEW:
-                    case ItemState.STATUS_EXISTING_MODIFIED:
-                        // add modified state to the list
-                        dirty.add(transientState);
-                        break;
-
-                    case ItemState.STATUS_STALE_MODIFIED:
-                        {
-                            String msg = transientState.getId()
-                                    + ": the item cannot be saved because it has been modified externally.";
-                            log.debug(msg);
-                            throw new InvalidItemStateException(msg);
-                        }
-
-                    case ItemState.STATUS_STALE_DESTROYED:
-                        {
-                            String msg = transientState.getId()
-                                    + ": the item cannot be saved because it has been deleted externally.";
-                            log.debug(msg);
-                            throw new InvalidItemStateException(msg);
-                        }
-
-                    case ItemState.STATUS_UNDEFINED:
-                        {
-                            String 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 (" + transientState.getStatus() + ")");
-                        // ignore
-                        break;
-                }
-            }
-        }
         return dirty;
     }