jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r773930 - in /jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version: VersionHistoryImpl.java VersionImpl.java
Date Tue, 12 May 2009 15:12:11 GMT
Author: angela
Date: Tue May 12 15:12:11 2009
New Revision: 773930

URL: http://svn.apache.org/viewvc?rev=773930&view=rev
Log:
JCR-2104: JSR 283 Versioning

Modified:
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionHistoryImpl.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionImpl.java

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionHistoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionHistoryImpl.java?rev=773930&r1=773929&r2=773930&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionHistoryImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionHistoryImpl.java
Tue May 12 15:12:11 2009
@@ -36,6 +36,7 @@
 
 import org.apache.jackrabbit.commons.iterator.RangeIteratorAdapter;
 import org.apache.jackrabbit.commons.iterator.FrozenNodeIteratorAdapter;
+import org.apache.jackrabbit.commons.iterator.VersionIteratorAdapter;
 import org.apache.jackrabbit.jcr2spi.ItemLifeCycleListener;
 import org.apache.jackrabbit.jcr2spi.LazyItemIterator;
 import org.apache.jackrabbit.jcr2spi.NodeImpl;
@@ -115,6 +116,42 @@
     }
 
     /**
+     * @see VersionHistory#getAllLinearVersions()
+     */
+    public VersionIterator getAllLinearVersions() throws RepositoryException {
+        checkStatus();
+
+        // TODO: improve and use lazy loading of versions as needed.
+        // TODO: change session.getNodeByUUID to Session.getNodeByIdentifier as soon as implemented
+
+        List versions = new ArrayList();
+        Version rootV = getRootVersion();
+        Node vn = session.getNodeByUUID(getVersionableUUID());
+        Version v = vn.getBaseVersion();
+        while (v != null && !rootV.isSame(v)) {
+            versions.add(0, v);
+            v = v.getLinearPredecessor();
+        }
+        versions.add(0, rootV);
+        
+        return new VersionIteratorAdapter(versions);
+    }
+
+    /**
+     * @see VersionHistory#getAllFrozenNodes()
+     */
+    public NodeIterator getAllFrozenNodes() throws RepositoryException {
+        return new FrozenNodeIteratorAdapter(getAllVersions());
+    }
+
+    /**
+     * @see VersionHistory#getAllLinearFrozenNodes()
+     */
+    public NodeIterator getAllLinearFrozenNodes() throws RepositoryException {
+        return new FrozenNodeIteratorAdapter(getAllLinearVersions());
+    }
+    
+    /**
      * @see VersionHistory#getVersion(String)
      */
     public Version getVersion(String versionName) throws VersionException, RepositoryException
{
@@ -232,30 +269,6 @@
         session.getVersionStateManager().removeVersion((NodeState) getItemState(), vState);
     }
 
-
-    /**
-     * @see VersionHistory#getAllFrozenNodes()
-     */
-    public NodeIterator getAllFrozenNodes() throws RepositoryException {
-        return new FrozenNodeIteratorAdapter(getAllVersions());
-    }
-
-    /**
-     * @see VersionHistory#getAllLinearFrozenNodes()
-     */
-    public NodeIterator getAllLinearFrozenNodes() throws RepositoryException {        
-        // TODO
-        throw new UnsupportedRepositoryOperationException("JCR-1104");
-    }
-
-    /**
-     * @see VersionHistory#getAllLinearVersions()
-     */
-    public VersionIterator getAllLinearVersions() throws RepositoryException {
-        // TODO
-        throw new UnsupportedRepositoryOperationException("JCR-1104");
-    }
-
     /**
      * @see VersionHistory#getVersionableIdentifier()
      */

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionImpl.java?rev=773930&r1=773929&r2=773930&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionImpl.java
Tue May 12 15:12:11 2009
@@ -27,6 +27,7 @@
 
 import javax.jcr.version.Version;
 import javax.jcr.version.VersionHistory;
+import javax.jcr.version.VersionIterator;
 import javax.jcr.RepositoryException;
 import javax.jcr.Value;
 import javax.jcr.Node;
@@ -49,9 +50,6 @@
 
     //------------------------------------------------------------< Version >---
     /**
-     *
-     * @return
-     * @throws RepositoryException
      * @see Version#getContainingHistory()
      */
     public VersionHistory getContainingHistory() throws RepositoryException {
@@ -59,9 +57,6 @@
     }
 
     /**
-     *
-     * @return
-     * @throws RepositoryException
      * @see Version#getCreated()
      */
     public Calendar getCreated() throws RepositoryException {
@@ -69,9 +64,6 @@
     }
 
     /**
-     *
-     * @return
-     * @throws RepositoryException
      * @see Version#getSuccessors()
      */
     public Version[] getSuccessors() throws RepositoryException {
@@ -82,14 +74,20 @@
      * @see Version#getLinearSuccessor()
      */
     public Version getLinearSuccessor() throws RepositoryException {
-        // TODO
-        throw new UnsupportedRepositoryOperationException("JCR-1104");
+        // TODO: improve.
+        VersionHistory vh = getContainingHistory();
+        for (VersionIterator it = vh.getAllLinearVersions(); it.hasNext();) {
+            Version v = it.nextVersion();
+            if (isSame(v.getLinearPredecessor())) {
+                return v;
+            }
+        }
+
+        // no linear successor found
+        return null;
     }
     
     /**
-     *
-     * @return
-     * @throws RepositoryException
      * @see Version#getPredecessors()
      */
     public Version[] getPredecessors() throws RepositoryException {



Mime
View raw message