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 276d804e160b6aaec10a6f7a5617de172313e7ed Author: Bertrand Delacretaz <bdelacre...@apache.org> AuthorDate: Thu Jan 17 13:14:44 2008 +0000 Added webdav-resource-config.xml to map nt:file and related nodetypes in the usual way git-svn-id: https://svn.apache.org/repos/asf/incubator/sling/trunk/jcr/webdav@612808 13f79535-47bb-0310-9956-ffa450edef68 --- .../sling/jcr/webdav/SimpleWebDavServlet.java | 33 +++-- src/main/resources/webdav-resource-config.xml | 162 +++++++++++++++++++++ 2 files changed, 179 insertions(+), 16 deletions(-) diff --git a/src/main/java/org/apache/sling/jcr/webdav/SimpleWebDavServlet.java b/src/main/java/org/apache/sling/jcr/webdav/SimpleWebDavServlet.java index 795c794..ad286f4 100644 --- a/src/main/java/org/apache/sling/jcr/webdav/SimpleWebDavServlet.java +++ b/src/main/java/org/apache/sling/jcr/webdav/SimpleWebDavServlet.java @@ -19,6 +19,7 @@ package org.apache.sling.jcr.webdav; import java.io.IOException; +import java.net.URL; import java.util.Dictionary; import java.util.Hashtable; @@ -27,11 +28,11 @@ import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.apache.jackrabbit.webdav.simple.ResourceConfig; 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> @@ -61,7 +62,7 @@ public class SimpleWebDavServlet extends SimpleWebdavServlet { public Repository getRepository() { return repository; } - + // ---------- AbstractWebdavServlet overwrite ------------------------------ @Override @@ -84,7 +85,7 @@ public class SimpleWebDavServlet extends SimpleWebdavServlet { // ---------- SCR integration ---------------------------------------------- - protected void activate(ComponentContext componentContext) { + protected void activate(ComponentContext componentContext) throws Exception { Dictionary<?, ?> props = componentContext.getProperties(); String context = getString(props, PROP_CONTEXT, DEFAULT_CONTEXT); @@ -98,25 +99,25 @@ public class SimpleWebDavServlet extends SimpleWebdavServlet { initparams.put(INIT_PARAM_AUTHENTICATE_HEADER, "Basic Realm=\"" + value + "\""); } + + // for now, the ResourceConfig is fixed + final String configPath = "/webdav-resource-config.xml"; + final ResourceConfig rc = new ResourceConfig(); + final URL cfg = getClass().getResource(configPath); + if(cfg == null) { + throw new IOException("ResourceConfig source not found:" + configPath); + } + rc.parse(cfg); + setResourceConfig(rc); // 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 - - } + // Register servlet, and set the contextPath field to signal successful registration + httpService.registerServlet(context, this, initparams, null); + this.contextPath = context; } protected void deactivate(ComponentContext context) { diff --git a/src/main/resources/webdav-resource-config.xml b/src/main/resources/webdav-resource-config.xml new file mode 100644 index 0000000..fb55f8a --- /dev/null +++ b/src/main/resources/webdav-resource-config.xml @@ -0,0 +1,162 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + 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. + --> +<!-- +<!DOCTYPE config [ + <!ELEMENT config (iomanager , propertymanager, (collection | noncollection)? , filter?) > + + <!ELEMENT iomanager (class, iohandler*) > + <!ELEMENT iohandler (class) > + + <!ELEMENT propertymanager (class, propertyhandler*) > + <!ELEMENT propertyhandler (class) > + + <!ELEMENT collection (nodetypes) > + <!ELEMENT noncollection (nodetypes) > + + <!ELEMENT filter (class, namespaces?, nodetypes?) > + + <!ELEMENT class > + <!ATTLIST class + name CDATA #REQUIRED + > + <!ELEMENT namespaces (prefix | uri)* > + <!ELEMENT prefix (CDATA) > + <!ELEMENT uri (CDATA) > + + <!ELEMENT nodetypes (nodetype)* > + <!ELEMENT nodetype (CDATA) > +]> +--> + +<config> + <!-- + Defines the IOManager implementation that is responsible for passing import/export + request to the individual IO-handlers. + --> + <iomanager> + <!-- class element defines the manager to be used. The specified class + must implement the IOManager interface. + Note, that the handlers are being added and called in the order + they appear in the configuration. + --> + <class name="org.apache.jackrabbit.server.io.IOManagerImpl" /> + <iohandler> + <class name="org.apache.jackrabbit.server.io.ZipHandler" /> + </iohandler> + <iohandler> + <class name="org.apache.jackrabbit.server.io.XmlHandler" /> + </iohandler> + <iohandler> + <class name="org.apache.jackrabbit.server.io.DirListingExportHandler" /> + </iohandler> + <iohandler> + <class name="org.apache.jackrabbit.server.io.DefaultHandler" /> + </iohandler> + </iomanager> + <!-- + Example config for iomanager that populates its list of handlers with + default values. Therefore the 'iohandler' elements are omited. + --> + <!-- + <iomanager> + <class name="org.apache.jackrabbit.server.io.DefaultIOManager" /> + </iomanager> + --> + <!-- + Defines the PropertyManager implementation that is responsible for export + and import of resource properties. + --> + <propertymanager> + <!-- class element defines the manager to be used. The specified class + must implement the PropertyManager interface. + Note, that the handlers are being added and called in the order + they appear in the configuration. + --> + <class name="org.apache.jackrabbit.server.io.PropertyManagerImpl" /> + <propertyhandler> + <class name="org.apache.jackrabbit.server.io.ZipHandler" /> + </propertyhandler> + <propertyhandler> + <class name="org.apache.jackrabbit.server.io.XmlHandler" /> + </propertyhandler> + <propertyhandler> + <class name="org.apache.jackrabbit.server.io.DirListingExportHandler" /> + </propertyhandler> + <propertyhandler> + <class name="org.apache.jackrabbit.server.io.DefaultHandler" /> + </propertyhandler> + </propertymanager> + <!-- + Define nodetypes, that should never by displayed as 'collection' + --> + <noncollection> + <nodetypes> + <nodetype>nt:file</nodetype> + <nodetype>nt:resource</nodetype> + </nodetypes> + </noncollection> + <!-- + Example: Defines nodetypes, that should always be displayed as 'collection'. + --> + <!-- + <collection> + <nodetypes> + <nodetype>nt:folder</nodetype> + <nodetype>rep:root</nodetype> + </nodetypes> + </collection> + --> + <!-- + Filter that allows to prevent certain items from being displayed. + Please note, that this has an effect on PROPFIND calls only and does not + provide limited access to those items matching any of the filters. + + However specifying a filter may cause problems with PUT or MKCOL if the + resource to be created is being filtered out, thus resulting in inconsistent + responses (e.g. PUT followed by PROPFIND on parent). + --> + <filter> + <!-- class element defines the resource filter to be used. The specified class + must implement the ItemFilter interface --> + <class name="org.apache.jackrabbit.webdav.simple.DefaultItemFilter" /> + <!-- Nodetype names to be used to filter child nodes. + A child node can be filtered if the declaring nodetype of its definition + is one of the nodetype names specified in the nodetypes Element. + E.g. defining 'rep:root' as filtered nodetype whould result in jcr:system + being hidden but no other child node of the root node, since those + are defined by the nodetype nt:unstructered. + --> + <!-- + <nodetypes> + <nodetype>rep:root</nodetype> + </nodetypes> + --> + <!-- Namespace prefixes or uris. Items having a name that matches any of the + entries will be filtered. + --> + <namespaces> + <prefix>rep</prefix> + <prefix>jcr</prefix> + <!-- + <uri>internal</uri> + <uri>http://www.jcp.org/jcr/1.0</uri> + --> + </namespaces> + </filter> +</config> + -- To stop receiving notification emails like this one, please contact "commits@sling.apache.org" <commits@sling.apache.org>.