incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r1164023 - in /sling/trunk/launchpad/test-services: ./ src/main/java/org/apache/sling/launchpad/testservices/handlers/
Date Thu, 01 Sep 2011 11:39:58 GMT
Author: fmeschbe
Date: Thu Sep  1 11:39:58 2011
New Revision: 1164023

URL: http://svn.apache.org/viewvc?rev=1164023&view=rev
Log:
SLING-2185 Test Services to support IOHandler and PropertyHandler services to extend the Jackrabbit
WebDAV functionality (thanks Timothee Maret for the patch)

Added:
    sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/handlers/
    sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/handlers/AbstractHandler.java
  (with props)
    sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/handlers/TestHandler1.java
  (with props)
    sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/handlers/TestHandler2.java
  (with props)
    sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/handlers/TestHandler3.java
  (with props)
Modified:
    sling/trunk/launchpad/test-services/pom.xml

Modified: sling/trunk/launchpad/test-services/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/test-services/pom.xml?rev=1164023&r1=1164022&r2=1164023&view=diff
==============================================================================
--- sling/trunk/launchpad/test-services/pom.xml (original)
+++ sling/trunk/launchpad/test-services/pom.xml Thu Sep  1 11:39:58 2011
@@ -78,6 +78,18 @@
     </build>
     <dependencies>
         <dependency>
+            <groupId>org.apache.jackrabbit</groupId>
+            <artifactId>jackrabbit-jcr-server</artifactId>
+            <version>2.2.8</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.jackrabbit</groupId>
+            <artifactId>jackrabbit-webdav</artifactId>
+            <version>2.2.8</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
             <groupId>org.apache.felix</groupId>
             <artifactId>org.apache.felix.scr.annotations</artifactId>
             <scope>provided</scope>

Added: sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/handlers/AbstractHandler.java
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/handlers/AbstractHandler.java?rev=1164023&view=auto
==============================================================================
--- sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/handlers/AbstractHandler.java
(added)
+++ sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/handlers/AbstractHandler.java
Thu Sep  1 11:39:58 2011
@@ -0,0 +1,137 @@
+/*
+ * 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.launchpad.testservices.handlers;
+
+import org.apache.jackrabbit.server.io.ExportContext;
+import org.apache.jackrabbit.server.io.IOManager;
+import org.apache.jackrabbit.server.io.ImportContext;
+import org.apache.jackrabbit.server.io.PropertyExportContext;
+import org.apache.jackrabbit.server.io.PropertyImportContext;
+import org.apache.jackrabbit.webdav.DavResource;
+import org.apache.jackrabbit.webdav.property.PropEntry;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import java.io.IOException;
+import java.util.Map;
+
+/**
+ * This handler can export only if the path given in the context contains the handler name.
+ */
+public abstract class AbstractHandler implements
+        org.apache.jackrabbit.server.io.IOHandler,
+        org.apache.jackrabbit.server.io.PropertyHandler {
+
+    private static final String HANDLER_IDENTIFIER = "handler-identifier";
+
+    private IOManager ioManager ;
+
+    // IOHandler
+
+    public IOManager getIOManager() {
+        return ioManager;
+    }
+
+    public void setIOManager(IOManager ioManager) {
+        this.ioManager = ioManager;
+    }
+
+    public String getName() {
+        return getClass().getName();
+    }
+
+    public boolean canImport(ImportContext context, DavResource davResource) {
+        return canImport(context, davResource.isCollection());
+    }
+
+    public boolean canImport(ImportContext context, boolean b) {
+        return false;
+    }
+
+    public boolean importContent(ImportContext context, DavResource davResource) throws IOException
{
+        return importContent(context, davResource.isCollection());
+    }
+
+    public boolean importContent(ImportContext context, boolean b) throws IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    public boolean canExport(ExportContext context, boolean b) {
+        try {
+            final Node node = (Node) context.getExportRoot();
+            return matches(node.getPath());
+        } catch (RepositoryException e) {
+            e.printStackTrace();
+        }
+        return false;
+    }
+
+    public boolean canExport(ExportContext context, DavResource davResource) {
+        return canExport(context, davResource.isCollection());
+    }
+
+    public boolean exportContent(ExportContext context, DavResource davResource) throws IOException
{
+        return exportContent(context, davResource.isCollection());
+    }
+
+    public boolean exportContent(ExportContext context, boolean b) throws IOException {
+        context.setProperty(HANDLER_IDENTIFIER, getIdentifier());
+        return true;
+    }
+
+    // PropertyHandler
+
+    public boolean canExport(PropertyExportContext context, boolean b) {
+        try {
+            final Node node = (Node) context.getExportRoot();
+            return matches(node.getPath());
+        } catch (RepositoryException e) {
+            e.printStackTrace();
+        }
+        return false;
+    }
+
+    public boolean exportProperties(PropertyExportContext context, boolean b) throws RepositoryException
{
+        context.setProperty(HANDLER_IDENTIFIER, getIdentifier());
+        return true;
+    }
+
+    public boolean canImport(PropertyImportContext context, boolean b) {
+        return false;
+    }
+
+    public Map<? extends PropEntry, ?> importProperties(PropertyImportContext context,
boolean b) throws RepositoryException {
+        throw new UnsupportedOperationException();
+    }
+
+    //
+
+    public String getIdentifier() {
+        return getHandlerName() + "-";
+    }
+
+    public boolean matches(String path) {
+        return path != null && path.contains(getHandlerName());
+    }
+
+    //
+
+    public abstract String getHandlerName() ;
+
+}
\ No newline at end of file

Propchange: sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/handlers/AbstractHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/handlers/AbstractHandler.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev Url

Added: sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/handlers/TestHandler1.java
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/handlers/TestHandler1.java?rev=1164023&view=auto
==============================================================================
--- sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/handlers/TestHandler1.java
(added)
+++ sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/handlers/TestHandler1.java
Thu Sep  1 11:39:58 2011
@@ -0,0 +1,38 @@
+/*
+ * 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.launchpad.testservices.handlers;
+
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Service;
+import org.osgi.framework.Constants;
+
+@Component(metatype = true)
+@Property(name = Constants.SERVICE_RANKING, intValue = 3, propertyPrivate = false)
+@Service(value = {
+        org.apache.jackrabbit.server.io.IOHandler.class,
+        org.apache.jackrabbit.server.io.PropertyHandler.class})
+public class TestHandler1 extends AbstractHandler {
+
+    @Override
+    public String getHandlerName(){
+        return "test-io-handler-1";
+    }
+
+}

Propchange: sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/handlers/TestHandler1.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/handlers/TestHandler1.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev Url

Added: sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/handlers/TestHandler2.java
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/handlers/TestHandler2.java?rev=1164023&view=auto
==============================================================================
--- sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/handlers/TestHandler2.java
(added)
+++ sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/handlers/TestHandler2.java
Thu Sep  1 11:39:58 2011
@@ -0,0 +1,37 @@
+/*
+ * 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.launchpad.testservices.handlers;
+
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Service;
+import org.osgi.framework.Constants;
+
+@Component(metatype = true)
+@Property(name = Constants.SERVICE_RANKING, intValue = 2, propertyPrivate = false)
+@Service(value = {
+        org.apache.jackrabbit.server.io.IOHandler.class,
+        org.apache.jackrabbit.server.io.PropertyHandler.class})
+public class TestHandler2 extends AbstractHandler {
+
+    @Override
+    public String getHandlerName(){
+        return "test-io-handler-11";
+    }
+}

Propchange: sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/handlers/TestHandler2.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/handlers/TestHandler2.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev Url

Added: sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/handlers/TestHandler3.java
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/handlers/TestHandler3.java?rev=1164023&view=auto
==============================================================================
--- sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/handlers/TestHandler3.java
(added)
+++ sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/handlers/TestHandler3.java
Thu Sep  1 11:39:58 2011
@@ -0,0 +1,37 @@
+/*
+ * 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.launchpad.testservices.handlers;
+
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Service;
+import org.osgi.framework.Constants;
+
+@Component(metatype = true)
+@Property(name = Constants.SERVICE_RANKING, intValue = 1, propertyPrivate = false)
+@Service(value = {
+        org.apache.jackrabbit.server.io.IOHandler.class,
+        org.apache.jackrabbit.server.io.PropertyHandler.class})
+public class TestHandler3 extends AbstractHandler {
+
+    @Override
+    public String getHandlerName(){
+        return "test-io-handler-111";
+    }
+}

Propchange: sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/handlers/TestHandler3.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/handlers/TestHandler3.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev Url



Mime
View raw message