You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by mr...@apache.org on 2007/02/28 16:09:29 UTC

svn commit: r512795 [3/4] - in /jackrabbit/trunk/contrib/spi/spi-rmi: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/jackrabbit/ src/main/java/org/apache/jackrabbit/spi/ src/main/java/org/apache/j...

Added: jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/remote/RemoteRepositoryService.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/remote/RemoteRepositoryService.java?view=auto&rev=512795
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/remote/RemoteRepositoryService.java (added)
+++ jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/remote/RemoteRepositoryService.java Wed Feb 28 07:09:27 2007
@@ -0,0 +1,662 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.spi.rmi.remote;
+
+import org.apache.jackrabbit.spi.ItemId;
+import org.apache.jackrabbit.spi.NodeId;
+import org.apache.jackrabbit.spi.QNodeDefinition;
+import org.apache.jackrabbit.spi.QPropertyDefinition;
+import org.apache.jackrabbit.spi.PropertyId;
+import org.apache.jackrabbit.spi.NodeInfo;
+import org.apache.jackrabbit.spi.PropertyInfo;
+import org.apache.jackrabbit.spi.LockInfo;
+import org.apache.jackrabbit.spi.EventFilter;
+import org.apache.jackrabbit.spi.EventBundle;
+import org.apache.jackrabbit.spi.QNodeTypeDefinition;
+import org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.name.Path;
+
+import javax.jcr.Credentials;
+import javax.jcr.RepositoryException;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.util.Map;
+import java.io.InputStream;
+
+/**
+ * <code>RemoteRepositoryService</code> is the remote version of the interface
+ * {@link org.apache.jackrabbit.spi.RepositoryService}.
+ */
+public interface RemoteRepositoryService extends Remote {
+
+    /**
+     * @return key-value pairs for repository descriptor keys and values.
+     * @throws RemoteException on RMI errors.
+     * @see org.apache.jackrabbit.spi.RepositoryService#getRepositoryDescriptors()
+     */
+    public Map getRepositoryDescriptors()
+            throws RepositoryException, RemoteException;
+
+    /**
+     * Returns a <code>RemoteSessionInfo</code> that will be used by other
+     * methods on the <code>RepositoryService</code>. An implementation may
+     * choose to authenticate the user using the supplied
+     * <code>credentials</code>.
+     *
+     * @param credentials the credentials of the user.
+     * @return a <code>RemoteSessionInfo</code> if authentication was
+     *         successful.
+     * @throws RemoteException if an error occurs.
+     * @see org.apache.jackrabbit.spi.RepositoryService#obtain(javax.jcr.Credentials, String)
+     */
+    public RemoteSessionInfo obtain(Credentials credentials,
+                                    String workspaceName)
+            throws RepositoryException, RemoteException;
+
+    /**
+     * Returns a new <code>RemoteSessionInfo</code> for the given workspace name
+     * that will be used by other methods on the <code>RepositoryService</code>.
+     *
+     * @param sessionInfo for another workspace
+     * @return a <code>RemoteSessionInfo</code> if authentication was
+     *         successful.
+     * @throws RemoteException if an error occurs.
+     * @see org.apache.jackrabbit.spi.RepositoryService#obtain(org.apache.jackrabbit.spi.SessionInfo, String)
+     */
+    public RemoteSessionInfo obtain(RemoteSessionInfo sessionInfo,
+                                    String workspaceName)
+            throws RepositoryException, RemoteException;
+
+    /**
+     * Indicates to the <code>RepositoryService</code>, that the given
+     * RemoteSessionInfo will not be used any more.
+     *
+     * @param sessionInfo
+     * @throws RemoteException if an error occurs.
+     * @see org.apache.jackrabbit.spi.RepositoryService#dispose(org.apache.jackrabbit.spi.SessionInfo)
+     */
+    public void dispose(RemoteSessionInfo sessionInfo)
+            throws RepositoryException, RemoteException;
+
+    /**
+     * @param sessionInfo
+     * @return an array of workspace ids
+     * @throws RemoteException if an error occurs.
+     * @see org.apache.jackrabbit.spi.RepositoryService#getWorkspaceNames(org.apache.jackrabbit.spi.SessionInfo)
+     */
+    public String[] getWorkspaceNames(RemoteSessionInfo sessionInfo)
+            throws RepositoryException, RemoteException;
+
+    /**
+     * @param sessionInfo
+     * @param itemId
+     * @param actions
+     * @return true if the session with the given <code>SessionInfo</code> has
+     *         the specified rights for the given item.
+     * @throws RemoteException if an error occurs.
+     * @see org.apache.jackrabbit.spi.RepositoryService#isGranted(org.apache.jackrabbit.spi.SessionInfo, org.apache.jackrabbit.spi.ItemId, String[])
+     */
+    public boolean isGranted(RemoteSessionInfo sessionInfo,
+                             ItemId itemId,
+                             String[] actions)
+            throws RepositoryException, RemoteException;
+
+    /**
+     * The <code>NodeId</code> of the root node may basically have two
+     * characteristics. If the root node can be identified with a unique ID the
+     * returned <code>NodeId</code> simply has a uniqueID part and the path
+     * part is <code>null</code>. If the root node cannot be identified with a
+     * unique ID the uniqueID part is <code>null</code> and the path part will be set
+     * to "/".
+     *
+     * @param sessionInfo
+     * @return
+     * @throws RepositoryException
+     * @throws RemoteException if an error occurs.
+     * @see org.apache.jackrabbit.spi.RepositoryService#getRootId(org.apache.jackrabbit.spi.SessionInfo)
+     */
+    public NodeId getRootId(RemoteSessionInfo sessionInfo)
+            throws RepositoryException, RemoteException;
+
+    /**
+     *
+     * @param sessionInfo
+     * @param nodeId
+     * @return
+     * @throws RepositoryException
+     * @throws RemoteException if an error occurs.
+     * @see org.apache.jackrabbit.spi.RepositoryService#getNodeDefinition(org.apache.jackrabbit.spi.SessionInfo, org.apache.jackrabbit.spi.NodeId)
+     */
+    public QNodeDefinition getNodeDefinition(RemoteSessionInfo sessionInfo,
+                                             NodeId nodeId)
+            throws RepositoryException, RemoteException;
+
+    /**
+     *
+     * @param sessionInfo
+     * @param propertyId
+     * @return
+     * @throws RepositoryException
+     * @throws RemoteException if an error occurs.
+     * @see org.apache.jackrabbit.spi.RepositoryService#getPropertyDefinition(org.apache.jackrabbit.spi.SessionInfo, org.apache.jackrabbit.spi.PropertyId)
+     */
+    public QPropertyDefinition getPropertyDefinition(RemoteSessionInfo sessionInfo,
+                                                     PropertyId propertyId)
+            throws RepositoryException, RemoteException;
+
+    /**
+     * @param sessionInfo
+     * @param itemId
+     * @return true if the item with the given id exists
+     * @throws javax.jcr.RepositoryException
+     * @throws RemoteException if an error occurs.
+     * @see org.apache.jackrabbit.spi.RepositoryService#exists(org.apache.jackrabbit.spi.SessionInfo, org.apache.jackrabbit.spi.ItemId)
+     */
+    public boolean exists(RemoteSessionInfo sessionInfo, ItemId itemId)
+            throws RepositoryException, RemoteException;
+
+    /**
+     * @param sessionInfo
+     * @param nodeId
+     * @return
+     * @throws RemoteException if an error occurs.
+     * @see org.apache.jackrabbit.spi.RepositoryService#getNodeInfo(org.apache.jackrabbit.spi.SessionInfo, org.apache.jackrabbit.spi.NodeId)
+     */
+    public NodeInfo getNodeInfo(RemoteSessionInfo sessionInfo, NodeId nodeId)
+            throws RepositoryException, RemoteException;
+
+    /**
+     * Returns a collection of child node entries present on the
+     * Node represented by the given parentId.
+     *
+     * @param sessionInfo
+     * @param parentId
+     * @return
+     * @throws RemoteException if an error occurs.
+     * @see org.apache.jackrabbit.spi.RepositoryService#getChildInfos(org.apache.jackrabbit.spi.SessionInfo, org.apache.jackrabbit.spi.NodeId)
+     */
+    public RemoteIterator getChildInfos(RemoteSessionInfo sessionInfo,
+                                  NodeId parentId)
+            throws RepositoryException, RemoteException;
+
+    /**
+     * @param sessionInfo
+     * @param propertyId
+     * @return
+     * @throws RemoteException if an error occurs.
+     * @see org.apache.jackrabbit.spi.RepositoryService#getPropertyInfo(org.apache.jackrabbit.spi.SessionInfo, org.apache.jackrabbit.spi.PropertyId)
+     */
+    public PropertyInfo getPropertyInfo(RemoteSessionInfo sessionInfo,
+                                        PropertyId propertyId)
+            throws RepositoryException, RemoteException;
+
+    /**
+     * Indicates the start of a set of operations that cause modifications
+     * on the underlaying persistence layer. All modification called on the
+     * Batch must be executed at once or non must be executed.
+     *
+     * @param itemId
+     * @param sessionInfo
+     * @return
+     * @throws RemoteException if an error occurs.
+     * @see org.apache.jackrabbit.spi.RepositoryService#createBatch(org.apache.jackrabbit.spi.ItemId, org.apache.jackrabbit.spi.SessionInfo)
+     */
+    public RemoteBatch createBatch(ItemId itemId,
+                                   RemoteSessionInfo sessionInfo)
+            throws RepositoryException, RemoteException;
+
+    /**
+     * Submits a batch.
+     *
+     * @param batch the remote batch
+     * @throws RepositoryException
+     * @throws RemoteException if an error occurs.
+     * @see org.apache.jackrabbit.spi.RepositoryService#submit(org.apache.jackrabbit.spi.Batch)
+     */
+    public void submit(RemoteBatch batch) throws RepositoryException, RemoteException;
+
+    /**
+     *
+     * @param sessionInfo
+     * @param parentId
+     * @param xmlStream
+     * @param uuidBehaviour
+     * @throws RepositoryException
+     * @throws RemoteException if an error occurs.
+     * @see org.apache.jackrabbit.spi.RepositoryService#importXml(org.apache.jackrabbit.spi.SessionInfo, org.apache.jackrabbit.spi.NodeId, java.io.InputStream, int)
+     */
+    public void importXml(RemoteSessionInfo sessionInfo,
+                          NodeId parentId,
+                          InputStream xmlStream,
+                          int uuidBehaviour)
+            throws RepositoryException, RemoteException;
+
+    /**
+     * @param sessionInfo
+     * @param srcNodeId
+     * @param destParentNodeId
+     * @param destName
+     * @throws javax.jcr.RepositoryException
+     * @throws RemoteException if an error occurs.
+     * @see org.apache.jackrabbit.spi.RepositoryService#move(org.apache.jackrabbit.spi.SessionInfo, org.apache.jackrabbit.spi.NodeId, org.apache.jackrabbit.spi.NodeId, org.apache.jackrabbit.name.QName)
+     */
+    public void move(RemoteSessionInfo sessionInfo,
+                     NodeId srcNodeId,
+                     NodeId destParentNodeId,
+                     QName destName)
+            throws RepositoryException, RemoteException;
+
+    /**
+     * @param sessionInfo
+     * @param srcWorkspaceName
+     * @param srcNodeId
+     * @param destParentNodeId
+     * @param destName
+     * @throws javax.jcr.RepositoryException
+     * @throws RemoteException if an error occurs.
+     * @see org.apache.jackrabbit.spi.RepositoryService#copy(org.apache.jackrabbit.spi.SessionInfo, String, org.apache.jackrabbit.spi.NodeId, org.apache.jackrabbit.spi.NodeId, org.apache.jackrabbit.name.QName)
+     */
+    public void copy(RemoteSessionInfo sessionInfo,
+                     String srcWorkspaceName,
+                     NodeId srcNodeId,
+                     NodeId destParentNodeId,
+                     QName destName)
+            throws RepositoryException, RemoteException;
+
+    /**
+     * @param sessionInfo
+     * @param nodeId
+     * @param srcWorkspaceName
+     * @throws javax.jcr.RepositoryException
+     * @throws RemoteException if an error occurs.
+     * @see org.apache.jackrabbit.spi.RepositoryService#update(org.apache.jackrabbit.spi.SessionInfo, org.apache.jackrabbit.spi.NodeId, String)
+     */
+    public void update(RemoteSessionInfo sessionInfo,
+                       NodeId nodeId,
+                       String srcWorkspaceName)
+            throws RepositoryException, RemoteException;
+
+    /**
+     * @param sessionInfo
+     * @param srcWorkspaceName
+     * @param srcNodeId
+     * @param destParentNodeId
+     * @param destName
+     * @param removeExisting
+     * @throws javax.jcr.RepositoryException
+     * @throws RemoteException if an error occurs.
+     * @see org.apache.jackrabbit.spi.RepositoryService#clone(org.apache.jackrabbit.spi.SessionInfo, String, org.apache.jackrabbit.spi.NodeId, org.apache.jackrabbit.spi.NodeId, org.apache.jackrabbit.name.QName, boolean)
+     */
+    public void clone(RemoteSessionInfo sessionInfo,
+                      String srcWorkspaceName,
+                      NodeId srcNodeId,
+                      NodeId destParentNodeId,
+                      QName destName,
+                      boolean removeExisting)
+            throws RepositoryException, RemoteException;
+
+    /**
+     * Retrieve available lock information for the given <code>NodeId</code>.
+     *
+     * @param sessionInfo
+     * @param nodeId
+     * @return
+     * @throws RepositoryException
+     * @throws RemoteException if an error occurs.
+     * @see org.apache.jackrabbit.spi.RepositoryService#getLockInfo(org.apache.jackrabbit.spi.SessionInfo, org.apache.jackrabbit.spi.NodeId)
+     */
+    public LockInfo getLockInfo(RemoteSessionInfo sessionInfo, NodeId nodeId)
+            throws RepositoryException, RemoteException;
+
+    /**
+     * @param sessionInfo
+     * @param nodeId
+     * @param deep
+     * @param sessionScoped
+     * @return returns the <code>LockInfo</code> associated with this lock.
+     * @throws javax.jcr.RepositoryException
+     * @throws RemoteException if an error occurs.
+     * @see org.apache.jackrabbit.spi.RepositoryService#lock(org.apache.jackrabbit.spi.SessionInfo, org.apache.jackrabbit.spi.NodeId, boolean, boolean)
+     */
+    public LockInfo lock(RemoteSessionInfo sessionInfo,
+                         NodeId nodeId,
+                         boolean deep,
+                         boolean sessionScoped)
+            throws RepositoryException, RemoteException;
+
+    /**
+     * Explicit refresh of an existing lock. Existing locks should be refreshed
+     * implicitely with all read and write methods listed here.
+     *
+     * @param sessionInfo
+     * @param nodeId
+     * @throws javax.jcr.RepositoryException
+     * @throws RemoteException if an error occurs.
+     * @see org.apache.jackrabbit.spi.RepositoryService#refreshLock(org.apache.jackrabbit.spi.SessionInfo, org.apache.jackrabbit.spi.NodeId)
+     */
+    public void refreshLock(RemoteSessionInfo sessionInfo, NodeId nodeId)
+            throws RepositoryException, RemoteException;
+
+    /**
+     * Releases the lock on the given node.<p/>
+     * Please note, that on {@link javax.jcr.Session#logout() logout} all
+     * session-scoped locks must be released by calling unlock.
+     *
+     * @param sessionInfo
+     * @param nodeId
+     * @throws javax.jcr.RepositoryException
+     * @throws RemoteException if an error occurs.
+     * @see org.apache.jackrabbit.spi.RepositoryService#unlock(org.apache.jackrabbit.spi.SessionInfo, org.apache.jackrabbit.spi.NodeId)
+     */
+    public void unlock(RemoteSessionInfo sessionInfo, NodeId nodeId)
+            throws RepositoryException, RemoteException;
+
+    /**
+     * @param sessionInfo
+     * @param nodeId
+     * @throws javax.jcr.RepositoryException
+     * @throws RemoteException if an error occurs.
+     * @see org.apache.jackrabbit.spi.RepositoryService#checkin(org.apache.jackrabbit.spi.SessionInfo, org.apache.jackrabbit.spi.NodeId)
+     */
+    public void checkin(RemoteSessionInfo sessionInfo, NodeId nodeId)
+            throws RepositoryException, RemoteException;
+
+    /**
+     * @param sessionInfo
+     * @param nodeId
+     * @throws javax.jcr.RepositoryException
+     * @throws RemoteException if an error occurs.
+     * @see org.apache.jackrabbit.spi.RepositoryService#checkout(org.apache.jackrabbit.spi.SessionInfo, org.apache.jackrabbit.spi.NodeId)
+     */
+    public void checkout(RemoteSessionInfo sessionInfo, NodeId nodeId)
+            throws RepositoryException, RemoteException;
+
+    /**
+     *
+     * @param sessionInfo
+     * @param versionHistoryId
+     * @param versionId
+     * @throws RepositoryException
+     * @throws RemoteException if an error occurs.
+     * @see org.apache.jackrabbit.spi.RepositoryService#checkout(org.apache.jackrabbit.spi.SessionInfo, org.apache.jackrabbit.spi.NodeId)
+     */
+    public void removeVersion(RemoteSessionInfo sessionInfo,
+                              NodeId versionHistoryId,
+                              NodeId versionId)
+            throws RepositoryException, RemoteException;
+
+    /**
+     * @param sessionInfo
+     * @param nodeId
+     * @param versionId
+     * @param removeExisting
+     * @throws javax.jcr.RepositoryException
+     * @throws RemoteException if an error occurs.
+     * @see org.apache.jackrabbit.spi.RepositoryService#restore(org.apache.jackrabbit.spi.SessionInfo, org.apache.jackrabbit.spi.NodeId, org.apache.jackrabbit.spi.NodeId, boolean)
+     */
+    public void restore(RemoteSessionInfo sessionInfo,
+                        NodeId nodeId,
+                        NodeId versionId,
+                        boolean removeExisting)
+            throws RepositoryException, RemoteException;
+
+    /**
+     * @param sessionInfo
+     * @param versionIds
+     * @param removeExisting
+     * @throws javax.jcr.RepositoryException
+     * @throws RemoteException if an error occurs.
+     * @see org.apache.jackrabbit.spi.RepositoryService#restore(org.apache.jackrabbit.spi.SessionInfo, org.apache.jackrabbit.spi.NodeId[], boolean)
+     */
+    public void restore(RemoteSessionInfo sessionInfo,
+                        NodeId[] versionIds,
+                        boolean removeExisting)
+            throws RepositoryException, RemoteException;
+
+    /**
+     * @param sessionInfo
+     * @param nodeId
+     * @param srcWorkspaceName
+     * @param bestEffort
+     * @return an <code>IdIterator</code> over all nodes that received a merge
+     * result of "fail" in the course of this operation.
+     * @throws javax.jcr.RepositoryException
+     * @throws RemoteException if an error occurs.
+     * @see org.apache.jackrabbit.spi.RepositoryService#merge(org.apache.jackrabbit.spi.SessionInfo, org.apache.jackrabbit.spi.NodeId, String, boolean)
+     */
+    public RemoteIterator merge(RemoteSessionInfo sessionInfo,
+                            NodeId nodeId,
+                            String srcWorkspaceName,
+                            boolean bestEffort)
+            throws RepositoryException, RemoteException;
+
+    /**
+     * @param sessionInfo
+     * @param nodeId
+     * @param mergeFailedIds
+     * @param predecessorIds
+     * @throws javax.jcr.RepositoryException
+     * @throws RemoteException if an error occurs.
+     * @see org.apache.jackrabbit.spi.RepositoryService#resolveMergeConflict(org.apache.jackrabbit.spi.SessionInfo, org.apache.jackrabbit.spi.NodeId, org.apache.jackrabbit.spi.NodeId[], org.apache.jackrabbit.spi.NodeId[])
+     */
+    public void resolveMergeConflict(RemoteSessionInfo sessionInfo,
+                                     NodeId nodeId,
+                                     NodeId[] mergeFailedIds,
+                                     NodeId[] predecessorIds)
+            throws RepositoryException, RemoteException;
+
+    /**
+     * @param sessionInfo
+     * @param versionId
+     * @param label
+     * @param moveLabel
+     * @throws javax.jcr.RepositoryException
+     * @throws RemoteException if an error occurs.
+     * @see org.apache.jackrabbit.spi.RepositoryService#addVersionLabel(org.apache.jackrabbit.spi.SessionInfo, org.apache.jackrabbit.spi.NodeId, org.apache.jackrabbit.spi.NodeId, org.apache.jackrabbit.name.QName, boolean)
+     */
+    public void addVersionLabel(RemoteSessionInfo sessionInfo,
+                                NodeId versionHistoryId,
+                                NodeId versionId,
+                                QName label,
+                                boolean moveLabel)
+            throws RepositoryException, RemoteException;
+
+    /**
+     * @param sessionInfo
+     * @param versionId
+     * @param label
+     * @throws javax.jcr.RepositoryException
+     * @throws RemoteException if an error occurs.
+     * @see org.apache.jackrabbit.spi.RepositoryService#removeVersionLabel(org.apache.jackrabbit.spi.SessionInfo, org.apache.jackrabbit.spi.NodeId, org.apache.jackrabbit.spi.NodeId, org.apache.jackrabbit.name.QName)
+     */
+    public void removeVersionLabel(RemoteSessionInfo sessionInfo,
+                                   NodeId versionHistoryId,
+                                   NodeId versionId,
+                                   QName label)
+            throws RepositoryException, RemoteException;
+
+    /**
+     * @param sessionInfo
+     * @return
+     * @throws javax.jcr.RepositoryException
+     * @throws RemoteException if an error occurs.
+     * @see org.apache.jackrabbit.spi.RepositoryService#getSupportedQueryLanguages(org.apache.jackrabbit.spi.SessionInfo)
+     */
+    public String[] getSupportedQueryLanguages(RemoteSessionInfo sessionInfo)
+            throws RepositoryException, RemoteException;
+
+    /**
+     * Checks if the query <code>statement</code> is valid according to the
+     * specified query <code>language</code>.
+     *
+     * @param sessionInfo the session info.
+     * @param statement   the query statement to check.
+     * @param language    the query language.
+     * @param namespaces  the locally re-mapped namespace which may be used in
+     *                    the query <code>statement</code>.
+     * @throws RepositoryException   if an error occurs while checking the
+     *                               statement.
+     * @throws RemoteException if an error occurs.
+     * @see org.apache.jackrabbit.spi.RepositoryService#checkQueryStatement(org.apache.jackrabbit.spi.SessionInfo, String, String, java.util.Map)
+     */
+    public void checkQueryStatement(RemoteSessionInfo sessionInfo,
+                                    String statement,
+                                    String language,
+                                    Map namespaces)
+            throws RepositoryException, RemoteException;
+
+    /**
+     * @param sessionInfo
+     * @param statement
+     * @param language
+     * @param namespaces  the locally re-mapped namespace which may be used in
+     *                    the query <code>statement</code>.
+     * @return
+     * @throws javax.jcr.RepositoryException
+     * @throws RemoteException if an error occurs.
+     * @see org.apache.jackrabbit.spi.RepositoryService#executeQuery(org.apache.jackrabbit.spi.SessionInfo, String, String, java.util.Map)
+     */
+    public RemoteQueryInfo executeQuery(RemoteSessionInfo sessionInfo,
+                                        String statement,
+                                        String language,
+                                        Map namespaces)
+            throws RepositoryException, RemoteException;
+
+    /**
+     * Creates an event filter.
+     *
+     * @param sessionInfo the session info which requests an event filter.
+     * @param eventTypes A combination of one or more event type constants
+     * encoded as a bitmask.
+     * @param absPath An absolute path.
+     * @param isDeep A <code>boolean</code>.
+     * @param uuid Array of jcr:uuid properties.
+     * @param nodeTypeName Array of node type names.
+     * @param noLocal A <code>boolean</code>.
+     * @return the event filter instance with the given parameters.
+     * @throws RepositoryException if an error occurs while creating the
+     * EventFilter.
+     * @throws RemoteException if an error occurs.
+     * @see org.apache.jackrabbit.spi.RepositoryService#createEventFilter(org.apache.jackrabbit.spi.SessionInfo, int, org.apache.jackrabbit.name.Path, boolean, String[], org.apache.jackrabbit.name.QName[], boolean)
+     */
+    public EventFilter createEventFilter(RemoteSessionInfo sessionInfo, int eventTypes,
+                                         Path absPath, boolean isDeep,
+                                         String[] uuid, QName[] nodeTypeName,
+                                         boolean noLocal)
+            throws RepositoryException, RemoteException;
+
+    /**
+     * Retrieves the events that occurred since the last call to this
+     * method.
+     *
+     * @param sessionInfo the session info.
+     * @param timeout     a timeout in milliseconds to wait at most for an
+     *                    event bundle.
+     * @param filters     the filters that are applied to the events as
+     *                    they occurred on the repository.
+     * @return an array of <code>EventBundle</code>s representing the external
+     *         events that occurred.
+     * @throws RepositoryException  if an error occurs while retrieving the
+     *                              event bundles or the currently set bundle
+     *                              identifier in <code>sessionInfo</code>
+     *                              references an unknown or outdated event
+     *                              bundle.
+     * @throws RemoteException if an error occurs.
+     * @see org.apache.jackrabbit.spi.RepositoryService#getEvents(org.apache.jackrabbit.spi.SessionInfo, long, org.apache.jackrabbit.spi.EventFilter[])
+     */
+    public EventBundle[] getEvents(RemoteSessionInfo sessionInfo, long timeout,
+                                   EventFilter[] filters)
+            throws RepositoryException, InterruptedException, RemoteException;
+
+    /**
+     * Retrieve all registered namespaces. The namespace to prefix mapping is
+     * done using the prefix as key and the namespace as value in the Map.
+     *
+     * @param sessionInfo
+     * @return
+     * @throws javax.jcr.RepositoryException
+     * @throws RemoteException if an error occurs.
+     * @see org.apache.jackrabbit.spi.RepositoryService#getRegisteredNamespaces(org.apache.jackrabbit.spi.SessionInfo)
+     */
+    public Map getRegisteredNamespaces(RemoteSessionInfo sessionInfo)
+            throws RepositoryException, RemoteException;
+
+    /**
+     * Returns the namespace URI for the given namespace <code>prefix</code>.
+     *
+     * @param sessionInfo the session info.
+     * @param prefix a namespace prefix to resolve.
+     * @return the namespace URI for the given namespace <code>prefix</code>.
+     * @throws RepositoryException if another error occurs.
+     * @throws RemoteException if an error occurs.
+     * @see org.apache.jackrabbit.spi.RepositoryService#getNamespaceURI(org.apache.jackrabbit.spi.SessionInfo, String)
+     */
+    public String getNamespaceURI(RemoteSessionInfo sessionInfo, String prefix)
+            throws RepositoryException, RemoteException;
+
+    /**
+     * Returns the namespace prefix for the given namespace <code>uri</code>.
+     *
+     * @param sessionInfo the session info.
+     * @param uri the namespace URI.
+     * @return the namespace prefix.
+     * @throws RepositoryException if another error occurs.
+     * @throws RemoteException if an error occurs.
+     * @see org.apache.jackrabbit.spi.RepositoryService#getNamespacePrefix(org.apache.jackrabbit.spi.SessionInfo, String)
+     */
+    public String getNamespacePrefix(RemoteSessionInfo sessionInfo, String uri)
+            throws RepositoryException, RemoteException;
+
+    /**
+     * Register a new namespace with the given prefix and uri
+     *
+     * @param sessionInfo
+     * @param prefix
+     * @param uri
+     * @throws javax.jcr.RepositoryException
+     * @throws RemoteException if an error occurs.
+     * @see org.apache.jackrabbit.spi.RepositoryService#registerNamespace(org.apache.jackrabbit.spi.SessionInfo, String, String)
+     */
+    public void registerNamespace(RemoteSessionInfo sessionInfo,
+                                  String prefix,
+                                  String uri)
+            throws RepositoryException, RemoteException;
+
+    /**
+     * Unregister the namesspace indentified by the given prefix
+     *
+     * @param sessionInfo
+     * @param uri
+     * @throws javax.jcr.RepositoryException
+     * @throws RemoteException if an error occurs.
+     * @see org.apache.jackrabbit.spi.RepositoryService#unregisterNamespace(org.apache.jackrabbit.spi.SessionInfo, String)
+     */
+    public void unregisterNamespace(RemoteSessionInfo sessionInfo, String uri)
+            throws RepositoryException, RemoteException;
+
+    /**
+     * Retrieve the <code>QNodeTypeDefinition</code>s of all registered nodetypes.
+     *
+     * @param sessionInfo
+     * @return
+     * @throws javax.jcr.RepositoryException
+     * @throws RemoteException if an error occurs.
+     * @see org.apache.jackrabbit.spi.RepositoryService#getNodeTypeDefinitions(org.apache.jackrabbit.spi.SessionInfo)
+     */
+    public QNodeTypeDefinition[] getNodeTypeDefinitions(RemoteSessionInfo sessionInfo)
+            throws RepositoryException, RemoteException;
+}

Propchange: jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/remote/RemoteRepositoryService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/remote/RemoteSessionInfo.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/remote/RemoteSessionInfo.java?view=auto&rev=512795
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/remote/RemoteSessionInfo.java (added)
+++ jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/remote/RemoteSessionInfo.java Wed Feb 28 07:09:27 2007
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.spi.rmi.remote;
+
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+/**
+ * <code>RemoteSessionInfo</code>...
+ */
+public interface RemoteSessionInfo extends Remote {
+
+    /**
+     * Remote version of {@link org.apache.jackrabbit.spi.SessionInfo#addLockToken(String)}.
+     */
+    public String getUserID() throws RemoteException;
+
+    /**
+     * Remote version of {@link org.apache.jackrabbit.spi.SessionInfo#addLockToken(String)}.
+     */
+    public String getWorkspaceName() throws RemoteException;
+
+    /**
+     * Remote version of {@link org.apache.jackrabbit.spi.SessionInfo#addLockToken(String)}.
+     */
+    public String[] getLockTokens() throws RemoteException;
+
+    /**
+     * Remote version of {@link org.apache.jackrabbit.spi.SessionInfo#addLockToken(String)}.
+     */
+    public void addLockToken(String lockToken) throws RemoteException;
+
+    /**
+     * Remote version of {@link org.apache.jackrabbit.spi.SessionInfo#removeLockToken(String)}.
+     */
+    public void removeLockToken(String lockToken) throws RemoteException;
+
+    /**
+     * Remote version of {@link org.apache.jackrabbit.spi.SessionInfo#getLastEventBundleId()}.
+     */
+    public String getLastEventBundleId() throws RemoteException;
+
+    /**
+     * Remote version of {@link org.apache.jackrabbit.spi.SessionInfo#setLastEventBundleId(String)}.
+     */
+    public void setLastEventBundleId(String eventBundleId) throws RemoteException;
+
+}

Propchange: jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/remote/RemoteSessionInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerBatch.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerBatch.java?view=auto&rev=512795
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerBatch.java (added)
+++ jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerBatch.java Wed Feb 28 07:09:27 2007
@@ -0,0 +1,162 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.spi.rmi.server;
+
+import org.apache.jackrabbit.spi.rmi.remote.RemoteBatch;
+import org.apache.jackrabbit.spi.NodeId;
+import org.apache.jackrabbit.spi.QValue;
+import org.apache.jackrabbit.spi.PropertyId;
+import org.apache.jackrabbit.spi.ItemId;
+import org.apache.jackrabbit.spi.Batch;
+import org.apache.jackrabbit.name.QName;
+
+import javax.jcr.RepositoryException;
+import java.rmi.RemoteException;
+
+/**
+ * <code>ServerBatch</code> implements the server side of a remote batch.
+ */
+class ServerBatch extends ServerObject implements RemoteBatch {
+
+    /**
+     * The wrapped SPI batch.
+     */
+    private final Batch batch;
+
+    ServerBatch(Batch batch) throws RemoteException {
+        this.batch = batch;
+    }
+
+    /**
+     * @return the wrapped SPI batch.
+     */
+    Batch getBatch() {
+        return batch;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void addNode(NodeId parentId,
+                        QName nodeName,
+                        QName nodetypeName,
+                        String uuid) throws RepositoryException, RemoteException {
+        try {
+            batch.addNode(parentId, nodeName, nodetypeName, uuid);
+        } catch (RepositoryException e) {
+            throw getRepositoryException(e);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void addProperty(NodeId parentId, QName propertyName, QValue value)
+            throws RepositoryException, RemoteException {
+        try {
+            batch.addProperty(parentId, propertyName, value);
+        } catch (RepositoryException e) {
+            throw getRepositoryException(e);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void addProperty(NodeId parentId,
+                            QName propertyName,
+                            QValue[] values) throws RepositoryException, RemoteException {
+        try {
+            batch.addProperty(parentId, propertyName, values);
+        } catch (RepositoryException e) {
+            throw getRepositoryException(e);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setValue(PropertyId propertyId, QValue value)
+            throws RepositoryException, RemoteException {
+        try {
+            batch.setValue(propertyId, value);
+        } catch (RepositoryException e) {
+            throw getRepositoryException(e);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setValue(PropertyId propertyId, QValue[] values)
+            throws RepositoryException, RemoteException {
+        try {
+            batch.setValue(propertyId, values);
+        } catch (RepositoryException e) {
+            throw getRepositoryException(e);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void remove(ItemId itemId) throws RepositoryException, RemoteException {
+        try {
+            batch.remove(itemId);
+        } catch (RepositoryException e) {
+            throw getRepositoryException(e);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void reorderNodes(NodeId parentId,
+                             NodeId srcNodeId,
+                             NodeId beforeNodeId) throws RepositoryException, RemoteException {
+        try {
+            batch.reorderNodes(parentId, srcNodeId, beforeNodeId);
+        } catch (RepositoryException e) {
+            throw getRepositoryException(e);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setMixins(NodeId nodeId, QName[] mixinNodeTypeIds)
+            throws RepositoryException, RemoteException {
+        try {
+            batch.setMixins(nodeId, mixinNodeTypeIds);
+        } catch (RepositoryException e) {
+            throw getRepositoryException(e);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void move(NodeId srcNodeId,
+                     NodeId destParentNodeId,
+                     QName destName) throws RepositoryException, RemoteException {
+        try {
+            batch.move(srcNodeId, destParentNodeId, destName);
+        } catch (RepositoryException e) {
+            throw getRepositoryException(e);
+        }
+    }
+}

Propchange: jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerBatch.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerIterator.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerIterator.java?view=auto&rev=512795
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerIterator.java (added)
+++ jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerIterator.java Wed Feb 28 07:09:27 2007
@@ -0,0 +1,170 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.spi.rmi.server;
+
+import org.apache.jackrabbit.spi.rmi.remote.RemoteIterator;
+
+import java.rmi.RemoteException;
+import java.util.ArrayList;
+import java.util.NoSuchElementException;
+import java.util.Iterator;
+
+import javax.jcr.RangeIterator;
+
+/**
+ * Remote adapter for the JCR {@link RangeIterator} interface. This
+ * class makes a local iterator available as an RMI service using the
+ * {@link RemoteIterator} interface.
+ */
+class ServerIterator extends ServerObject implements RemoteIterator {
+
+    /** The adapted local iterator. */
+    private final RangeIterator iterator;
+
+    /** The maximum number of elements to send per request. */
+    private final int maxBufferSize;
+
+    /**
+     * The cached number of elements in the iterator, -1 if the iterator
+     * size is unknown, or -2 if the size has not been retrieved from the
+     * adapted local iterator. This variable is useful in cases when the
+     * underlying iterator does not know its sizes (getSize() returns -1)
+     * but we reach the end of the iterator in a nextObjects() call and
+     * can thus determine the size of the iterator.
+     */
+    private long size;
+
+    /**
+     * Creates a remote adapter for the given local item.
+     *
+     * @param iterator      local iterator to be adapted
+     * @param maxBufferSize maximum buffer size
+     */
+    public ServerIterator(RangeIterator iterator, int maxBufferSize)
+            throws RemoteException {
+        this.iterator = iterator;
+        this.maxBufferSize = maxBufferSize;
+        this.size = -2;
+    }
+
+    /**
+     * Creates a remote adapter for the given local item.
+     *
+     * @param iterator      local iterator to be adapted
+     * @param maxBufferSize maximum buffer size
+     */
+    public ServerIterator(Iterator iterator, int maxBufferSize)
+            throws RemoteException {
+        this(new IteratorAdapter(iterator), maxBufferSize);
+    }
+
+    /**
+     * Returns the size of the iterator. The size is cached by invoking the
+     * adapted local iterator when this method is first called or by
+     * determining the size from an end-of-iterator condition in nextObjects().
+     *
+     * @return size of the iterator
+     * @throws RemoteException on RMI errors
+     * @see RemoteIterator#getSize()
+     * @see RangeIterator#getSize()
+     */
+    public long getSize() throws RemoteException {
+        if (size == -2) {
+            size = iterator.getSize();
+        }
+        return size;
+    }
+
+    /**
+     * Skips the given number of elements.
+     *
+     * @param items number of elements to skip
+     * @throws NoSuchElementException if skipped past the last element
+     * @throws RemoteException on RMI errors
+     */
+    public void skip(long items)
+            throws NoSuchElementException, RemoteException {
+        try {
+            iterator.skip(items);
+        } catch (NoSuchElementException e) {
+            throw new NoSuchElementException(e.getMessage());
+        }
+    }
+
+    /**
+     * Returns an array of remote references to the next elements in this
+     * iteration.
+     *
+     * @return array of remote references, or <code>null</code>
+     * @throws RemoteException on RMI errors
+     * @see RemoteIterator#nextObjects()
+     * @see java.util.Iterator#next()
+     */
+    public Object[] nextObjects() throws RemoteException {
+        if (!iterator.hasNext()) {
+            return null;
+        } else {
+            ArrayList items = new ArrayList();
+            while (items.size() < maxBufferSize && iterator.hasNext()) {
+                items.add(iterator.next());
+            }
+            if (!iterator.hasNext()) {
+                size = iterator.getPosition();
+            }
+            return items.toArray();
+        }
+    }
+
+    private static final class IteratorAdapter implements RangeIterator {
+
+        private final Iterator iter;
+
+        private long pos = 0;
+
+        private IteratorAdapter(Iterator iter) {
+            this.iter = iter;
+        }
+
+        public void skip(long skipNum) {
+            while (skipNum-- > 0) {
+                next();
+            }
+        }
+
+        public long getSize() {
+            return -1;
+        }
+
+        public long getPosition() {
+            return pos;
+        }
+
+        public void remove() {
+            iter.remove();
+        }
+
+        public boolean hasNext() {
+            return iter.hasNext();
+        }
+
+        public Object next() {
+            Object obj = iter.next();
+            pos++;
+            return obj;
+        }
+    }
+}

Propchange: jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerIterator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerObject.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerObject.java?view=auto&rev=512795
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerObject.java (added)
+++ jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerObject.java Wed Feb 28 07:09:27 2007
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.spi.rmi.server;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.ValueFormatException;
+import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.ReferentialIntegrityException;
+import javax.jcr.PathNotFoundException;
+import javax.jcr.NoSuchWorkspaceException;
+import javax.jcr.NamespaceException;
+import javax.jcr.MergeException;
+import javax.jcr.LoginException;
+import javax.jcr.ItemNotFoundException;
+import javax.jcr.ItemExistsException;
+import javax.jcr.InvalidSerializedDataException;
+import javax.jcr.InvalidItemStateException;
+import javax.jcr.AccessDeniedException;
+import javax.jcr.query.InvalidQueryException;
+import javax.jcr.lock.LockException;
+import javax.jcr.nodetype.NoSuchNodeTypeException;
+import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.version.VersionException;
+import java.rmi.server.UnicastRemoteObject;
+import java.rmi.RemoteException;
+
+/**
+ * <code>ServerObject</code> provides utility methods to server objects.
+ */
+class ServerObject extends UnicastRemoteObject {
+
+    ServerObject() throws RemoteException {
+        super();
+    }
+
+    /**
+     * Returns a cleaned version of the given exception. In some cases
+     * the underlying repository implementation may throw exceptions
+     * that are either unserializable, use exception subclasses that are
+     * only locally available, contain references to unserializable or
+     * only locally available classes. This method returns a cleaned
+     * version of such an exception. The returned exception contains only
+     * the message string from the original exception, and uses the public
+     * JCR exception class that most specifically matches the original
+     * exception.
+     *
+     * @param ex the original exception
+     * @return clean exception
+     */
+    protected RepositoryException getRepositoryException(
+            RepositoryException ex) {
+        if (ex instanceof AccessDeniedException) {
+            return new AccessDeniedException(ex.getMessage());
+        } else if (ex instanceof ConstraintViolationException) {
+            return new ConstraintViolationException(ex.getMessage());
+        } else if (ex instanceof InvalidItemStateException) {
+            return new InvalidItemStateException(ex.getMessage());
+        } else if (ex instanceof InvalidQueryException) {
+            return new InvalidQueryException(ex.getMessage());
+        } else if (ex instanceof InvalidSerializedDataException) {
+            return new InvalidSerializedDataException(ex.getMessage());
+        } else if (ex instanceof ItemExistsException) {
+            return new ItemExistsException(ex.getMessage());
+        } else if (ex instanceof ItemNotFoundException) {
+            return new ItemNotFoundException(ex.getMessage());
+        } else if (ex instanceof LockException) {
+            return new LockException(ex.getMessage());
+        } else if (ex instanceof LoginException) {
+            return new LoginException(ex.getMessage());
+        } else if (ex instanceof MergeException) {
+            return new MergeException(ex.getMessage());
+        } else if (ex instanceof NamespaceException) {
+            return new NamespaceException(ex.getMessage());
+        } else if (ex instanceof NoSuchNodeTypeException) {
+            return new NoSuchNodeTypeException(ex.getMessage());
+        } else if (ex instanceof NoSuchWorkspaceException) {
+            return new NoSuchWorkspaceException(ex.getMessage());
+        } else if (ex instanceof PathNotFoundException) {
+            return new PathNotFoundException(ex.getMessage());
+        } else if (ex instanceof ReferentialIntegrityException) {
+            return new ReferentialIntegrityException(ex.getMessage());
+        } else if (ex instanceof UnsupportedRepositoryOperationException) {
+            return new UnsupportedRepositoryOperationException(ex.getMessage());
+        } else if (ex instanceof ValueFormatException) {
+            return new ValueFormatException(ex.getMessage());
+        } else if (ex instanceof VersionException) {
+            return new VersionException(ex.getMessage());
+        } else {
+            return new RepositoryException(ex.getMessage());
+        }
+    }
+}

Propchange: jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerObject.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerQueryInfo.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerQueryInfo.java?view=auto&rev=512795
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerQueryInfo.java (added)
+++ jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerQueryInfo.java Wed Feb 28 07:09:27 2007
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.spi.rmi.server;
+
+import org.apache.jackrabbit.spi.rmi.remote.RemoteQueryInfo;
+import org.apache.jackrabbit.spi.rmi.remote.RemoteIterator;
+import org.apache.jackrabbit.spi.rmi.common.QueryResultRowImpl;
+import org.apache.jackrabbit.spi.QueryInfo;
+import org.apache.jackrabbit.spi.QueryResultRow;
+import org.apache.jackrabbit.spi.IdFactory;
+import org.apache.jackrabbit.spi.NodeId;
+import org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.util.IteratorHelper;
+
+import java.rmi.RemoteException;
+
+/**
+ * <code>ServerQueryInfo</code>...
+ */
+class ServerQueryInfo extends ServerObject implements RemoteQueryInfo {
+
+    /**
+     * The underlying query info.
+     */
+    private final QueryInfo queryInfo;
+
+    /**
+     * The number of rows to transmit in a single RMI call.
+     */
+    private final int iteratorBufferSize;
+
+    /**
+     * An id factory, which creates serializable ids.
+     */
+    private final IdFactory idFactory;
+
+    public ServerQueryInfo(QueryInfo queryInfo,
+                           int iteratorBufferSize,
+                           IdFactory idFactory)
+            throws RemoteException {
+        this.queryInfo = queryInfo;
+        this.iteratorBufferSize = iteratorBufferSize;
+        this.idFactory = idFactory;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public RemoteIterator getRows() throws RemoteException {
+        return new ServerIterator(new IteratorHelper(queryInfo.getRows()) {
+            public Object next() {
+                QueryResultRow row = (QueryResultRow) super.next();
+                NodeId rowId = row.getNodeId();
+                rowId = idFactory.createNodeId(
+                        rowId.getUniqueID(), rowId.getPath());
+                return new QueryResultRowImpl(
+                        rowId, row.getScore(), row.getValues());
+            }
+        }, iteratorBufferSize);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public QName[] getColumnNames() throws RemoteException {
+        return queryInfo.getColumnNames();
+    }
+}

Propchange: jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerQueryInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerRepositoryService.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerRepositoryService.java?view=auto&rev=512795
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerRepositoryService.java (added)
+++ jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerRepositoryService.java Wed Feb 28 07:09:27 2007
@@ -0,0 +1,873 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.spi.rmi.server;
+
+import org.apache.jackrabbit.spi.rmi.remote.RemoteRepositoryService;
+import org.apache.jackrabbit.spi.rmi.remote.RemoteSessionInfo;
+import org.apache.jackrabbit.spi.rmi.remote.RemoteBatch;
+import org.apache.jackrabbit.spi.rmi.remote.RemoteQueryInfo;
+import org.apache.jackrabbit.spi.rmi.remote.RemoteIterator;
+import org.apache.jackrabbit.spi.rmi.common.SerializableIdFactory;
+import org.apache.jackrabbit.spi.rmi.common.QNodeDefinitionImpl;
+import org.apache.jackrabbit.spi.rmi.common.QPropertyDefinitionImpl;
+import org.apache.jackrabbit.spi.rmi.common.NodeInfoImpl;
+import org.apache.jackrabbit.spi.rmi.common.PropertyInfoImpl;
+import org.apache.jackrabbit.spi.rmi.common.LockInfoImpl;
+import org.apache.jackrabbit.spi.rmi.common.QNodeTypeDefinitionImpl;
+import org.apache.jackrabbit.spi.rmi.common.ChildInfoImpl;
+import org.apache.jackrabbit.spi.rmi.common.IteratorHelper;
+import org.apache.jackrabbit.spi.ItemId;
+import org.apache.jackrabbit.spi.RepositoryService;
+import org.apache.jackrabbit.spi.SessionInfo;
+import org.apache.jackrabbit.spi.NodeId;
+import org.apache.jackrabbit.spi.QNodeDefinition;
+import org.apache.jackrabbit.spi.QPropertyDefinition;
+import org.apache.jackrabbit.spi.PropertyId;
+import org.apache.jackrabbit.spi.NodeInfo;
+import org.apache.jackrabbit.spi.PropertyInfo;
+import org.apache.jackrabbit.spi.LockInfo;
+import org.apache.jackrabbit.spi.EventFilter;
+import org.apache.jackrabbit.spi.EventBundle;
+import org.apache.jackrabbit.spi.QNodeTypeDefinition;
+import org.apache.jackrabbit.spi.IdIterator;
+import org.apache.jackrabbit.spi.QueryInfo;
+import org.apache.jackrabbit.spi.QNodeTypeDefinitionIterator;
+import org.apache.jackrabbit.spi.ChildInfo;
+import org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.name.Path;
+
+import javax.jcr.Credentials;
+import javax.jcr.RepositoryException;
+import java.util.Map;
+import java.util.Iterator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.rmi.RemoteException;
+import java.rmi.Remote;
+import java.rmi.server.RemoteObject;
+import java.io.InputStream;
+import java.io.Serializable;
+
+/**
+ * <code>ServerRepositoryService</code> implements a remote repository service
+ * based on a SPI {@link org.apache.jackrabbit.spi.RepositoryService}.
+ */
+public class ServerRepositoryService extends ServerObject implements RemoteRepositoryService {
+
+    /**
+     * The default iterator buffer size.
+     */
+    private static final int DEFAULT_BUFFER_SIZE = 100;
+
+    /**
+     * The underlying repository service to remote.
+     */
+    private final RepositoryService service;
+
+    /**
+     * The id factory.
+     */
+    private final SerializableIdFactory idFactory = SerializableIdFactory.getInstance();
+
+    /**
+     * Maps remote stubs to {@link ServerSessionInfo}s.
+     */
+    private final Map activeSessionInfos = Collections.synchronizedMap(new HashMap());
+
+    /**
+     * Maps remote stubs to {@link ServerBatch}es.
+     */
+    private final Map activeBatches = Collections.synchronizedMap(new HashMap());
+
+    /**
+     * Creates a new server repository service.
+     *
+     * @param service repository service to remote.
+     */
+    public ServerRepositoryService(RepositoryService service)
+            throws RemoteException {
+        this.service = service;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Map getRepositoryDescriptors() throws RepositoryException, RemoteException {
+        try {
+            Map descriptors = service.getRepositoryDescriptors();
+            if (descriptors instanceof Serializable) {
+                return descriptors;
+            } else {
+                return new HashMap(descriptors);
+            }
+        } catch (RepositoryException e) {
+            throw getRepositoryException(e);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public RemoteSessionInfo obtain(Credentials credentials,
+                                    String workspaceName)
+            throws RepositoryException, RemoteException {
+        try {
+            return createServerSessionInfo(service.obtain(credentials, workspaceName));
+        } catch (RepositoryException e) {
+            throw getRepositoryException(e);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public RemoteSessionInfo obtain(RemoteSessionInfo sessionInfo,
+                                    String workspaceName)
+            throws RepositoryException, RemoteException {
+
+        try {
+            return createServerSessionInfo(
+                    service.obtain(getSessionInfo(sessionInfo), workspaceName));
+        } catch (RepositoryException e) {
+            throw getRepositoryException(e);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void dispose(RemoteSessionInfo sessionInfo)
+            throws RepositoryException, RemoteException {
+        try {
+            activeSessionInfos.remove(RemoteObject.toStub(sessionInfo));
+            service.dispose(getSessionInfo(sessionInfo));
+        } catch (RepositoryException e) {
+            throw getRepositoryException(e);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String[] getWorkspaceNames(RemoteSessionInfo sessionInfo)
+            throws RepositoryException, RemoteException {
+        try {
+            return service.getWorkspaceNames(getSessionInfo(sessionInfo));
+        } catch (RepositoryException e) {
+            throw getRepositoryException(e);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isGranted(RemoteSessionInfo sessionInfo,
+                             ItemId itemId,
+                             String[] actions) throws RepositoryException, RemoteException {
+        try {
+            return service.isGranted(getSessionInfo(sessionInfo), itemId, actions);
+        } catch (RepositoryException e) {
+            throw getRepositoryException(e);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public NodeId getRootId(RemoteSessionInfo sessionInfo)
+            throws RepositoryException, RemoteException {
+        try {
+            return createSerializableNodeId(
+                    service.getRootId(getSessionInfo(sessionInfo)));
+        } catch (RepositoryException e) {
+            throw getRepositoryException(e);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public QNodeDefinition getNodeDefinition(RemoteSessionInfo sessionInfo,
+                                             NodeId nodeId)
+            throws RepositoryException, RemoteException {
+        try {
+            QNodeDefinition nDef = service.getNodeDefinition(
+                    getSessionInfo(sessionInfo), nodeId);
+            if (nDef instanceof Serializable) {
+                return nDef;
+            } else {
+                return new QNodeDefinitionImpl(nDef);
+            }
+        } catch (RepositoryException e) {
+            throw getRepositoryException(e);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public QPropertyDefinition getPropertyDefinition(
+            RemoteSessionInfo sessionInfo, PropertyId propertyId)
+            throws RepositoryException, RemoteException {
+        try {
+            QPropertyDefinition pDef = service.getPropertyDefinition(
+                    getSessionInfo(sessionInfo), propertyId);
+            if (pDef instanceof Serializable) {
+                return pDef;
+            } else {
+                return new QPropertyDefinitionImpl(pDef);
+            }
+        } catch (RepositoryException e) {
+            throw getRepositoryException(e);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean exists(RemoteSessionInfo sessionInfo, ItemId itemId)
+            throws RepositoryException, RemoteException {
+        try {
+            return service.exists(getSessionInfo(sessionInfo), itemId);
+        } catch (RepositoryException e) {
+            throw getRepositoryException(e);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public NodeInfo getNodeInfo(RemoteSessionInfo sessionInfo, NodeId nodeId)
+            throws RepositoryException, RemoteException {
+        try {
+            NodeInfo nInfo = service.getNodeInfo(getSessionInfo(sessionInfo), nodeId);
+            if (nInfo instanceof Serializable) {
+                return nInfo;
+            } else {
+                PropertyId[] refs = nInfo.getReferences();
+                PropertyId[] serRefs = new PropertyId[refs.length];
+                for (int i = 0; i < serRefs.length; i++) {
+                    serRefs[i] = createSerializablePropertyId(refs[i]);
+                }
+                NodeId parentId = null;
+                if (nInfo.getParentId() != null) {
+                    parentId = createSerializableNodeId(nInfo.getParentId());
+                }
+                return new NodeInfoImpl(parentId, nInfo.getQName(),
+                        nInfo.getPath(),
+                        createSerializableNodeId(nInfo.getId()),
+                        nInfo.getIndex(), nInfo.getNodetype(),
+                        nInfo.getMixins(), serRefs,
+                        new IteratorHelper(nInfo.getPropertyIds()) {
+                            public ItemId nextId() {
+                                return createSerializablePropertyId(
+                                        (PropertyId) super.nextId());
+                            }
+                        });
+            }
+        } catch (RepositoryException e) {
+            throw getRepositoryException(e);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public RemoteIterator getChildInfos(RemoteSessionInfo sessionInfo,
+                                  NodeId parentId) throws RepositoryException, RemoteException {
+        try {
+            Iterator childInfos = service.getChildInfos(
+                    getSessionInfo(sessionInfo), parentId);
+            return new ServerIterator(new IteratorHelper(childInfos) {
+                public Object next() {
+                    ChildInfo cInfo = (ChildInfo) super.next();
+                    if (cInfo instanceof Serializable) {
+                        return cInfo;
+                    } else {
+                        return new ChildInfoImpl(cInfo.getName(),
+                                cInfo.getUniqueID(), cInfo.getIndex());
+                    }
+                }
+            }, DEFAULT_BUFFER_SIZE);
+        } catch (RepositoryException e) {
+            throw getRepositoryException(e);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public PropertyInfo getPropertyInfo(RemoteSessionInfo sessionInfo,
+                                        PropertyId propertyId)
+            throws RepositoryException, RemoteException {
+        try {
+            PropertyInfo propInfo = service.getPropertyInfo(
+                    getSessionInfo(sessionInfo), propertyId);
+            return new PropertyInfoImpl(
+                    createSerializableNodeId(propInfo.getParentId()),
+                    propInfo.getQName(), propInfo.getPath(),
+                    createSerializablePropertyId(propInfo.getId()),
+                    propInfo.getType(), propInfo.isMultiValued(),
+                    propInfo.getValues());
+        } catch (RepositoryException e) {
+            throw getRepositoryException(e);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public RemoteBatch createBatch(ItemId itemId,
+                                   RemoteSessionInfo sessionInfo)
+            throws RepositoryException, RemoteException {
+        try {
+            ServerBatch sBatch = new ServerBatch(
+                    service.createBatch(itemId, getSessionInfo(sessionInfo)));
+            activeBatches.put(RemoteObject.toStub(sBatch), sBatch);
+            return sBatch;
+        } catch (RepositoryException e) {
+            throw getRepositoryException(e);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void submit(RemoteBatch batch) throws RepositoryException, RemoteException {
+        ServerBatch sBatch = (ServerBatch) activeBatches.remove(
+                RemoteObject.toStub(batch));
+        if (sBatch != null) {
+            try {
+                service.submit(sBatch.getBatch());
+            } catch (RepositoryException e) {
+                throw getRepositoryException(e);
+            }
+        } else {
+            throw new RepositoryException("Unknown RemoteBatch: " +
+                    ((RemoteObject) batch).getRef());
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void importXml(RemoteSessionInfo sessionInfo,
+                          NodeId parentId,
+                          InputStream xmlStream,
+                          int uuidBehaviour) throws RepositoryException, RemoteException {
+        try {
+            service.importXml(getSessionInfo(sessionInfo),
+                    parentId, xmlStream, uuidBehaviour);
+        } catch (RepositoryException e) {
+            throw getRepositoryException(e);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void move(RemoteSessionInfo sessionInfo,
+                     NodeId srcNodeId,
+                     NodeId destParentNodeId,
+                     QName destName) throws RepositoryException, RemoteException {
+        try {
+            service.move(getSessionInfo(sessionInfo),
+                    srcNodeId, destParentNodeId, destName);
+        } catch (RepositoryException e) {
+            throw getRepositoryException(e);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void copy(RemoteSessionInfo sessionInfo,
+                     String srcWorkspaceName,
+                     NodeId srcNodeId,
+                     NodeId destParentNodeId,
+                     QName destName) throws RepositoryException, RemoteException {
+        try {
+            service.copy(getSessionInfo(sessionInfo), srcWorkspaceName,
+                    srcNodeId, destParentNodeId, destName);
+        } catch (RepositoryException e) {
+            throw getRepositoryException(e);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void update(RemoteSessionInfo sessionInfo,
+                       NodeId nodeId,
+                       String srcWorkspaceName) throws RepositoryException, RemoteException {
+        try {
+            service.update(getSessionInfo(sessionInfo),
+                    nodeId, srcWorkspaceName);
+        } catch (RepositoryException e) {
+            throw getRepositoryException(e);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void clone(RemoteSessionInfo sessionInfo,
+                      String srcWorkspaceName,
+                      NodeId srcNodeId,
+                      NodeId destParentNodeId,
+                      QName destName,
+                      boolean removeExisting) throws RepositoryException, RemoteException {
+        try {
+            service.clone(getSessionInfo(sessionInfo), srcWorkspaceName,
+                    srcNodeId, destParentNodeId, destName, removeExisting);
+        } catch (RepositoryException e) {
+            throw getRepositoryException(e);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public LockInfo getLockInfo(RemoteSessionInfo sessionInfo, NodeId nodeId)
+            throws RepositoryException, RemoteException {
+        try {
+            LockInfo lockInfo = service.getLockInfo(
+                    getSessionInfo(sessionInfo), nodeId);
+            if (lockInfo instanceof Serializable) {
+                return lockInfo;
+            } else {
+                return new LockInfoImpl(lockInfo.getLockToken(),
+                        lockInfo.getOwner(), lockInfo.isDeep(),
+                        lockInfo.isSessionScoped(),
+                        createSerializableNodeId(lockInfo.getNodeId()));
+            }
+        } catch (RepositoryException e) {
+            throw getRepositoryException(e);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public LockInfo lock(RemoteSessionInfo sessionInfo,
+                         NodeId nodeId,
+                         boolean deep,
+                         boolean sessionScoped) throws RepositoryException, RemoteException {
+        try {
+            LockInfo lockInfo = service.lock(getSessionInfo(sessionInfo),
+                    nodeId, deep, sessionScoped);
+            if (lockInfo instanceof Serializable) {
+                return lockInfo;
+            } else {
+                return new LockInfoImpl(lockInfo.getLockToken(),
+                        lockInfo.getOwner(), lockInfo.isDeep(),
+                        lockInfo.isSessionScoped(),
+                        createSerializableNodeId(lockInfo.getNodeId()));
+            }
+        } catch (RepositoryException e) {
+            throw getRepositoryException(e);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void refreshLock(RemoteSessionInfo sessionInfo, NodeId nodeId)
+            throws RepositoryException, RemoteException {
+        try {
+            service.refreshLock(getSessionInfo(sessionInfo), nodeId);
+        } catch (RepositoryException e) {
+            throw getRepositoryException(e);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void unlock(RemoteSessionInfo sessionInfo, NodeId nodeId)
+            throws RepositoryException, RemoteException {
+        try {
+            service.unlock(getSessionInfo(sessionInfo), nodeId);
+        } catch (RepositoryException e) {
+            throw getRepositoryException(e);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void checkin(RemoteSessionInfo sessionInfo, NodeId nodeId)
+            throws RepositoryException, RemoteException {
+        try {
+            service.checkin(getSessionInfo(sessionInfo), nodeId);
+        } catch (RepositoryException e) {
+            throw getRepositoryException(e);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void checkout(RemoteSessionInfo sessionInfo, NodeId nodeId)
+            throws RepositoryException, RemoteException {
+        try {
+            service.checkout(getSessionInfo(sessionInfo), nodeId);
+        } catch (RepositoryException e) {
+            throw getRepositoryException(e);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void removeVersion(RemoteSessionInfo sessionInfo,
+                              NodeId versionHistoryId,
+                              NodeId versionId) throws RepositoryException, RemoteException {
+        try {
+            service.removeVersion(getSessionInfo(sessionInfo),
+                    versionHistoryId, versionId);
+        } catch (RepositoryException e) {
+            throw getRepositoryException(e);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void restore(RemoteSessionInfo sessionInfo,
+                        NodeId nodeId,
+                        NodeId versionId,
+                        boolean removeExisting) throws RepositoryException, RemoteException {
+        try {
+            service.restore(getSessionInfo(sessionInfo),
+                    nodeId, versionId, removeExisting);
+        } catch (RepositoryException e) {
+            throw getRepositoryException(e);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void restore(RemoteSessionInfo sessionInfo,
+                        NodeId[] versionIds,
+                        boolean removeExisting) throws RepositoryException, RemoteException {
+        try {
+            service.restore(getSessionInfo(sessionInfo), versionIds, removeExisting);
+        } catch (RepositoryException e) {
+            throw getRepositoryException(e);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public RemoteIterator merge(RemoteSessionInfo sessionInfo,
+                                NodeId nodeId,
+                                String srcWorkspaceName,
+                                boolean bestEffort) throws RepositoryException, RemoteException {
+        try {
+            IdIterator it = service.merge(getSessionInfo(sessionInfo),
+                    nodeId, srcWorkspaceName, bestEffort);
+            return new ServerIterator(it, DEFAULT_BUFFER_SIZE);
+        } catch (RepositoryException e) {
+            throw getRepositoryException(e);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void resolveMergeConflict(RemoteSessionInfo sessionInfo,
+                                     NodeId nodeId,
+                                     NodeId[] mergeFailedIds,
+                                     NodeId[] predecessorIds)
+            throws RepositoryException, RemoteException {
+        try {
+            service.resolveMergeConflict(getSessionInfo(sessionInfo),
+                    nodeId, mergeFailedIds, predecessorIds);
+        } catch (RepositoryException e) {
+            throw getRepositoryException(e);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void addVersionLabel(RemoteSessionInfo sessionInfo,
+                                NodeId versionHistoryId,
+                                NodeId versionId,
+                                QName label,
+                                boolean moveLabel) throws RepositoryException, RemoteException {
+        try {
+            service.addVersionLabel(getSessionInfo(sessionInfo),
+                    versionHistoryId, versionId, label, moveLabel);
+        } catch (RepositoryException e) {
+            throw getRepositoryException(e);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void removeVersionLabel(RemoteSessionInfo sessionInfo,
+                                   NodeId versionHistoryId,
+                                   NodeId versionId,
+                                   QName label) throws RepositoryException, RemoteException {
+        try {
+            service.removeVersionLabel(getSessionInfo(sessionInfo),
+                    versionHistoryId, versionId, label);
+        } catch (RepositoryException e) {
+            throw getRepositoryException(e);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String[] getSupportedQueryLanguages(RemoteSessionInfo sessionInfo)
+            throws RepositoryException, RemoteException {
+        try {
+            return service.getSupportedQueryLanguages(getSessionInfo(sessionInfo));
+        } catch (RepositoryException e) {
+            throw getRepositoryException(e);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void checkQueryStatement(RemoteSessionInfo sessionInfo,
+                                    String statement,
+                                    String language,
+                                    Map namespaces) throws RepositoryException, RemoteException {
+        try {
+            service.checkQueryStatement(getSessionInfo(sessionInfo),
+                    statement, language, namespaces);
+        } catch (RepositoryException e) {
+            throw getRepositoryException(e);
+        }
+    }
+
+    public RemoteQueryInfo executeQuery(RemoteSessionInfo sessionInfo,
+                                        String statement,
+                                        String language,
+                                        Map namespaces)
+            throws RepositoryException, RemoteException {
+        try {
+            QueryInfo qInfo = service.executeQuery(getSessionInfo(sessionInfo), statement, language, namespaces);
+            return new ServerQueryInfo(qInfo, DEFAULT_BUFFER_SIZE, idFactory);
+        } catch (RepositoryException e) {
+            throw getRepositoryException(e);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public EventFilter createEventFilter(RemoteSessionInfo sessionInfo,
+                                         int eventTypes,
+                                         Path absPath,
+                                         boolean isDeep,
+                                         String[] uuid,
+                                         QName[] nodeTypeName,
+                                         boolean noLocal)
+            throws RepositoryException, RemoteException {
+        try {
+            return service.createEventFilter(getSessionInfo(sessionInfo),
+                    eventTypes, absPath, isDeep, uuid, nodeTypeName, noLocal);
+        } catch (RepositoryException e) {
+            throw getRepositoryException(e);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public EventBundle[] getEvents(RemoteSessionInfo sessionInfo,
+                                   long timeout,
+                                   EventFilter[] filters)
+            throws RepositoryException, InterruptedException, RemoteException {
+        try {
+            EventBundle[] bundles = service.getEvents(
+                    getSessionInfo(sessionInfo), timeout, filters);
+            // TODO
+            return new EventBundle[0];
+        } catch (RepositoryException e) {
+            throw getRepositoryException(e);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Map getRegisteredNamespaces(RemoteSessionInfo sessionInfo)
+            throws RepositoryException, RemoteException {
+        try {
+            Map namespaces = service.getRegisteredNamespaces(getSessionInfo(sessionInfo));
+            if (namespaces instanceof Serializable) {
+                return namespaces;
+            } else {
+                return new HashMap(namespaces);
+            }
+        } catch (RepositoryException e) {
+            throw getRepositoryException(e);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getNamespaceURI(RemoteSessionInfo sessionInfo,
+                                  String prefix) throws RepositoryException, RemoteException {
+        try {
+            return service.getNamespaceURI(getSessionInfo(sessionInfo), prefix);
+        } catch (RepositoryException e) {
+            throw getRepositoryException(e);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getNamespacePrefix(RemoteSessionInfo sessionInfo,
+                                     String uri) throws RepositoryException, RemoteException {
+        try {
+            return service.getNamespacePrefix(getSessionInfo(sessionInfo), uri);
+        } catch (RepositoryException e) {
+            throw getRepositoryException(e);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void registerNamespace(RemoteSessionInfo sessionInfo,
+                                  String prefix,
+                                  String uri) throws RepositoryException, RemoteException {
+        try {
+            service.registerNamespace(getSessionInfo(sessionInfo), prefix, uri);
+        } catch (RepositoryException e) {
+            throw getRepositoryException(e);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void unregisterNamespace(RemoteSessionInfo sessionInfo, String uri)
+            throws RepositoryException, RemoteException {
+        try {
+            service.unregisterNamespace(getSessionInfo(sessionInfo), uri);
+        } catch (RepositoryException e) {
+            throw getRepositoryException(e);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public QNodeTypeDefinition[] getNodeTypeDefinitions(RemoteSessionInfo sessionInfo)
+            throws RepositoryException, RemoteException {
+        QNodeTypeDefinitionIterator it = service.getNodeTypeDefinitions(getSessionInfo(sessionInfo));
+        List nts = new ArrayList();
+        while (it.hasNext()) {
+            QNodeTypeDefinition nt = it.nextDefinition();
+            if (nt instanceof Serializable) {
+                nts.add(nt);
+            } else {
+                nts.add(new QNodeTypeDefinitionImpl(nt));
+            }
+        }
+        return (QNodeTypeDefinition[]) nts.toArray(new QNodeTypeDefinition[nts.size()]);
+    }
+
+    //---------------------------< internal >-----------------------------------
+
+    /**
+     * Creates a server session info for the given <code>sessionInfo</code>.
+     *
+     * @param sessionInfo the session info.
+     * @return a remote server session info.
+     * @throws RemoteException if the rmi sub system fails to export the newly
+     *                         created object.
+     */
+    private ServerSessionInfo createServerSessionInfo(SessionInfo sessionInfo)
+            throws RemoteException {
+        ServerSessionInfo ssInfo = new ServerSessionInfo(sessionInfo);
+        activeSessionInfos.put(RemoteObject.toStub(ssInfo), ssInfo);
+        return ssInfo;
+    }
+
+    /**
+     * Retrieves the server session info for the given remote
+     * <code>sInfo</code>.
+     *
+     * @param sInfo the remote session info.
+     * @return the server session info.
+     * @throws RepositoryException if server session info is not found for the
+     *                             given remote session info.
+     * @throws RemoteException     on rmi errors.
+     */
+    private SessionInfo getSessionInfo(RemoteSessionInfo sInfo)
+            throws RepositoryException, RemoteException {
+        Remote stub = RemoteObject.toStub(sInfo);
+        ServerSessionInfo ssInfo = (ServerSessionInfo) activeSessionInfos.get(stub);
+        if (ssInfo != null) {
+            return ssInfo.getSessionInfo();
+        } else {
+            throw new RepositoryException("Unknown RemoteSessionInfo: " +
+                    ((RemoteObject) sInfo).getRef());
+        }
+    }
+
+    /**
+     * Checks if the passed <code>nodeId</code> is serializable and if it is not
+     * creates a serializable version for the given <code>nodeId</code>.
+     *
+     * @param nodeId the node id to check.
+     * @return a serializable version of <code>nodeId</code> or the passed
+     *         nodeId itself it is already serializable.
+     */
+    private NodeId createSerializableNodeId(NodeId nodeId) {
+        if (nodeId instanceof Serializable) {
+            return nodeId;
+        } else {
+            return idFactory.createNodeId(nodeId.getUniqueID(), nodeId.getPath());
+        }
+    }
+
+    /**
+     * Checks if the passed <code>propId</code> is serializable and if it is not
+     * creates a serializable version for the given <code>propId</code>.
+     *
+     * @param propId the property id to check.
+     * @return a serializable version of <code>propId</code> or the passed
+     *         propId itself it is already serializable.
+     */
+    private PropertyId createSerializablePropertyId(PropertyId propId) {
+        if (propId instanceof Serializable) {
+            return propId;
+        } else {
+            return idFactory.createPropertyId(
+                    createSerializableNodeId(propId.getParentId()),
+                    propId.getQName());
+        }
+    }
+}

Propchange: jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerRepositoryService.java
------------------------------------------------------------------------------
    svn:eol-style = native