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 11c2e9503b4036b1847df79192f77caa620b6e88 Author: Felix Meschberger <fmesc...@apache.org> AuthorDate: Thu Jun 18 09:21:02 2009 +0000 Move Sling to new TLP location git-svn-id: https://svn.eu.apache.org/repos/asf/sling/tags/org.apache.sling.jcr.webdav-2.0.2-incubator@785979 13f79535-47bb-0310-9956-ffa450edef68 --- LICENSE | 202 ++++++++++++++++++++ NOTICE | 9 + README.txt | 38 ++++ pom.xml | 169 +++++++++++++++++ .../webdav/impl/helper/SlingLocatorFactory.java | 103 +++++++++++ .../webdav/impl/helper/SlingResourceLocator.java | 206 +++++++++++++++++++++ .../webdav/impl/helper/SlingSessionProvider.java | 76 ++++++++ .../impl/servlets/AbstractSlingWebDavServlet.java | 65 +++++++ .../webdav/impl/servlets/SimpleWebDavServlet.java | 132 +++++++++++++ .../webdav/impl/servlets/SlingWebDavServlet.java | 100 ++++++++++ src/main/resources/META-INF/DISCLAIMER | 7 + src/main/resources/META-INF/LICENSE | 202 ++++++++++++++++++++ src/main/resources/META-INF/NOTICE | 16 ++ .../OSGI-INF/metatype/metatype.properties | 41 ++++ src/main/resources/webdav-resource-config.xml | 156 ++++++++++++++++ 15 files changed, 1522 insertions(+) diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d645695 --- /dev/null +++ b/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. diff --git a/NOTICE b/NOTICE new file mode 100644 index 0000000..483c6f4 --- /dev/null +++ b/NOTICE @@ -0,0 +1,9 @@ +Apache Sling WebDAV +Copyright 2008 The Apache Software Foundation + +Apache Sling is based on source code originally developed +by Day Software (http://www.day.com/). + +This product includes software developed at +The Apache Software Foundation (http://www.apache.org/). + diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..7d1bf0d --- /dev/null +++ b/README.txt @@ -0,0 +1,38 @@ +Apache Sling WebDAV + +Bundle to access JCR repositories over WebDAV + + +Disclaimer +========== +Apache Sling is an effort undergoing incubation at The Apache Software Foundation (ASF), +sponsored by the Apache Jackrabbit PMC. Incubation is required of all newly accepted +projects until a further review indicates that the infrastructure, communications, +and decision making process have stabilized in a manner consistent with other +successful ASF projects. While incubation status is not necessarily a reflection of +the completeness or stability of the code, it does indicate that the project has yet +to be fully endorsed by the ASF. + +Getting Started +=============== + +This component uses a Maven 2 (http://maven.apache.org/) build +environment. It requires a Java 5 JDK (or higher) and Maven (http://maven.apache.org/) +2.0.7 or later. We recommend to use the latest Maven version. + +If you have Maven 2 installed, you can compile and +package the jar using the following command: + + mvn package + +See the Maven 2 documentation for other build features. + +The latest source code for this component is available in the +Subversion (http://subversion.tigris.org/) source repository of +the Apache Software Foundation. If you have Subversion installed, +you can checkout the latest source using the following command: + + svn checkout http://svn.apache.org/repos/asf/incubator/sling/trunk/jcr/webdav + +See the Subversion documentation for other source control features. + diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..505c9b4 --- /dev/null +++ b/pom.xml @@ -0,0 +1,169 @@ +<?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>3-incubator</version> + <relativePath>../../parent/pom.xml</relativePath> + </parent> + + <artifactId>org.apache.sling.jcr.webdav</artifactId> + <packaging>bundle</packaging> + <version>2.0.2-incubator</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/tags/org.apache.sling.jcr.webdav-2.0.2-incubator</connection> + <developerConnection>scm:svn:https://svn.apache.org/repos/asf/incubator/sling/tags/org.apache.sling.jcr.webdav-2.0.2-incubator</developerConnection> + <url>http://svn.apache.org/viewvc/incubator/sling/tags/org.apache.sling.jcr.webdav-2.0.2-incubator</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.impl.*, + org.apache.jackrabbit; + org.apache.jackrabbit.commons.iterator; + org.apache.jackrabbit.name; + org.apache.jackrabbit.uuid; + org.apache.jackrabbit.util; + org.apache.jackrabbit.value;-split-package:=merge-first, + 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.jackrabbit.webdav.header, + org.apache.jackrabbit.webdav.io, + org.apache.jackrabbit.webdav.jcr, + org.apache.jackrabbit.webdav.jcr.lock, + org.apache.jackrabbit.webdav.jcr.nodetype, + org.apache.jackrabbit.webdav.jcr.observation, + org.apache.jackrabbit.webdav.jcr.property, + org.apache.jackrabbit.webdav.jcr.search, + org.apache.jackrabbit.webdav.jcr.transaction, + org.apache.jackrabbit.webdav.jcr.version, + org.apache.jackrabbit.webdav.jcr.version.report, + org.apache.jackrabbit.webdav.lock, + org.apache.jackrabbit.webdav.observation, + org.apache.jackrabbit.webdav.ordering, + org.apache.jackrabbit.webdav.property, + org.apache.jackrabbit.webdav.search, + org.apache.jackrabbit.webdav.security, + org.apache.jackrabbit.webdav.server, + org.apache.jackrabbit.webdav.transaction, + org.apache.jackrabbit.webdav.util, + org.apache.jackrabbit.webdav.version, + org.apache.jackrabbit.webdav.version.report, + org.apache.jackrabbit.webdav.xml, + 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> + <reporting> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-javadoc-plugin</artifactId> + <configuration> + <excludePackageNames> + org.apache.sling.jcr.webdav.impl + </excludePackageNames> + </configuration> + </plugin> + </plugins> + </reporting> + + <dependencies> + <dependency> + <groupId>org.apache.sling</groupId> + <artifactId>org.apache.sling.jcr.api</artifactId> + <version>2.0.2-incubator</version> + </dependency> + + <dependency> + <groupId>org.apache.jackrabbit</groupId> + <artifactId>jackrabbit-jcr-commons</artifactId> + <scope>compile</scope> + </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-api</artifactId> + </dependency> + + <!-- OSGi Libraries --> + <dependency> + <groupId>org.apache.felix</groupId> + <artifactId>org.osgi.core</artifactId> + </dependency> + <dependency> + <groupId>org.apache.felix</groupId> + <artifactId>org.osgi.compendium</artifactId> + </dependency> + </dependencies> +</project> diff --git a/src/main/java/org/apache/sling/jcr/webdav/impl/helper/SlingLocatorFactory.java b/src/main/java/org/apache/sling/jcr/webdav/impl/helper/SlingLocatorFactory.java new file mode 100644 index 0000000..6c35a6c --- /dev/null +++ b/src/main/java/org/apache/sling/jcr/webdav/impl/helper/SlingLocatorFactory.java @@ -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.sling.jcr.webdav.impl.helper; + +import org.apache.jackrabbit.util.Text; +import org.apache.jackrabbit.webdav.DavLocatorFactory; +import org.apache.jackrabbit.webdav.DavResourceLocator; + +public class SlingLocatorFactory implements DavLocatorFactory { + + private final String workspaceName; + + public SlingLocatorFactory(String workspaceName) { + this.workspaceName = workspaceName; + } + + public DavResourceLocator createResourceLocator(String prefix, String href) { + + if (href == null) { + throw new IllegalArgumentException( + "Request handle must not be null."); + } + + + // if href starts with the prefix, cut the prefix off the href + if (prefix != null && prefix.length() > 0) { + if (href.startsWith(prefix)) { + href = href.substring(prefix.length()); + } + } + + // remove trailing "/" that is present with collections + if (href.endsWith("/")) { + href = href.substring(0, href.length() - 1); + } + + + // an empty requestHandle (after removal of the "/") signifies a request + // to the root that does not represent a repository item. + String resourcePath; + if ("".equals(href)) { + resourcePath = "/"; + } else { + resourcePath = Text.unescape(href); + } + + return new SlingResourceLocator(prefix, workspaceName, resourcePath, + this); + } + + /** + * Create a new <code>DavResourceLocator</code> from the specified prefix, + * workspace path and resource path, whithout modifying the specified + * Strings. Note, that it is expected that the resource path starts with the + * given workspace path unless both values are <code>null</code>. + * + * @param prefix + * @param workspacePath path or the workspace containing this resource or + * <code>null</code>. + * @param resourcePath Path of the resource or <code>null</code>. Any non + * null value must start with the specified workspace path. + * @return a new <code>DavResourceLocator</code> + * @see DavLocatorFactory#createResourceLocator(String, String, String) + */ + public DavResourceLocator createResourceLocator(String prefix, + String workspacePath, String resourcePath) { + return createResourceLocator(prefix, workspacePath, resourcePath, true); + } + + /** + * Create a new <code>DavResourceLocator</code> from the specified prefix, + * workspace path and resource path. I + * + * @param prefix + * @param workspacePath + * @param resourcePath + * @param isResourcePath + * @see DavLocatorFactory#createResourceLocator(String, String, String, + * boolean) + */ + public DavResourceLocator createResourceLocator(String prefix, + String workspacePath, String resourcePath, boolean isResourcePath) { + return new SlingResourceLocator(prefix, workspacePath, resourcePath, + this); + } + +} diff --git a/src/main/java/org/apache/sling/jcr/webdav/impl/helper/SlingResourceLocator.java b/src/main/java/org/apache/sling/jcr/webdav/impl/helper/SlingResourceLocator.java new file mode 100644 index 0000000..8ce9f15 --- /dev/null +++ b/src/main/java/org/apache/sling/jcr/webdav/impl/helper/SlingResourceLocator.java @@ -0,0 +1,206 @@ +/* + * 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.helper; + +import org.apache.jackrabbit.util.Text; +import org.apache.jackrabbit.webdav.DavLocatorFactory; +import org.apache.jackrabbit.webdav.DavResourceLocator; + +class SlingResourceLocator implements DavResourceLocator { + + private final String prefix; + + private final String workspaceName; + + private final String resourcePath; + + private final SlingLocatorFactory factory; + + private final String href; + + SlingResourceLocator(String prefix, String workspaceName, + String resourcePath, SlingLocatorFactory factory) { + + this.prefix = prefix; + this.workspaceName = workspaceName; + this.resourcePath = resourcePath; + this.factory = factory; + + StringBuffer buf = new StringBuffer(prefix); + buf.append(Text.escapePath(resourcePath)); + int length = buf.length(); + if (length > 0 && buf.charAt(length - 1) != '/') { + buf.append("/"); + } + href = buf.toString(); + } + + /** + * Return the prefix used to build the href String. This includes the + * initial hrefPrefix as well a the path prefix. + * + * @return prefix String used to build the href. + */ + public String getPrefix() { + return prefix; + } + + /** + * Returns the resource path which always starts with the workspace + * path, if a workspace resource exists. For the top most resource + * (request handle '/'), <code>null</code> is returned. + * + * @return resource path or <code>null</code> + * @see org.apache.jackrabbit.webdav.DavResourceLocator#getResourcePath() + */ + public String getResourcePath() { + return resourcePath; + } + + /** + * Return the workspace path or <code>null</code> if this locator + * object represents the '/' request handle. + * + * @return workspace path or <code>null</code> + * @see org.apache.jackrabbit.webdav.DavResourceLocator#getWorkspacePath() + */ + public String getWorkspacePath() { + return "/" + workspaceName; + } + + /** + * Return the workspace name or <code>null</code> if this locator + * object represents the '/' request handle, which does not contain a + * workspace path. + * + * @return workspace name or <code>null</code> + * @see org.apache.jackrabbit.webdav.DavResourceLocator#getWorkspaceName() + */ + public String getWorkspaceName() { + return workspaceName; + } + + /** + * Returns true if the specified locator object refers to a resource + * within the same workspace. + * + * @param locator + * @return true if the workspace name obtained from the given locator + * refers to the same workspace as the workspace name of this + * locator. + * @see DavResourceLocator#isSameWorkspace(org.apache.jackrabbit.webdav.DavResourceLocator) + */ + public boolean isSameWorkspace(DavResourceLocator locator) { + return (locator == null) + ? false + : isSameWorkspace(locator.getWorkspaceName()); + } + + /** + * Returns true if the specified string equals to this workspace name or + * if both names are null. + * + * @param workspaceName + * @return true if the workspace name is equal to this workspace name. + * @see DavResourceLocator#isSameWorkspace(String) + */ + public boolean isSameWorkspace(String workspaceName) { + String thisWspName = getWorkspaceName(); + return (thisWspName == null) + ? workspaceName == null + : thisWspName.equals(workspaceName); + } + + /** + * Returns an 'href' consisting of prefix and resource path (which + * starts with the workspace path). It assures a trailing '/' in case + * the href is used for collection. Note, that the resource path is + * {@link Text#escapePath(String) escaped}. + * + * @param isCollection + * @return href String representing the text of the href element + * @see org.apache.jackrabbit.webdav.DavConstants#XML_HREF + * @see DavResourceLocator#getHref(boolean) + */ + public String getHref(boolean isCollection) { + return (isCollection) ? href : href.substring(0, href.length() - 1); + } + + /** + * Returns true if the 'workspacePath' field is <code>null</code>. + * + * @return true if the 'workspacePath' field is <code>null</code>. + * @see org.apache.jackrabbit.webdav.DavResourceLocator#isRootLocation() + */ + public boolean isRootLocation() { + return getWorkspacePath() == null; + } + + /** + * Return the factory that created this locator. + * + * @return factory + * @see org.apache.jackrabbit.webdav.DavResourceLocator#getFactory() + */ + public DavLocatorFactory getFactory() { + return factory; + } + + /** + * Uses {@link #getResourcePath()} + * to build the repository path. + * + * @see DavResourceLocator#getRepositoryPath() + */ + public String getRepositoryPath() { + return getResourcePath(); +// factory.getRepositoryPath(getResourcePath(), +// getWorkspacePath()); + } + + /** + * Computes the hash code from the href, that is built from the prefix, + * the workspace name and the resource path all of them representing + * final instance fields. + * + * @return the hash code + */ + public int hashCode() { + return href.hashCode(); + } + + /** + * Returns true, if the given object is a + * <code>SlingResourceLocator</code> with the same hash code. + * + * @param obj the object to compare to + * @return <code>true</code> if the 2 objects are equal; + * <code>false</code> otherwise + */ + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (obj instanceof SlingResourceLocator) { + SlingResourceLocator other = (SlingResourceLocator) obj; + return hashCode() == other.hashCode(); + } + return false; + } +} \ No newline at end of file diff --git a/src/main/java/org/apache/sling/jcr/webdav/impl/helper/SlingSessionProvider.java b/src/main/java/org/apache/sling/jcr/webdav/impl/helper/SlingSessionProvider.java new file mode 100644 index 0000000..771f2d5 --- /dev/null +++ b/src/main/java/org/apache/sling/jcr/webdav/impl/helper/SlingSessionProvider.java @@ -0,0 +1,76 @@ +/* + * 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.helper; + +import javax.jcr.LoginException; +import javax.jcr.Repository; +import javax.jcr.Session; +import javax.servlet.http.HttpServletRequest; + +import org.apache.jackrabbit.server.SessionProvider; + +/** + * The <code>SlingSessionProvider</code> is a Jackrabbit WebDAV server + * <code>SessionProvider</code> which returns the session stored as the + * <code>javax.jcr.Session</code> request attribute. This request attribute is + * set by the Sling Authenticator when the request is authenticated. If the + * request is not authenticated, the request attribute is not set and hence no + * session is returned. + * <p> + * This class expects an authenticated request, which is identified by the + * request authentication type to not be <code>null</code>. Otherwise the + * {@link #getSession(HttpServletRequest, Repository, String)} method throws a + * <code>LoginException</code> to force authentication. + */ +public class SlingSessionProvider implements SessionProvider { + + /** + * The name of the request attribute providing the JCR session (value is + * "javax.jcr.Session"). + */ + private static final String ATTR_SESSION_NAME = Session.class.getName(); + + /** + * Returns the value of the <code>javax.jcr.Session</code> request + * attribute or <code>null</code> if the request attribute is not set. If + * the request is not authenticated, that is the authentication type is + * <code>null</code>, a <code>LoginException</code> is thrown to force + * authentication. + */ + public Session getSession(HttpServletRequest request, Repository rep, + String workspace) throws LoginException { + + // we do not accept the anonymous session for WebDAV ! + if (request.getAuthType() == null) { + throw new LoginException("Authentication required for WebDAV"); + } + + // otherwise return the session from the request attribute + return (Session) request.getAttribute(ATTR_SESSION_NAME); + } + + /** + * Does nothing as the session is taken from the Sling request and hence the + * session will be released by Sling. + */ + public void releaseSession(Session session) { + // nothing to do, we must not logout the Sling session + } + +} diff --git a/src/main/java/org/apache/sling/jcr/webdav/impl/servlets/AbstractSlingWebDavServlet.java b/src/main/java/org/apache/sling/jcr/webdav/impl/servlets/AbstractSlingWebDavServlet.java new file mode 100644 index 0000000..a5145d1 --- /dev/null +++ b/src/main/java/org/apache/sling/jcr/webdav/impl/servlets/AbstractSlingWebDavServlet.java @@ -0,0 +1,65 @@ +/* + * 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.servlets; + +import java.net.URL; + +import javax.jcr.Repository; +import javax.servlet.ServletException; +import javax.servlet.UnavailableException; + +import org.apache.jackrabbit.webdav.simple.ResourceConfig; +import org.apache.jackrabbit.webdav.simple.SimpleWebdavServlet; +import org.apache.sling.jcr.api.SlingRepository; + +/** + * The <code>SimpleWebDavServlet</code> + * + * @scr.component + * immediate="true" + * metatype="no" + */ +abstract class AbstractSlingWebDavServlet extends SimpleWebdavServlet { + + /** @scr.reference */ + private SlingRepository repository; + + @Override + public Repository getRepository() { + return repository; + } + + @Override + public void init() throws ServletException { + super.init(); + + // 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 UnavailableException("ResourceConfig source not found:" + + configPath); + } + + rc.parse(cfg); + setResourceConfig(rc); + } + +} diff --git a/src/main/java/org/apache/sling/jcr/webdav/impl/servlets/SimpleWebDavServlet.java b/src/main/java/org/apache/sling/jcr/webdav/impl/servlets/SimpleWebDavServlet.java new file mode 100644 index 0000000..4cd1947 --- /dev/null +++ b/src/main/java/org/apache/sling/jcr/webdav/impl/servlets/SimpleWebDavServlet.java @@ -0,0 +1,132 @@ +/* + * 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.servlets; + +import java.io.IOException; +import java.util.Dictionary; +import java.util.Hashtable; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +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 label="%dav.name" description="%dav.description" + * @scr.property name="service.description" + * value="Sling JcrResourceResolverFactory Implementation" + * @scr.property name="service.vendor" value="The Apache Software Foundation" + */ +public class SimpleWebDavServlet extends AbstractSlingWebDavServlet { + + /** @scr.property valueRef="DEFAULT_CONTEXT" */ + private static final String PROP_CONTEXT = "dav.root"; + + /** @scr.property valueRef="DEFAULT_REALM" */ + private static final String PROP_REALM = "dav.realm"; + + private static final String DEFAULT_CONTEXT = "/dav"; + + private static final String DEFAULT_REALM = "Sling WebDAV"; + + /** @scr.reference */ + private HttpService httpService; + + // the alias under which the servlet is registered, null if not + private String contextPath; + + // ---------- AbstractWebdavServlet overwrite ------------------------------ + + @Override + protected void service(HttpServletRequest request, + HttpServletResponse response) throws ServletException, IOException { + + final String pinfo = request.getPathInfo(); + + if (pinfo == null || "/".equals(pinfo)) { + // redirect to the default workspace if directly addressing the + // servlet + // and if the default workspace name is not null (in which case we'd + // need + // to login to find out the actual workspace name, SLING-256) + SlingRepository slingRepo = (SlingRepository) getRepository(); + if (slingRepo.getDefaultWorkspace() == null) { + response.sendError( + HttpServletResponse.SC_NOT_FOUND, + "JCR workspace name required, please add it to the end of the URL" + + " (for the Jackrabbit embedded repository the default name is 'default') "); + } else { + String uri = request.getRequestURI(); + if (pinfo == null) { + uri += "/"; + } + uri += slingRepo.getDefaultWorkspace(); + response.sendRedirect(uri); + } + } + + super.service(request, response); + } + + // ---------- SCR integration ---------------------------------------------- + + protected void activate(ComponentContext componentContext) + throws NamespaceException, ServletException { + + 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, DEFAULT_REALM); + initparams.put(INIT_PARAM_AUTHENTICATE_HEADER, "Basic Realm=\"" + value + + "\""); + + // 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) { + 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; + } +} diff --git a/src/main/java/org/apache/sling/jcr/webdav/impl/servlets/SlingWebDavServlet.java b/src/main/java/org/apache/sling/jcr/webdav/impl/servlets/SlingWebDavServlet.java new file mode 100644 index 0000000..e68cba3 --- /dev/null +++ b/src/main/java/org/apache/sling/jcr/webdav/impl/servlets/SlingWebDavServlet.java @@ -0,0 +1,100 @@ +/* + * 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.servlets; + +import javax.jcr.Session; + +import org.apache.jackrabbit.server.SessionProvider; +import org.apache.jackrabbit.webdav.DavLocatorFactory; +import org.apache.sling.jcr.api.SlingRepository; +import org.apache.sling.jcr.webdav.impl.helper.SlingLocatorFactory; +import org.apache.sling.jcr.webdav.impl.helper.SlingSessionProvider; + +/** + * The <code>SlingWebDavServlet</code> implements the WebDAV protocol as a + * default servlet for Sling handling all WebDAV methods. + * + * @scr.component + * immediate="true" + * metatype="no" + * + * @scr.service + * interface="javax.servlet.Servlet" + * + * @scr.property + * name="service.description" + * value="Sling WebDAV Servlet" + * + * @scr.property + * name="service.vendor" + * value="The Apache Software Foundation" + * + * Use this as the default servlet for all requests to Sling + * @scr.property + * name="sling.servlet.resourceTypes" + * value="sling/servlet/default" + * @scr.property + * name="sling.servlet.methods" + * value="*" + */ +public class SlingWebDavServlet extends AbstractSlingWebDavServlet { + + private DavLocatorFactory locatorFactory; + + private SessionProvider sessionProvider; + + //---------- SimpleWebdavServlet overwrites ------------------------------- + + @Override + public DavLocatorFactory getLocatorFactory() { + if (locatorFactory == null) { + + // configured default workspace name + SlingRepository slingRepo = (SlingRepository) getRepository(); + String workspace = slingRepo.getDefaultWorkspace(); + + // no configuration, try to login and acquire the default name + if (workspace == null || workspace.length() == 0) { + Session tmp = null; + try { + tmp = slingRepo.login(); + workspace = tmp.getWorkspace().getName(); + } catch (Throwable t) { + // TODO: log !! + workspace = "default"; // fall back name + } finally { + if (tmp != null) { + tmp.logout(); + } + } + } + + locatorFactory = new SlingLocatorFactory(workspace); + } + return locatorFactory; + } + + @Override + public synchronized SessionProvider getSessionProvider() { + if (sessionProvider == null) { + sessionProvider = new SlingSessionProvider(); + } + return sessionProvider; + } +} diff --git a/src/main/resources/META-INF/DISCLAIMER b/src/main/resources/META-INF/DISCLAIMER new file mode 100644 index 0000000..90850c2 --- /dev/null +++ b/src/main/resources/META-INF/DISCLAIMER @@ -0,0 +1,7 @@ +Apache Sling is an effort undergoing incubation at The Apache Software Foundation (ASF), +sponsored by the Apache Jackrabbit PMC. Incubation is required of all newly accepted +projects until a further review indicates that the infrastructure, communications, +and decision making process have stabilized in a manner consistent with other +successful ASF projects. While incubation status is not necessarily a reflection of +the completeness or stability of the code, it does indicate that the project has yet +to be fully endorsed by the ASF. \ No newline at end of file diff --git a/src/main/resources/META-INF/LICENSE b/src/main/resources/META-INF/LICENSE new file mode 100644 index 0000000..d645695 --- /dev/null +++ b/src/main/resources/META-INF/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. diff --git a/src/main/resources/META-INF/NOTICE b/src/main/resources/META-INF/NOTICE new file mode 100644 index 0000000..662f012 --- /dev/null +++ b/src/main/resources/META-INF/NOTICE @@ -0,0 +1,16 @@ +Apache Sling WebDAV +Copyright 2008 The Apache Software Foundation + +Apache Sling is based on source code originally developed +by Day Software (http://www.day.com/). + +This product includes software developed at +The Apache Software Foundation (http://www.apache.org/). + +This product includes Apache Xerces, portions of which were +originally based on the following: +- software copyright (c) 1999, IBM Corporation., http://www.ibm.com. +- software copyright (c) 1999, Sun Microsystems., http://www.sun.com. +- voluntary contributions made by Paul Eng on behalf of the + Apache Software Foundation that were originally developed at iClick, Inc., + software copyright (c) 1999. diff --git a/src/main/resources/OSGI-INF/metatype/metatype.properties b/src/main/resources/OSGI-INF/metatype/metatype.properties new file mode 100644 index 0000000..1d6bd0e --- /dev/null +++ b/src/main/resources/OSGI-INF/metatype/metatype.properties @@ -0,0 +1,41 @@ +# +# 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. +# + + +# +# This file contains localization strings for configuration labels and +# descriptions as used in the metatype.xml descriptor generated by the +# the SCR plugin + +# +# SimpleWebDavServlet +# (This servlet is directly registered with the HttpService besides the +# SlingMainServlet. Requests to this servlet do not pass by Sling) +dav.name = Simple WebDAV Servlet +dav.description = The Simple WebDAV Servlet allows direct access to the \ + complete Repository. It is directly accessible in its own URL space and \ + requests to this servlet do not pass by the Sling Main Servlet and request \ + processing. +dav.root.name = Root Path +dav.root.description = The root path at which the Simple WebDAV Servlet is \ + accessible. The default value is "/dav". +dav.realm.name = Authentication Realm +dav.realm.description = The name of the HTTP Basic Authentication Realm \ + presented to the client to ask for authentication credentials to access the \ + repository. diff --git a/src/main/resources/webdav-resource-config.xml b/src/main/resources/webdav-resource-config.xml new file mode 100644 index 0000000..3d9175b --- /dev/null +++ b/src/main/resources/webdav-resource-config.xml @@ -0,0 +1,156 @@ +<?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.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>.