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.6-incubator in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-webdav.git
commit 8e3754c01801e6095e7d0dcf125a8b6d7c6a3243 Author: Felix Meschberger <[email protected]> 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.6-incubator@785979 13f79535-47bb-0310-9956-ffa450edef68 --- LICENSE | 202 ++++++++++++++++++++ NOTICE | 9 + README.txt | 38 ++++ pom.xml | 144 ++++++++++++++ .../webdav/impl/helper/SlingLocatorFactory.java | 103 +++++++++++ .../jcr/webdav/impl/helper/SlingMimeResolver.java | 41 ++++ .../webdav/impl/helper/SlingResourceConfig.java | 175 +++++++++++++++++ .../webdav/impl/helper/SlingResourceLocator.java | 206 +++++++++++++++++++++ .../webdav/impl/helper/SlingSessionProvider.java | 76 ++++++++ .../impl/servlets/SlingSimpleWebDavServlet.java | 97 ++++++++++ .../webdav/impl/servlets/SlingWebDavServlet.java | 193 +++++++++++++++++++ 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 | 101 ++++++++++ .../jcr/webdav/impl/helper/mimetypes.properties | 23 +++ 16 files changed, 1633 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..d9d3bda --- /dev/null +++ b/NOTICE @@ -0,0 +1,9 @@ +Apache Sling WebDAV +Copyright 2008-2009 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..641fbf2 --- /dev/null +++ b/pom.xml @@ -0,0 +1,144 @@ +<?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>5-incubator</version> + <relativePath>../../../parent/pom.xml</relativePath> + </parent> + + <artifactId>org.apache.sling.jcr.webdav</artifactId> + <packaging>bundle</packaging> + <version>2.0.6-incubator</version> + + <name>Apache 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.6-incubator</connection> + <developerConnection>scm:svn:https://svn.apache.org/repos/asf/incubator/sling/tags/org.apache.sling.jcr.webdav-2.0.6-incubator</developerConnection> + <url>http://svn.apache.org/viewvc/incubator/sling/tags/org.apache.sling.jcr.webdav-2.0.6-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> + <Private-Package> + org.apache.sling.jcr.webdav.impl.* + </Private-Package> + <Import-Package> + <!-- ignore HTTP client methods of webdav --> + !org.apache.commons.httpclient.*, + + <!-- ignore XML resolver of xerces --> + !org.apache.xml.resolver.*, + + <!-- don't import any sun stuff --> + !sun.*, + + <!-- import the rest --> + * + </Import-Package> + <Embed-Dependency> + jackrabbit-jcr-server, + jackrabbit-webdav, + xercesImpl, + jackrabbit-jcr-commons + </Embed-Dependency> + <Embed-Transitive>true</Embed-Transitive> + </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.sling</groupId> + <artifactId>org.apache.sling.commons.osgi</artifactId> + <version>2.0.4-incubator</version> + </dependency> + <dependency> + <groupId>org.apache.sling</groupId> + <artifactId>org.apache.sling.commons.mime</artifactId> + <version>2.0.2-incubator</version> + </dependency> + + <dependency> + <groupId>org.apache.jackrabbit</groupId> + <artifactId>jackrabbit-jcr-server</artifactId> + <version>1.5.0</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/SlingMimeResolver.java b/src/main/java/org/apache/sling/jcr/webdav/impl/helper/SlingMimeResolver.java new file mode 100644 index 0000000..a01ee22 --- /dev/null +++ b/src/main/java/org/apache/sling/jcr/webdav/impl/helper/SlingMimeResolver.java @@ -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. + */ +package org.apache.sling.jcr.webdav.impl.helper; + +import org.apache.jackrabbit.server.io.MimeResolver; +import org.apache.sling.commons.mime.MimeTypeService; + +public class SlingMimeResolver extends MimeResolver { + + private final MimeTypeService mimeTypeService; + + public SlingMimeResolver(MimeTypeService mimeTypeService) { + this.mimeTypeService = mimeTypeService; + } + + @Override + public String getMimeType(String filename) { + String type = mimeTypeService.getMimeType(filename); + if (type == null) { + type = getDefaultMimeType(); + } + return type; + } + +} diff --git a/src/main/java/org/apache/sling/jcr/webdav/impl/helper/SlingResourceConfig.java b/src/main/java/org/apache/sling/jcr/webdav/impl/helper/SlingResourceConfig.java new file mode 100644 index 0000000..270c416 --- /dev/null +++ b/src/main/java/org/apache/sling/jcr/webdav/impl/helper/SlingResourceConfig.java @@ -0,0 +1,175 @@ +/* + * 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 java.net.URL; +import java.util.Dictionary; +import java.util.Hashtable; + +import javax.jcr.Item; +import javax.jcr.Node; +import javax.jcr.RepositoryException; + +import org.apache.jackrabbit.server.io.DefaultHandler; +import org.apache.jackrabbit.server.io.DirListingExportHandler; +import org.apache.jackrabbit.server.io.IOManager; +import org.apache.jackrabbit.server.io.IOManagerImpl; +import org.apache.jackrabbit.server.io.MimeResolver; +import org.apache.jackrabbit.server.io.PropertyManager; +import org.apache.jackrabbit.server.io.PropertyManagerImpl; +import org.apache.jackrabbit.webdav.simple.DefaultItemFilter; +import org.apache.jackrabbit.webdav.simple.ItemFilter; +import org.apache.jackrabbit.webdav.simple.ResourceConfig; +import org.apache.jackrabbit.webdav.simple.SimpleWebdavServlet; +import org.apache.sling.commons.mime.MimeTypeService; +import org.apache.sling.commons.osgi.OsgiUtil; +import org.apache.sling.jcr.webdav.impl.servlets.SlingWebDavServlet; + +public class SlingResourceConfig extends ResourceConfig { + + private final MimeResolver mimeResolver; + + private final String[] collectionTypes; + + private final ItemFilter itemFilter; + + private final IOManager ioManager; + + private final PropertyManager propertyManager; + + private final String servletContextPath; + + private final Dictionary<String, String> servletInitParams; + + public SlingResourceConfig(MimeTypeService mimetypService, + Dictionary<?, ?> config) { + mimeResolver = new SlingMimeResolver(mimetypService); + collectionTypes = OsgiUtil.toStringArray( + config.get(SlingWebDavServlet.COLLECTION_TYPES), + SlingWebDavServlet.COLLECTION_TYPES_DEFAULT); + + String[] filterPrefixes = OsgiUtil.toStringArray( + config.get(SlingWebDavServlet.FILTER_PREFIXES), + SlingWebDavServlet.FILTER_PREFIXES_DEFAULT); + String[] filterNodeTypes = OsgiUtil.toStringArray( + config.get(SlingWebDavServlet.FILTER_TYPES), + SlingWebDavServlet.EMPTY_DEFAULT); + String[] filterURIs = OsgiUtil.toStringArray( + config.get(SlingWebDavServlet.FILTER_URIS), + SlingWebDavServlet.EMPTY_DEFAULT); + + itemFilter = new DefaultItemFilter(); + itemFilter.setFilteredPrefixes(filterPrefixes); + itemFilter.setFilteredURIs(filterURIs); + itemFilter.setFilteredNodetypes(filterNodeTypes); + + String collectionType = OsgiUtil.toString( + config.get(SlingWebDavServlet.TYPE_COLLECTIONS), + SlingWebDavServlet.TYPE_COLLECTIONS_DEFAULT); + String nonCollectionType = OsgiUtil.toString( + config.get(SlingWebDavServlet.TYPE_NONCOLLECTIONS), + SlingWebDavServlet.TYPE_NONCOLLECTIONS_DEFAULT); + String contentType = OsgiUtil.toString( + config.get(SlingWebDavServlet.TYPE_CONTENT), + SlingWebDavServlet.TYPE_CONTENT_DEFAULT); + + // share these handlers between the IOManager and the PropertyManager + DirListingExportHandler dirHandler = new DirListingExportHandler(); + DefaultHandler defaultHandler = new DefaultHandler(null, collectionType, + nonCollectionType, contentType); + + ioManager = new IOManagerImpl(); + ioManager.addIOHandler(dirHandler); + ioManager.addIOHandler(defaultHandler); + + propertyManager = new PropertyManagerImpl(); + propertyManager.addPropertyHandler(dirHandler); + propertyManager.addPropertyHandler(defaultHandler); + + servletContextPath = OsgiUtil.toString( + config.get(SlingWebDavServlet.PROP_CONTEXT), + SlingWebDavServlet.DEFAULT_CONTEXT); + + servletInitParams = new Hashtable<String, String>(); + servletInitParams.put( + SimpleWebdavServlet.INIT_PARAM_RESOURCE_PATH_PREFIX, + servletContextPath); + String value = OsgiUtil.toString( + config.get(SlingWebDavServlet.PROP_REALM), + SlingWebDavServlet.DEFAULT_REALM); + servletInitParams.put( + SimpleWebdavServlet.INIT_PARAM_AUTHENTICATE_HEADER, + "Basic Realm=\"" + value + "\""); + } + + // ---------- ResourceConfig overwrites + + @Override + public IOManager getIOManager() { + return ioManager; + } + + @Override + public ItemFilter getItemFilter() { + return itemFilter; + } + + @Override + public MimeResolver getMimeResolver() { + return mimeResolver; + } + + @Override + public PropertyManager getPropertyManager() { + return propertyManager; + } + + @Override + public boolean isCollectionResource(Item item) { + if (item.isNode()) { + Node node = (Node) item; + for (String type : collectionTypes) { + try { + if (node.isNodeType(type)) { + return false; + } + } catch (RepositoryException re) { + // TODO: log and continue + } + } + } + + return true; + } + + @Override + public void parse(URL configURL) { + // we don't parse nothing + } + + // ---------- SlingResourceConfig additions + + public String getServletContextPath() { + return servletContextPath; + } + + public Dictionary<String, String> getServletInitParams() { + return servletInitParams; + } +} 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/SlingSimpleWebDavServlet.java b/src/main/java/org/apache/sling/jcr/webdav/impl/servlets/SlingSimpleWebDavServlet.java new file mode 100644 index 0000000..57f5f5a --- /dev/null +++ b/src/main/java/org/apache/sling/jcr/webdav/impl/servlets/SlingSimpleWebDavServlet.java @@ -0,0 +1,97 @@ +/* + * 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 javax.jcr.Repository; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.jackrabbit.webdav.simple.SimpleWebdavServlet; +import org.apache.sling.jcr.api.SlingRepository; +import org.apache.sling.jcr.webdav.impl.helper.SlingResourceConfig; + +/** + * The <code>SlingSimpleWebDavServlet</code> extends the + * JCR <code>SimpleWebdavServlet</code> with some + * Sling-specific features + */ +public class SlingSimpleWebDavServlet extends SimpleWebdavServlet { + + private final SlingResourceConfig resourceConfig; + + private final Repository repository; + + /* package */ SlingSimpleWebDavServlet(SlingResourceConfig resourceConfig, + Repository repository) { + this.resourceConfig = resourceConfig; + this.repository = repository; + } + + // ---------- AbstractWebdavServlet overwrite ------------------------------ + + @Override + public void init() throws ServletException { + super.init(); + + setResourceConfig(resourceConfig); + } + + @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); + } + + } else { + + super.service(request, response); + } + + } + + @Override + public Repository getRepository() { + return repository; + } + +} 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..6585a36 --- /dev/null +++ b/src/main/java/org/apache/sling/jcr/webdav/impl/servlets/SlingWebDavServlet.java @@ -0,0 +1,193 @@ +/* + * 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.Repository; +import javax.jcr.Session; +import javax.servlet.Servlet; +import javax.servlet.ServletException; + +import org.apache.jackrabbit.server.SessionProvider; +import org.apache.jackrabbit.webdav.DavLocatorFactory; +import org.apache.jackrabbit.webdav.simple.SimpleWebdavServlet; +import org.apache.sling.commons.mime.MimeTypeService; +import org.apache.sling.jcr.api.SlingRepository; +import org.apache.sling.jcr.webdav.impl.helper.SlingLocatorFactory; +import org.apache.sling.jcr.webdav.impl.helper.SlingResourceConfig; +import org.apache.sling.jcr.webdav.impl.helper.SlingSessionProvider; +import org.osgi.service.component.ComponentContext; +import org.osgi.service.http.HttpService; +import org.osgi.service.http.NamespaceException; + +/** + * The <code>SlingWebDavServlet</code> implements the WebDAV protocol as a + * default servlet for Sling handling all WebDAV methods. + * + * @scr.component name="org.apache.sling.jcr.webdav.impl.servlets.SimpleWebDavServlet" + * label="%dav.name" description="%dav.description" + * immediate="true" + * @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" + * @scr.property name="sling.servlet.resourceTypes" + * value="sling/servlet/default" private="true" + * @scr.property name="sling.servlet.methods" value="*" private="true" + */ +public class SlingWebDavServlet extends SimpleWebdavServlet { + + /** @scr.property valueRef="DEFAULT_CONTEXT" */ + public static final String PROP_CONTEXT = "dav.root"; + + /** @scr.property valueRef="DEFAULT_REALM" */ + public static final String PROP_REALM = "dav.realm"; + + /** @scr.property valueRef="COLLECTION_TYPES_DEFAULT" */ + public static final String COLLECTION_TYPES = "collection.types"; + + /** @scr.property valueRef="FILTER_PREFIXES_DEFAULT" */ + public static final String FILTER_PREFIXES = "filter.prefixes"; + + /** @scr.property valueRef="EMPTY_DEFAULT" */ + public static final String FILTER_TYPES = "filter.types"; + + /** @scr.property valueRef="EMPTY_DEFAULT" */ + public static final String FILTER_URIS = "filter.uris"; + + /** @scr.property valueRef="TYPE_COLLECTIONS_DEFAULT" */ + public static final String TYPE_COLLECTIONS = "type.collections"; + + /** @scr.property valueRef="TYPE_NONCOLLECTIONS_DEFAULT" */ + public static final String TYPE_NONCOLLECTIONS = "type.noncollections"; + + /** @scr.property valueRef="TYPE_CONTENT_DEFAULT" */ + public static final String TYPE_CONTENT = "type.content"; + + public static final String DEFAULT_CONTEXT = "/dav"; + + public static final String DEFAULT_REALM = "Sling WebDAV"; + + public static final String[] EMPTY_DEFAULT = new String[0]; + + public static final String[] FILTER_PREFIXES_DEFAULT = new String[] { + "rep", "jcr" }; + + public static final String TYPE_COLLECTIONS_DEFAULT = "sling:Folder"; + + public static final String TYPE_NONCOLLECTIONS_DEFAULT = "nt:file"; + + public static final String TYPE_CONTENT_DEFAULT = "nt:resource"; + + public static final String[] COLLECTION_TYPES_DEFAULT = new String[] { + TYPE_NONCOLLECTIONS_DEFAULT, TYPE_CONTENT_DEFAULT }; + + /** @scr.reference */ + private SlingRepository repository; + + /** @scr.reference */ + private HttpService httpService; + + /** @scr.reference */ + private MimeTypeService mimeTypeService; + + private SlingResourceConfig resourceConfig; + + private DavLocatorFactory locatorFactory; + + private SessionProvider sessionProvider; + + private boolean simpleWebDavServletRegistered; + + // ---------- SimpleWebdavServlet overwrites ------------------------------- + + @Override + public void init() throws ServletException { + super.init(); + + setResourceConfig(resourceConfig); + } + + @Override + public Repository getRepository() { + return repository; + } + + @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; + } + + // ---------- SCR integration + + protected void activate(ComponentContext context) + throws NamespaceException, ServletException { + + resourceConfig = new SlingResourceConfig(mimeTypeService, + context.getProperties()); + + // Register servlet, and set the contextPath field to signal successful + // registration + Servlet simpleServlet = new SlingSimpleWebDavServlet(resourceConfig, + getRepository()); + httpService.registerServlet(resourceConfig.getServletContextPath(), + simpleServlet, resourceConfig.getServletInitParams(), null); + simpleWebDavServletRegistered = true; + } + + protected void deactivate(ComponentContext context) { + + if (simpleWebDavServletRegistered) { + httpService.unregister(resourceConfig.getServletContextPath()); + simpleWebDavServletRegistered = false; + } + + resourceConfig = null; + } +} 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..d410975 --- /dev/null +++ b/src/main/resources/META-INF/NOTICE @@ -0,0 +1,16 @@ +Apache Sling WebDAV +Copyright 2008-2009 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..a90afa5 --- /dev/null +++ b/src/main/resources/OSGI-INF/metatype/metatype.properties @@ -0,0 +1,101 @@ +# +# 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 = Apache Sling 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". Access to the repository is provided \ + in two ways. You may connect your WebDAV client directly to the root of the \ + Sling web application to access the workspace of Sling directly. The other way \ + is required if you want to connect your WebDAV client to any other workspace \ + besides the Sling workspace. In this case you connect your WebDAV client to \ + another a path comprised of this root path plus the name of the workspace. For \ + example to connect to the some_other workspace, you might connect to \ + http://slinghost/dav/some_other. + +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. + +collection.types.name = Non Collection Node Types +collection.types.description = The JCR Node Types considered being \ + non-collection resouces by WebDAV. Any node replying true to Node.isNodeType() \ + for one of the listed types is considered a non-collection resource. Otherwise \ + the respective node is considered a colleciton resource. + +filter.prefixes.name = Filter Prefixes +filter.prefixes.description = A list of namespace prefixes indicating JCR items \ + filtered from being reported as collection members or properties. The default \ + list includes jcr and rep (Jackrabbit internal namespace prefix) items. \ + Do not modify this setting unless you know exactly what you are doing. + +filter.uris.name = Filter URIs +filter.uris.description = A list of namespace URIs indicating JCR items \ + filtered from being reported as collection members or properties. The default \ + list is empty. Do not modify this setting unless you know exactly what you \ + are doing. + +filter.types.name = Filter Node Types +filter.types.description = 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. The default is empty. Do not modify this setting unless you \ + know exactly what you are doing. + +type.collections.name = Collection Primary Type +type.collections.description = The JCR Primary Node Type to assign to nodes \ + created to reflect WebDAV collections. The default value is sling:Folder. \ + You may name any primary node type here, provided it allows the creation of \ + nodex of this type and the defined Non-Collection Primary Type below it. + +type.noncollections.name = Non-Collection Primary Type +type.noncollections.description = The JCR Primary Node Type to assign to \ + nodes created to reflect WebDAV non-collection resources. The default value \ + is nt:file. You may name any primary node type here, provided the node type \ + is allowed to be created below nodes of the type defined for the Collection \ + Primary Type and that a child node with the name "jcr:content" may be created \ + below the non-collection resource whose type is defined by the Content Primary \ + Type. + +type.content.name = Content Primary Type +type.content.description = The JCR Primary Node Type to assign to the \ + jcr:content child node of a WebDAV non-collection resource. The default value \ + is nt:resource. You may name any primary node type here, provided the node \ + type is allowed to be created as the jcr:content child node of the node type \ + defined by the Non-Collection Primary Type. In addition the node type must \ + allow at least the following properties: jcr:data (binary), jcr:lastModified \ + (date), and jcr:mimeType (string). diff --git a/src/main/resources/org/apache/sling/jcr/webdav/impl/helper/mimetypes.properties b/src/main/resources/org/apache/sling/jcr/webdav/impl/helper/mimetypes.properties new file mode 100644 index 0000000..da8f690 --- /dev/null +++ b/src/main/resources/org/apache/sling/jcr/webdav/impl/helper/mimetypes.properties @@ -0,0 +1,23 @@ +# 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 is required by the Jackrabbit MimeResolver class, which uses +# the class loader to retrieve the mimetypes.properties file from the same +# package as the class. +# +# We don't have any MIME Type mappings here, since the SlingMimeResolver +# is based on Sling's MIME Type Resolution +# \ No newline at end of file -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
