jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r577701 - in /jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core: ItemImpl.java state/NodeState.java state/SessionItemStateManager.java
Date Thu, 20 Sep 2007 11:56:42 GMT
Author: jukka
Date: Thu Sep 20 04:56:42 2007
New Revision: 577701

URL: http://svn.apache.org/viewvc?rev=577701&view=rev
Log:
1.3: Merged revisions 56100 and 562512 (JCR-1034)

Modified:
    jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java
    jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeState.java
    jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java

Modified: jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java?rev=577701&r1=577700&r2=577701&view=diff
==============================================================================
--- jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java
(original)
+++ jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java
Thu Sep 20 04:56:42 2007
@@ -1114,8 +1114,9 @@
                     NodeState nodeState = (NodeState) transientState;
                     Set dependentIDs = new HashSet();
                     if (nodeState.hasOverlayedState()) {
-                        NodeId oldParentId =
-                                nodeState.getOverlayedState().getParentId();
+                        NodeState overlayedState =
+                                (NodeState) nodeState.getOverlayedState();
+                        NodeId oldParentId = overlayedState.getParentId();
                         NodeId newParentId = nodeState.getParentId();
                         if (oldParentId != null) {
                             if (newParentId == null) {
@@ -1124,14 +1125,39 @@
                                 dependentIDs.add(oldParentId);
                             } else {
                                 if (!oldParentId.equals(newParentId)) {
-                                    // node has been moved, add old and new parent
-                                    // to dependencies
+                                    // node has been moved to a new location,
+                                    // add old and new parent to dependencies
                                     dependentIDs.add(oldParentId);
                                     dependentIDs.add(newParentId);
+                                } else {
+                                    // parent id hasn't changed, check whether
+                                    // the node has been renamed (JCR-1034)
+                                    if (!affectedIds.contains(newParentId)
+                                            && stateMgr.hasTransientItemState(newParentId))
{
+                                        try {
+                                            NodeState parent = (NodeState) stateMgr.getTransientItemState(newParentId);
+                                            // check parent's renamed child node entries
+                                            for (Iterator cneIt =
+                                                    parent.getRenamedChildNodeEntries().iterator();
+                                                 cneIt.hasNext();) {
+                                                NodeState.ChildNodeEntry cne =
+                                                        (NodeState.ChildNodeEntry) cneIt.next();
+                                                if (cne.getId().equals(nodeState.getId()))
{
+                                                    // node has been renamed,
+                                                    // add parent to dependencies
+                                                    dependentIDs.add(newParentId);
+                                                }
+                                            }
+                                        } catch (ItemStateException ise) {
+                                            // should never get here
+                                            log.warn("failed to retrieve transient state:
" + newParentId, ise);
+                                        }
+                                    }
                                 }
                             }
                         }
                     }
+
                     // removed child node entries
                     for (Iterator cneIt =
                             nodeState.getRemovedChildNodeEntries().iterator();
@@ -1155,7 +1181,7 @@
                     while (depIt.hasNext()) {
                         NodeId id = (NodeId) depIt.next();
                         if (!affectedIds.contains(id)) {
-                            // need to save the parent as well
+                            // need to save dependency as well
                             String msg = itemMgr.safeGetJCRPath(id)
                                     + " needs to be saved as well.";
                             log.debug(msg);

Modified: jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeState.java?rev=577701&r1=577700&r2=577701&view=diff
==============================================================================
--- jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeState.java
(original)
+++ jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeState.java
Thu Sep 20 04:56:42 2007
@@ -626,6 +626,43 @@
 
     /**
      * Returns a list of child node entries that exist both in <i>this</i> node
+     * state and in the overlayed node state but have been renamed.
+     *
+     * @return list of renamed child node entries
+     */
+    public synchronized List getRenamedChildNodeEntries() {
+        if (!hasOverlayedState()) {
+            return Collections.EMPTY_LIST;
+        }
+
+        ChildNodeEntries otherChildNodeEntries =
+                ((NodeState) overlayedState).childNodeEntries;
+
+        // do a lazy init
+        List renamed = null;
+
+        for (Iterator iter = childNodeEntries.iterator(); iter.hasNext();) {
+            ChildNodeEntry cne = (ChildNodeEntry) iter.next();
+            ChildNodeEntry cneOther = otherChildNodeEntries.get(cne.getId());
+            if (cneOther != null && !cne.getName().equals(cneOther.getName())) {
+                // child node entry with same id but different name exists in
+                // overlayed and this state => renamed entry detected
+                if (renamed == null) {
+                    renamed = new ArrayList();
+                }
+                renamed.add(cne);
+            }
+        }
+
+        if (renamed == null) {
+            return Collections.EMPTY_LIST;
+        } else {
+            return renamed;
+        }
+    }
+
+    /**
+     * Returns a list of child node entries that exist both in <i>this</i> node
      * state and in the overlayed node state but have been reordered.
      * <p/>
      * The list may include only the minimal set of nodes that have been

Modified: jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java?rev=577701&r1=577700&r2=577701&view=diff
==============================================================================
--- jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java
(original)
+++ jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java
Thu Sep 20 04:56:42 2007
@@ -336,6 +336,24 @@
     }
 
     /**
+     *
+     * @param id
+     * @return
+     */
+    public boolean hasTransientItemState(ItemId id) {
+        return transientStore.contains(id);
+    }
+
+    /**
+     *
+     * @param id
+     * @return
+     */
+    public boolean hasTransientItemStateInAttic(ItemId id) {
+        return atticStore.contains(id);
+    }
+
+    /**
      * @return <code>true</code> if this manager has any transient state;
      *         <code>false</code> otherwise.
      */



Mime
View raw message