This is an automated email from the ASF dual-hosted git repository. rombert pushed a commit to annotated tag org.apache.sling.jcr.webdav-2.0.2-incubator in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-webdav.git
commit cf5d7e6fea69bd057a91730ee7d9b6c54e657b05 Author: Felix Meschberger <[email protected]> AuthorDate: Wed Jan 16 16:51:50 2008 +0000 SLING-150 Add support for Jackrabbit Simple WebDAV git-svn-id: https://svn.apache.org/repos/asf/incubator/sling/whiteboard/fmeschbe/resource/jcr/webdav@612506 13f79535-47bb-0310-9956-ffa450edef68 --- pom.xml | 129 +++++++++++++++++++++ .../sling/jcr/webdav/SimpleWebDavServlet.java | 115 ++++++++++++++++++ 2 files changed, 244 insertions(+) diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..eabc6f5 --- /dev/null +++ b/pom.xml @@ -0,0 +1,129 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<!-- + 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. +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.sling</groupId> + <artifactId>sling</artifactId> + <version>1-incubator-SNAPSHOT</version> + <relativePath>../../parent/pom.xml</relativePath> + </parent> + + <artifactId>org.apache.sling.jcr.webdav</artifactId> + <packaging>bundle</packaging> + <version>2.0.0-incubator-SNAPSHOT</version> + + <name>Sling - Simple WebDAV Access to repositories</name> + <description> + Bundle to access JCR repositories over WebDAV + </description> + + <scm> + <connection> + scm:svn:http://svn.apache.org/repos/asf/incubator/sling/trunk/jcr/webdav + </connection> + <developerConnection> + scm:svn:https://svn.apache.org/repos/asf/incubator/sling/trunk/jcr/webdav + </developerConnection> + <url> + http://svn.apache.org/viewvc/incubator/sling/trunk/jcr/webdav + </url> + </scm> + + <build> + <plugins> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-scr-plugin</artifactId> + </plugin> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + <extensions>true</extensions> + <configuration> + <instructions> + <Bundle-Category>sling,jcr</Bundle-Category> + <!-- No Export-Package --> + <Private-Package> + org.apache.sling.jcr.webdav, + org.apache.jackrabbit.webdav.simple, + org.apache.jackrabbit.server, + org.apache.jackrabbit.server.io, + org.apache.jackrabbit.server.jcr, + org.apache.jackrabbit.webdav.*, , + org.apache.xml.serialize, + org.apache.xerces.* + </Private-Package> + <Import-Package> + javax.transaction.xa; javax.xml.*; + org.apache.xml.resolver.*;org.w3c.*; + org.xml.sax.*;resolution:=optional, + !sun.*,* + </Import-Package> + </instructions> + </configuration> + </plugin> + </plugins> + </build> + + <dependencies> + <dependency> + <groupId>org.apache.sling</groupId> + <artifactId>org.apache.sling.jcr.api</artifactId> + <version>2.0.0-incubator-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.jackrabbit</groupId> + <artifactId>jackrabbit-jcr-server</artifactId> + <version>1.4</version> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>org.apache.jackrabbit</groupId> + <artifactId>jackrabbit-webdav</artifactId> + <version>1.4</version> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>servlet-api</artifactId> + </dependency> + + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-simple</artifactId> + </dependency> + + <!-- OSGi Libraries --> + <dependency> + <groupId>org.osgi</groupId> + <artifactId>osgi_R4_core</artifactId> + </dependency> + <dependency> + <groupId>org.osgi</groupId> + <artifactId>osgi_R4_compendium</artifactId> + </dependency> + </dependencies> +</project> diff --git a/src/main/java/org/apache/sling/jcr/webdav/SimpleWebDavServlet.java b/src/main/java/org/apache/sling/jcr/webdav/SimpleWebDavServlet.java new file mode 100644 index 0000000..03267ba --- /dev/null +++ b/src/main/java/org/apache/sling/jcr/webdav/SimpleWebDavServlet.java @@ -0,0 +1,115 @@ +/* + * 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; + +import java.util.Dictionary; +import java.util.Hashtable; + +import javax.jcr.Repository; +import javax.servlet.ServletException; + +import org.apache.jackrabbit.webdav.simple.SimpleWebdavServlet; +import org.apache.sling.jcr.api.SlingRepository; +import org.osgi.service.component.ComponentContext; +import org.osgi.service.http.HttpService; +import org.osgi.service.http.NamespaceException; + +/** + * The <code>SimpleWebDavServlet</code> + * + * @scr.component + */ +public class SimpleWebDavServlet extends SimpleWebdavServlet { + + /** @scr.property value="/dav" */ + private static final String PROP_CONTEXT = "dav.root"; + + /** @scr.property value="Sling WebDAV" */ + private static final String PROP_REALM = "dav.realm"; + + private static final String DEFAULT_CONTEXT = "/dav"; + + /** @scr.reference */ + private HttpService httpService; + + /** @scr.reference */ + private SlingRepository repository; + + // the alias under which the servlet is registered, null if not + private String contextPath; + + @Override + public Repository getRepository() { + return repository; + } + + // ---------- SCR integration ---------------------------------------------- + + protected void activate(ComponentContext componentContext) { + Dictionary<?, ?> props = componentContext.getProperties(); + + String context = getString(props, PROP_CONTEXT, DEFAULT_CONTEXT); + + Dictionary<String, String> initparams = new Hashtable<String, String>(); + + initparams.put(INIT_PARAM_RESOURCE_PATH_PREFIX, context); + + String value = getString(props, PROP_REALM, null); + if (value != null) { + initparams.put(INIT_PARAM_AUTHENTICATE_HEADER, "Basic Realm=\"" + + value + "\""); + } + +// value = getString(props, INIT_PARAM_MISSING_AUTH_MAPPING, null); +// if (value != null) { +// initparams.put(INIT_PARAM_MISSING_AUTH_MAPPING, value); +// } + + try { + httpService.registerServlet(context, this, initparams, null); + + // set the contextPath field to signal successfull registration + this.contextPath = context; + + } catch (NamespaceException ne) { + // context collision + + } catch (ServletException se) { + // servlet initialization failure + + } + } + + protected void deactivate(ComponentContext context) { + if (contextPath != null) { + httpService.unregister(contextPath); + contextPath = null; + } + } + + // ---------- internal ----------------------------------------------------- + + private String getString(Dictionary<?, ?> props, String name, + String defaultValue) { + Object propValue = props.get(name); + return (propValue instanceof String) + ? (String) propValue + : defaultValue; + } +} -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
