jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r159670 - in incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi: client/ iterator/ remote/ server/
Date Fri, 01 Apr 2005 09:23:41 GMT
Author: jukka
Date: Fri Apr  1 01:23:37 2005
New Revision: 159670

URL: http://svn.apache.org/viewcvs?view=rev&rev=159670
Log:
JCR-94: Versioning support for JCR-RMI, contributed by Felix Meschberger.

Added:
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientVersion.java
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientVersionHistory.java
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/iterator/ArrayVersionIterator.java
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteVersion.java
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteVersionHistory.java
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerVersion.java
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerVersionHistory.java
Modified:
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientAdapterFactory.java
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientItem.java
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientNode.java
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientObject.java
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientQueryResult.java
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientSession.java
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/LocalAdapterFactory.java
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteNode.java
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/RemoteAdapterFactory.java
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerAdapterFactory.java
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerItem.java
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerNode.java
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerObject.java
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerQueryResult.java
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerSession.java

Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientAdapterFactory.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientAdapterFactory.java?view=diff&r1=159669&r2=159670
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientAdapterFactory.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientAdapterFactory.java Fri Apr  1 01:23:37 2005
@@ -33,6 +33,8 @@
 import javax.jcr.query.QueryManager;
 import javax.jcr.query.QueryResult;
 import javax.jcr.query.Row;
+import javax.jcr.version.Version;
+import javax.jcr.version.VersionHistory;
 
 import org.apache.jackrabbit.rmi.remote.RemoteItem;
 import org.apache.jackrabbit.rmi.remote.RemoteItemDef;
@@ -50,6 +52,8 @@
 import org.apache.jackrabbit.rmi.remote.RemoteRepository;
 import org.apache.jackrabbit.rmi.remote.RemoteRow;
 import org.apache.jackrabbit.rmi.remote.RemoteSession;
+import org.apache.jackrabbit.rmi.remote.RemoteVersion;
+import org.apache.jackrabbit.rmi.remote.RemoteVersionHistory;
 import org.apache.jackrabbit.rmi.remote.RemoteWorkspace;
 
 /**
@@ -139,6 +143,25 @@
      */
     public Node getNode(Session session, RemoteNode remote) {
         return new ClientNode(session, remote, this);
+    }
+
+    /**
+     * Creates and returns a {@link ClientVersion ClientVersion} instance.
+     *
+     * {@inheritDoc}
+     */
+    public Version getVersion(Session session, RemoteVersion remote) {
+        return new ClientVersion(session, remote, this);
+    }
+    
+    /**
+     * Creates and returns a {@link ClientVersionHistory ClientVersionHistory}
+     * instance.
+     *
+     * {@inheritDoc}
+     */
+    public VersionHistory getVersionHistory(Session session, RemoteVersionHistory remote) {
+        return new ClientVersionHistory(session, remote, this);
     }
 
     /**

Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientItem.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientItem.java?view=diff&r1=159669&r2=159670
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientItem.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientItem.java Fri Apr  1 01:23:37 2005
@@ -102,7 +102,7 @@
     /** {@inheritDoc} */
     public Node getParent() throws RepositoryException {
         try {
-            return getFactory().getNode(getSession(), remote.getParent());
+            return getNode(getSession(), remote.getParent());
         } catch (RemoteException ex) {
             throw new RemoteRepositoryException(ex);
         }

Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientNode.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientNode.java?view=diff&r1=159669&r2=159670
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientNode.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientNode.java Fri Apr  1 01:23:37 2005
@@ -99,7 +99,7 @@
     /** {@inheritDoc} */
     public Node addNode(String path) throws RepositoryException {
         try {
-            return getFactory().getNode(getSession(), remote.addNode(path));
+            return getNode(getSession(), remote.addNode(path));
         } catch (RemoteException ex) {
             throw new RemoteRepositoryException(ex);
         }
@@ -109,7 +109,7 @@
     public Node addNode(String path, String type) throws RepositoryException {
         try {
             RemoteNode node = remote.addNode(path, type);
-            return getFactory().getNode(getSession(), node);
+            return getNode(getSession(), node);
         } catch (RemoteException ex) {
             throw new RemoteRepositoryException(ex);
         }
@@ -203,7 +203,7 @@
     /** {@inheritDoc} */
     public Node getNode(String path) throws RepositoryException {
         try {
-            return getFactory().getNode(getSession(), remote.getNode(path));
+            return getNode(getSession(), remote.getNode(path));
         } catch (RemoteException ex) {
             throw new RemoteRepositoryException(ex);
         }
@@ -385,9 +385,11 @@
 
     /** {@inheritDoc} */
     public Version checkin() throws RepositoryException {
-        // TODO Auto-generated method stub
-        // return null;
-        throw new UnsupportedRepositoryOperationException();
+        try {
+            return getFactory().getVersion(getSession(), remote.checkin());
+        } catch (RemoteException ex) {
+            throw new RemoteRepositoryException(ex);
+        }
     }
 
     /** {@inheritDoc} */
@@ -420,14 +422,20 @@
 
     /** {@inheritDoc} */
     public void cancelMerge(Version version) throws RepositoryException {
-        // TODO Auto-generated method stub
-        throw new UnsupportedRepositoryOperationException();
+        try {
+            remote.cancelMerge(version.getUUID());
+        } catch (RemoteException ex) {
+            throw new RemoteRepositoryException(ex);
+        }
     }
 
     /** {@inheritDoc} */
     public void doneMerge(Version version) throws RepositoryException {
-        // TODO Auto-generated method stub
-        throw new UnsupportedRepositoryOperationException();
+        try {
+            remote.doneMerge(version.getUUID());
+        } catch (RemoteException ex) {
+            throw new RemoteRepositoryException(ex);
+        }
     }
 
     /** {@inheritDoc} */
@@ -462,15 +470,21 @@
     /** {@inheritDoc} */
     public void restore(Version version, boolean removeExisting)
             throws RepositoryException {
-        // TODO Auto-generated method stub
-        throw new UnsupportedRepositoryOperationException();
+        try {
+            remote.restoreByUUID(version.getUUID(), removeExisting);
+        } catch (RemoteException ex) {
+            throw new RemoteRepositoryException(ex);
+        }
     }
 
     /** {@inheritDoc} */
     public void restore(Version version, String path, boolean removeExisting)
             throws RepositoryException {
-        // TODO Auto-generated method stub
-        throw new UnsupportedRepositoryOperationException();
+        try {
+            remote.restore(version.getUUID(), path, removeExisting);
+        } catch (RemoteException ex) {
+            throw new RemoteRepositoryException(ex);
+        }
     }
 
     /** {@inheritDoc} */
@@ -516,16 +530,20 @@
 
     /** {@inheritDoc} */
     public VersionHistory getVersionHistory() throws RepositoryException {
-        // TODO Auto-generated method stub
-        // return null;
-        throw new UnsupportedRepositoryOperationException();
+        try {
+            return getFactory().getVersionHistory(getSession(), remote.getVersionHistory());
+        } catch (RemoteException ex) {
+            throw new RemoteRepositoryException(ex);
+        }
     }
 
     /** {@inheritDoc} */
     public Version getBaseVersion() throws RepositoryException {
-        // TODO Auto-generated method stub
-        // return null;
-        throw new UnsupportedRepositoryOperationException();
+        try {
+            return getFactory().getVersion(getSession(), remote.getBaseVersion());
+        } catch (RemoteException ex) {
+            throw new RemoteRepositoryException(ex);
+        }
     }
 
     /** {@inheritDoc} */

Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientObject.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientObject.java?view=diff&r1=159669&r2=159670
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientObject.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientObject.java Fri Apr  1 01:23:37 2005
@@ -26,16 +26,21 @@
 import javax.jcr.nodetype.NodeType;
 import javax.jcr.nodetype.NodeTypeIterator;
 import javax.jcr.nodetype.PropertyDef;
+import javax.jcr.version.Version;
+import javax.jcr.version.VersionIterator;
 
 import org.apache.jackrabbit.rmi.iterator.ArrayNodeIterator;
 import org.apache.jackrabbit.rmi.iterator.ArrayNodeTypeIterator;
 import org.apache.jackrabbit.rmi.iterator.ArrayPropertyIterator;
+import org.apache.jackrabbit.rmi.iterator.ArrayVersionIterator;
 import org.apache.jackrabbit.rmi.remote.RemoteItem;
 import org.apache.jackrabbit.rmi.remote.RemoteNode;
 import org.apache.jackrabbit.rmi.remote.RemoteNodeDef;
 import org.apache.jackrabbit.rmi.remote.RemoteNodeType;
 import org.apache.jackrabbit.rmi.remote.RemoteProperty;
 import org.apache.jackrabbit.rmi.remote.RemotePropertyDef;
+import org.apache.jackrabbit.rmi.remote.RemoteVersion;
+import org.apache.jackrabbit.rmi.remote.RemoteVersionHistory;
 
 /**
  * Base class for client adapter objects. The only purpose of
@@ -75,6 +80,9 @@
      * whether to instantiate a {@link Property Property},
      * a {@link Node Node}, or an {@link Item Item} adapter using
      * the local adapter factory.
+     * <p>
+     * If the remote item is a {@link RemoteNode}, this method delegates
+     * to {@link #getNode(Session, RemoteNode)}.
      *
      * @param session current session
      * @param remote remote item
@@ -84,13 +92,35 @@
         if (remote instanceof RemoteProperty) {
             return factory.getProperty(session, (RemoteProperty) remote);
         } else if (remote instanceof RemoteNode) {
-            return factory.getNode(session, (RemoteNode) remote);
+            return getNode(session, (RemoteNode) remote);
         } else {
             return factory.getItem(session, remote);
         }
     }
 
     /**
+     * Utility method to create a local adapter for a remote node.
+     * This method introspects the remote reference to determine
+     * whether to instantiate a {@link Node Node},
+     * a {@link javax.jcr.version.VersionHistory VersionHistory}, or a
+     *  {@link Version Version} adapter using
+     * the local adapter factory.
+     *
+     * @param session current session
+     * @param remote remote node
+     * @return local node, version, or version history adapter
+     */
+    protected Node getNode(Session session, RemoteNode remote) {
+        if (remote instanceof RemoteVersion) {
+            return factory.getVersion(session, (RemoteVersion) remote);
+        } else if (remote instanceof RemoteVersionHistory) {
+            return factory.getVersionHistory(session, (RemoteVersionHistory) remote);
+        } else {
+            return factory.getNode(session, (RemoteNode) remote);
+        }
+    }
+
+    /**
      * Utility method for creating a property iterator for an array
      * of remote properties. The properties in the returned iterator
      * are created using the local adapter factory.
@@ -130,12 +160,52 @@
         if (remotes != null) {
             Node[] nodes = new Node[remotes.length];
             for (int i = 0; i < remotes.length; i++) {
-                nodes[i] = factory.getNode(session, remotes[i]);
+                nodes[i] = getNode(session, remotes[i]);
             }
             return new ArrayNodeIterator(nodes);
         } else {
             return new ArrayNodeIterator(new Node[0]); // for safety
         }
+    }
+
+    /**
+     * Utility method for creating a version array for an array
+     * of remote versions. The versions in the returned array
+     * are created using the local adapter factory.
+     * <p>
+     * A <code>null</code> input is treated as an empty array.
+     *
+     * @param session current session
+     * @param remotes remote versions
+     * @return local version array
+     */
+    protected Version[] getVersionArray(
+            Session session, RemoteVersion[] remotes) {
+        if (remotes != null) {
+            Version[] versions = new Version[remotes.length];
+            for (int i = 0; i < remotes.length; i++) {
+                versions[i] = factory.getVersion(session, remotes[i]);
+            }
+            return versions;
+        } else {
+            return new Version[0]; // for safety
+        }
+    }
+
+    /**
+     * Utility method for creating a version iterator for an array
+     * of remote versions. The versions in the returned iterator
+     * are created using the local adapter factory.
+     * <p>
+     * A <code>null</code> input is treated as an empty array.
+     *
+     * @param session current session
+     * @param remotes remote versions
+     * @return local version iterator
+     */
+    protected VersionIterator getVersionIterator(
+            Session session, RemoteVersion[] remotes) {
+        return new ArrayVersionIterator(getVersionArray(session, remotes));
     }
 
     /**

Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientQueryResult.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientQueryResult.java?view=diff&r1=159669&r2=159670
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientQueryResult.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientQueryResult.java Fri Apr  1 01:23:37 2005
@@ -99,7 +99,7 @@
             if (remotes != null) {
                 Node[] nodes = new Node[remotes.length];
                 for (int i = 0; i < nodes.length; i++) {
-                    nodes[i] = getFactory().getNode(session, remotes[i]);
+                    nodes[i] = getNode(session, remotes[i]);
                 }
                 return new ArrayNodeIterator(nodes);
             } else {

Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientSession.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientSession.java?view=diff&r1=159669&r2=159670
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientSession.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientSession.java Fri Apr  1 01:23:37 2005
@@ -136,7 +136,7 @@
     /** {@inheritDoc} */
     public Node getRootNode() throws RepositoryException {
         try {
-            return getFactory().getNode(this, remote.getRootNode());
+            return getNode(this, remote.getRootNode());
         } catch (RemoteException ex) {
             throw new RemoteRepositoryException(ex);
         }
@@ -145,7 +145,7 @@
     /** {@inheritDoc} */
     public Node getNodeByUUID(String uuid) throws RepositoryException {
         try {
-            return getFactory().getNode(this, remote.getNodeByUUID(uuid));
+            return getNode(this, remote.getNodeByUUID(uuid));
         } catch (RemoteException ex) {
             throw new RemoteRepositoryException(ex);
         }

Added: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientVersion.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientVersion.java?view=auto&rev=159670
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientVersion.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientVersion.java Fri Apr  1 01:23:37 2005
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.rmi.client;
+
+import java.rmi.RemoteException;
+import java.util.Calendar;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.version.Version;
+
+import org.apache.jackrabbit.rmi.remote.RemoteVersion;
+
+/**
+ * Local adapter for the JCR-RMI
+ * {@link org.apache.jackrabbit.rmi.remote.RemoteVersion RemoteVersion}
+ * interface. This class makes a remote version locally available using
+ * the JCR {@link javax.jcr.version.Version Version} interface.
+ *
+ * @author Felix Meschberger
+ * @see javax.jcr.version.Version
+ * @see org.apache.jackrabbit.rmi.remote.RemoteVersion
+ */
+public class ClientVersion extends ClientNode implements Version {
+
+    /** The adapted remote version. */
+    private RemoteVersion remote;
+
+    /**
+     * Creates a local adapter for the given remote version.
+     *
+     * @param session current session
+     * @param remote  remote version
+     * @param factory local adapter factory
+     */
+    public ClientVersion(Session session, RemoteVersion remote,
+        LocalAdapterFactory factory) {
+        super(session, remote, factory);
+        this.remote = remote;
+    }
+
+    /** {@inheritDoc} */
+    public Calendar getCreated() throws RepositoryException {
+        try {
+            return remote.getCreated();
+        } catch (RemoteException ex) {
+            throw new RemoteRepositoryException(ex);
+        }
+    }
+
+    /** {@inheritDoc} */
+    public Version[] getSuccessors() throws RepositoryException {
+        try {
+            return getVersionArray(getSession(), remote.getSuccessors());
+        } catch (RemoteException ex) {
+            throw new RemoteRepositoryException(ex);
+        }
+    }
+
+    /** {@inheritDoc} */
+    public Version[] getPredecessors() throws RepositoryException {
+        try {
+            return getVersionArray(getSession(), remote.getPredecessors());
+        } catch (RemoteException ex) {
+            throw new RemoteRepositoryException(ex);
+        }
+    }
+}
\ No newline at end of file

Added: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientVersionHistory.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientVersionHistory.java?view=auto&rev=159670
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientVersionHistory.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientVersionHistory.java Fri Apr  1 01:23:37 2005
@@ -0,0 +1,169 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.rmi.client;
+
+import java.rmi.RemoteException;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.version.Version;
+import javax.jcr.version.VersionException;
+import javax.jcr.version.VersionHistory;
+import javax.jcr.version.VersionIterator;
+
+import org.apache.jackrabbit.rmi.remote.RemoteNode;
+import org.apache.jackrabbit.rmi.remote.RemoteVersion;
+import org.apache.jackrabbit.rmi.remote.RemoteVersionHistory;
+
+/**
+ * Local adapter for the JCR-RMI
+ * {@link org.apache.jackrabbit.rmi.remote.RemoteVersionHistory RemoteVersionHistory}
+ * interface. This class makes a remote version history locally available using
+ * the JCR {@link javax.jcr.version.VersionHistory VersionHistory} interface.
+ *
+ * @author Felix Meschberger
+ * @see javax.jcr.version.VersionHistory
+ * @see org.apache.jackrabbit.rmi.remote.RemoteVersionHistory
+ */
+public class ClientVersionHistory extends ClientNode implements VersionHistory {
+
+    /** The adapted remote version history. */
+    private RemoteVersionHistory remote;
+
+    /**
+     * Creates a local adapter for the given remote version history.
+     *
+     * @param session current session
+     * @param remote  remote version history
+     * @param factory local adapter factory
+     */
+    public ClientVersionHistory(Session session, RemoteVersionHistory remote,
+        LocalAdapterFactory factory) {
+        super(session, remote, factory);
+        this.remote = remote;
+    }
+
+    public Version getRootVersion() throws RepositoryException {
+        try {
+            return getFactory().getVersion(getSession(), remote.getRootVersion());
+        } catch (RemoteException ex) {
+            throw new RemoteRepositoryException(ex);
+        }
+    }
+
+    /** {@inheritDoc} */
+    public VersionIterator getAllVersions() throws RepositoryException {
+        try {
+            return getVersionIterator(getSession(), remote.getAllVersions());
+        } catch (RemoteException ex) {
+            throw new RemoteRepositoryException(ex);
+        }
+    }
+
+    /** {@inheritDoc} */
+    public Version getVersion(String versionName) throws VersionException,
+        RepositoryException {
+        try {
+            return getFactory().getVersion(getSession(), remote.getVersion(versionName));
+        } catch (RemoteException ex) {
+            throw new RemoteRepositoryException(ex);
+        }
+    }
+
+    /** {@inheritDoc} */
+    public Version getVersionByLabel(String label) throws RepositoryException {
+        try {
+            return getFactory().getVersion(getSession(), remote.getVersionByLabel(label));
+        } catch (RemoteException ex) {
+            throw new RemoteRepositoryException(ex);
+        }
+    }
+
+    /** {@inheritDoc} */
+    public void addVersionLabel(String versionName, String label,
+            boolean moveLabel) throws VersionException, RepositoryException {
+        try {
+            remote.addVersionLabel(versionName, label, moveLabel);
+        } catch (RemoteException ex) {
+            throw new RemoteRepositoryException(ex);
+        }
+    }
+
+    /** {@inheritDoc} */
+    public void removeVersionLabel(String label)
+            throws VersionException, RepositoryException {
+        try {
+            remote.removeVersionLabel(label);
+        } catch (RemoteException ex) {
+            throw new RemoteRepositoryException(ex);
+        }
+    }
+
+    /** {@inheritDoc} */
+    public boolean hasVersionLabel(String label) {
+        try {
+            return remote.hasVersionLabel(label);
+        } catch (RemoteException ex) {
+            // grok the exception and assume label is missing
+            return false;
+        }
+    }
+
+    /** {@inheritDoc} */
+    public boolean hasVersionLabel(Version version, String label)
+            throws VersionException, RepositoryException {
+        try {
+            String versionUUID = version.getUUID();
+            return remote.hasVersionLabel(versionUUID, label);
+        } catch (RemoteException ex) {
+            throw new RemoteRepositoryException(ex);
+        }
+    }
+
+    /** {@inheritDoc} */
+    public String[] getVersionLabels() {
+        try {
+            return remote.getVersionLabels();
+        } catch (RemoteException ex) {
+            // grok the exception and return an empty array
+            return new String[0];
+        }
+    }
+
+    /** {@inheritDoc} */
+    public String[] getVersionLabels(Version version)
+            throws VersionException, RepositoryException {
+        try {
+            String versionUUID = version.getUUID();
+            return remote.getVersionLabels(versionUUID);
+        } catch (RemoteException ex) {
+            throw new RemoteRepositoryException(ex);
+        }
+    }
+
+    /** {@inheritDoc} */
+    public void removeVersion(String versionName)
+            throws UnsupportedRepositoryOperationException, VersionException,
+            RepositoryException {
+        try {
+            remote.removeVersion(versionName);
+        } catch (RemoteException ex) {
+            throw new RemoteRepositoryException(ex);
+        }
+    }
+}

Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/LocalAdapterFactory.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/LocalAdapterFactory.java?view=diff&r1=159669&r2=159670
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/LocalAdapterFactory.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/LocalAdapterFactory.java Fri Apr  1 01:23:37 2005
@@ -33,6 +33,8 @@
 import javax.jcr.query.QueryManager;
 import javax.jcr.query.QueryResult;
 import javax.jcr.query.Row;
+import javax.jcr.version.Version;
+import javax.jcr.version.VersionHistory;
 
 import org.apache.jackrabbit.rmi.remote.RemoteItem;
 import org.apache.jackrabbit.rmi.remote.RemoteItemDef;
@@ -50,6 +52,8 @@
 import org.apache.jackrabbit.rmi.remote.RemoteRepository;
 import org.apache.jackrabbit.rmi.remote.RemoteRow;
 import org.apache.jackrabbit.rmi.remote.RemoteSession;
+import org.apache.jackrabbit.rmi.remote.RemoteVersion;
+import org.apache.jackrabbit.rmi.remote.RemoteVersionHistory;
 import org.apache.jackrabbit.rmi.remote.RemoteWorkspace;
 
 /**
@@ -149,6 +153,24 @@
      * @return local node adapter
      */
     Node getNode(Session session, RemoteNode remote);
+
+    /**
+     * Factory method for creating a local adapter for a remote version.
+     *
+     * @param session current session
+     * @param remote remote version
+     * @return local version adapter
+     */
+    Version getVersion(Session session, RemoteVersion remote);
+
+    /**
+     * Factory method for creating a local adapter for a remote version history.
+     *
+     * @param session current session
+     * @param remote remote version history
+     * @return local version history adapter
+     */
+    VersionHistory getVersionHistory(Session session, RemoteVersionHistory remote);
 
     /**
      * Factory method for creating a local adapter for a remote node type.

Added: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/iterator/ArrayVersionIterator.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/iterator/ArrayVersionIterator.java?view=auto&rev=159670
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/iterator/ArrayVersionIterator.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/iterator/ArrayVersionIterator.java Fri Apr  1 01:23:37 2005
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.rmi.iterator;
+
+import javax.jcr.version.Version;
+import javax.jcr.version.VersionIterator;
+
+/**
+ * Array implementation of the JCR
+ * {@link javax.jcr.version.VersionIterator VersionIterator} interface.
+ * This class is used by the JCR-RMI client adapters to convert
+ * version arrays to iterators.
+ *
+ * @author Felix Meschberger
+ */
+public class ArrayVersionIterator extends ArrayIterator implements VersionIterator {
+
+    /**
+     * Creates an iterator for the given array of nodes.
+     *
+     * @param nodes the nodes to iterate
+     */
+    public ArrayVersionIterator(Version[] versions) {
+        super(versions);
+    }
+
+    /** {@inheritDoc} */
+    public Version nextVersion() {
+        return (Version) next();
+    }
+
+}

Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteNode.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteNode.java?view=diff&r1=159669&r2=159670
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteNode.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteNode.java Fri Apr  1 01:23:37 2005
@@ -351,6 +351,15 @@
 
     /**
      * Remote version of the
+     * {@link javax.jcr.Node#checkin() Node.checkin()} method.
+     *
+     * @throws RepositoryException on repository errors
+     * @throws RemoteException on RMI errors
+     */
+    RemoteVersion checkin() throws RepositoryException, RemoteException;
+
+    /**
+     * Remote version of the
      * {@link javax.jcr.Node#checkout() Node.checkout()} method.
      *
      * @throws RepositoryException on repository errors
@@ -383,6 +392,30 @@
 
     /**
      * Remote version of the
+     * {@link javax.jcr.Node#cancelMerge(javax.jcr.version.Version) Node.cancelMerge(Version)}
+     * method.
+     *
+     * @param versionUUID The UUID of the version whose labels are to be returned.
+     * @throws RepositoryException on repository errors
+     * @throws RemoteException on RMI errors
+     */
+    void cancelMerge(String versionUUID)
+            throws RepositoryException, RemoteException;
+
+    /**
+     * Remote version of the
+     * {@link javax.jcr.Node#doneMerge(javax.jcr.version.Version) Node.doneMerge(Version)}
+     * method.
+     *
+     * @param versionUUID The UUID of the version whose labels are to be returned.
+     * @throws RepositoryException on repository errors
+     * @throws RemoteException on RMI errors
+     */
+    void doneMerge(String versionUUID)
+            throws RepositoryException, RemoteException;
+
+    /**
+     * Remote version of the
      * {@link javax.jcr.Node#getCorrespondingNodePath(String) Node.getCorrespondingNodePath(String)}
      * method.
      *
@@ -419,6 +452,36 @@
 
     /**
      * Remote version of the
+     * {@link javax.jcr.Node#restore(javax.jcr.version.Version, boolean) Node.restore(Version,boolean)}
+     * method.
+     * <p>
+     * This method has been rename to prevent a naming clash with
+     * {@link #restore(String, boolean)}.
+     *
+     * @param versionUUID The UUID of the version whose labels are to be returned.
+     * @param removeExisting flag to remove conflicting nodes
+     * @throws RepositoryException on repository errors
+     * @throws RemoteException on RMI errors
+     */
+    void restoreByUUID(String versionUUID, boolean removeExisting)
+            throws RepositoryException, RemoteException;
+
+    /**
+     * Remote version of the
+     * {@link javax.jcr.Node#restore(javax.jcr.version.Version, String, boolean) Node.restore(Version,String,boolean)}
+     * method.
+     *
+     * @param versionUUID The UUID of the version whose labels are to be returned.
+     * @param path the path to which the version is to be restored
+     * @param removeExisting flag to remove conflicting nodes
+     * @throws RepositoryException on repository errors
+     * @throws RemoteException on RMI errors
+     */
+    void restore(String versionUUID, String path, boolean removeExisting)
+            throws RepositoryException, RemoteException;
+
+    /**
+     * Remote version of the
      * {@link javax.jcr.Node#restoreByLabel(String,boolean) Node.restoreByLabel(String,boolean)}
      * method.
      *
@@ -471,6 +534,26 @@
      * @throws RemoteException on RMI errors
      */
     boolean isCheckedOut() throws RepositoryException, RemoteException;
+
+    /**
+     * Remote version of the
+     * {@link javax.jcr.Node#getVersionHistory() Node.getVersionHistory()} method.
+     *
+     * @return the remote version history.
+     * @throws RepositoryException on repository errors
+     * @throws RemoteException on RMI errors
+     */
+    RemoteVersionHistory getVersionHistory() throws RepositoryException, RemoteException;
+
+    /**
+     * Remote version of the
+     * {@link javax.jcr.Node#getBaseVersion() Node.getBaseVersion()} method.
+     *
+     * @return the remote base version
+     * @throws RepositoryException on repository errors
+     * @throws RemoteException on RMI errors
+     */
+    RemoteVersion getBaseVersion() throws RepositoryException, RemoteException;
 
     /**
      * Remote version of the

Added: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteVersion.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteVersion.java?view=auto&rev=159670
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteVersion.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteVersion.java Fri Apr  1 01:23:37 2005
@@ -0,0 +1,90 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.rmi.remote;
+
+import java.rmi.RemoteException;
+import java.util.Calendar;
+
+import javax.jcr.RepositoryException;
+
+
+/**
+ * Remote version of the JCR {@link javax.jcr.version.Version Version} interface.
+ * Used by the {@link org.apache.jackrabbit.rmi.server.ServerVersion ServerVersion}
+ * and {@link org.apache.jackrabbit.rmi.client.ClientVersion ClientVersion}
+ * adapters to provide transparent RMI access to remote versions.
+ * <p>
+ * The methods in this interface are documented only with a reference
+ * to a corresponding Version method. The remote object will simply forward
+ * the method call to the underlying Version instance. Argument and return
+ * values, as well as possible exceptions, are copied over the network.
+ * Complex return values (like Versions) are returned as remote
+ * references to the corresponding remote interfaces. Iterator values
+ * are transmitted as object arrays. RMI errors are signalled with
+ * RemoteExceptions.
+ *
+ * @author Felix Meschberger
+ * @see javax.jcr.version.Version
+ * @see org.apache.jackrabbit.rmi.client.ClientVersion
+ * @see org.apache.jackrabbit.rmi.server.ServerVersion
+ */
+public interface RemoteVersion extends RemoteNode {
+
+    /**
+     * Remote version of the
+     * {@link javax.jcr.version.Version#getContainingHistory() Version.getContainingHistory()} method.
+     *
+     * @return a <code>RemoteVersionHistory</code> object.
+     * 
+     * @throws RepositoryException on repository errors
+     * @throws RemoteException on RMI errors
+     */
+//     public RemoteVersionHistory getContainingHistory() throws RepositoryException;
+
+    /**
+     * Remote version of the
+     * {@link javax.jcr.version.Version#getCreated() Version.getCreated()} method.
+     *
+     * @return a <code>Calendar</code> object.
+     * 
+     * @throws RepositoryException on repository errors
+     * @throws RemoteException on RMI errors
+     */
+    public Calendar getCreated() throws RepositoryException, RemoteException;
+
+    /**
+     * Remote version of the
+     * {@link javax.jcr.version.Version#getSuccessors() Version.getSuccessors()} method.
+     *
+     * @return a <code>RemoteVersion</code> array.
+     * 
+     * @throws RepositoryException on repository errors
+     * @throws RemoteException on RMI errors
+     */
+    public RemoteVersion[] getSuccessors() throws RepositoryException, RemoteException;
+
+    /**
+     * Remote version of the
+     * {@link javax.jcr.version.Version#getPredecessors() Version.getPredecessors()} method.
+     *
+     * @return a <code>RemoteVersion</code> array.
+     * 
+     * @throws RepositoryException on repository errors
+     * @throws RemoteException on RMI errors
+     */
+    public RemoteVersion[] getPredecessors() throws RepositoryException, RemoteException;
+}

Added: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteVersionHistory.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteVersionHistory.java?view=auto&rev=159670
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteVersionHistory.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteVersionHistory.java Fri Apr  1 01:23:37 2005
@@ -0,0 +1,198 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.rmi.remote;
+
+import java.rmi.RemoteException;
+
+import javax.jcr.RepositoryException;
+
+/**
+ * Remote version of the JCR 
+ * {@link javax.jcr.version.VersionHistory VersionHistory} interface. Used by
+ * the 
+ * {@link org.apache.jackrabbit.rmi.server.ServerVersionHistory ServerVersionHistory}
+ * and
+ * {@link org.apache.jackrabbit.rmi.client.ClientVersionHistory ClientVersionHistory}
+ * adapters to provide transparent RMI access to remote version histories.
+ * <p>
+ * The methods in this interface are documented only with a reference
+ * to a corresponding VersionHistory method. The remote object will simply
+ * forward the method call to the underlying VersionHistory instance. Argument
+ * and return values, as well as possible exceptions, are copied over the
+ * network. Complex return values (like Versions) are returned as remote
+ * references to the corresponding remote interfaces. Iterator values
+ * are transmitted as object arrays. RMI errors are signalled with
+ * RemoteExceptions.
+ *
+ * @author Felix Meschberger
+ * @see javax.jcr.version.Version
+ * @see org.apache.jackrabbit.rmi.client.ClientVersionHistory
+ * @see org.apache.jackrabbit.rmi.server.ServerVersionHistory
+ */
+public interface RemoteVersionHistory extends RemoteNode {
+
+    /**
+     * Remote version of the
+     * {@link javax.jcr.version.VersionHistory#getVersionableUUID() VersionHistory.getVersionableUUID()}
+     * method.
+     *
+     * @return the UUID of the versionable node for which this is the version history.
+     * @throws RepositoryException if an error occurs.
+     * @throws RemoteException on RMI errors
+     */
+//    public String getVersionableUUID() 
+//            throws RepositoryException, RemoteException;
+
+    /**
+     * Remote version of the
+     * {@link javax.jcr.version.VersionHistory#getRootVersion() VersionHistory.getRootVersion()}
+     * method.
+     *
+     * @return a <code>Version</code> object.
+     * @throws RepositoryException if an error occurs.
+     * @throws RemoteException on RMI errors
+     */
+    public RemoteVersion getRootVersion() 
+            throws RepositoryException, RemoteException;
+
+    /**
+     * Remote version of the
+     * {@link javax.jcr.version.VersionHistory#getAllVersions() VersionHistory.getAllVersions()}
+     * method.
+     *
+     * @return a <code>VersionIterator</code> object.
+     * @throws RepositoryException if an error occurs.
+     * @throws RemoteException on RMI errors
+     */
+    public RemoteVersion[] getAllVersions() 
+            throws RepositoryException, RemoteException;
+
+    /**
+     * Remote version of the
+     * {@link javax.jcr.version.VersionHistory#getVersion(String) VersionHistory.getVersion(String)}
+     * method.
+     *
+     * @param versionName a version name
+     * @return a <code>Version</code> object.
+     * @throws RepositoryException if an error occurs.
+     * @throws RemoteException on RMI errors
+     */
+    public RemoteVersion getVersion(String versionName)
+            throws RepositoryException, RemoteException;
+
+    /**
+     * Remote version of the
+     * {@link javax.jcr.version.VersionHistory#getVersionByLabel(String) VersionHistory.getVersionByLabel(String)}
+     * method.
+     *
+     * @param label a version label
+     * @return a <code>Version</code> object.
+     * @throws RepositoryException if an error occurs.
+     * @throws RemoteException on RMI errors
+     */
+    public RemoteVersion getVersionByLabel(String label)
+            throws RepositoryException, RemoteException;
+
+    /**
+     * Remote version of the
+     * {@link javax.jcr.version.VersionHistory#addVersionLabel(String, String, boolean) VersionHistory.addVersionLabel(String, String, boolean)}
+     * method.
+     *
+     * @param versionName the name of the version to which the label is to be added.
+     * @param label the label to be added.
+     * @param moveLabel if <code>true</code>, then if <code>label</code> is already assigned to a version in
+     * this version history, it is moved to the new version specified; if <code>false</code>, then attempting
+     * to assign an already used label will throw a <code>VersionException</code>.
+     *
+     * @throws RepositoryException if another error occurs.
+     * @throws RemoteException on RMI errors
+     */
+    public void addVersionLabel(String versionName, String label, boolean moveLabel)
+            throws RepositoryException, RemoteException;
+
+    /**
+     * Remote version of the
+     * {@link javax.jcr.version.VersionHistory#removeVersionLabel(String) VersionHistory.removeVersionLabel(String)}
+     * method.
+     *
+     * @param label a version label
+     * @throws RepositoryException if another error occurs.
+     * @throws RemoteException on RMI errors
+     */
+    public void removeVersionLabel(String label)
+            throws RepositoryException, RemoteException;
+
+    /**
+     * Remote version of the
+     * {@link javax.jcr.version.VersionHistory#hasVersionLabel(String) VersionHistory.hasVersionLabel(String)}
+     * method.
+     *
+     * @param label a version label
+     * @return a <code>boolean</code>
+     * @throws RemoteException on RMI errors
+     */
+    public boolean hasVersionLabel(String label) throws RemoteException;
+
+    /**
+     * Remote version of the
+     * {@link javax.jcr.version.VersionHistory#hasVersionLabel(RemoteVersion, String) hasVersionLabel(RemoteVersion, String)}
+     * method.
+     *
+     * @param versionUUID The UUID of the version whose labels are to be returned.
+     * @param label a version label
+     * @return a <code>boolean</code>.
+     * @throws RepositoryException if another error occurs.
+     * @throws RemoteException on RMI errors
+     */
+    public boolean hasVersionLabel(String versionUUID, String label)
+            throws RepositoryException, RemoteException;
+
+    /**
+     * Remote version of the
+     * {@link javax.jcr.version.VersionHistory#getVersionLabels() VersionHistory.getVersionLabels()}
+     * method.
+     *
+     * @return a <code>String</code> array containing all the labels of the version history
+     * @throws RemoteException on RMI errors
+     */
+    public String[] getVersionLabels() throws RemoteException;
+
+    /**
+     * Remote version of the
+     * {@link javax.jcr.version.VersionHistory#getVersionLabels(RemoteVersion) VersionHistory.getVersionLabels(RemoteVersion)}
+     * method.
+     *
+     * @param versionUUID The UUID of the version whose labels are to be returned.
+     * @return a <code>String</code> array containing all the labels of the given version
+     * @throws RepositoryException if another error occurs.
+     * @throws RemoteException on RMI errors
+     */
+    public String[] getVersionLabels(String versionUUID)
+            throws RepositoryException, RemoteException;
+
+    /**
+     * Remote version of the
+     * {@link javax.jcr.version.VersionHistory#removeVersion(String) VersionHistory.removeVersion(String)}
+     * method.
+     *
+     * @param versionName the name of a version in this version history.
+     * @throws RepositoryException if another error occurs.
+     * @throws RemoteException on RMI errors
+     */
+    public void removeVersion(String versionName)
+            throws RepositoryException, RemoteException;
+}

Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/RemoteAdapterFactory.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/RemoteAdapterFactory.java?view=diff&r1=159669&r2=159670
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/RemoteAdapterFactory.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/RemoteAdapterFactory.java Fri Apr  1 01:23:37 2005
@@ -35,6 +35,8 @@
 import javax.jcr.query.QueryManager;
 import javax.jcr.query.QueryResult;
 import javax.jcr.query.Row;
+import javax.jcr.version.Version;
+import javax.jcr.version.VersionHistory;
 
 import org.apache.jackrabbit.rmi.remote.RemoteItem;
 import org.apache.jackrabbit.rmi.remote.RemoteItemDef;
@@ -52,6 +54,8 @@
 import org.apache.jackrabbit.rmi.remote.RemoteRepository;
 import org.apache.jackrabbit.rmi.remote.RemoteRow;
 import org.apache.jackrabbit.rmi.remote.RemoteSession;
+import org.apache.jackrabbit.rmi.remote.RemoteVersion;
+import org.apache.jackrabbit.rmi.remote.RemoteVersionHistory;
 import org.apache.jackrabbit.rmi.remote.RemoteWorkspace;
 
 /**
@@ -155,6 +159,25 @@
      */
     RemoteNode getRemoteNode(Node node) throws RemoteException;
 
+    /**
+     * Returns a remote adapter for the given local version.
+     *
+     * @param version local version
+     * @return remote version adapter
+     * @throws RemoteException on RMI errors
+     */
+    RemoteVersion getRemoteVersion(Version version) throws RemoteException;
+
+    /**
+     * Returns a remote adapter for the given local version history.
+     *
+     * @param versionHistory local version history
+     * @return remote version history adapter
+     * @throws RemoteException on RMI errors
+     */
+    RemoteVersionHistory getRemoteVersionHistory(VersionHistory versionHistory) 
+            throws RemoteException;
+    
     /**
      * Returns a remote adapter for the given local node type.
      *

Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerAdapterFactory.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerAdapterFactory.java?view=diff&r1=159669&r2=159670
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerAdapterFactory.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerAdapterFactory.java Fri Apr  1 01:23:37 2005
@@ -35,6 +35,8 @@
 import javax.jcr.query.QueryManager;
 import javax.jcr.query.QueryResult;
 import javax.jcr.query.Row;
+import javax.jcr.version.Version;
+import javax.jcr.version.VersionHistory;
 
 import org.apache.jackrabbit.rmi.remote.RemoteItem;
 import org.apache.jackrabbit.rmi.remote.RemoteItemDef;
@@ -52,6 +54,8 @@
 import org.apache.jackrabbit.rmi.remote.RemoteRepository;
 import org.apache.jackrabbit.rmi.remote.RemoteRow;
 import org.apache.jackrabbit.rmi.remote.RemoteSession;
+import org.apache.jackrabbit.rmi.remote.RemoteVersion;
+import org.apache.jackrabbit.rmi.remote.RemoteVersionHistory;
 import org.apache.jackrabbit.rmi.remote.RemoteWorkspace;
 
 /**
@@ -139,6 +143,23 @@
         return new ServerNode(node, this);
     }
 
+    /**
+     * Creates a {@link ServerVersion ServerVersion} instance.
+     * {@inheritDoc}
+     */
+    public RemoteVersion getRemoteVersion(Version version) throws RemoteException {
+        return new ServerVersion(version, this);
+    }
+    
+    /**
+     * Creates a {@link ServerVersionHistory ServerVersionHistory} instance.
+     * {@inheritDoc}
+     */
+    public RemoteVersionHistory getRemoteVersionHistory(VersionHistory versionHistory)
+            throws RemoteException {
+        return new ServerVersionHistory(versionHistory, this);
+    }
+    
     /**
      * Creates a {@link ServerNodeType ServerNodeType} instance.
      * {@inheritDoc}

Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerItem.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerItem.java?view=diff&r1=159669&r2=159670
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerItem.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerItem.java Fri Apr  1 01:23:37 2005
@@ -104,7 +104,7 @@
     /** {@inheritDoc} */
     public RemoteNode getParent() throws RepositoryException, RemoteException {
         try {
-            return getFactory().getRemoteNode(item.getParent());
+            return getRemoteNode(item.getParent());
         } catch (RepositoryException ex) {
             throw getRepositoryException(ex);
         }

Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerNode.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerNode.java?view=diff&r1=159669&r2=159670
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerNode.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerNode.java Fri Apr  1 01:23:37 2005
@@ -21,8 +21,10 @@
 import javax.jcr.Node;
 import javax.jcr.Property;
 import javax.jcr.RepositoryException;
+import javax.jcr.Session;
 import javax.jcr.Value;
 import javax.jcr.lock.Lock;
+import javax.jcr.version.Version;
 
 import org.apache.jackrabbit.rmi.remote.RemoteItem;
 import org.apache.jackrabbit.rmi.remote.RemoteLock;
@@ -30,6 +32,8 @@
 import org.apache.jackrabbit.rmi.remote.RemoteNodeDef;
 import org.apache.jackrabbit.rmi.remote.RemoteNodeType;
 import org.apache.jackrabbit.rmi.remote.RemoteProperty;
+import org.apache.jackrabbit.rmi.remote.RemoteVersion;
+import org.apache.jackrabbit.rmi.remote.RemoteVersionHistory;
 
 /**
  * Remote adapter for the JCR {@link javax.jcr.Node Node} interface.
@@ -63,7 +67,7 @@
     public RemoteNode addNode(String path)
             throws RepositoryException, RemoteException {
         try {
-            return getFactory().getRemoteNode(node.addNode(path));
+            return getRemoteNode(node.addNode(path));
         } catch (RepositoryException ex) {
             throw getRepositoryException(ex);
         }
@@ -73,7 +77,7 @@
     public RemoteNode addNode(String path, String type)
             throws RepositoryException, RemoteException {
         try {
-            return getFactory().getRemoteNode(node.addNode(path, type));
+            return getRemoteNode(node.addNode(path, type));
         } catch (RepositoryException ex) {
             throw getRepositoryException(ex);
         }
@@ -219,7 +223,7 @@
     public RemoteNode getNode(String path)
             throws RepositoryException, RemoteException {
         try {
-            return getFactory().getRemoteNode(node.getNode(path));
+            return getRemoteNode(node.getNode(path));
         } catch (RepositoryException ex) {
             throw getRepositoryException(ex);
         }
@@ -307,6 +311,15 @@
     }
 
     /** {@inheritDoc} */
+    public RemoteVersion checkin() throws RepositoryException, RemoteException {
+        try {
+            return getFactory().getRemoteVersion(node.checkin());
+        } catch (RepositoryException ex) {
+            throw getRepositoryException(ex);
+        }
+    }
+
+    /** {@inheritDoc} */
     public void checkout() throws RepositoryException, RemoteException {
         try {
             node.checkout();
@@ -345,6 +358,26 @@
     }
 
     /** {@inheritDoc} */
+    public void cancelMerge(String versionUUID)
+            throws RepositoryException, RemoteException {
+        try {
+            node.cancelMerge(getVersionByUUID(versionUUID));
+        } catch (RepositoryException ex) {
+            throw getRepositoryException(ex);
+        }
+    }
+
+    /** {@inheritDoc} */
+    public void doneMerge(String versionUUID)
+            throws RepositoryException, RemoteException {
+        try {
+            node.doneMerge(getVersionByUUID(versionUUID));
+        } catch (RepositoryException ex) {
+            throw getRepositoryException(ex);
+        }
+    }
+
+    /** {@inheritDoc} */
     public void restore(String version, boolean removeExisting)
             throws RepositoryException, RemoteException {
         try {
@@ -355,6 +388,26 @@
     }
 
     /** {@inheritDoc} */
+    public void restoreByUUID(String versionUUID, boolean removeExisting)
+            throws RepositoryException, RemoteException {
+        try {
+            node.restore(getVersionByUUID(versionUUID), removeExisting);
+        } catch (RepositoryException ex) {
+            throw getRepositoryException(ex);
+        }
+    }
+
+    /** {@inheritDoc} */
+    public void restore(String versionUUID, String path, boolean removeExisting)
+            throws RepositoryException, RemoteException {
+        try {
+            node.restore(getVersionByUUID(versionUUID), path, removeExisting);
+        } catch (RepositoryException ex) {
+            throw getRepositoryException(ex);
+        }
+    }
+
+    /** {@inheritDoc} */
     public void restoreByLabel(String label, boolean removeExisting)
             throws RepositoryException, RemoteException {
         try {
@@ -393,6 +446,26 @@
     }
 
     /** {@inheritDoc} */
+    public RemoteVersionHistory getVersionHistory()
+            throws RepositoryException, RemoteException {
+        try {
+            return getFactory().getRemoteVersionHistory(node.getVersionHistory());
+        } catch (RepositoryException ex) {
+            throw getRepositoryException(ex);
+        }
+    }
+    
+    /** {@inheritDoc} */
+    public RemoteVersion getBaseVersion()
+            throws RepositoryException, RemoteException {
+        try {
+            return getFactory().getRemoteVersion(node.getBaseVersion());
+        } catch (RepositoryException ex) {
+            throw getRepositoryException(ex);
+        }
+    }
+    
+    /** {@inheritDoc} */
     public boolean isLocked() throws RepositoryException, RemoteException {
         try {
             return node.isLocked();
@@ -441,4 +514,33 @@
         }
     }
 
+    //---------- Implementation helper -----------------------------------------
+    
+    /**
+     * Returns the {@link Version} instance for the given UUID.
+     * 
+     * @param versionUUID The UUID of the version.
+     * 
+     * @return The version node.
+     * 
+     * @throws RepositoryException if an error occurrs accessing the version
+     *      node or if the UUID does not denote a version.
+     */
+    protected Version getVersionByUUID(String versionUUID)
+            throws RepositoryException {
+        
+        // get the version node by its UUID from the version history's session
+        Session session = node.getSession();
+        Node versionNode = session.getNodeByUUID(versionUUID);
+        
+        // check whether the node is a session, which it should be according
+        // to the spec (methods returning nodes should automatically return
+        // the correct type).
+        if (versionNode instanceof Version) {
+            return (Version) versionNode;
+        }
+        
+        // otherwise fail
+        throw new RepositoryException("Cannot find version " + versionUUID);
+    }
 }

Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerObject.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerObject.java?view=diff&r1=159669&r2=159670
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerObject.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerObject.java Fri Apr  1 01:23:37 2005
@@ -46,7 +46,10 @@
 import javax.jcr.nodetype.NodeTypeIterator;
 import javax.jcr.nodetype.PropertyDef;
 import javax.jcr.query.InvalidQueryException;
+import javax.jcr.version.Version;
 import javax.jcr.version.VersionException;
+import javax.jcr.version.VersionHistory;
+import javax.jcr.version.VersionIterator;
 
 import org.apache.jackrabbit.rmi.remote.RemoteItem;
 import org.apache.jackrabbit.rmi.remote.RemoteNode;
@@ -54,6 +57,7 @@
 import org.apache.jackrabbit.rmi.remote.RemoteNodeType;
 import org.apache.jackrabbit.rmi.remote.RemoteProperty;
 import org.apache.jackrabbit.rmi.remote.RemotePropertyDef;
+import org.apache.jackrabbit.rmi.remote.RemoteVersion;
 
 /**
  * Base class for remote adapters. The purpose of this class is to
@@ -151,6 +155,9 @@
      * method introspects the type of the local item and returns the
      * corresponding node, property, or item remote reference using the
      * remote adapter factory.
+     * <p>
+     * If the <code>item</code>, this method calls the
+     * {@link #getRemoteNode(Node)} to return the correct remote type.
      *
      * @param item local node, property, or item
      * @return remote node, property, or item reference
@@ -160,13 +167,34 @@
         if (item instanceof Property) {
             return factory.getRemoteProperty((Property) item);
         } else if (item instanceof Node) {
-            return factory.getRemoteNode((Node) item);
+            return getRemoteNode((Node) item);
         } else {
             return factory.getRemoteItem(item);
         }
     }
 
     /**
+     * Utility method for creating a remote reference for a local node.
+     * Unlike the factory method for creating remote node references, this
+     * method introspects the type of the local node and returns the
+     * corresponding node, version, or version history remote reference using
+     * the remote adapter factory.
+     *
+     * @param item local node, property, or item
+     * @return remote node, property, or item reference
+     * @throws RemoteException on RMI errors
+     */
+    protected RemoteNode getRemoteNode(Node node) throws RemoteException {
+        if (node instanceof Version) {
+            return factory.getRemoteVersion((Version) node);
+        } else if (node instanceof VersionHistory) {
+            return factory.getRemoteVersionHistory((VersionHistory) node);
+        } else {
+            return factory.getRemoteNode(node);
+        }
+    }
+
+    /**
      * Utility method for creating an array of remote references for
      * local properties. The remote references are created using the
      * remote adapter factory.
@@ -206,11 +234,59 @@
         if (iterator != null) {
             RemoteNode[] remotes = new RemoteNode[(int) iterator.getSize()];
             for (int i = 0; iterator.hasNext(); i++) {
-                remotes[i] = factory.getRemoteNode(iterator.nextNode());
+                remotes[i] = getRemoteNode(iterator.nextNode());
             }
             return remotes;
         } else {
             return new RemoteNode[0]; // for safety
+        }
+    }
+
+    /**
+     * Utility method for creating an array of remote references for
+     * local versions. The remote references are created using the
+     * remote adapter factory.
+     * <p>
+     * A <code>null</code> input is treated as an empty array.
+     *
+     * @param versions local version array
+     * @return remote version array
+     * @throws RemoteException on RMI errors
+     */
+    protected RemoteVersion[] getRemoteVersionArray(Version[] versions)
+            throws RemoteException {
+        if (versions != null) {
+            RemoteVersion[] remotes = new RemoteVersion[versions.length];
+            for (int i = 0; i < remotes.length; i++) {
+                remotes[i] = factory.getRemoteVersion(versions[i]);
+            }
+            return remotes;
+        } else {
+            return new RemoteVersion[0]; // for safety
+        }
+    }
+
+    /**
+     * Utility method for creating an array of remote references for
+     * local versions. The remote references are created using the
+     * remote adapter factory.
+     * <p>
+     * A <code>null</code> input is treated as an empty iterator.
+     *
+     * @param iterator local version iterator
+     * @return remote version array
+     * @throws RemoteException on RMI errors
+     */
+    protected RemoteVersion[] getRemoteVersionArray(VersionIterator iterator)
+            throws RemoteException {
+        if (iterator != null) {
+            RemoteVersion[] remotes = new RemoteVersion[(int) iterator.getSize()];
+            for (int i = 0; iterator.hasNext(); i++) {
+                remotes[i] = factory.getRemoteVersion(iterator.nextVersion());
+            }
+            return remotes;
+        } else {
+            return new RemoteVersion[0]; // for safety
         }
     }
 

Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerQueryResult.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerQueryResult.java?view=diff&r1=159669&r2=159670
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerQueryResult.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerQueryResult.java Fri Apr  1 01:23:37 2005
@@ -82,7 +82,7 @@
         if (iterator != null) {
             RemoteNode[] remotes = new RemoteNode[(int) iterator.getSize()];
             for (int i = 0; iterator.hasNext(); i++) {
-                remotes[i] = getFactory().getRemoteNode(iterator.nextNode());
+                remotes[i] = getRemoteNode(iterator.nextNode());
             }
             return remotes;
         } else {

Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerSession.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerSession.java?view=diff&r1=159669&r2=159670
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerSession.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerSession.java Fri Apr  1 01:23:37 2005
@@ -145,7 +145,7 @@
     public RemoteNode getNodeByUUID(String uuid)
             throws RepositoryException, RemoteException {
         try {
-            return getFactory().getRemoteNode(session.getNodeByUUID(uuid));
+            return getRemoteNode(session.getNodeByUUID(uuid));
         } catch (RepositoryException ex) {
             throw getRepositoryException(ex);
         }
@@ -155,7 +155,7 @@
     public RemoteNode getRootNode()
             throws RepositoryException, RemoteException {
         try {
-            return getFactory().getRemoteNode(session.getRootNode());
+            return getRemoteNode(session.getRootNode());
         } catch (RepositoryException ex) {
             throw getRepositoryException(ex);
         }

Added: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerVersion.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerVersion.java?view=auto&rev=159670
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerVersion.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerVersion.java Fri Apr  1 01:23:37 2005
@@ -0,0 +1,91 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.rmi.server;
+
+import java.rmi.RemoteException;
+import java.util.Calendar;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.version.Version;
+
+import org.apache.jackrabbit.rmi.remote.RemoteVersion;
+
+/**
+ * Remote adapter for the JCR {@link javax.jcr.version.Version Version} interface.
+ * This class makes a local version available as an RMI service using
+ * the {@link org.apache.jackrabbit.rmi.remote.RemoteVersion RemoteVersion}
+ * interface.
+ *
+ * @author Felix Meschberger
+ * @see javax.jcr.version.Version
+ * @see org.apache.jackrabbit.rmi.remote.RemoteVersion
+ */
+public class ServerVersion extends ServerNode implements RemoteVersion {
+    
+    /** The adapted local version. */
+    private Version version;
+
+    /**
+     * Creates a remote adapter for the given local version.
+     *
+     * @param version local version
+     * @param factory remote adapter factory
+     * @throws RemoteException on RMI errors
+     */
+    public ServerVersion(Version version, RemoteAdapterFactory factory)
+            throws RemoteException {
+        super(version, factory);
+        this.version = version;
+    }
+
+//  This is only available after 0.16.2
+//    /** {@inheritDoc} */
+//    public RemoteVersionHistory getContainingHistory() throws RepositoryException {
+//        try {
+//            return getFactory().getRemoteVersionHistory(version.getContainingHistory());
+//        } catch (RepositoryException ex) {
+//            throw getRepositoryException(ex);
+//        }
+//    }
+
+    /** {@inheritDoc} */
+    public Calendar getCreated() throws RepositoryException {
+        try {
+            return version.getCreated();
+        } catch (RepositoryException ex) {
+            throw getRepositoryException(ex);
+        }
+    }
+
+    /** {@inheritDoc} */
+    public RemoteVersion[] getSuccessors() throws RepositoryException, RemoteException {
+        try {
+            return getRemoteVersionArray(version.getSuccessors());
+        } catch (RepositoryException ex) {
+            throw getRepositoryException(ex);
+        }
+    }
+
+    /** {@inheritDoc} */
+    public RemoteVersion[] getPredecessors() throws RepositoryException, RemoteException {
+        try {
+            return getRemoteVersionArray(version.getPredecessors());
+        } catch (RepositoryException ex) {
+            throw getRepositoryException(ex);
+        }
+    }
+}

Added: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerVersionHistory.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerVersionHistory.java?view=auto&rev=159670
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerVersionHistory.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerVersionHistory.java Fri Apr  1 01:23:37 2005
@@ -0,0 +1,176 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.rmi.server;
+
+import java.rmi.RemoteException;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.version.Version;
+import javax.jcr.version.VersionHistory;
+
+import org.apache.jackrabbit.rmi.remote.RemoteVersion;
+import org.apache.jackrabbit.rmi.remote.RemoteVersionHistory;
+
+/**
+ * Remote adapter for the JCR {@link javax.jcr.version.VersionHistory VersionHistory}
+ * interface. This class makes a local version history available as an RMI
+ * service using the 
+ * {@link org.apache.jackrabbit.rmi.remote.RemoteVersionHistory RemoteVersionHistory}
+ * interface.
+ *
+ * @author Felix Meschberger
+ * @see javax.jcr.version.VersionHistory
+ * @see org.apache.jackrabbit.rmi.remote.RemoteVersionHistory
+ */
+public class ServerVersionHistory extends ServerNode
+        implements RemoteVersionHistory {
+
+    /** The adapted local version history. */
+    private VersionHistory versionHistory;
+
+    /**
+     * Creates a remote adapter for the given local version history.
+     *
+     * @param versionHistory local version history
+     * @param factory remote adapter factory
+     * @throws RemoteException on RMI errors
+     */
+    public ServerVersionHistory(VersionHistory versionHistory,
+            RemoteAdapterFactory factory) throws RemoteException {
+        super(versionHistory, factory);
+        this.versionHistory = versionHistory;
+    }
+
+    /** {@inheritDoc} */
+//    public String getVersionableUUID()
+//            throws RepositoryException, RemoteException {
+//        try {
+//            return versionHistory.getVersionableUUID();
+//        } catch (RepositoryException ex) {
+//            throw getRepositoryException(ex);
+//        }
+//    }
+
+    /** {@inheritDoc} */
+    public RemoteVersion getRootVersion()
+            throws RepositoryException, RemoteException {
+        try {
+            return getFactory().getRemoteVersion(versionHistory.getRootVersion());
+        } catch (RepositoryException ex) {
+            throw getRepositoryException(ex);
+        }
+    }
+
+    /** {@inheritDoc} */
+    public RemoteVersion[] getAllVersions() 
+            throws RepositoryException, RemoteException {
+        try {
+            return getRemoteVersionArray(versionHistory.getAllVersions());
+        } catch (RepositoryException ex) {
+            throw getRepositoryException(ex);
+        }
+    }
+
+    /** {@inheritDoc} */
+    public RemoteVersion getVersion(String versionName)
+        throws RepositoryException, RemoteException {
+        try {
+            Version version = versionHistory.getVersion(versionName);
+            return getFactory().getRemoteVersion(version);
+        } catch (RepositoryException ex) {
+            throw getRepositoryException(ex);
+        }
+    }
+
+    /** {@inheritDoc} */
+    public RemoteVersion getVersionByLabel(String label)
+            throws RepositoryException, RemoteException {
+        try {
+            Version version = versionHistory.getVersionByLabel(label);
+            return getFactory().getRemoteVersion(version);
+        } catch (RepositoryException ex) {
+            throw getRepositoryException(ex);
+        }
+    }
+
+    /** {@inheritDoc} */
+    public void addVersionLabel(String versionName, String label,
+            boolean moveLabel) throws RepositoryException, RemoteException {
+        try {
+            versionHistory.addVersionLabel(versionName, label, moveLabel);
+        } catch (RepositoryException ex) {
+            throw getRepositoryException(ex);
+        }
+    }
+
+    /** {@inheritDoc} */
+    public void removeVersionLabel(String label) throws RepositoryException,
+        RemoteException {
+        try {
+            versionHistory.removeVersionLabel(label);
+        } catch (RepositoryException ex) {
+            throw getRepositoryException(ex);
+        }
+    }
+
+    /** {@inheritDoc} */
+    public boolean hasVersionLabel(String label) throws RemoteException {
+        return versionHistory.hasVersionLabel(label);
+    }
+
+    /** {@inheritDoc} */
+    public boolean hasVersionLabel(String versionUUID, String label)
+        throws RepositoryException, RemoteException {
+        try {
+            Version version = getVersionByUUID(versionUUID);
+            return versionHistory.hasVersionLabel(version, label);
+        } catch (RepositoryException ex) {
+            throw getRepositoryException(ex);
+        }
+    }
+
+    /** {@inheritDoc} */
+    public String[] getVersionLabels() throws RemoteException {
+        return versionHistory.getVersionLabels();
+    }
+
+    /** {@inheritDoc} */
+    public String[] getVersionLabels(String versionUUID)
+            throws RepositoryException, RemoteException {
+        try {
+            Version version = getVersionByUUID(versionUUID);
+            return versionHistory.getVersionLabels(version);
+        } catch (ClassCastException cce) {
+            // we do not expect this here as nodes should be returned correctly
+            throw getRepositoryException(new RepositoryException(cce));
+        } catch (RepositoryException ex) {
+            throw getRepositoryException(ex);
+        }
+    }
+
+    /** {@inheritDoc} */
+    public void removeVersion(String versionName)
+            throws RepositoryException, RemoteException {
+        try {
+            versionHistory.removeVersion(versionName);
+        } catch (RepositoryException ex) {
+            throw getRepositoryException(ex);
+        }
+    }
+}



Mime
View raw message