Return-Path: Delivered-To: apmail-incubator-jackrabbit-commits-archive@www.apache.org Received: (qmail 28134 invoked from network); 1 Apr 2005 09:23:55 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 1 Apr 2005 09:23:55 -0000 Received: (qmail 19720 invoked by uid 500); 1 Apr 2005 09:23:48 -0000 Mailing-List: contact jackrabbit-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: jackrabbit-dev@incubator.apache.org Delivered-To: mailing list jackrabbit-commits@incubator.apache.org Received: (qmail 19682 invoked by uid 500); 1 Apr 2005 09:23:47 -0000 Delivered-To: apmail-incubator-jackrabbit-cvs@incubator.apache.org Received: (qmail 19495 invoked by uid 99); 1 Apr 2005 09:23:46 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Fri, 01 Apr 2005 01:23:44 -0800 Received: (qmail 28028 invoked by uid 65534); 1 Apr 2005 09:23:41 -0000 Message-ID: <20050401092341.28027.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Mailer: svnmailer-1.0.0-dev Date: Fri, 01 Apr 2005 09:23:41 -0000 Subject: svn commit: r159670 - in incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi: client/ iterator/ remote/ server/ To: jackrabbit-cvs@incubator.apache.org From: jukka@apache.org X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: jukka Date: Fri Apr 1 01:23:37 2005 New Revision: 159670 URL: http://svn.apache.org/viewcvs?view=3Drev&rev=3D159670 Log: JCR-94: Versioning support for JCR-RMI, contributed by Felix Meschberger. Added: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabb= it/rmi/client/ClientVersion.java incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabb= it/rmi/client/ClientVersionHistory.java incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabb= it/rmi/iterator/ArrayVersionIterator.java incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabb= it/rmi/remote/RemoteVersion.java incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabb= it/rmi/remote/RemoteVersionHistory.java incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabb= it/rmi/server/ServerVersion.java incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabb= it/rmi/server/ServerVersionHistory.java Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabb= it/rmi/client/ClientAdapterFactory.java incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabb= it/rmi/client/ClientItem.java incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabb= it/rmi/client/ClientNode.java incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabb= it/rmi/client/ClientObject.java incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabb= it/rmi/client/ClientQueryResult.java incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabb= it/rmi/client/ClientSession.java incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabb= it/rmi/client/LocalAdapterFactory.java incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabb= it/rmi/remote/RemoteNode.java incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabb= it/rmi/server/RemoteAdapterFactory.java incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabb= it/rmi/server/ServerAdapterFactory.java incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabb= it/rmi/server/ServerItem.java incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabb= it/rmi/server/ServerNode.java incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabb= it/rmi/server/ServerObject.java incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabb= it/rmi/server/ServerQueryResult.java incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabb= it/rmi/server/ServerSession.java Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/ja= ckrabbit/rmi/client/ClientAdapterFactory.java URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-r= mi/src/java/org/apache/jackrabbit/rmi/client/ClientAdapterFactory.java?view= =3Ddiff&r1=3D159669&r2=3D159670 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabb= it/rmi/client/ClientAdapterFactory.java (original) +++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabb= it/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; =20 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; =20 /** @@ -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); + } + =20 + /** + * Creates and returns a {@link ClientVersionHistory ClientVersionHist= ory} + * instance. + * + * {@inheritDoc} + */ + public VersionHistory getVersionHistory(Session session, RemoteVersion= History remote) { + return new ClientVersionHistory(session, remote, this); } =20 /** Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/ja= ckrabbit/rmi/client/ClientItem.java URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-r= mi/src/java/org/apache/jackrabbit/rmi/client/ClientItem.java?view=3Ddiff&r1= =3D159669&r2=3D159670 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabb= it/rmi/client/ClientItem.java (original) +++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabb= it/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/ja= ckrabbit/rmi/client/ClientNode.java URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-r= mi/src/java/org/apache/jackrabbit/rmi/client/ClientNode.java?view=3Ddiff&r1= =3D159669&r2=3D159670 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabb= it/rmi/client/ClientNode.java (original) +++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabb= it/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 RepositoryExcepti= on { try { RemoteNode node =3D 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 @@ =20 /** {@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); + } } =20 /** {@inheritDoc} */ @@ -420,14 +422,20 @@ =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); + } } =20 /** {@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); + } } =20 /** {@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); + } } =20 /** {@inheritDoc} */ public void restore(Version version, String path, boolean removeExisti= ng) throws RepositoryException { - // TODO Auto-generated method stub - throw new UnsupportedRepositoryOperationException(); + try { + remote.restore(version.getUUID(), path, removeExisting); + } catch (RemoteException ex) { + throw new RemoteRepositoryException(ex); + } } =20 /** {@inheritDoc} */ @@ -516,16 +530,20 @@ =20 /** {@inheritDoc} */ public VersionHistory getVersionHistory() throws RepositoryException { - // TODO Auto-generated method stub - // return null; - throw new UnsupportedRepositoryOperationException(); + try { + return getFactory().getVersionHistory(getSession(), remote.get= VersionHistory()); + } catch (RemoteException ex) { + throw new RemoteRepositoryException(ex); + } } =20 /** {@inheritDoc} */ public Version getBaseVersion() throws RepositoryException { - // TODO Auto-generated method stub - // return null; - throw new UnsupportedRepositoryOperationException(); + try { + return getFactory().getVersion(getSession(), remote.getBaseVer= sion()); + } catch (RemoteException ex) { + throw new RemoteRepositoryException(ex); + } } =20 /** {@inheritDoc} */ Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/ja= ckrabbit/rmi/client/ClientObject.java URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-r= mi/src/java/org/apache/jackrabbit/rmi/client/ClientObject.java?view=3Ddiff&= r1=3D159669&r2=3D159670 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabb= it/rmi/client/ClientObject.java (original) +++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabb= it/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; =20 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; =20 /** * 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. + *

+ * 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); } } =20 /** + * 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, (RemoteVersionHistor= y) 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 !=3D null) { Node[] nodes =3D new Node[remotes.length]; for (int i =3D 0; i < remotes.length; i++) { - nodes[i] =3D factory.getNode(session, remotes[i]); + nodes[i] =3D 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. + *

+ * A null 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 !=3D null) { + Version[] versions =3D new Version[remotes.length]; + for (int i =3D 0; i < remotes.length; i++) { + versions[i] =3D 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. + *

+ * A null 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)); } =20 /** Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/ja= ckrabbit/rmi/client/ClientQueryResult.java URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-r= mi/src/java/org/apache/jackrabbit/rmi/client/ClientQueryResult.java?view=3D= diff&r1=3D159669&r2=3D159670 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabb= it/rmi/client/ClientQueryResult.java (original) +++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabb= it/rmi/client/ClientQueryResult.java Fri Apr 1 01:23:37 2005 @@ -99,7 +99,7 @@ if (remotes !=3D null) { Node[] nodes =3D new Node[remotes.length]; for (int i =3D 0; i < nodes.length; i++) { - nodes[i] =3D getFactory().getNode(session, remotes[i])= ; + nodes[i] =3D getNode(session, remotes[i]); } return new ArrayNodeIterator(nodes); } else { Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/ja= ckrabbit/rmi/client/ClientSession.java URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-r= mi/src/java/org/apache/jackrabbit/rmi/client/ClientSession.java?view=3Ddiff= &r1=3D159669&r2=3D159670 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabb= it/rmi/client/ClientSession.java (original) +++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabb= it/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/jackr= abbit/rmi/client/ClientVersion.java URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-r= mi/src/java/org/apache/jackrabbit/rmi/client/ClientVersion.java?view=3Dauto= &rev=3D159670 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabb= it/rmi/client/ClientVersion.java (added) +++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabb= it/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 =3D 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/jackr= abbit/rmi/client/ClientVersionHistory.java URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-r= mi/src/java/org/apache/jackrabbit/rmi/client/ClientVersionHistory.java?view= =3Dauto&rev=3D159670 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabb= it/rmi/client/ClientVersionHistory.java (added) +++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabb= it/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 RemoteVers= ionHistory} + * interface. This class makes a remote version history locally available = using + * the JCR {@link javax.jcr.version.VersionHistory VersionHistory} interfa= ce. + * + * @author Felix Meschberger + * @see javax.jcr.version.VersionHistory + * @see org.apache.jackrabbit.rmi.remote.RemoteVersionHistory + */ +public class ClientVersionHistory extends ClientNode implements VersionHis= tory { + + /** 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 remo= te, + LocalAdapterFactory factory) { + super(session, remote, factory); + this.remote =3D remote; + } + + public Version getRootVersion() throws RepositoryException { + try { + return getFactory().getVersion(getSession(), remote.getRootVer= sion()); + } 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 RepositoryExcept= ion { + try { + return getFactory().getVersion(getSession(), remote.getVersion= ByLabel(label)); + } catch (RemoteException ex) { + throw new RemoteRepositoryException(ex); + } + } + + /** {@inheritDoc} */ + public void addVersionLabel(String versionName, String label, + boolean moveLabel) throws VersionException, RepositoryExceptio= n { + 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 =3D 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 =3D version.getUUID(); + return remote.getVersionLabels(versionUUID); + } catch (RemoteException ex) { + throw new RemoteRepositoryException(ex); + } + } + + /** {@inheritDoc} */ + public void removeVersion(String versionName) + throws UnsupportedRepositoryOperationException, VersionExcepti= on, + RepositoryException { + try { + remote.removeVersion(versionName); + } catch (RemoteException ex) { + throw new RemoteRepositoryException(ex); + } + } +} Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/ja= ckrabbit/rmi/client/LocalAdapterFactory.java URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-r= mi/src/java/org/apache/jackrabbit/rmi/client/LocalAdapterFactory.java?view= =3Ddiff&r1=3D159669&r2=3D159670 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabb= it/rmi/client/LocalAdapterFactory.java (original) +++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabb= it/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; =20 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; =20 /** @@ -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 hi= story. + * + * @param session current session + * @param remote remote version history + * @return local version history adapter + */ + VersionHistory getVersionHistory(Session session, RemoteVersionHistory= remote); =20 /** * Factory method for creating a local adapter for a remote node type. Added: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackr= abbit/rmi/iterator/ArrayVersionIterator.java URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-r= mi/src/java/org/apache/jackrabbit/rmi/iterator/ArrayVersionIterator.java?vi= ew=3Dauto&rev=3D159670 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabb= it/rmi/iterator/ArrayVersionIterator.java (added) +++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabb= it/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 Version= Iterator { + + /** + * 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/ja= ckrabbit/rmi/remote/RemoteNode.java URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-r= mi/src/java/org/apache/jackrabbit/rmi/remote/RemoteNode.java?view=3Ddiff&r1= =3D159669&r2=3D159670 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabb= it/rmi/remote/RemoteNode.java (original) +++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabb= it/rmi/remote/RemoteNode.java Fri Apr 1 01:23:37 2005 @@ -351,6 +351,15 @@ =20 /** * 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 @@ =20 /** * Remote version of the + * {@link javax.jcr.Node#cancelMerge(javax.jcr.version.Version) Node.c= ancelMerge(Version)} + * method. + * + * @param versionUUID The UUID of the version whose labels are to be r= eturned. + * @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.don= eMerge(Version)} + * method. + * + * @param versionUUID The UUID of the version whose labels are to be r= eturned. + * @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.getCorr= espondingNodePath(String)} * method. * @@ -419,6 +452,36 @@ =20 /** * Remote version of the + * {@link javax.jcr.Node#restore(javax.jcr.version.Version, boolean) N= ode.restore(Version,boolean)} + * method. + *

+ * 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 r= eturned. + * @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, bo= olean) Node.restore(Version,String,boolean)} + * method. + * + * @param versionUUID The UUID of the version whose labels are to be r= eturned. + * @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.restoreBy= Label(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, R= emoteException; + + /** + * Remote version of the + * {@link javax.jcr.Node#getBaseVersion() Node.getBaseVersion()} metho= d=2E + * + * @return the remote base version + * @throws RepositoryException on repository errors + * @throws RemoteException on RMI errors + */ + RemoteVersion getBaseVersion() throws RepositoryException, RemoteExcep= tion; =20 /** * Remote version of the Added: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackr= abbit/rmi/remote/RemoteVersion.java URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-r= mi/src/java/org/apache/jackrabbit/rmi/remote/RemoteVersion.java?view=3Dauto= &rev=3D159670 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabb= it/rmi/remote/RemoteVersion.java (added) +++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabb= it/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} int= erface. + * Used by the {@link org.apache.jackrabbit.rmi.server.ServerVersion Serve= rVersion} + * and {@link org.apache.jackrabbit.rmi.client.ClientVersion ClientVersion= } + * adapters to provide transparent RMI access to remote versions. + *

+ * The methods in this interface are documented only with a reference + * to a corresponding Version method. The remote object will simply forwar= d + * 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.get= ContainingHistory()} method. + * + * @return a RemoteVersionHistory object. + *=20 + * @throws RepositoryException on repository errors + * @throws RemoteException on RMI errors + */ +// public RemoteVersionHistory getContainingHistory() throws Repositor= yException; + + /** + * Remote version of the + * {@link javax.jcr.version.Version#getCreated() Version.getCreated()}= method. + * + * @return a Calendar object. + *=20 + * @throws RepositoryException on repository errors + * @throws RemoteException on RMI errors + */ + public Calendar getCreated() throws RepositoryException, RemoteExcepti= on; + + /** + * Remote version of the + * {@link javax.jcr.version.Version#getSuccessors() Version.getSuccess= ors()} method. + * + * @return a RemoteVersion array. + *=20 + * @throws RepositoryException on repository errors + * @throws RemoteException on RMI errors + */ + public RemoteVersion[] getSuccessors() throws RepositoryException, Rem= oteException; + + /** + * Remote version of the + * {@link javax.jcr.version.Version#getPredecessors() Version.getPrede= cessors()} method. + * + * @return a RemoteVersion array. + *=20 + * @throws RepositoryException on repository errors + * @throws RemoteException on RMI errors + */ + public RemoteVersion[] getPredecessors() throws RepositoryException, R= emoteException; +} Added: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackr= abbit/rmi/remote/RemoteVersionHistory.java URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-r= mi/src/java/org/apache/jackrabbit/rmi/remote/RemoteVersionHistory.java?view= =3Dauto&rev=3D159670 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabb= it/rmi/remote/RemoteVersionHistory.java (added) +++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabb= it/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=20 + * {@link javax.jcr.version.VersionHistory VersionHistory} interface. Used= by + * the=20 + * {@link org.apache.jackrabbit.rmi.server.ServerVersionHistory ServerVers= ionHistory} + * and + * {@link org.apache.jackrabbit.rmi.client.ClientVersionHistory ClientVers= ionHistory} + * adapters to provide transparent RMI access to remote version histories. + *

+ * 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. Argu= ment + * 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() Versio= nHistory.getVersionableUUID()} + * method. + * + * @return the UUID of the versionable node for which this is the vers= ion history. + * @throws RepositoryException if an error occurs. + * @throws RemoteException on RMI errors + */ +// public String getVersionableUUID()=20 +// throws RepositoryException, RemoteException; + + /** + * Remote version of the + * {@link javax.jcr.version.VersionHistory#getRootVersion() VersionHis= tory.getRootVersion()} + * method. + * + * @return a Version object. + * @throws RepositoryException if an error occurs. + * @throws RemoteException on RMI errors + */ + public RemoteVersion getRootVersion()=20 + throws RepositoryException, RemoteException; + + /** + * Remote version of the + * {@link javax.jcr.version.VersionHistory#getAllVersions() VersionHis= tory.getAllVersions()} + * method. + * + * @return a VersionIterator object. + * @throws RepositoryException if an error occurs. + * @throws RemoteException on RMI errors + */ + public RemoteVersion[] getAllVersions()=20 + throws RepositoryException, RemoteException; + + /** + * Remote version of the + * {@link javax.jcr.version.VersionHistory#getVersion(String) VersionH= istory.getVersion(String)} + * method. + * + * @param versionName a version name + * @return a Version 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) V= ersionHistory.getVersionByLabel(String)} + * method. + * + * @param label a version label + * @return a Version 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, Str= ing, 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 true, then if label i= s already assigned to a version in + * this version history, it is moved to the new version specified; if = false, then attempting + * to assign an already used label will throw a VersionException= . + * + * @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) Ver= sionHistory.hasVersionLabel(String)} + * method. + * + * @param label a version label + * @return a boolean + * @throws RemoteException on RMI errors + */ + public boolean hasVersionLabel(String label) throws RemoteException; + + /** + * Remote version of the + * {@link javax.jcr.version.VersionHistory#hasVersionLabel(RemoteVersi= on, String) hasVersionLabel(RemoteVersion, String)} + * method. + * + * @param versionUUID The UUID of the version whose labels are to be r= eturned. + * @param label a version label + * @return a boolean. + * @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() VersionH= istory.getVersionLabels()} + * method. + * + * @return a String array containing all the labels of th= e version history + * @throws RemoteException on RMI errors + */ + public String[] getVersionLabels() throws RemoteException; + + /** + * Remote version of the + * {@link javax.jcr.version.VersionHistory#getVersionLabels(RemoteVers= ion) VersionHistory.getVersionLabels(RemoteVersion)} + * method. + * + * @param versionUUID The UUID of the version whose labels are to be r= eturned. + * @return a String array containing all the labels of th= e 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) Versi= onHistory.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/ja= ckrabbit/rmi/server/RemoteAdapterFactory.java URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-r= mi/src/java/org/apache/jackrabbit/rmi/server/RemoteAdapterFactory.java?view= =3Ddiff&r1=3D159669&r2=3D159670 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabb= it/rmi/server/RemoteAdapterFactory.java (original) +++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabb= it/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; =20 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; =20 /** @@ -155,6 +159,25 @@ */ RemoteNode getRemoteNode(Node node) throws RemoteException; =20 + /** + * 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 versionHis= tory)=20 + throws RemoteException; + =20 /** * Returns a remote adapter for the given local node type. * Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/ja= ckrabbit/rmi/server/ServerAdapterFactory.java URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-r= mi/src/java/org/apache/jackrabbit/rmi/server/ServerAdapterFactory.java?view= =3Ddiff&r1=3D159669&r2=3D159670 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabb= it/rmi/server/ServerAdapterFactory.java (original) +++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabb= it/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; =20 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; =20 /** @@ -139,6 +143,23 @@ return new ServerNode(node, this); } =20 + /** + * Creates a {@link ServerVersion ServerVersion} instance. + * {@inheritDoc} + */ + public RemoteVersion getRemoteVersion(Version version) throws RemoteEx= ception { + return new ServerVersion(version, this); + } + =20 + /** + * Creates a {@link ServerVersionHistory ServerVersionHistory} instanc= e=2E + * {@inheritDoc} + */ + public RemoteVersionHistory getRemoteVersionHistory(VersionHistory ver= sionHistory) + throws RemoteException { + return new ServerVersionHistory(versionHistory, this); + } + =20 /** * Creates a {@link ServerNodeType ServerNodeType} instance. * {@inheritDoc} Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/ja= ckrabbit/rmi/server/ServerItem.java URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-r= mi/src/java/org/apache/jackrabbit/rmi/server/ServerItem.java?view=3Ddiff&r1= =3D159669&r2=3D159670 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabb= it/rmi/server/ServerItem.java (original) +++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabb= it/rmi/server/ServerItem.java Fri Apr 1 01:23:37 2005 @@ -104,7 +104,7 @@ /** {@inheritDoc} */ public RemoteNode getParent() throws RepositoryException, RemoteExcept= ion { 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/ja= ckrabbit/rmi/server/ServerNode.java URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-r= mi/src/java/org/apache/jackrabbit/rmi/server/ServerNode.java?view=3Ddiff&r1= =3D159669&r2=3D159670 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabb= it/rmi/server/ServerNode.java (original) +++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabb= it/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; =20 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; =20 /** * 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 @@ } =20 /** {@inheritDoc} */ + public RemoteVersion checkin() throws RepositoryException, RemoteExcep= tion { + 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 @@ } =20 /** {@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 @@ } =20 /** {@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 removeExi= sting) + throws RepositoryException, RemoteException { + try { + node.restore(getVersionByUUID(versionUUID), path, removeExisti= ng); + } catch (RepositoryException ex) { + throw getRepositoryException(ex); + } + } + + /** {@inheritDoc} */ public void restoreByLabel(String label, boolean removeExisting) throws RepositoryException, RemoteException { try { @@ -393,6 +446,26 @@ } =20 /** {@inheritDoc} */ + public RemoteVersionHistory getVersionHistory() + throws RepositoryException, RemoteException { + try { + return getFactory().getRemoteVersionHistory(node.getVersionHis= tory()); + } catch (RepositoryException ex) { + throw getRepositoryException(ex); + } + } + =20 + /** {@inheritDoc} */ + public RemoteVersion getBaseVersion() + throws RepositoryException, RemoteException { + try { + return getFactory().getRemoteVersion(node.getBaseVersion()); + } catch (RepositoryException ex) { + throw getRepositoryException(ex); + } + } + =20 + /** {@inheritDoc} */ public boolean isLocked() throws RepositoryException, RemoteException { try { return node.isLocked(); @@ -441,4 +514,33 @@ } } =20 + //---------- Implementation helper -----------------------------------= ------ + =20 + /** + * Returns the {@link Version} instance for the given UUID. + *=20 + * @param versionUUID The UUID of the version. + *=20 + * @return The version node. + *=20 + * @throws RepositoryException if an error occurrs accessing the versi= on + * node or if the UUID does not denote a version. + */ + protected Version getVersionByUUID(String versionUUID) + throws RepositoryException { + =20 + // get the version node by its UUID from the version history's ses= sion + Session session =3D node.getSession(); + Node versionNode =3D session.getNodeByUUID(versionUUID); + =20 + // check whether the node is a session, which it should be accordi= ng + // to the spec (methods returning nodes should automatically return + // the correct type). + if (versionNode instanceof Version) { + return (Version) versionNode; + } + =20 + // otherwise fail + throw new RepositoryException("Cannot find version " + versionUUID= ); + } } Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/ja= ckrabbit/rmi/server/ServerObject.java URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-r= mi/src/java/org/apache/jackrabbit/rmi/server/ServerObject.java?view=3Ddiff&= r1=3D159669&r2=3D159670 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabb= it/rmi/server/ServerObject.java (original) +++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabb= it/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; =20 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; =20 /** * 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. + *

+ * If the item, 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); } } =20 /** + * 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 us= ing + * 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 !=3D null) { RemoteNode[] remotes =3D new RemoteNode[(int) iterator.getSize= ()]; for (int i =3D 0; iterator.hasNext(); i++) { - remotes[i] =3D factory.getRemoteNode(iterator.nextNode()); + remotes[i] =3D 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. + *

+ * A null 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 !=3D null) { + RemoteVersion[] remotes =3D new RemoteVersion[versions.length]; + for (int i =3D 0; i < remotes.length; i++) { + remotes[i] =3D 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. + *

+ * A null 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 iterat= or) + throws RemoteException { + if (iterator !=3D null) { + RemoteVersion[] remotes =3D new RemoteVersion[(int) iterator.g= etSize()]; + for (int i =3D 0; iterator.hasNext(); i++) { + remotes[i] =3D factory.getRemoteVersion(iterator.nextVersi= on()); + } + return remotes; + } else { + return new RemoteVersion[0]; // for safety } } =20 Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/ja= ckrabbit/rmi/server/ServerQueryResult.java URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-r= mi/src/java/org/apache/jackrabbit/rmi/server/ServerQueryResult.java?view=3D= diff&r1=3D159669&r2=3D159670 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabb= it/rmi/server/ServerQueryResult.java (original) +++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabb= it/rmi/server/ServerQueryResult.java Fri Apr 1 01:23:37 2005 @@ -82,7 +82,7 @@ if (iterator !=3D null) { RemoteNode[] remotes =3D new RemoteNode[(int) iterator.getSize= ()]; for (int i =3D 0; iterator.hasNext(); i++) { - remotes[i] =3D getFactory().getRemoteNode(iterator.nextNod= e()); + remotes[i] =3D getRemoteNode(iterator.nextNode()); } return remotes; } else { Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/ja= ckrabbit/rmi/server/ServerSession.java URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-r= mi/src/java/org/apache/jackrabbit/rmi/server/ServerSession.java?view=3Ddiff= &r1=3D159669&r2=3D159670 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabb= it/rmi/server/ServerSession.java (original) +++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabb= it/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/jackr= abbit/rmi/server/ServerVersion.java URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-r= mi/src/java/org/apache/jackrabbit/rmi/server/ServerVersion.java?view=3Dauto= &rev=3D159670 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabb= it/rmi/server/ServerVersion.java (added) +++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabb= it/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} in= terface. + * 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 { + =20 + /** 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 =3D version; + } + +// This is only available after 0.16.2 +// /** {@inheritDoc} */ +// public RemoteVersionHistory getContainingHistory() throws Repository= Exception { +// try { +// return getFactory().getRemoteVersionHistory(version.getConta= iningHistory()); +// } 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, Rem= oteException { + try { + return getRemoteVersionArray(version.getSuccessors()); + } catch (RepositoryException ex) { + throw getRepositoryException(ex); + } + } + + /** {@inheritDoc} */ + public RemoteVersion[] getPredecessors() throws RepositoryException, R= emoteException { + try { + return getRemoteVersionArray(version.getPredecessors()); + } catch (RepositoryException ex) { + throw getRepositoryException(ex); + } + } +} Added: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackr= abbit/rmi/server/ServerVersionHistory.java URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-r= mi/src/java/org/apache/jackrabbit/rmi/server/ServerVersionHistory.java?view= =3Dauto&rev=3D159670 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabb= it/rmi/server/ServerVersionHistory.java (added) +++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabb= it/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 Vers= ionHistory} + * interface. This class makes a local version history available as an RMI + * service using the=20 + * {@link org.apache.jackrabbit.rmi.remote.RemoteVersionHistory RemoteVers= ionHistory} + * 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 =3D 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.getRootVer= sion()); + } catch (RepositoryException ex) { + throw getRepositoryException(ex); + } + } + + /** {@inheritDoc} */ + public RemoteVersion[] getAllVersions()=20 + 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 =3D 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 =3D 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 RepositoryExceptio= n, + 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 =3D 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 =3D getVersionByUUID(versionUUID); + return versionHistory.getVersionLabels(version); + } catch (ClassCastException cce) { + // we do not expect this here as nodes should be returned corr= ectly + 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); + } + } +}