jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r562512 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core: ItemImpl.java NodeImpl.java state/NodeState.java state/SessionItemStateManager.java
Date Fri, 03 Aug 2007 16:08:42 GMT
Author: stefan
Date: Fri Aug  3 09:08:41 2007
New Revision: 562512

URL: http://svn.apache.org/viewvc?view=rev&rev=562512
Log:
JCR-1038: java.lang.ArrayIndexOutOfBoundsException while importXML in Java 6

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeState.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.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?view=diff&rev=562512&r1=562511&r2=562512
==============================================================================
--- 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
Fri Aug  3 09:08:41 2007
@@ -1130,26 +1130,34 @@
                                     dependentIDs.add(oldParentId);
                                     dependentIDs.add(newParentId);
                                 } else {
-                                    // edge case: check whether definition id
-                                    // has changed (indicating that the node
-                                    // had been renamed, subsequently acquiring
-                                    // a new definition) (JCR-1034)
-                                    if (!nodeState.getDefinitionId().equals(
-                                            overlayedState.getDefinitionId())) {
-                                        // node has been renamed and as result
-                                        // got redefined, add parent to dependencies
-                                        dependentIDs.add(newParentId);
+                                    // 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);
+                                        }
                                     }
                                 }
                             }
                         }
                     }
 
-                    // note that there's no need to check removed/added
-                    // child node entries since those, being descendants, 
-                    // will automatically be included in the hierarchical
-                    // scope of this save operation.
-/*
                     // removed child node entries
                     for (Iterator cneIt =
                             nodeState.getRemovedChildNodeEntries().iterator();
@@ -1166,14 +1174,14 @@
                                 (NodeState.ChildNodeEntry) cneIt.next();
                         dependentIDs.add(cne.getId());
                     }
-  */
+
                     // now walk through dependencies and check whether they
                     // are within the scope of this save operation
                     Iterator depIt = dependentIDs.iterator();
                     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/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java?view=diff&rev=562512&r1=562511&r2=562512
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
Fri Aug  3 09:08:41 2007
@@ -635,10 +635,6 @@
     }
 
     protected void onRedefine(NodeDefId defId) throws RepositoryException {
-        if (defId.equals(((NodeState) state).getDefinitionId())) {
-            // no change, ignore silently...
-            return;
-        }
         NodeDefinitionImpl newDef =
                 session.getNodeTypeManager().getNodeDefinition(defId);
         // modify the state of 'this', i.e. the target node

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeState.java?view=diff&rev=562512&r1=562511&r2=562512
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeState.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeState.java
Fri Aug  3 09:08:41 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/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java?view=diff&rev=562512&r1=562511&r2=562512
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java
Fri Aug  3 09:08:41 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