incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r1176743 - in /sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl: handler/DefaultHandlerService.java handler/SlingCopyMoveManager.java helper/SlingResourceConfig.java servlets/SlingWebDavServlet.java
Date Wed, 28 Sep 2011 06:15:27 GMT
Author: fmeschbe
Date: Wed Sep 28 06:15:26 2011
New Revision: 1176743

URL: http://svn.apache.org/viewvc?rev=1176743&view=rev
Log:
SLING-2233 Apply patch providing support for CopyMoveManager supplied by Sameer Charles (Thanks)

Added:
    sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/handler/SlingCopyMoveManager.java
  (with props)
Modified:
    sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/handler/DefaultHandlerService.java
    sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/helper/SlingResourceConfig.java
    sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/servlets/SlingWebDavServlet.java

Modified: sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/handler/DefaultHandlerService.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/handler/DefaultHandlerService.java?rev=1176743&r1=1176742&r2=1176743&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/handler/DefaultHandlerService.java
(original)
+++ sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/handler/DefaultHandlerService.java
Wed Sep 28 06:15:26 2011
@@ -33,6 +33,9 @@ import org.apache.jackrabbit.server.io.I
 import org.apache.jackrabbit.server.io.PropertyExportContext;
 import org.apache.jackrabbit.server.io.PropertyHandler;
 import org.apache.jackrabbit.server.io.PropertyImportContext;
+import org.apache.jackrabbit.server.io.CopyMoveHandler;
+import org.apache.jackrabbit.server.io.CopyMoveContext;
+import org.apache.jackrabbit.webdav.DavException;
 import org.apache.jackrabbit.webdav.DavResource;
 import org.apache.jackrabbit.webdav.property.PropEntry;
 import org.apache.sling.commons.osgi.OsgiUtil;
@@ -55,7 +58,7 @@ import javax.jcr.RepositoryException;
     @Property(name = SlingWebDavServlet.TYPE_NONCOLLECTIONS, value = SlingWebDavServlet.TYPE_NONCOLLECTIONS_DEFAULT,
propertyPrivate = false),
     @Property(name = SlingWebDavServlet.TYPE_CONTENT, value = SlingWebDavServlet.TYPE_CONTENT_DEFAULT,
propertyPrivate = false) })
 @Service
-public class DefaultHandlerService implements IOHandler, PropertyHandler {
+public class DefaultHandlerService implements IOHandler, PropertyHandler, CopyMoveHandler
{
 
     private DefaultHandler delegatee;
 
@@ -149,4 +152,20 @@ public class DefaultHandlerService imple
             throws RepositoryException {
         return delegatee.importProperties(importContext, isCollection);
     }
+
+    public boolean canCopy(CopyMoveContext context, DavResource source, DavResource destination)
{
+        return delegatee.canCopy(context, source, destination);
+    }
+
+    public boolean copy(CopyMoveContext context, DavResource source, DavResource destination)
throws DavException {
+        return delegatee.copy(context, source, destination);
+    }
+
+    public boolean canMove(CopyMoveContext context, DavResource source, DavResource destination)
{
+        return delegatee.canMove(context, source, destination);
+    }
+
+    public boolean move(CopyMoveContext context, DavResource source, DavResource destination)
throws DavException {
+      return delegatee.move(context, source, destination);
+    }
 }

Added: sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/handler/SlingCopyMoveManager.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/handler/SlingCopyMoveManager.java?rev=1176743&view=auto
==============================================================================
--- sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/handler/SlingCopyMoveManager.java
(added)
+++ sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/handler/SlingCopyMoveManager.java
Wed Sep 28 06:15:26 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.sling.jcr.webdav.impl.handler;
+
+import org.apache.jackrabbit.server.io.CopyMoveHandler;
+import org.apache.jackrabbit.server.io.CopyMoveManagerImpl;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.component.ComponentContext;
+
+/**
+ * CopyMoveManager service that uses a ServiceTracker to find available
+ * CopyMoveHandler.
+ */
+public class SlingCopyMoveManager extends CopyMoveManagerImpl {
+
+    private static final CopyMoveHandler[] COPYMOVEHANDLERS_PROTOTYPE = new CopyMoveHandler[0];
+
+    private final SlingHandlerManager<CopyMoveHandler> handlerManager;
+
+    public SlingCopyMoveManager(final String referenceName) {
+        handlerManager = new SlingHandlerManager<CopyMoveHandler>(referenceName);
+    }
+
+    @Override
+    public void addCopyMoveHandler(CopyMoveHandler propertyHandler) {
+        throw new UnsupportedOperationException(
+            "This CopyMoveManager only supports registered CopyMoveHandler services");
+    }
+
+    @Override
+    public CopyMoveHandler[] getCopyMoveHandlers() {
+        return this.handlerManager.getHandlers(COPYMOVEHANDLERS_PROTOTYPE);
+    }
+
+    public void setComponentContext(ComponentContext componentContext) {
+        this.handlerManager.setComponentContext(componentContext);
+    }
+
+    public void bindCopyMoveHandler(final ServiceReference copyMoveHandlerReference) {
+        this.handlerManager.bindHandler(copyMoveHandlerReference);
+    }
+
+    public void unbindCopyMoveHandler(final ServiceReference copyMoveHandlerReference) {
+        this.handlerManager.unbindHandler(copyMoveHandlerReference);
+    }
+}

Propchange: sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/handler/SlingCopyMoveManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/handler/SlingCopyMoveManager.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev Url

Modified: sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/helper/SlingResourceConfig.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/helper/SlingResourceConfig.java?rev=1176743&r1=1176742&r2=1176743&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/helper/SlingResourceConfig.java
(original)
+++ sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/helper/SlingResourceConfig.java
Wed Sep 28 06:15:26 2011
@@ -18,6 +18,7 @@
  */
 package org.apache.sling.jcr.webdav.impl.helper;
 
+import org.apache.jackrabbit.server.io.CopyMoveManager;
 import org.apache.jackrabbit.server.io.IOManager;
 import org.apache.jackrabbit.server.io.PropertyManager;
 import org.apache.jackrabbit.webdav.simple.DefaultItemFilter;
@@ -45,6 +46,8 @@ public class SlingResourceConfig extends
 
     private final PropertyManager propertyManager;
 
+    private final CopyMoveManager copyMoveManager;
+
     private final String servletContextPath;
 
     private final Dictionary<String, String> servletInitParams;
@@ -52,10 +55,12 @@ public class SlingResourceConfig extends
     public SlingResourceConfig(MimeTypeService mimeTypeService,
             Dictionary<?, ?> config,
             IOManager ioManager,
-            PropertyManager propertyManager) {
+            PropertyManager propertyManager,
+            CopyMoveManager copyMoveManager) {
         super(new SlingTikaDetector(mimeTypeService));
         this.ioManager = ioManager;
         this.propertyManager = propertyManager;
+        this.copyMoveManager = copyMoveManager;
         collectionTypes = OsgiUtil.toStringArray(
             config.get(SlingWebDavServlet.COLLECTION_TYPES),
             SlingWebDavServlet.COLLECTION_TYPES_DEFAULT);
@@ -109,6 +114,11 @@ public class SlingResourceConfig extends
     }
 
     @Override
+    public CopyMoveManager getCopyMoveManager() {
+        return copyMoveManager;
+    }
+
+    @Override
     public boolean isCollectionResource(Item item) {
         if (item.isNode()) {
             Node node = (Node) item;

Modified: sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/servlets/SlingWebDavServlet.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/servlets/SlingWebDavServlet.java?rev=1176743&r1=1176742&r2=1176743&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/servlets/SlingWebDavServlet.java
(original)
+++ sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/servlets/SlingWebDavServlet.java
Wed Sep 28 06:15:26 2011
@@ -32,12 +32,14 @@ import org.apache.felix.scr.annotations.
 import org.apache.felix.scr.annotations.References;
 import org.apache.felix.scr.annotations.Service;
 import org.apache.jackrabbit.server.SessionProvider;
+import org.apache.jackrabbit.server.io.CopyMoveHandler;
 import org.apache.jackrabbit.server.io.IOHandler;
 import org.apache.jackrabbit.server.io.PropertyHandler;
 import org.apache.jackrabbit.webdav.DavLocatorFactory;
 import org.apache.jackrabbit.webdav.simple.SimpleWebdavServlet;
 import org.apache.sling.commons.mime.MimeTypeService;
 import org.apache.sling.jcr.api.SlingRepository;
+import org.apache.sling.jcr.webdav.impl.handler.SlingCopyMoveManager;
 import org.apache.sling.jcr.webdav.impl.handler.SlingIOManager;
 import org.apache.sling.jcr.webdav.impl.handler.SlingPropertyManager;
 import org.apache.sling.jcr.webdav.impl.helper.SlingLocatorFactory;
@@ -72,7 +74,8 @@ import org.osgi.service.http.NamespaceEx
     @Property(name = "sling.servlet.methods", value = "*", propertyPrivate = true) })
     @References({
         @Reference(name = SlingWebDavServlet.IOHANDLER_REF_NAME, referenceInterface = IOHandler.class,
cardinality = ReferenceCardinality.OPTIONAL_MULTIPLE, policy = ReferencePolicy.DYNAMIC),
-        @Reference(name = SlingWebDavServlet.PROPERTYHANDLER_REF_NAME, referenceInterface
= PropertyHandler.class, cardinality = ReferenceCardinality.OPTIONAL_MULTIPLE, policy = ReferencePolicy.DYNAMIC)
+        @Reference(name = SlingWebDavServlet.PROPERTYHANDLER_REF_NAME, referenceInterface
= PropertyHandler.class, cardinality = ReferenceCardinality.OPTIONAL_MULTIPLE, policy = ReferencePolicy.DYNAMIC),
+        @Reference(name = SlingWebDavServlet.COPYMOVEHANDLER_REF_NAME, referenceInterface
= CopyMoveHandler.class, cardinality = ReferenceCardinality.OPTIONAL_MULTIPLE, policy = ReferencePolicy.DYNAMIC)
 })
 public class SlingWebDavServlet extends SimpleWebdavServlet {
 
@@ -125,6 +128,8 @@ public class SlingWebDavServlet extends 
 
     static final String PROPERTYHANDLER_REF_NAME = "PropertyHandler";
 
+    static final String COPYMOVEHANDLER_REF_NAME = "CopyMoveHandler";
+
     @Reference
     private SlingRepository repository;
 
@@ -140,6 +145,9 @@ public class SlingWebDavServlet extends 
     private final SlingPropertyManager propertyManager = new SlingPropertyManager(
         PROPERTYHANDLER_REF_NAME);
 
+    private final SlingCopyMoveManager copyMoveManager = new SlingCopyMoveManager(
+        COPYMOVEHANDLER_REF_NAME);
+
     private SlingResourceConfig resourceConfig;
 
     private DavLocatorFactory locatorFactory;
@@ -206,11 +214,13 @@ public class SlingWebDavServlet extends 
 
         this.ioManager.setComponentContext(context);
         this.propertyManager.setComponentContext(context);
+        this.copyMoveManager.setComponentContext(context);
 
         resourceConfig = new SlingResourceConfig(mimeTypeService,
             context.getProperties(),
             ioManager,
-            propertyManager);
+            propertyManager,
+            copyMoveManager);
 
         // Register servlet, and set the contextPath field to signal successful
         // registration
@@ -231,6 +241,7 @@ public class SlingWebDavServlet extends 
         this.resourceConfig = null;
         this.ioManager.setComponentContext(null);
         this.propertyManager.setComponentContext(null);
+        this.copyMoveManager.setComponentContext(null);
     }
 
     public void bindIOHandler(final ServiceReference ioHandlerReference) {
@@ -248,4 +259,12 @@ public class SlingWebDavServlet extends 
     public void unbindPropertyHandler(final ServiceReference propertyHandlerReference) {
         this.propertyManager.unbindPropertyHandler(propertyHandlerReference);
     }
+
+    public void bindCopyMoveHandler(final ServiceReference copyMoveHandlerReference) {
+        this.copyMoveManager.bindCopyMoveHandler(copyMoveHandlerReference);
+    }
+
+    public void unbindCopyMoveHandler(final ServiceReference copyMoveHandlerReference) {
+        this.copyMoveManager.unbindCopyMoveHandler(copyMoveHandlerReference);
+    }
 }



Mime
View raw message