jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r773907 - in /jackrabbit/trunk: jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/ jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/l...
Date Tue, 12 May 2009 14:14:19 GMT
Author: angela
Date: Tue May 12 14:14:19 2009
New Revision: 773907

URL: http://svn.apache.org/viewvc?rev=773907&view=rev
Log:
JCR-2003: Add support for JCR 2.0

- Workspace.createWorkspace
- Workspace.deleteWorkspace

Modified:
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceImpl.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/AbstractReadableRepositoryService.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/RepositoryServiceLogger.java
    jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/RepositoryService.java
    jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
    jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceImpl.java?rev=773907&r1=773906&r2=773907&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceImpl.java
Tue May 12 14:14:19 2009
@@ -346,18 +346,19 @@
      * @see javax.jcr.Workspace#createWorkspace(String)
      */
     public void createWorkspace(String name) throws RepositoryException {
-        // TODO: implementation missing
-        throw new UnsupportedRepositoryOperationException("JCR-1104");
+        session.checkIsAlive();
+        session.checkSupportedOption(Repository.OPTION_WORKSPACE_MANAGEMENT_SUPPORTED);
+        wspManager.createWorkspace(name, null);
     }
 
 
     /**
      * @see javax.jcr.Workspace#createWorkspace(String, String)
      */
-    public void createWorkspace(String name, String srcWorkspace)
-            throws RepositoryException {
-        // TODO: implementation missing
-        throw new UnsupportedRepositoryOperationException("JCR-1104");
+    public void createWorkspace(String name, String srcWorkspace) throws RepositoryException
{
+        session.checkIsAlive();
+        session.checkSupportedOption(Repository.OPTION_WORKSPACE_MANAGEMENT_SUPPORTED);
+        wspManager.createWorkspace(name, srcWorkspace);
     }
 
 
@@ -365,8 +366,9 @@
      * @see javax.jcr.Workspace#deleteWorkspace(String)
      */
     public void deleteWorkspace(String name) throws RepositoryException {
-        // TODO: implementation missing
-        throw new UnsupportedRepositoryOperationException("JCR-1104");
+        session.checkIsAlive();
+        session.checkSupportedOption(Repository.OPTION_WORKSPACE_MANAGEMENT_SUPPORTED);
+        wspManager.deleteWorkspace(name);
     }
 
 

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java?rev=773907&r1=773906&r2=773907&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
Tue May 12 14:14:19 2009
@@ -388,6 +388,7 @@
         throws UnsupportedRepositoryOperationException, RepositoryException {
         return service.createEventFilter(sessionInfo, eventTypes, path, isDeep, uuids, nodeTypes,
noLocal);
     }
+
     //--------------------------------------------------------------------------
 
     /**
@@ -483,6 +484,32 @@
         return t;
     }
 
+    //-----------------------------------------------------< wsp management >---
+    /**
+     * Create a new workspace with the specified <code>name</code>. If
+     * <code>srcWorkspaceName</code> isn't <code>null</code> the
content of
+     * that workspace is used as inital content, otherwise an empty workspace
+     * will be created.
+     *
+     * @param name The name of the workspace to be created.
+     * @param srcWorkspaceName The name of the workspace from which the initial
+     * content of the new workspace will be 'cloned'.
+     * @throws RepositoryException If an exception occurs.
+     */
+    void createWorkspace(String name, String srcWorkspaceName) throws RepositoryException
{
+        service.createWorkspace(sessionInfo, name, srcWorkspaceName);
+    }
+
+    /**
+     * Deletes the workspace with the specified <code>name</code>.
+     * 
+     * @param name
+     * @throws RepositoryException
+     */
+    void deleteWorkspace(String name) throws RepositoryException {
+        service.deleteWorkspace(sessionInfo, name);
+    }
+
     //------------------------------------------< UpdatableItemStateManager >---
     /**
      * Creates a new batch from the single workspace operation and executes it.

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/AbstractReadableRepositoryService.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/AbstractReadableRepositoryService.java?rev=773907&r1=773906&r2=773907&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/AbstractReadableRepositoryService.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/AbstractReadableRepositoryService.java
Tue May 12 14:14:19 2009
@@ -75,8 +75,7 @@
  * repository service implementation that only provide read access to the
  * underlying content.
  */
-public abstract class AbstractReadableRepositoryService
-        extends AbstractRepositoryService {
+public abstract class AbstractReadableRepositoryService extends AbstractRepositoryService
{
 
     protected static final Set WRITE_ACTIONS = new HashSet(Arrays.asList(
             new String[]{"add_node", "set_property", "remove"}));
@@ -683,7 +682,7 @@
         throw new UnsupportedRepositoryOperationException();
     }
 
-    //----------------------< namespace registry >------------------------------
+    //-------------------------------------------------< namespace registry >---
 
     /**
      * @throws UnsupportedRepositoryOperationException always.
@@ -702,6 +701,23 @@
         throw new UnsupportedRepositoryOperationException();
     }
 
+    //-----------------------------------------------< Workspace Management >---
+    /**
+     * @throws UnsupportedRepositoryOperationException always.
+     */
+    public void createWorkspace(SessionInfo sessionInfo, String name, String srcWorkspaceName)
throws AccessDeniedException, UnsupportedRepositoryOperationException, NoSuchWorkspaceException,
RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+
+    }
+
+    /**
+     * @throws UnsupportedRepositoryOperationException always.
+     */
+    public void deleteWorkspace(SessionInfo sessionInfo, String name) throws AccessDeniedException,
UnsupportedRepositoryOperationException, NoSuchWorkspaceException, RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+
+    }
+    
     //-------------------------------< query >----------------------------------
 
     public String[] getSupportedQueryLanguages(SessionInfo sessionInfo) throws

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/RepositoryServiceLogger.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/RepositoryServiceLogger.java?rev=773907&r1=773906&r2=773907&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/RepositoryServiceLogger.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/RepositoryServiceLogger.java
Tue May 12 14:14:19 2009
@@ -657,6 +657,25 @@
         }, "getQNodeTypeDefinitions(SessionInfo, Name[])", new Object[]{unwrap(sessionInfo),
nodetypeNames});
     }
 
+    public void createWorkspace(final SessionInfo sessionInfo, final String name, final String
srcWorkspaceName) throws RepositoryException {
+        execute(new Callable() {
+            public Object call() throws RepositoryException {
+                service.createWorkspace(unwrap(sessionInfo), name, srcWorkspaceName);
+                return null;
+            }
+        }, "createWorkspace(SessionInfo, String, String)", new Object[]{unwrap(sessionInfo),
name, srcWorkspaceName});
+    }
+
+    public void deleteWorkspace(final SessionInfo sessionInfo, final String name) throws
RepositoryException {
+        execute(new Callable() {
+            public Object call() throws RepositoryException {
+                service.deleteWorkspace(unwrap(sessionInfo), name);
+                return null;
+            }
+        }, "deleteWorkspace(SessionInfo, String, String)", new Object[]{unwrap(sessionInfo),
name});
+
+    }
+
     // -----------------------------------------------------< private  >---
 
     private static SessionInfo unwrap(SessionInfo sessionInfo) {

Modified: jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/RepositoryService.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/RepositoryService.java?rev=773907&r1=773906&r2=773907&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/RepositoryService.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/RepositoryService.java
Tue May 12 14:14:19 2009
@@ -610,6 +610,7 @@
      * @throws javax.jcr.lock.LockException
      * @throws javax.jcr.RepositoryException
      * @see javax.jcr.version.VersionManager#checkpoint(String)
+     * @since JCR 2.0
      */
     public NodeId checkpoint(SessionInfo sessionInfo, NodeId nodeId) throws UnsupportedRepositoryOperationException,
RepositoryException;
 
@@ -700,25 +701,26 @@
     public Iterator merge(SessionInfo sessionInfo, NodeId nodeId, String srcWorkspaceName,
boolean bestEffort) throws NoSuchWorkspaceException, AccessDeniedException, MergeException,
LockException, InvalidItemStateException, RepositoryException;
 
     /**
-      * Merge the node identified by the given <code>NodeId</code> and its subtree
-      * with the corresponding node present in the workspace with the name of
-      * <code>srcWorkspaceName</code>.
-      *
-      * @param sessionInfo
-      * @param nodeId
-      * @param srcWorkspaceName
-      * @param bestEffort
-      * @return an <code>Iterator</code> over the {@link NodeId}s of all nodes
that
-      * received a merge result of "fail" in the course of this operation.
-      * @throws javax.jcr.NoSuchWorkspaceException
-      * @throws javax.jcr.AccessDeniedException
-      * @throws javax.jcr.MergeException
-      * @throws javax.jcr.lock.LockException
-      * @throws javax.jcr.InvalidItemStateException
-      * @throws javax.jcr.RepositoryException
-      * @see javax.jcr.version.VersionManager#merge(String, String, boolean, boolean)
-      */
-     public Iterator merge(SessionInfo sessionInfo, NodeId nodeId, String srcWorkspaceName,
boolean bestEffort, boolean isShallow) throws NoSuchWorkspaceException, AccessDeniedException,
MergeException, LockException, InvalidItemStateException, RepositoryException;
+     * Merge the node identified by the given <code>NodeId</code> and its subtree
+     * with the corresponding node present in the workspace with the name of
+     * <code>srcWorkspaceName</code>.
+     *
+     * @param sessionInfo
+     * @param nodeId
+     * @param srcWorkspaceName
+     * @param bestEffort
+     * @return an <code>Iterator</code> over the {@link NodeId}s of all nodes
that
+     * received a merge result of "fail" in the course of this operation.
+     * @throws javax.jcr.NoSuchWorkspaceException
+     * @throws javax.jcr.AccessDeniedException
+     * @throws javax.jcr.MergeException
+     * @throws javax.jcr.lock.LockException
+     * @throws javax.jcr.InvalidItemStateException
+     * @throws javax.jcr.RepositoryException
+     * @see javax.jcr.version.VersionManager#merge(String, String, boolean, boolean)
+     * @since JCR 2.0
+     */
+    public Iterator merge(SessionInfo sessionInfo, NodeId nodeId, String srcWorkspaceName,
boolean bestEffort, boolean isShallow) throws NoSuchWorkspaceException, AccessDeniedException,
MergeException, LockException, InvalidItemStateException, RepositoryException;
 
     /**
      * Resolve an existing merge conflict present with the node identified by
@@ -1053,4 +1055,39 @@
      * @see javax.jcr.nodetype.NodeTypeManager#getNodeType(String)
      */
     public Iterator getQNodeTypeDefinitions(SessionInfo sessionInfo, Name[] nodetypeNames)
throws RepositoryException;
+
+    //-----------------------------------------------< Workspace Management >---
+    /**
+     * Create a new workspace with the specified <code>name</code>. If
+     * <code>srcWorkspaceName</code> isn't <code>null</code> the
content of
+     * that workspace is 'cloned' to the new workspace as inital content,
+     * otherwise an empty workspace will be created.
+     *
+     * @param sessionInfo
+     * @param name The name of the new workspace.
+     * @param srcWorkspaceName The name of the workspace from which the initial
+     * content of the new workspace will be 'cloned'.
+     * @throws AccessDeniedException
+     * @throws UnsupportedRepositoryOperationException
+     * @throws NoSuchWorkspaceException
+     * @throws RepositoryException
+     * @see javax.jcr.Workspace#createWorkspace(String)
+     * @see javax.jcr.Workspace#createWorkspace(String, String)
+     * @since JCR 2.0
+     */
+    public void createWorkspace(SessionInfo sessionInfo, String name, String srcWorkspaceName)
throws AccessDeniedException, UnsupportedRepositoryOperationException, NoSuchWorkspaceException,
RepositoryException;
+
+    /**
+     * Deletes the workspace with the specified <code>name</code>.
+     *
+     * @param sessionInfo
+     * @param name  The name of the workspace to be deleted.
+     * @throws AccessDeniedException
+     * @throws UnsupportedRepositoryOperationException
+     * @throws NoSuchWorkspaceException
+     * @throws RepositoryException
+     * @see javax.jcr.Workspace#deleteWorkspace(String)
+     * @since JCR 2.0
+     */
+    public void deleteWorkspace(SessionInfo sessionInfo, String name) throws AccessDeniedException,
UnsupportedRepositoryOperationException, NoSuchWorkspaceException, RepositoryException;
 }

Modified: jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java?rev=773907&r1=773906&r2=773907&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
Tue May 12 14:14:19 2009
@@ -1450,35 +1450,43 @@
             throw ExceptionConverter.generate(e);
         }
     }
+
     /**
      * @see RepositoryService#merge(SessionInfo, NodeId, String, boolean)
      */
     public Iterator merge(SessionInfo sessionInfo, NodeId nodeId, String srcWorkspaceName,
boolean bestEffort) throws NoSuchWorkspaceException, AccessDeniedException, MergeException,
LockException, InvalidItemStateException, RepositoryException {
-        try {
-            String wspHref = uriResolver.getWorkspaceUri(srcWorkspaceName);
-            Element mElem = MergeInfo.createMergeElement(new String[] {wspHref}, bestEffort,
false, domFactory);
-            MergeInfo mInfo = new MergeInfo(mElem);
-
-            MergeMethod method = new MergeMethod(getItemUri(nodeId, sessionInfo), mInfo);
-            execute(method, sessionInfo);
-
-            MultiStatusResponse[] resps = method.getResponseBodyAsMultiStatus().getResponses();
-            List failedIds = new ArrayList(resps.length);
-            for (int i = 0; i < resps.length; i++) {
-                String href = resps[i].getHref();
-                failedIds.add(uriResolver.getNodeId(href, sessionInfo));
-            }
-            return failedIds.iterator();
-        } catch (IOException e) {
-            throw new RepositoryException(e);
-        } catch (DavException e) {
-            throw ExceptionConverter.generate(e);
-        }
+        return merge(sessionInfo, nodeId, srcWorkspaceName, bestEffort, false);
     }
 
+    /**
+     * @see RepositoryService#merge(SessionInfo, NodeId, String, boolean, boolean)
+     */
     public Iterator merge(SessionInfo sessionInfo, NodeId nodeId, String srcWorkspaceName,
boolean bestEffort, boolean isShallow) throws NoSuchWorkspaceException, AccessDeniedException,
MergeException, LockException, InvalidItemStateException, RepositoryException {
-        // TODO
-        throw new UnsupportedOperationException("JCR-2104: JSR 283 Versioning. Implementation
missing");
+        if (!isShallow) {
+            try {
+                String wspHref = uriResolver.getWorkspaceUri(srcWorkspaceName);
+                Element mElem = MergeInfo.createMergeElement(new String[] {wspHref}, bestEffort,
false, domFactory);
+                MergeInfo mInfo = new MergeInfo(mElem);
+
+                MergeMethod method = new MergeMethod(getItemUri(nodeId, sessionInfo), mInfo);
+                execute(method, sessionInfo);
+
+                MultiStatusResponse[] resps = method.getResponseBodyAsMultiStatus().getResponses();
+                List failedIds = new ArrayList(resps.length);
+                for (int i = 0; i < resps.length; i++) {
+                    String href = resps[i].getHref();
+                    failedIds.add(uriResolver.getNodeId(href, sessionInfo));
+                }
+                return failedIds.iterator();
+            } catch (IOException e) {
+                throw new RepositoryException(e);
+            } catch (DavException e) {
+                throw ExceptionConverter.generate(e);
+            }
+        } else {
+            // TODO
+            throw new UnsupportedOperationException("JCR-2104: JSR 283 Versioning. Implementation
missing");
+        }
     }
 
     /**
@@ -2006,6 +2014,22 @@
     }
 
     /**
+     * {@inheritDoc}
+     */
+    public void createWorkspace(SessionInfo sessionInfo, String name, String srcWorkspaceName)
throws AccessDeniedException, UnsupportedRepositoryOperationException, NoSuchWorkspaceException,
RepositoryException {
+        // TODO
+        throw new UnsupportedOperationException("JCR-2003. Implementation missing");
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void deleteWorkspace(SessionInfo sessionInfo, String name) throws AccessDeniedException,
UnsupportedRepositoryOperationException, NoSuchWorkspaceException, RepositoryException {
+        // TODO
+        throw new UnsupportedOperationException("JCR-2003. Implementation missing");
+    }
+
+    /**
      *
      * @param sessionInfo
      * @param reportDoc

Modified: jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java?rev=773907&r1=773906&r2=773907&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java
Tue May 12 14:14:19 2009
@@ -1105,6 +1105,28 @@
         return defs.iterator();
     }
 
+    /**
+     * {@inheritDoc}
+     */
+    public void createWorkspace(SessionInfo sessionInfo, String name, String srcWorkspaceName)
throws AccessDeniedException, UnsupportedRepositoryOperationException, NoSuchWorkspaceException,
RepositoryException {
+        SessionInfoImpl sInfo = getSessionInfoImpl(sessionInfo);
+        Workspace wsp = sInfo.getSession().getWorkspace();
+        if (srcWorkspaceName == null) {
+            wsp.createWorkspace(name);
+        } else {
+            wsp.createWorkspace(name, srcWorkspaceName);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void deleteWorkspace(SessionInfo sessionInfo, String name) throws AccessDeniedException,
UnsupportedRepositoryOperationException, NoSuchWorkspaceException, RepositoryException {
+        SessionInfoImpl sInfo = getSessionInfoImpl(sessionInfo);
+        Workspace wsp = sInfo.getSession().getWorkspace();
+        wsp.deleteWorkspace(name);
+    }
+
     //----------------------------< internal >----------------------------------
 
     private final class BatchImpl implements Batch {



Mime
View raw message