You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by an...@apache.org on 2011/09/21 11:10:33 UTC

svn commit: r1173533 - in /jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit: server/io/ webdav/simple/

Author: angela
Date: Wed Sep 21 09:10:33 2011
New Revision: 1173533

URL: http://svn.apache.org/viewvc?rev=1173533&view=rev
Log:
JCR-3078 - Add CopyMoveHanlder so that the copy/move behavior can be customized (as this is the case for the IOHandler and PropertyHandler)

Added:
    jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/CopyMoveContext.java   (with props)
    jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/CopyMoveContextImpl.java   (with props)
    jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/CopyMoveHandler.java   (with props)
    jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/CopyMoveManager.java   (with props)
    jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/CopyMoveManagerImpl.java   (with props)
Modified:
    jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/DefaultHandler.java
    jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/simple/DavResourceImpl.java
    jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/simple/ResourceConfig.java

Added: jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/CopyMoveContext.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/CopyMoveContext.java?rev=1173533&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/CopyMoveContext.java (added)
+++ jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/CopyMoveContext.java Wed Sep 21 09:10:33 2011
@@ -0,0 +1,43 @@
+/*
+ * 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.server.io;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.Workspace;
+
+/**
+ * <code>CopyMoveContext</code>...
+ */
+public interface CopyMoveContext {
+
+    /**
+     * @return true if this context defines a shallow copy.
+     */
+    boolean isShallowCopy();
+
+    /**
+     * @return the jcr session associated with this context.
+     */
+    Session getSession();
+
+    /**
+     * @return The JCR workspace associated with this context.
+     * @throws RepositoryException If an error occurs.
+     */
+    Workspace getWorkspace() throws RepositoryException;
+}
\ No newline at end of file

Propchange: jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/CopyMoveContext.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/CopyMoveContext.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/CopyMoveContextImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/CopyMoveContextImpl.java?rev=1173533&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/CopyMoveContextImpl.java (added)
+++ jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/CopyMoveContextImpl.java Wed Sep 21 09:10:33 2011
@@ -0,0 +1,69 @@
+/*
+ * 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.server.io;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.Workspace;
+
+/**
+ * <code>CopyMoveContextImpl</code>...
+ */
+public class CopyMoveContextImpl implements CopyMoveContext {
+
+    /**
+     * logger instance
+     */
+    private static final Logger log = LoggerFactory.getLogger(CopyMoveContextImpl.class);
+
+    private final boolean isShallow;
+    private final Session session;
+
+    public CopyMoveContextImpl(Session session) {
+        this(session, false);
+    }
+
+    public CopyMoveContextImpl(Session session, boolean isShallowCopy) {
+        this.isShallow = isShallowCopy;
+        this.session = session;
+    }
+
+    //----------------------------------------------------< CopyMoveContext >---    
+    /**
+     * @see org.apache.jackrabbit.server.io.CopyMoveContext#isShallowCopy()
+     */
+    public boolean isShallowCopy() {
+        return isShallow;
+    }
+
+    /**
+     * @see org.apache.jackrabbit.server.io.CopyMoveContext#getSession() 
+     */
+    public Session getSession() {
+        return session;
+    }
+
+    /**
+     * @see org.apache.jackrabbit.server.io.CopyMoveContext#getWorkspace() 
+     */
+    public Workspace getWorkspace() throws RepositoryException {
+        return session.getWorkspace();
+    }
+}
\ No newline at end of file

Propchange: jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/CopyMoveContextImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/CopyMoveContextImpl.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/CopyMoveHandler.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/CopyMoveHandler.java?rev=1173533&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/CopyMoveHandler.java (added)
+++ jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/CopyMoveHandler.java Wed Sep 21 09:10:33 2011
@@ -0,0 +1,75 @@
+/*
+ * 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.server.io;
+
+import org.apache.jackrabbit.webdav.DavException;
+import org.apache.jackrabbit.webdav.DavResource;
+
+/**
+ * <code>CopyMoveHandler</code>...
+ */
+public interface CopyMoveHandler {
+
+    /**
+     * Validates if this handler is able to execute a copy with the given
+     * parameters.
+     *
+     * @param context The context of the copy.
+     * @param source The source of the copy.
+     * @param destination The destination of the copy.
+     * @return true if this instance can handle a copy with the given parameters;
+     * false otherwise.
+     */
+    public boolean canCopy(CopyMoveContext context, DavResource source, DavResource destination);
+
+    /**
+     * Executes the copy with the given parameters.
+     *
+     * @param context The context of the copy.
+     * @param source The source of the copy.
+     * @param destination The destination of the copy.
+     * @return true if this instance successfully executed the copy operation
+     * with the given parameters; false otherwise.
+     * @throws DavException If an error occurs.
+     */
+    public boolean copy(CopyMoveContext context, DavResource source, DavResource destination) throws DavException;
+
+    /**
+     * Validates if this handler is able to execute a move with the given
+     * parameters.
+     *
+     * @param context The context of the move.
+     * @param source The source of the move.
+     * @param destination The destination of the move.
+     * @return true if this instance successfully executed the move operation
+     * with the given parameters; false otherwise.
+     */
+    public boolean canMove(CopyMoveContext context, DavResource source, DavResource destination);
+
+    /**
+     * Executes the move with the given parameters.
+     *
+     * @param context The context of the move.
+     * @param source The source of the move.
+     * @param destination The destination of the move.
+     * @return true if this instance successfully executed the move operation
+     * with the given parameters;
+     * false otherwise.
+     * @throws DavException If an error occurs.
+     */
+    public boolean move(CopyMoveContext context, DavResource source, DavResource destination) throws DavException;
+}

Propchange: jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/CopyMoveHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/CopyMoveHandler.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/CopyMoveManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/CopyMoveManager.java?rev=1173533&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/CopyMoveManager.java (added)
+++ jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/CopyMoveManager.java Wed Sep 21 09:10:33 2011
@@ -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.server.io;
+
+import org.apache.jackrabbit.webdav.DavException;
+import org.apache.jackrabbit.webdav.DavResource;
+
+/**
+ *  <code>CopyMoveManager</code>...
+ */
+public interface CopyMoveManager {
+
+    /**
+     * Handles the copy command
+     *
+     * @param context The context used for this copy operation.
+     * @param source The source of the copy.
+     * @param destination The destination of the copy.
+     * @return true if the copy succeeded.
+     * @throws DavException If an error occurs.
+     */
+    public boolean copy(CopyMoveContext context, DavResource source, DavResource destination) throws DavException;
+
+    /**
+     * Handles the move command
+     *
+     * @param context The context used for this move operation.
+     * @param source The source of the move.
+     * @param destination The destination of the move.
+     * @return true if the move succeeded.
+     * @throws DavException If an error occurs.
+     */
+    public boolean move(CopyMoveContext context, DavResource source, DavResource destination) throws DavException;
+
+    /**
+     * Adds the specified handler to the list of handlers.
+     *
+     * @param copyMoveHandler handler to be added
+     */
+    public void addCopyMoveHandler(CopyMoveHandler copyMoveHandler);
+
+    /**
+     * Returns all handlers that have been added to this manager.
+     *
+     * @return Array of all handlers
+     */
+    public CopyMoveHandler[] getCopyMoveHandlers();
+}

Propchange: jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/CopyMoveManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/CopyMoveManager.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/CopyMoveManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/CopyMoveManagerImpl.java?rev=1173533&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/CopyMoveManagerImpl.java (added)
+++ jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/CopyMoveManagerImpl.java Wed Sep 21 09:10:33 2011
@@ -0,0 +1,103 @@
+/*
+ * 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.server.io;
+
+import org.apache.jackrabbit.webdav.DavException;
+import org.apache.jackrabbit.webdav.DavResource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * <code>CopyMoveManagerImpl</code>...
+ */
+public class CopyMoveManagerImpl implements CopyMoveManager {
+
+    private static Logger log = LoggerFactory.getLogger(CopyMoveManagerImpl.class);
+
+    private static CopyMoveManager DEFAULT_MANAGER;
+
+    private final List<CopyMoveHandler> copyMoveHandlers = new ArrayList<CopyMoveHandler>();
+
+    /**
+     * Create a new <code>CopyMoveManagerImpl</code>.
+     */
+    public CopyMoveManagerImpl() {
+    }
+
+    //----------------------------------------------------< CopyMoveManager >---
+    /**
+     * @see CopyMoveManager#copy(CopyMoveContext,org.apache.jackrabbit.webdav.DavResource,org.apache.jackrabbit.webdav.DavResource)
+     */
+    public boolean copy(CopyMoveContext context, DavResource source, DavResource destination) throws DavException {
+        boolean success = false;
+        CopyMoveHandler[] copyMoveHandlers = getCopyMoveHandlers();
+        for (int i = 0; i < copyMoveHandlers.length && !success; i++) {
+            CopyMoveHandler cmh = copyMoveHandlers[i];
+            if (cmh.canCopy(context, source, destination)) {
+                success = cmh.copy(context, source, destination);
+            }
+        }
+        return success;
+    }
+
+    /**
+     * @see CopyMoveManager#move(CopyMoveContext,org.apache.jackrabbit.webdav.DavResource,org.apache.jackrabbit.webdav.DavResource)
+     */
+    public boolean move(CopyMoveContext context, DavResource source, DavResource destination) throws DavException {
+        boolean success = false;
+        CopyMoveHandler[] copyMoveHandlers = getCopyMoveHandlers();
+        for (int i = 0; i < copyMoveHandlers.length && !success; i++) {
+            CopyMoveHandler cmh = copyMoveHandlers[i];
+            if (cmh.canMove(context, source, destination)) {
+                success = cmh.move(context, source, destination);
+            }
+        }
+        return success;
+    }
+
+    /**
+     * @see org.apache.jackrabbit.server.io.CopyMoveManager#addCopyMoveHandler(CopyMoveHandler)
+     */
+    public void addCopyMoveHandler(CopyMoveHandler copyMoveHandler) {
+        if (copyMoveHandler == null) {
+            throw new IllegalArgumentException("'null' is not a valid copyMoveHandler.");
+        }
+        copyMoveHandlers.add(copyMoveHandler);
+    }
+
+    /**
+     * @see CopyMoveManager#getCopyMoveHandlers()
+     */
+    public CopyMoveHandler[] getCopyMoveHandlers() {
+        return copyMoveHandlers.toArray(new CopyMoveHandler[copyMoveHandlers.size()]);
+    }
+
+    //--------------------------------------------------------------------------
+    /**
+     * @return an instance of CopyMoveManager populated with default handlers.
+     */
+    public static CopyMoveManager getDefaultManager() {
+        if (DEFAULT_MANAGER == null) {
+            DEFAULT_MANAGER = new CopyMoveManagerImpl();
+            DEFAULT_MANAGER.addCopyMoveHandler(new DefaultHandler());
+        }
+        return DEFAULT_MANAGER;
+    }
+}

Propchange: jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/CopyMoveManagerImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/CopyMoveManagerImpl.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Modified: jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/DefaultHandler.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/DefaultHandler.java?rev=1173533&r1=1173532&r2=1173533&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/DefaultHandler.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/DefaultHandler.java Wed Sep 21 09:10:33 2011
@@ -20,7 +20,10 @@ import org.apache.jackrabbit.JcrConstant
 import org.apache.jackrabbit.commons.NamespaceHelper;
 import org.apache.jackrabbit.util.ISO9075;
 import org.apache.jackrabbit.util.Text;
+import org.apache.jackrabbit.webdav.DavException;
 import org.apache.jackrabbit.webdav.DavResource;
+import org.apache.jackrabbit.webdav.DavServletResponse;
+import org.apache.jackrabbit.webdav.jcr.JcrDavException;
 import org.apache.jackrabbit.webdav.xml.Namespace;
 import org.apache.jackrabbit.webdav.property.DavPropertyName;
 import org.apache.jackrabbit.webdav.property.DavProperty;
@@ -32,6 +35,7 @@ import org.slf4j.LoggerFactory;
 import javax.jcr.Item;
 import javax.jcr.Node;
 import javax.jcr.NodeIterator;
+import javax.jcr.PathNotFoundException;
 import javax.jcr.Property;
 import javax.jcr.RepositoryException;
 import javax.jcr.PropertyIterator;
@@ -67,7 +71,7 @@ import java.util.HashMap;
  * Subclasses therefore should provide their own {@link #importData(ImportContext, boolean, Node)
  * importData} method, that handles the data according their needs.
  */
-public class DefaultHandler implements IOHandler, PropertyHandler {
+public class DefaultHandler implements IOHandler, PropertyHandler, CopyMoveHandler {
 
     private static Logger log = LoggerFactory.getLogger(DefaultHandler.class);
 
@@ -574,9 +578,9 @@ public class DefaultHandler implements I
                     continue;
                 }
                 if (JcrConstants.JCR_DATA.equals(name)
-                    || JcrConstants.JCR_MIMETYPE.equals(name)
-                    || JcrConstants.JCR_ENCODING.equals(name)
-                    || JcrConstants.JCR_LASTMODIFIED.equals(name)) {
+                        || JcrConstants.JCR_MIMETYPE.equals(name)
+                        || JcrConstants.JCR_ENCODING.equals(name)
+                        || JcrConstants.JCR_LASTMODIFIED.equals(name)) {
                     continue;
                 }
 
@@ -671,6 +675,54 @@ public class DefaultHandler implements I
         }
     }
 
+    //----------------------------------------------------< CopyMoveHandler >---
+    /**
+     * @see CopyMoveHandler#canCopy(CopyMoveContext, org.apache.jackrabbit.webdav.DavResource, org.apache.jackrabbit.webdav.DavResource)
+     */
+    public boolean canCopy(CopyMoveContext context, DavResource source, DavResource destination) {
+        return true;
+    }
+
+    /**
+     * @see CopyMoveHandler#copy(CopyMoveContext, org.apache.jackrabbit.webdav.DavResource, org.apache.jackrabbit.webdav.DavResource)
+     */
+    public boolean copy(CopyMoveContext context, DavResource source, DavResource destination) throws DavException {
+        if (context.isShallowCopy() && source.isCollection()) {
+            // TODO: currently no support for shallow copy; however this is
+            // only relevant if the source resource is a collection, because
+            // otherwise it doesn't make a difference
+            throw new DavException(DavServletResponse.SC_FORBIDDEN, "Unable to perform shallow copy.");
+        }
+        try {
+            context.getSession().getWorkspace().copy(source.getLocator().getRepositoryPath(), destination.getLocator().getRepositoryPath());
+            return true;
+        }  catch (PathNotFoundException e) {
+            // according to rfc 2518: missing parent
+            throw new DavException(DavServletResponse.SC_CONFLICT, e.getMessage());
+        } catch (RepositoryException e) {
+            throw new JcrDavException(e);
+        }
+    }
+
+    /**
+     * @see CopyMoveHandler#canMove(CopyMoveContext, org.apache.jackrabbit.webdav.DavResource, org.apache.jackrabbit.webdav.DavResource)
+     */
+    public boolean canMove(CopyMoveContext context, DavResource source, DavResource destination) {
+        return true;
+    }
+
+    /**
+     * @see CopyMoveHandler#move(CopyMoveContext, org.apache.jackrabbit.webdav.DavResource, org.apache.jackrabbit.webdav.DavResource) 
+     */
+    public boolean move(CopyMoveContext context, DavResource source, DavResource destination) throws DavException {
+        try {
+            context.getWorkspace().move(source.getLocator().getRepositoryPath(), destination.getLocator().getRepositoryPath());
+            return true;
+        } catch (RepositoryException e) {
+            throw new JcrDavException(e);
+        }
+    }
+
     //------------------------------------------------------------< private >---
     /**
      * Builds a webdav property name from the given jcrName. In case the jcrName
@@ -784,9 +836,9 @@ public class DefaultHandler implements I
     private static boolean isDefinedByFilteredNodeType(PropertyDefinition def) {
         String ntName = def.getDeclaringNodeType().getName();
         return ntName.equals(JcrConstants.NT_BASE)
-               || ntName.equals(JcrConstants.MIX_REFERENCEABLE)
-               || ntName.equals(JcrConstants.MIX_VERSIONABLE)
-               || ntName.equals(JcrConstants.MIX_LOCKABLE);
+                || ntName.equals(JcrConstants.MIX_REFERENCEABLE)
+                || ntName.equals(JcrConstants.MIX_VERSIONABLE)
+                || ntName.equals(JcrConstants.MIX_LOCKABLE);
     }
 
     //-------------------------------------------< setter for configuration >---

Modified: jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/simple/DavResourceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/simple/DavResourceImpl.java?rev=1173533&r1=1173532&r2=1173533&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/simple/DavResourceImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/simple/DavResourceImpl.java Wed Sep 21 09:10:33 2011
@@ -18,6 +18,7 @@ package org.apache.jackrabbit.webdav.sim
 
 import org.apache.jackrabbit.JcrConstants;
 import org.apache.jackrabbit.server.io.AbstractExportContext;
+import org.apache.jackrabbit.server.io.CopyMoveContextImpl;
 import org.apache.jackrabbit.server.io.DefaultIOListener;
 import org.apache.jackrabbit.server.io.ExportContext;
 import org.apache.jackrabbit.server.io.ExportContextImpl;
@@ -68,7 +69,6 @@ import org.slf4j.LoggerFactory;
 import javax.jcr.Item;
 import javax.jcr.Node;
 import javax.jcr.NodeIterator;
-import javax.jcr.PathNotFoundException;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.jcr.Workspace;
@@ -599,11 +599,8 @@ public class DavResourceImpl implements 
         }
         // make sure, that src and destination belong to the same workspace
         checkSameWorkspace(destination.getLocator());
-        try {
-            String destItemPath = destination.getLocator().getRepositoryPath();
-            getJcrSession().getWorkspace().move(locator.getRepositoryPath(), destItemPath);
-        } catch (RepositoryException e) {
-            throw new JcrDavException(e);
+        if (!config.getCopyMoveManager().move(new CopyMoveContextImpl(getJcrSession()), this, destination)) {
+            throw new DavException(DavServletResponse.SC_UNSUPPORTED_MEDIA_TYPE);
         }
     }
 
@@ -620,22 +617,10 @@ public class DavResourceImpl implements 
         if (isFilteredResource(destination)) {
             throw new DavException(DavServletResponse.SC_FORBIDDEN);
         }
-        if (shallow && isCollection()) {
-            // TODO: currently no support for shallow copy; however this is
-            // only relevant if the source resource is a collection, because
-            // otherwise it doesn't make a difference
-            throw new DavException(DavServletResponse.SC_FORBIDDEN, "Unable to perform shallow copy.");
-        }
         // make sure, that src and destination belong to the same workspace
         checkSameWorkspace(destination.getLocator());
-        try {
-            String destItemPath = destination.getLocator().getRepositoryPath();
-            getJcrSession().getWorkspace().copy(locator.getRepositoryPath(), destItemPath);
-        } catch (PathNotFoundException e) {
-            // according to rfc 2518: missing parent
-            throw new DavException(DavServletResponse.SC_CONFLICT, e.getMessage());
-        } catch (RepositoryException e) {
-            throw new JcrDavException(e);
+        if (!config.getCopyMoveManager().copy(new CopyMoveContextImpl(getJcrSession(), shallow), this, destination)) {
+            throw new DavException(DavServletResponse.SC_UNSUPPORTED_MEDIA_TYPE);
         }
     }
 

Modified: jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/simple/ResourceConfig.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/simple/ResourceConfig.java?rev=1173533&r1=1173532&r2=1173533&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/simple/ResourceConfig.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/simple/ResourceConfig.java Wed Sep 21 09:10:33 2011
@@ -31,6 +31,9 @@ import javax.jcr.Node;
 import javax.jcr.RepositoryException;
 import javax.xml.parsers.ParserConfigurationException;
 
+import org.apache.jackrabbit.server.io.CopyMoveHandler;
+import org.apache.jackrabbit.server.io.CopyMoveManager;
+import org.apache.jackrabbit.server.io.CopyMoveManagerImpl;
 import org.apache.jackrabbit.server.io.DefaultIOManager;
 import org.apache.jackrabbit.server.io.IOHandler;
 import org.apache.jackrabbit.server.io.IOManager;
@@ -59,6 +62,9 @@ public class ResourceConfig {
     private static final String ELEMENT_PROPERTYMANAGER = "propertymanager";
     private static final String ELEMENT_PROPERTYHANDLER = "propertyhandler";
 
+    private static final String ELEMENT_COPYMOVEMANAGER = "copymovemanager";
+    private static final String ELEMENT_COPYMOVEHANDLER = "copymovehandler";
+
     private static final String ELEMENT_CLASS = "class";
 
     private static final String ELEMENT_PARAM = "param";
@@ -72,6 +78,7 @@ public class ResourceConfig {
 
     private ItemFilter itemFilter;
     private IOManager ioManager;
+    private CopyMoveManager cmManager;
     private PropertyManager propManager;
     private String[] nodetypeNames = new String[0];
     private boolean collectionNames = false;
@@ -225,6 +232,33 @@ public class ResourceConfig {
                 log.debug("'propertymanager' element is missing.");
             }
 
+            // copymovemanager config entry
+            el = DomUtil.getChildElement(config, ELEMENT_COPYMOVEMANAGER, null);
+            if (el != null) {
+                Object inst = buildClassFromConfig(el);
+                if (inst != null && inst instanceof CopyMoveManager) {
+                    cmManager = (CopyMoveManager) inst;
+                    // get optional 'copymovehandler' child elements and populate
+                    // the copy move manager with the instances
+                    ElementIterator iohElements = DomUtil.getChildren(el, ELEMENT_COPYMOVEHANDLER, null);
+                    while (iohElements.hasNext()) {
+                        Element iohEl = iohElements.nextElement();
+                        inst = buildClassFromConfig(iohEl);
+                        if (inst != null && inst instanceof CopyMoveHandler) {
+                            CopyMoveHandler handler = (CopyMoveHandler) inst;
+                            setParameters(handler, iohEl);
+                            cmManager.addCopyMoveHandler(handler);
+                        } else {
+                            log.warn("Not a valid CopyMoveHandler : " + getClassName(iohEl));
+                        }
+                    }
+                } else {
+                    log.warn("'copymovemanager' element does not define a valid CopyMoveManager.");
+                }
+            } else {
+                log.debug("'copymovemanager' element is missing.");
+            }
+
             // collection/non-collection config entry
             el = DomUtil.getChildElement(config, "collection", null);
             if (el != null) {
@@ -427,6 +461,18 @@ public class ResourceConfig {
     }
 
     /**
+     *
+     * @return
+     */
+    public CopyMoveManager getCopyMoveManager() {
+        if (cmManager == null) {
+            log.debug("Missing copymove-manager > building default.");
+            cmManager = CopyMoveManagerImpl.getDefaultManager();
+        }
+        return cmManager;
+    }
+
+    /**
      * Returns true, if the given item represents a {@link Node node} that is
      * either any of the nodetypes specified to represent a collection or
      * none of the nodetypes specified to represent a non-collection, respectively.