From commits-return-10033-apmail-jackrabbit-commits-archive=jackrabbit.apache.org@jackrabbit.apache.org Wed Jun 16 17:30:25 2010 Return-Path: Delivered-To: apmail-jackrabbit-commits-archive@www.apache.org Received: (qmail 62138 invoked from network); 16 Jun 2010 17:30:25 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 16 Jun 2010 17:30:25 -0000 Received: (qmail 97370 invoked by uid 500); 16 Jun 2010 17:30:25 -0000 Delivered-To: apmail-jackrabbit-commits-archive@jackrabbit.apache.org Received: (qmail 97273 invoked by uid 500); 16 Jun 2010 17:30:24 -0000 Mailing-List: contact commits-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@jackrabbit.apache.org Delivered-To: mailing list commits@jackrabbit.apache.org Received: (qmail 97266 invoked by uid 99); 16 Jun 2010 17:30:24 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 16 Jun 2010 17:30:24 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 16 Jun 2010 17:30:21 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id DB92C23888D2; Wed, 16 Jun 2010 17:29:32 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r955314 - in /jackrabbit/branches/2.1: ./ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/ Date: Wed, 16 Jun 2010 17:29:32 -0000 To: commits@jackrabbit.apache.org From: jukka@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100616172932.DB92C23888D2@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: jukka Date: Wed Jun 16 17:29:32 2010 New Revision: 955314 URL: http://svn.apache.org/viewvc?rev=955314&view=rev Log: 2.1: Merged revision 955307 (JCR-2579) Modified: jackrabbit/branches/2.1/ (props changed) jackrabbit/branches/2.1/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/ChildNodeEntries.java jackrabbit/branches/2.1/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeState.java jackrabbit/branches/2.1/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionHistoryImpl.java Propchange: jackrabbit/branches/2.1/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Wed Jun 16 17:29:32 2010 @@ -2,4 +2,4 @@ /jackrabbit/sandbox/JCR-1456:774917-886178 /jackrabbit/sandbox/JCR-2170:812417-816332 /jackrabbit/sandbox/tripod-JCR-2209:795441-795863 -/jackrabbit/trunk:931121,931479,931483-931484,931504,931609,931613,931838,931919,932318-932319,933144,933197,933203,933213,933216,933554,933646,933694,934405,934412,934849,935557,955222,955229 +/jackrabbit/trunk:931121,931479,931483-931484,931504,931609,931613,931838,931919,932318-932319,933144,933197,933203,933213,933216,933554,933646,933694,934405,934412,934849,935557,955222,955229,955307 Modified: jackrabbit/branches/2.1/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/ChildNodeEntries.java URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.1/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/ChildNodeEntries.java?rev=955314&r1=955313&r2=955314&view=diff ============================================================================== --- jackrabbit/branches/2.1/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/ChildNodeEntries.java (original) +++ jackrabbit/branches/2.1/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/ChildNodeEntries.java Wed Jun 16 17:29:32 2010 @@ -17,8 +17,6 @@ package org.apache.jackrabbit.core.state; import org.apache.commons.collections.map.LinkedMap; -import org.apache.commons.collections.MapIterator; -import org.apache.commons.collections.OrderedMapIterator; import org.apache.jackrabbit.core.id.NodeId; import org.apache.jackrabbit.core.util.EmptyLinkedMap; import org.apache.jackrabbit.spi.Name; @@ -27,20 +25,14 @@ import java.util.List; import java.util.HashMap; import java.util.Collections; import java.util.ArrayList; -import java.util.Iterator; -import java.util.Collection; -import java.util.ListIterator; import java.util.Map; /** * ChildNodeEntries represents an insertion-ordered * collection of ChildNodeEntrys that also maintains * the index values of same-name siblings on insertion and removal. - *

- * ChildNodeEntries also provides an unmodifiable - * List view. */ -class ChildNodeEntries implements List, Cloneable { +class ChildNodeEntries implements Cloneable { /** * Insertion-ordered map of entries @@ -264,11 +256,12 @@ class ChildNodeEntries implements List result = new ArrayList(); - for (ChildNodeEntry entry : this) { + for (Object e : entries.values()) { + ChildNodeEntry entry = (ChildNodeEntry) e; ChildNodeEntry otherEntry = other.get(entry.getId()); if (entry == otherEntry) { continue; @@ -301,7 +294,8 @@ class ChildNodeEntries implements List result = new ArrayList(); - for (ChildNodeEntry entry : this) { + for (Object e : entries.values()) { + ChildNodeEntry entry = (ChildNodeEntry) e; ChildNodeEntry otherEntry = other.get(entry.getId()); if (entry == otherEntry) { result.add(entry); @@ -314,138 +308,37 @@ class ChildNodeEntries implements List - public boolean contains(Object o) { - if (o instanceof ChildNodeEntry) { - return entries.containsKey(((ChildNodeEntry) o).getId()); - } else { - return false; - } - } - - public boolean containsAll(Collection c) { - for (Object entry : c) { - if (!contains(entry)) { - return false; - } - } - return true; - } - - public ChildNodeEntry get(int index) { - return (ChildNodeEntry) entries.getValue(index); - } - - public int indexOf(Object o) { - if (o instanceof ChildNodeEntry) { - return entries.indexOf(((ChildNodeEntry) o).getId()); - } else { - return -1; - } - } public boolean isEmpty() { return entries.isEmpty(); } - public int lastIndexOf(Object o) { - // entries are unique - return indexOf(o); - } - - public Iterator iterator() { - return new EntriesIterator(); - } - - public ListIterator listIterator() { - return new EntriesIterator(); + @SuppressWarnings("unchecked") + public List list() { + return new ArrayList(entries.values()); } - public ListIterator listIterator(int index) { - if (index < 0 || index >= entries.size()) { - throw new IndexOutOfBoundsException(); - } - ListIterator iter = new EntriesIterator(); - while (index-- > 0) { - iter.next(); + public List getRenamedEntries(ChildNodeEntries that) { + List renamed = Collections.emptyList(); + for (Object e : entries.values()) { + ChildNodeEntry entry = (ChildNodeEntry) e; + ChildNodeEntry other = that.get(entry.getId()); + if (other != null && !entry.getName().equals(other.getName())) { + // child node entry with same id but different name exists in + // overlaid and this state => renamed entry detected + if (renamed.isEmpty()) { + renamed = new ArrayList(); + } + renamed.add(entry); + } } - return iter; + return renamed; } public int size() { return entries.size(); } - public List subList(int fromIndex, int toIndex) { - // @todo FIXME does not fulfill the contract of List.subList(int,int) - return Collections.unmodifiableList(new ArrayList(this).subList(fromIndex, toIndex)); - } - - public Object[] toArray() { - ChildNodeEntry[] array = new ChildNodeEntry[size()]; - return toArray(array); - } - - @SuppressWarnings("unchecked") - public Object[] toArray(Object[] a) { - if (!a.getClass().getComponentType().isAssignableFrom(ChildNodeEntry.class)) { - throw new ArrayStoreException(); - } - if (a.length < size()) { - a = new ChildNodeEntry[size()]; - } - MapIterator iter = entries.mapIterator(); - int i = 0; - while (iter.hasNext()) { - iter.next(); - a[i] = entries.getValue(i); - i++; - } - while (i < a.length) { - a[i++] = null; - } - return a; - } - - public void add(int index, ChildNodeEntry element) { - throw new UnsupportedOperationException(); - } - - public boolean add(ChildNodeEntry o) { - throw new UnsupportedOperationException(); - } - - public boolean addAll(Collection c) { - throw new UnsupportedOperationException(); - } - - public boolean addAll(int index, Collection c) { - throw new UnsupportedOperationException(); - } - - public void clear() { - throw new UnsupportedOperationException(); - } - - public ChildNodeEntry remove(int index) { - throw new UnsupportedOperationException(); - } - - public boolean remove(Object o) { - throw new UnsupportedOperationException(); - } - - public boolean removeAll(Collection c) { - throw new UnsupportedOperationException(); - } - - public boolean retainAll(Collection c) { - throw new UnsupportedOperationException(); - } - - public ChildNodeEntry set(int index, ChildNodeEntry element) { - throw new UnsupportedOperationException(); - } - //-------------------------------------------< java.lang.Object overrides > public boolean equals(Object obj) { if (this == obj) { @@ -527,51 +420,4 @@ class ChildNodeEntries implements List - class EntriesIterator implements ListIterator { - - private final OrderedMapIterator mapIter; - - EntriesIterator() { - mapIter = entries.orderedMapIterator(); - } - - public boolean hasNext() { - return mapIter.hasNext(); - } - - public ChildNodeEntry next() { - mapIter.next(); - return (ChildNodeEntry) mapIter.getValue(); - } - - public boolean hasPrevious() { - return mapIter.hasPrevious(); - } - - public int nextIndex() { - return entries.indexOf(mapIter.getKey()) + 1; - } - - public ChildNodeEntry previous() { - mapIter.previous(); - return (ChildNodeEntry) mapIter.getValue(); - } - - public int previousIndex() { - return entries.indexOf(mapIter.getKey()) - 1; - } - - public void add(ChildNodeEntry o) { - throw new UnsupportedOperationException(); - } - - public void remove() { - throw new UnsupportedOperationException(); - } - - public void set(ChildNodeEntry o) { - throw new UnsupportedOperationException(); - } - } } Modified: jackrabbit/branches/2.1/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeState.java URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.1/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeState.java?rev=955314&r1=955313&r2=955314&view=diff ============================================================================== --- jackrabbit/branches/2.1/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeState.java (original) +++ jackrabbit/branches/2.1/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeState.java Wed Jun 16 17:29:32 2010 @@ -23,7 +23,6 @@ import org.apache.jackrabbit.spi.Name; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; -import java.util.Iterator; import java.util.LinkedHashSet; import java.util.List; import java.util.Set; @@ -298,7 +297,7 @@ public class NodeState extends ItemState * @see #removeChildNodeEntry */ public synchronized List getChildNodeEntries() { - return childNodeEntries; + return childNodeEntries.list(); } /** @@ -606,7 +605,7 @@ public class NodeState extends ItemState */ public synchronized List getAddedChildNodeEntries() { if (!hasOverlayedState()) { - return childNodeEntries; + return childNodeEntries.list(); } NodeState other = (NodeState) getOverlayedState(); @@ -655,32 +654,10 @@ public class NodeState extends ItemState */ public synchronized List getRenamedChildNodeEntries() { if (!hasOverlayedState()) { - return Collections.emptyList(); - } - - ChildNodeEntries otherChildNodeEntries = - ((NodeState) overlayedState).childNodeEntries; - - // do a lazy init - List renamed = null; - - for (Iterator iter = childNodeEntries.iterator(); iter.hasNext();) { - ChildNodeEntry cne = 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.emptyList(); + return childNodeEntries.getRenamedEntries( + ((NodeState) overlayedState).childNodeEntries); } else { - return renamed; + return Collections.emptyList(); } } @@ -735,8 +712,8 @@ public class NodeState extends ItemState // both entry lists now contain the set of nodes that have not // been removed or added, but they may have changed their position. for (int i = 0; i < ours.size();) { - ChildNodeEntry entry = (ChildNodeEntry) ours.get(i); - ChildNodeEntry other = (ChildNodeEntry) others.get(i); + ChildNodeEntry entry = ours.get(i); + ChildNodeEntry other = others.get(i); if (entry == other || entry.getId().equals(other.getId())) { // no reorder, move to next child entry i++; @@ -753,10 +730,10 @@ public class NodeState extends ItemState if (i + 1 < ours.size()) { // if entry is the next in the other list then probably // the other entry at position i was reordered - if (entry.getId().equals(((ChildNodeEntry) others.get(i + 1)).getId())) { + if (entry.getId().equals(others.get(i + 1).getId())) { // scan for the uuid of the other entry in our list for (int j = i; j < ours.size(); j++) { - if (((ChildNodeEntry) ours.get(j)).getId().equals(other.getId())) { + if (ours.get(j).getId().equals(other.getId())) { // found it entry = (ChildNodeEntry) ours.get(j); break; @@ -769,12 +746,12 @@ public class NodeState extends ItemState // remove the entry from both lists // entries > i are already cleaned for (int j = i; j < ours.size(); j++) { - if (((ChildNodeEntry) ours.get(j)).getId().equals(entry.getId())) { + if (ours.get(j).getId().equals(entry.getId())) { ours.remove(j); } } for (int j = i; j < ours.size(); j++) { - if (((ChildNodeEntry) others.get(j)).getId().equals(entry.getId())) { + if (others.get(j).getId().equals(entry.getId())) { others.remove(j); } } Modified: jackrabbit/branches/2.1/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionHistoryImpl.java URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.1/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionHistoryImpl.java?rev=955314&r1=955313&r2=955314&view=diff ============================================================================== --- jackrabbit/branches/2.1/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionHistoryImpl.java (original) +++ jackrabbit/branches/2.1/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionHistoryImpl.java Wed Jun 16 17:29:32 2010 @@ -154,9 +154,7 @@ class InternalVersionHistoryImpl extends rootVersion = createVersionInstance(NameConstants.JCR_ROOTVERSION); // get version entries - ChildNodeEntry[] children = (ChildNodeEntry[]) - node.getState().getChildNodeEntries().toArray(); - for (ChildNodeEntry child : children) { + for (ChildNodeEntry child : node.getState().getChildNodeEntries()) { if (child.getName().equals(NameConstants.JCR_VERSIONLABELS)) { continue; }