jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1174686 - in /jackrabbit/branches/2.1: ./ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/ jackrabbit-core/src/test/java/org/apache/jackrabbit/core/version/
Date Fri, 23 Sep 2011 12:07:38 GMT
Author: jukka
Date: Fri Sep 23 12:07:37 2011
New Revision: 1174686

URL: http://svn.apache.org/viewvc?rev=1174686&view=rev
Log:
2.1: Merged revisions 1000912 and 1032621 (JCR-2655)

Modified:
    jackrabbit/branches/2.1/   (props changed)
    jackrabbit/branches/2.1/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersion.java
    jackrabbit/branches/2.1/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionHistoryImpl.java
    jackrabbit/branches/2.1/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionImpl.java
    jackrabbit/branches/2.1/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionManagerBase.java
    jackrabbit/branches/2.1/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalXAVersionManager.java
    jackrabbit/branches/2.1/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionImpl.java
    jackrabbit/branches/2.1/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionIteratorImpl.java
    jackrabbit/branches/2.1/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImplRestore.java
    jackrabbit/branches/2.1/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/version/VersionIteratorImplTest.java

Propchange: jackrabbit/branches/2.1/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Sep 23 12:07:37 2011
@@ -3,4 +3,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,936668,938099,945528,950440,950680,955222,955229,955307,955852,961487,961626,964362,965539,986682,986686,986715,991144,995411-995412,996810,999298-999299,999965,1000947,1001707,1002065-1002066,1002084,1002101-1002102,1002168,1002170,1002589,1002608,1002657,1002729,1003423,1003470,1003542,1003773,1004182,1004184,1004223-1004224,1004652,1005057,1005112,1036117,1036336-1036337,1038201,1039064,1039423,1040090,1065599,1069831,1071562,1071573,1087304,1089436,1104027,1165609,1173196
+/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,936668,938099,945528,950440,950680,955222,955229,955307,955852,961487,961626,964362,965539,986682,986686,986715,991144,995411-995412,996810,999298-999299,999965,1000912,1000947,1001707,1002065-1002066,1002084,1002101-1002102,1002168,1002170,1002589,1002608,1002657,1002729,1003423,1003470,1003542,1003773,1004182,1004184,1004223-1004224,1004652,1005057,1005112,1032621,1036117,1036336-1036337,1038201,1039064,1039423,1040090,1065599,1069831,1071562,1071573,1087304,1089436,1104027,1165609,1173196

Modified: jackrabbit/branches/2.1/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersion.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.1/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersion.java?rev=1174686&r1=1174685&r2=1174686&view=diff
==============================================================================
--- jackrabbit/branches/2.1/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersion.java
(original)
+++ jackrabbit/branches/2.1/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersion.java
Fri Sep 23 12:07:37 2011
@@ -21,6 +21,7 @@ import org.apache.jackrabbit.core.id.Nod
 import javax.jcr.version.Version;
 
 import java.util.Calendar;
+import java.util.List;
 
 /**
  * This interface defines the internal version.
@@ -63,7 +64,7 @@ public interface InternalVersion extends
      * @see javax.jcr.version.Version#getSuccessors()
      * @return the successors as internal versions
      */
-    InternalVersion[] getSuccessors();
+    List<InternalVersion> getSuccessors();
 
     /**
      * Equivalent to {@link Version#getLinearSuccessor()}.

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=1174686&r1=1174685&r2=1174686&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
Fri Sep 23 12:07:37 2011
@@ -162,7 +162,7 @@ class InternalVersionHistoryImpl extends
         }
 
         // fix legacy
-        if (rootVersion.getSuccessors().length == 0) {
+        if (rootVersion.getSuccessors().isEmpty()) {
             for (Name versionName : nameCache.keySet()) {
                 InternalVersionImpl v = createVersionInstance(versionName);
                 v.legacyResolveSuccessors();

Modified: jackrabbit/branches/2.1/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.1/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionImpl.java?rev=1174686&r1=1174685&r2=1174686&view=diff
==============================================================================
--- jackrabbit/branches/2.1/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionImpl.java
(original)
+++ jackrabbit/branches/2.1/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionImpl.java
Fri Sep 23 12:07:37 2011
@@ -21,11 +21,14 @@ import org.apache.jackrabbit.core.value.
 import org.apache.jackrabbit.core.id.NodeId;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.commons.name.NameConstants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
 import java.util.Arrays;
 import java.util.Calendar;
+import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
 import java.util.ArrayList;
@@ -36,6 +39,10 @@ import java.util.ArrayList;
 class InternalVersionImpl extends InternalVersionItemImpl
         implements InternalVersion {
 
+    /** Logger instance */
+    private static final Logger log =
+        LoggerFactory.getLogger(InternalVersionImpl.class);
+
     /**
      * the date when this version was created
      */
@@ -137,18 +144,27 @@ class InternalVersionImpl extends Intern
     /**
      * {@inheritDoc}
      */
-    public InternalVersion[] getSuccessors() {
+    public List<InternalVersion> getSuccessors() {
         VersioningLock.ReadLock lock = vMgr.acquireReadLock();
         try {
-            InternalValue[] values = node.getPropertyValues(NameConstants.JCR_SUCCESSORS);
+            InternalValue[] values =
+                node.getPropertyValues(NameConstants.JCR_SUCCESSORS);
             if (values != null) {
-                InternalVersion[] versions = new InternalVersion[values.length];
-                for (int i = 0; i < values.length; i++) {
-                    versions[i] = versionHistory.getVersion(values[i].getNodeId());
+                List<InternalVersion> versions =
+                    new ArrayList<InternalVersion>(values.length);
+                for (InternalValue value : values) {
+                    InternalVersion version =
+                        versionHistory.getVersion(value.getNodeId());
+                    if (version != null) {
+                        versions.add(version);
+                    } else {
+                        // Can happen with a corrupted repository (JCR-2655)
+                        log.warn("Missing successor {}", value.getNodeId());
+                    }
                 }
                 return versions;
             } else {
-                return new InternalVersion[0];
+                return Collections.emptyList();
             }
         } finally {
             lock.release();
@@ -274,8 +290,7 @@ class InternalVersionImpl extends Intern
      */
     void internalDetach() throws RepositoryException {
         // detach this from all successors
-        InternalVersion[] succ = getSuccessors();
-        for (InternalVersion aSucc : succ) {
+        for (InternalVersion aSucc :  getSuccessors()) {
             ((InternalVersionImpl) aSucc).internalDetachPredecessor(this, true);
         }
 
@@ -311,7 +326,7 @@ class InternalVersionImpl extends Intern
      */
     private void internalAddSuccessor(InternalVersionImpl succ, boolean store)
             throws RepositoryException {
-        List<InternalVersion> l = new ArrayList<InternalVersion>(Arrays.asList(getSuccessors()));
+        List<InternalVersion> l = new ArrayList<InternalVersion>(getSuccessors());
         if (!l.contains(succ)) {
             l.add(succ);
             storeXCessors(l, NameConstants.JCR_SUCCESSORS, store);
@@ -352,11 +367,11 @@ class InternalVersionImpl extends Intern
     private void internalDetachSuccessor(InternalVersionImpl v, boolean store)
             throws RepositoryException {
         // remove 'v' from successors list
-        List<InternalVersion> l = new ArrayList<InternalVersion>(Arrays.asList(getSuccessors()));
+        List<InternalVersion> l = new ArrayList<InternalVersion>(getSuccessors());
         l.remove(v);
 
         // attach V's successors
-        l.addAll(Arrays.asList(v.getSuccessors()));
+        l.addAll(v.getSuccessors());
         storeXCessors(l, NameConstants.JCR_SUCCESSORS, store);
     }
 

Modified: jackrabbit/branches/2.1/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionManagerBase.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.1/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionManagerBase.java?rev=1174686&r1=1174685&r2=1174686&view=diff
==============================================================================
--- jackrabbit/branches/2.1/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionManagerBase.java
(original)
+++ jackrabbit/branches/2.1/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionManagerBase.java
Fri Sep 23 12:07:37 2011
@@ -661,7 +661,7 @@ abstract class InternalVersionManagerBas
             return newVersionName;
         } else {
             // best is root version
-            return String.valueOf(best.getSuccessors().length + 1) + ".0";
+            return String.valueOf(best.getSuccessors().size() + 1) + ".0";
         }
     }
 

Modified: jackrabbit/branches/2.1/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalXAVersionManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.1/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalXAVersionManager.java?rev=1174686&r1=1174685&r2=1174686&view=diff
==============================================================================
--- jackrabbit/branches/2.1/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalXAVersionManager.java
(original)
+++ jackrabbit/branches/2.1/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalXAVersionManager.java
Fri Sep 23 12:07:37 2011
@@ -510,12 +510,10 @@ public class InternalXAVersionManager ex
             xaItems.put(history.getId(), history);
             // also put 'successor' and 'predecessor' version items to xaItem sets
             InternalVersion v = history.getVersion(name);
-            InternalVersion[] vs = v.getSuccessors();
-            for (InternalVersion v1 : vs) {
+            for (InternalVersion v1 : v.getSuccessors()) {
                 xaItems.put(v1.getId(), v1);
             }
-            vs = v.getPredecessors();
-            for (InternalVersion v1 : vs) {
+            for (InternalVersion v1 : v.getPredecessors()) {
                 xaItems.put(v1.getId(), v1);
             }
         }

Modified: jackrabbit/branches/2.1/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.1/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionImpl.java?rev=1174686&r1=1174685&r2=1174686&view=diff
==============================================================================
--- jackrabbit/branches/2.1/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionImpl.java
(original)
+++ jackrabbit/branches/2.1/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionImpl.java
Fri Sep 23 12:07:37 2011
@@ -33,6 +33,7 @@ import javax.jcr.RepositoryException;
 import javax.jcr.Node;
 import javax.jcr.nodetype.ConstraintViolationException;
 import java.util.Calendar;
+import java.util.List;
 
 /**
  * Base implementation of the {@link javax.jcr.version.Version} interface.
@@ -80,10 +81,10 @@ public class VersionImpl extends NodeImp
      */
     public javax.jcr.version.Version[] getSuccessors() throws RepositoryException {
         // need to wrap it around proper node
-        InternalVersion[] suc = getInternalVersion().getSuccessors();
-        Version[] ret = new Version[suc.length];
-        for (int i = 0; i < suc.length; i++) {
-            ret[i] = (Version) session.getNodeById(suc[i].getId());
+        List<InternalVersion> suc = getInternalVersion().getSuccessors();
+        Version[] ret = new Version[suc.size()];
+        for (int i = 0; i < ret.length; i++) {
+            ret[i] = (Version) session.getNodeById(suc.get(i).getId());
         }
         return ret;
     }

Modified: jackrabbit/branches/2.1/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionIteratorImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.1/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionIteratorImpl.java?rev=1174686&r1=1174685&r2=1174686&view=diff
==============================================================================
--- jackrabbit/branches/2.1/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionIteratorImpl.java
(original)
+++ jackrabbit/branches/2.1/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionIteratorImpl.java
Fri Sep 23 12:07:37 2011
@@ -26,7 +26,6 @@ import javax.jcr.version.VersionIterator
 import java.util.ConcurrentModificationException;
 import java.util.LinkedList;
 import java.util.NoSuchElementException;
-import java.util.Arrays;
 
 /**
  * This Class implements a VersionIterator that iterates over a version
@@ -44,7 +43,7 @@ class VersionIteratorImpl implements Ver
     /**
      * the id's of the versions to return
      */
-    private LinkedList<NodeId> versions = new LinkedList<NodeId>();
+    private final LinkedList<NodeId> versions = new LinkedList<NodeId>();
 
     /**
      * the current position
@@ -170,8 +169,7 @@ class VersionIteratorImpl implements Ver
             NodeId id = currentVersion.getId();
             if (!versions.contains(id)) {
                 versions.add(id);
-                InternalVersion[] successors = currentVersion.getSuccessors();
-                workQueue.addAll(Arrays.asList(successors));
+                workQueue.addAll(currentVersion.getSuccessors());
             }
         }
 

Modified: jackrabbit/branches/2.1/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImplRestore.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.1/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImplRestore.java?rev=1174686&r1=1174685&r2=1174686&view=diff
==============================================================================
--- jackrabbit/branches/2.1/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImplRestore.java
(original)
+++ jackrabbit/branches/2.1/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImplRestore.java
Fri Sep 23 12:07:37 2011
@@ -19,6 +19,7 @@ package org.apache.jackrabbit.core.versi
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.LinkedList;
+import java.util.List;
 import java.util.Set;
 
 import javax.jcr.ItemExistsException;
@@ -575,14 +576,14 @@ abstract public class VersionManagerImpl
                     if (v == null) {
                         // if version selector was unable to select version,
                         // choose the initial one
-                        InternalVersion[] vs = vh.getRootVersion().getSuccessors();
-                        if (vs.length == 0) {
+                        List<InternalVersion> vs = vh.getRootVersion().getSuccessors();
+                        if (vs.isEmpty()) {
                             String msg = "Unable to select appropariate version for "
                                     + child.getName() + " using " + vsel;
                             log.error(msg);
                             throw new VersionException(msg);
                         }
-                        v = vs[0];
+                        v = vs.get(0);
                     }
                     InternalFrozenNode f = v.getFrozenNode();
                     restoredChild = state.addNode(fh.getName(), f.getFrozenPrimaryType(),
f.getFrozenId());

Modified: jackrabbit/branches/2.1/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/version/VersionIteratorImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.1/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/version/VersionIteratorImplTest.java?rev=1174686&r1=1174685&r2=1174686&view=diff
==============================================================================
--- jackrabbit/branches/2.1/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/version/VersionIteratorImplTest.java
(original)
+++ jackrabbit/branches/2.1/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/version/VersionIteratorImplTest.java
Fri Sep 23 12:07:37 2011
@@ -16,7 +16,9 @@
  */
 package org.apache.jackrabbit.core.version;
 
+import java.util.Arrays;
 import java.util.Calendar;
+import java.util.List;
 
 import junit.framework.TestCase;
 
@@ -37,8 +39,8 @@ public class VersionIteratorImplTest ext
             this.id = id;
         }
 
-        public InternalVersion[] getSuccessors() {
-            return successors;
+        public List<InternalVersion> getSuccessors() {
+            return Arrays.asList(successors);
         }
 
         public NodeId getId() {



Mime
View raw message