You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/07 09:38:24 UTC
[sling-org-apache-sling-fsresource] annotated tag
org.apache.sling.fsresource-1.4.8 created (now 1daa3b0)
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a change to annotated tag org.apache.sling.fsresource-1.4.8
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-fsresource.git.
at 1daa3b0 (tag)
tagging 89e35c4d10263ef6466867283d9a6b874ef59b11 (commit)
by Stefan Seifert
on Sat Jul 15 09:53:49 2017 +0000
- Log -----------------------------------------------------------------
org.apache.sling.fsresource-1.4.8
-----------------------------------------------------------------------
This annotated tag includes the following new commits:
new 0c33118 SLING-583 Initial implementation of a filesystem resource provider
new fd8bbdc Code formatting
new 6f617dc SLING-583 Fix FsResourceProvider.listChildren if the provider root is to be return as the single entry in the iterator
new fc83e32 SLING-583 Latest change introduces dependency on JCR API (because a directory is not returned any more as a resource if a repository item with the same name exists)
new 7ab3c81 SLING-583 Cleanup to consistently not return FsResource instances for directories "hiding" existing repository items.
new a46c284 Remove redundant null check
new c361d2a SLING-808 : Increase version to 5-incubator-SNAPSHOT
new a284078 SLING-829 Cosmetics to the bundle/project names
new 6ec1315 SLING-829 Ensure Apache Sling prefix on all configuration names
new 4d89314 SLING-865 - Correct location
new 48e6a1d SLING-865 - Correct pom and svn reference.
new 5150158 SLING-916 move non-exported packages to internal packages and remove javadoc configuration which will be inherited from parent pom
new 19d32c4 Fix fsresource provider and sling plugin after recent refactorings.
new 6799d74 Use release parent pom
new bee824c [maven-release-plugin] prepare release org.apache.sling.fsresource-0.9.0-incubator
new fe60fe1 [maven-release-plugin] prepare for next development iteration
new 8958da0 Use next dev version of parent pom
new 36ccd05 Add missing licence, notice etc.
new 6bcf253 Prepare new release.
new 16644cd [maven-release-plugin] prepare release org.apache.sling.fsresource-0.9.2-incubator
new 746e1d1 [maven-release-plugin] prepare for next development iteration
new 16ecaa5 Use next parent pom for development.
new f943311 Set parent pom to released version.
new ab2cf0f Move Sling to new TLP location
new 501bb88 SLING-1011 : Remove disclaimer file.
new b47fdc9 SLING-1011 : Adjust svn location
new 40f9091 SLING-1011 : Remove disclaimer from readme's, adjust links to webite, fix versions in poms.
new 164dbcf SLING-1033 Upgrade to Sling parent POM 6 (and ensure web app has the leglize stuff, too)
new 2f0cded Use official release instead of incubator release.
new 10c9088 Update to latest Sling releases.
new a8b5bdf Update to latest release.
new 2d2ef3d SLING-1186 Upgrade to Sling Parent POM 8-SNAPSHOT (to use SCR plugin 1.4.0), set DS specification version of components to 1.1, convert component into a regular (non-ComponentFactory) component and ensure meta type descriptor is generated with factoryPid set to the same value as the PID to have factory configuration support.
new 3111d96 SLING-1186 Parent POM 7 is good enough (no need for 8-SNAPSHOT)
new 2051b5f SLING-1187 Remove FsProviderConstants (moved constants to FsResource) and FsFolderServlet (duplicate code from default GET Servlet)
new 3a95821 SLING-1192 use nt:file and nt:folder for files and folders and drop the special resource super type
new a78ef39 SLING-1205 Upgrade all projects to parent POM 8 and use OSGi provided OSGi libraries
new 5137b7e Just code cleanup - no functional changes.
new 71d0b66 Check whether the abstract file is a directory before trying to open the FileInputStream on it (to prevent a nasty log message)
new 93cda71 SLING-1387 : File system provider should send resource events
new 38aa5a1 SLING-1387 : File system provider should send resource events
new 5d6630a [maven-release-plugin] prepare release org.apache.sling.fsresource-1.0.0
new c0d679e [maven-release-plugin] prepare for next development iteration
new feb2473 SLING-1516 Fixed by looking for a factory pid on activation.
new b109367 SLING-1516 A much better fix provided by Felix.
new 8df175a Use released parent pom.
new a30c588 SLING-1193 Fsresoruce and bundle resource implement the 2.0.8 API which means they cant be used with ResourceUtil, updated.
new c385893 SLING-1193 Have the bundle plugin set the correct import version range for the resource API implemented by the bundles
new 61509be SLING-1625 Check File.listFiles() result to prevent NullPointerException
new b5c493c Use latest Sling API release
new 8cd0450 Fix javadocs
new 26c5948 updating all modules to parent 10-SNAPSHOT in anticipation of emma additions to parent
new 9281408 fixing relativePaths
new a8d1b87 Update to recent snapshots
new 2979d42 Use latest releases.
new abcabe3 Remove obsolete licence and notice
new 4d518af [maven-release-plugin] prepare release org.apache.sling.fsresource-1.0.2
new 820f5c2 [maven-release-plugin] prepare for next development iteration
new 04c2091 SLING-2150 : Update plugins to use the latest available versions
new 15cc17a Update to recent snapshot
new 366633f Using latest released parent pom
new 630b18e SLING-2187 - adding new module to contain our custom notice file; adding remote-resources plugin configuration to parent pom and removing all existing appended-resources NOTICE files
new f4a2616 temporarily using snapshots during release vote
new 15c85c9 using latest releases
new 0aba830 SLING-2312 - adding adapter annotations for fsresource bundle
new 8309283 SLING-2314 - applying patch from Stefan Seifert to switch annotation style on FSResourceProvider. Thanks for the patch!
new 8318373 SLING-1081 : fsresource: allow to adapt to ValueMap
new cc90f52 using next snapshots during release process
new d3e5959 Use released adapter annotations.
new 7c14443 Use released maven sling plugin
new a30d734 SLING-2480 : Add config for maven-sling-plugin to m2e configuration
new 1c8b6ab SLING-2483 Use provide:=true instead of version macros to define the proper import version range. Also fix a small glitch in the parent pom relativePath of the framework-extension-ws bundle
new d61a155 Correctly increase resource package version and include latest resource providers.
new 9363ec0 Update to latest parent pom
new 28ecd71 Use released versions
new 195c76d SLING-2541 : General mechanism to chain resource providers
new e71601f Preparing release
new 5468aa2 [maven-release-plugin] prepare release org.apache.sling.fsresource-1.1.0
new 7b1b0a6 [maven-release-plugin] prepare for next development iteration
new f867347 Set dependencies to latest snapshots after release
new 747e4bb Update to released bundles
new d93f502 Use latest releases and update to new parent pom
new 94c55fa Update to latest parent pom and use latest releases in launchpad
new 2653bcb SLING-2739 : Add methods for handling the resource type hierarchy to the resource resolver
new 0e9dd0f Prepare for release
new a76cf10 [maven-release-plugin] prepare release org.apache.sling.fsresource-1.1.2
new 418479c [maven-release-plugin] prepare for next development iteration
new fb5221e Use latest snapshot
new 8cf1d4e Use released versions after release.
new b273649 Correct reactor pom and update to parent pom 16
new c9aca5b Update to latest parent pom
new 592bc1e SLING-2944 Revert Sling API dependency to 2.3.0 again
new d5588c1 Update to parent pom 18
new 0bb72cc SLING-3286 - Remove plugin version overrides from poms
new 2254ba3 Update to parent pom v19
new 9584f16 3804 : Fields for dynamic references must be volatile
new 07281a3 Updated to parent version 20
new 4392745 [maven-release-plugin] prepare release org.apache.sling.fsresource-1.1.4
new a4d1ae4 [maven-release-plugin] prepare for next development iteration
new 2b642b2 Update to Sling Parent POM 22 with baselining enabled
new 43259e6 SLING-4698 - Set parent.relativePath to empty for all modules
new be69e70 Update to Sling Parent 23
new b030d0c set parent version to 24 and add empty relativePath where missing
new 0320672 Update the main reactor to parent 25
new 9f877f5 SLING-5192 - FsResourceProvider should set webconsole.configurationFactory.nameHint
new a5f05c9 Switch to parent pom 26
new f4b94c0 branch fsresource version before switch to new Sling API
new 54e89e7 backport of changes from SLING-6440 and SLING-6537 to 1.1.x version of fsresource based on old resource provider SPI
new 88b3a59 SLING-6440 simplify FileMonitor
new 2ea8852 SLING-6440 switch to fscontentparser rename "Filesystem" to "File System" update to latest parent
new aa2eecc SLING-6440 update to latest API
new b342fb6 set version in branch to 1.3.0-SNAPSHOT (for old Resource Provider SPI)
new af87b04 SLING-6537 FileVault XML support
new 633173f rename branch folder to 1.x
new a30fb87 update scm urls for branch
new 62f16aa SLING-6537 FileVault XML support
new 4c1b15f SLING-6440 use ManifestHeader to parse directives
new 56b09e5 SLING-6537 FileVault XML support
new 98a2215 SLING-6537 BigDecimal support, use copy of enhanced ValueMap with proper type converstion from Sling API 2.17.0
new f21de7a SLING-6630 rename INITIAL_CONTENT_FILES_FOLDERS to FILES_FOLDERS
new 16babc3 SLING-6630 make FILES_FOLDERS default
new 81a06d6 cosmetic: use consistent wording, reorder config attributes
new a353cfb SLING-6440 switch to latest jcr/contentparser API
new 8c0e64a SLING-6440 switch to latest jcr/contentparser API
new aa6fca1 SLING-6440 switch to latest contentparser API
new ac983c8 update dependencies
new 2386504 fix javadoc errors
new 3f53032 [maven-release-plugin] prepare release org.apache.sling.fsresource-1.3.0
new 717d5d4 [maven-release-plugin] prepare for next development iteration
new 6313850 update sling-mock dependency
new 935fb00 SLING-6829 FSResource: Support node descriptor files for folders and binary files
new 737a614 SLING-6829 make unit tests independent of resource child order
new cb0c2b3 SLING-6829 make sour FileResource for directories is only overlayed in FILES_FOLDERS mode
new e2a4f74 update dependency
new 4498633 [maven-release-plugin] prepare release org.apache.sling.fsresource-1.4.0
new e08009b [maven-release-plugin] prepare for next development iteration
new 2e1b434 update to next development version until release version is available on maven central
new 583913a switch to release versions
new 16bef10 SLING-6869 fsresource: Avoid NPE when content fragment file contains invalid JSON
new 980006d SLING-6873 FSResource: Support tick as well as double quote when parsing JSON files
new 635d236 SLING-6877 FSResource: Allow to adapt to Node from FileResource
new eb2f6c4 update dependency to release version
new f5f0d1c [maven-release-plugin] prepare release org.apache.sling.fsresource-1.4.2
new c594241 [maven-release-plugin] prepare for next development iteration
new 4cfa020 update to next development version until release version is available on maven central
new b49ef53 SLING-6918 enable json comments and tick quotes by default (same as JCR content loader)
new 07d1059 update dependency
new 80f6903 [maven-release-plugin] prepare release org.apache.sling.fsresource-1.4.4
new a3f0786 [maven-release-plugin] prepare for next development iteration
new 716d36d rollback release
new 2008ba1 update dependency
new f2fc5ca [maven-release-plugin] prepare release org.apache.sling.fsresource-1.4.4
new 5a81901 [maven-release-plugin] prepare for next development iteration
new 8af661e [maven-release-plugin] rollback the release of org.apache.sling.fsresource-1.4.4
new d8a6361 [maven-release-plugin] prepare release org.apache.sling.fsresource-1.4.4
new c3203a4 [maven-release-plugin] rollback the release of org.apache.sling.fsresource-1.4.4
new c512027 [maven-release-plugin] prepare release org.apache.sling.fsresource-1.4.4
new 931b808 [maven-release-plugin] prepare for next development iteration
new 502df52 update to next development version until release version is available on maven central
new 3f51dbe switch back to released version
new 0f777ae SLING-6961 FsResource: Ignore security:acl and security:principals nodes
new d321cae update to release version
new f93e2f1 [maven-release-plugin] prepare release org.apache.sling.fsresource-1.4.6
new 75223a8 [maven-release-plugin] prepare for next development iteration
new 2932d06 update to next development version until release version is available on maven central
new a17999f update dependency
new ded2b95 SLING-7007 fsresource: Support URL-encoded file names
new 9d71685 SLING-7011 fsresource: Detect FileVault <any>.xml JCR XML files
new 3307897 fix javadoc error
new 9954112 [maven-release-plugin] prepare release org.apache.sling.fsresource-1.4.8
new 89e35c4 [maven-release-plugin] copy for tag org.apache.sling.fsresource-1.4.8
The 170 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
--
To stop receiving notification emails like this one, please contact
['"commits@sling.apache.org" <co...@sling.apache.org>'].
[sling-org-apache-sling-fsresource] 07/08: [maven-release-plugin]
prepare release org.apache.sling.fsresource-1.4.8
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.fsresource-1.4.8
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-fsresource.git
commit 9954112b756d7bb104945c68a21fb5e8c6572ad0
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Sat Jul 15 09:53:35 2017 +0000
[maven-release-plugin] prepare release org.apache.sling.fsresource-1.4.8
git-svn-id: https://svn.apache.org/repos/asf/sling/branches/fsresource-1.x@1802014 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/pom.xml b/pom.xml
index 9a9158f..60f86c5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,7 +28,7 @@
<artifactId>org.apache.sling.fsresource</artifactId>
<packaging>bundle</packaging>
- <version>1.4.7-SNAPSHOT</version>
+ <version>1.4.8</version>
<name>Apache Sling File System Resource Provider</name>
<description>
@@ -36,9 +36,9 @@
</description>
<scm>
- <connection>scm:svn:http://svn.apache.org/repos/asf/sling/branches/fsresource-1.x</connection>
- <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/branches/fsresource-1.x</developerConnection>
- <url>http://svn.apache.org/viewvc/sling/branches/fsresource-1.x</url>
+ <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.fsresource-1.4.8</connection>
+ <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.fsresource-1.4.8</developerConnection>
+ <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.fsresource-1.4.8</url>
</scm>
<build>
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-fsresource] 05/08: SLING-7011 fsresource:
Detect FileVault .xml JCR XML files
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.fsresource-1.4.8
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-fsresource.git
commit 9d716855d68f89f6371e96a403c918391d9ded20
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Fri Jul 14 10:36:36 2017 +0000
SLING-7011 fsresource: Detect FileVault <any>.xml JCR XML files
git-svn-id: https://svn.apache.org/repos/asf/sling/branches/fsresource-1.x@1801930 13f79535-47bb-0310-9956-ffa450edef68
---
.../fsprovider/internal/FsResourceProvider.java | 1 +
.../fsprovider/internal/mapper/ContentFile.java | 16 +++++++++-
.../internal/mapper/FileVaultResourceMapper.java | 26 ++++++++++++++--
.../internal/parser/ContentFileCache.java | 19 +++++++++++-
.../internal/parser/ContentFileParserUtil.java | 35 ++++++++++++++++++----
.../fsprovider/internal/FileVaultContentTest.java | 26 +++++++++++++---
.../jcr_root/content/samples/en/.content.xml | 4 +++
.../content/samples/en/extra/binaryfile.xml | 28 +++++++++++++++++
.../en/extra/binaryfile.xml.dir/.content.xml | 25 ++++++++++++++++
.../content/samples/en/extra/extracontent.xml | 28 +++++++++++++++++
10 files changed, 194 insertions(+), 14 deletions(-)
diff --git a/src/main/java/org/apache/sling/fsprovider/internal/FsResourceProvider.java b/src/main/java/org/apache/sling/fsprovider/internal/FsResourceProvider.java
index 14a7dec..58babc8 100644
--- a/src/main/java/org/apache/sling/fsprovider/internal/FsResourceProvider.java
+++ b/src/main/java/org/apache/sling/fsprovider/internal/FsResourceProvider.java
@@ -266,6 +266,7 @@ public final class FsResourceProvider implements ResourceProvider {
List<String> contentFileSuffixes = new ArrayList<>();
if (fsMode == FsMode.FILEVAULT_XML) {
contentFileSuffixes.add("/" + DOT_CONTENT_XML);
+ contentFileSuffixes.add(ContentFileTypes.XML_SUFFIX);
if (StringUtils.isNotBlank(config.provider_filevault_filterxml_path())) {
filterXmlFile = new File(config.provider_filevault_filterxml_path());
}
diff --git a/src/main/java/org/apache/sling/fsprovider/internal/mapper/ContentFile.java b/src/main/java/org/apache/sling/fsprovider/internal/mapper/ContentFile.java
index 184d184..853fe82 100644
--- a/src/main/java/org/apache/sling/fsprovider/internal/mapper/ContentFile.java
+++ b/src/main/java/org/apache/sling/fsprovider/internal/mapper/ContentFile.java
@@ -26,6 +26,7 @@ import org.apache.sling.api.resource.ValueMap;
import org.apache.sling.fsprovider.internal.mapper.valuemap.ValueMapUtil;
import org.apache.sling.fsprovider.internal.parser.ContentElement;
import org.apache.sling.fsprovider.internal.parser.ContentFileCache;
+import org.apache.sling.jcr.contentparser.ContentType;
/**
* Reference to a file that contains a content fragment (e.g. JSON, JCR XML).
@@ -36,6 +37,7 @@ public final class ContentFile {
private final String path;
private final String subPath;
private final ContentFileCache contentFileCache;
+ private final ContentType contentType;
private boolean contentInitialized;
private ContentElement content;
private ValueMap valueMap;
@@ -47,10 +49,22 @@ public final class ContentFile {
* @param contentFileCache Content file cache
*/
public ContentFile(File file, String path, String subPath, ContentFileCache contentFileCache) {
+ this(file, path, subPath, contentFileCache, null);
+ }
+
+ /**
+ * @param file File with content fragment
+ * @param path Root path of the content file
+ * @param subPath Relative path addressing content fragment inside file
+ * @param contentFileCache Content file cache
+ * @param contentType Content type
+ */
+ public ContentFile(File file, String path, String subPath, ContentFileCache contentFileCache, ContentType contentType) {
this.file = file;
this.path = path;
this.subPath = subPath;
this.contentFileCache = contentFileCache;
+ this.contentType = contentType;
}
/**
@@ -80,7 +94,7 @@ public final class ContentFile {
*/
public ContentElement getContent() {
if (!contentInitialized) {
- ContentElement rootContent = contentFileCache.get(path, file);
+ ContentElement rootContent = contentFileCache.get(path, file, contentType);
if (subPath == null) {
content = rootContent;
}
diff --git a/src/main/java/org/apache/sling/fsprovider/internal/mapper/FileVaultResourceMapper.java b/src/main/java/org/apache/sling/fsprovider/internal/mapper/FileVaultResourceMapper.java
index c772e40..6665f55 100644
--- a/src/main/java/org/apache/sling/fsprovider/internal/mapper/FileVaultResourceMapper.java
+++ b/src/main/java/org/apache/sling/fsprovider/internal/mapper/FileVaultResourceMapper.java
@@ -19,6 +19,7 @@
package org.apache.sling.fsprovider.internal.mapper;
import static org.apache.jackrabbit.vault.util.Constants.DOT_CONTENT_XML;
+import static org.apache.sling.fsprovider.internal.parser.ContentFileTypes.XML_SUFFIX;
import java.io.File;
import java.io.IOException;
@@ -41,13 +42,15 @@ import org.apache.sling.fsprovider.internal.FsMode;
import org.apache.sling.fsprovider.internal.FsResourceMapper;
import org.apache.sling.fsprovider.internal.parser.ContentElement;
import org.apache.sling.fsprovider.internal.parser.ContentFileCache;
+import org.apache.sling.jcr.contentparser.ContentType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public final class FileVaultResourceMapper implements FsResourceMapper {
private static final String DOT_CONTENT_XML_SUFFIX = "/" + DOT_CONTENT_XML;
- private static final String DOT_DIR_SUFFIX = "/.dir";
+ private static final String DOT_DIR = ".dir";
+ private static final String DOT_DIR_SUFFIX = "/" + DOT_DIR;
private final File providerFile;
private final File filterXmlFile;
@@ -174,6 +177,9 @@ public final class FileVaultResourceMapper implements FsResourceMapper {
}
File file = new File(providerFile, "." + PlatformNameFormat.getPlatformPath(path));
if (file.exists()) {
+ if (StringUtils.endsWith(path, XML_SUFFIX) && !hasDotDirFile(file)) {
+ return null;
+ }
return file;
}
return null;
@@ -182,7 +188,15 @@ public final class FileVaultResourceMapper implements FsResourceMapper {
private ContentFile getContentFile(String path, String subPath) {
File file = new File(providerFile, "." + PlatformNameFormat.getPlatformPath(path) + DOT_CONTENT_XML_SUFFIX);
if (file.exists()) {
- ContentFile contentFile = new ContentFile(file, path, subPath, contentFileCache);
+ ContentFile contentFile = new ContentFile(file, path, subPath, contentFileCache, ContentType.JCR_XML);
+ if (contentFile.hasContent()) {
+ return contentFile;
+ }
+ }
+
+ file = new File(providerFile, "." + PlatformNameFormat.getPlatformPath(path) + XML_SUFFIX);
+ if (file.exists() && !hasDotDirFile(file)) {
+ ContentFile contentFile = new ContentFile(file, path, subPath, contentFileCache, ContentType.JCR_XML);
if (contentFile.hasContent()) {
return contentFile;
}
@@ -197,5 +211,13 @@ public final class FileVaultResourceMapper implements FsResourceMapper {
+ (subPath != null ? "/" + subPath : "");
return getContentFile(parentPath, nextSubPath);
}
+
+ private boolean hasDotDirFile(File file) {
+ File dotDir = new File(file.getPath() + DOT_DIR);
+ if (dotDir.exists() && dotDir.isDirectory()) {
+ return true;
+ }
+ return false;
+ }
}
diff --git a/src/main/java/org/apache/sling/fsprovider/internal/parser/ContentFileCache.java b/src/main/java/org/apache/sling/fsprovider/internal/parser/ContentFileCache.java
index 4222e98..e18a0ff 100644
--- a/src/main/java/org/apache/sling/fsprovider/internal/parser/ContentFileCache.java
+++ b/src/main/java/org/apache/sling/fsprovider/internal/parser/ContentFileCache.java
@@ -23,6 +23,7 @@ import java.util.Collections;
import java.util.Map;
import org.apache.commons.collections.map.LRUMap;
+import org.apache.sling.jcr.contentparser.ContentType;
/**
* Cache for parsed content from content files (e.g. JSON, JCR XML).
@@ -52,12 +53,28 @@ public final class ContentFileCache {
* @return Content or null
*/
public ContentElement get(String path, File file) {
+ return get(path, file, null);
+ }
+
+ /**
+ * Get content.
+ * @param path Path (used as cache key).
+ * @param file File
+ * @param contentType Content type - if null type is auto-detected
+ * @return Content or null
+ */
+ public ContentElement get(String path, File file, ContentType contentType) {
ContentElement content = null;
if (contentCache != null) {
content = contentCache.get(path);
}
if (content == null) {
- content = ContentFileParserUtil.parse(file);
+ if (contentType != null) {
+ content = ContentFileParserUtil.parse(file, contentType);
+ }
+ else {
+ content = ContentFileParserUtil.parse(file);
+ }
if (content == null) {
content = NULL_ELEMENT;
}
diff --git a/src/main/java/org/apache/sling/fsprovider/internal/parser/ContentFileParserUtil.java b/src/main/java/org/apache/sling/fsprovider/internal/parser/ContentFileParserUtil.java
index a105dad..e0d0e0c 100644
--- a/src/main/java/org/apache/sling/fsprovider/internal/parser/ContentFileParserUtil.java
+++ b/src/main/java/org/apache/sling/fsprovider/internal/parser/ContentFileParserUtil.java
@@ -75,15 +75,38 @@ class ContentFileParserUtil {
if (!file.exists()) {
return null;
}
+ if (StringUtils.endsWith(file.getName(), JSON_SUFFIX)) {
+ return parse(file, ContentType.JSON);
+ }
+ else if (StringUtils.equals(file.getName(), DOT_CONTENT_XML) || StringUtils.endsWith(file.getName(), JCR_XML_SUFFIX)) {
+ return parse(file, ContentType.JCR_XML);
+ }
+ else if (StringUtils.endsWith(file.getName(), XML_SUFFIX) && !StringUtils.endsWith(file.getName(), JCR_XML_SUFFIX)) {
+ return parse(file, ContentType.XML);
+ }
+ return null;
+ }
+
+ /**
+ * Parse content from file.
+ * @param file File. Type is detected automatically.
+ * @param contentType Content type
+ * @return Content or null if content could not be parsed.
+ */
+ public static ContentElement parse(File file, ContentType contentType) {
+ if (!file.exists()) {
+ return null;
+ }
try {
- if (StringUtils.endsWith(file.getName(), JSON_SUFFIX)) {
+ switch (contentType) {
+ case JSON:
return parse(JSON_PARSER, file);
- }
- else if (StringUtils.equals(file.getName(), DOT_CONTENT_XML) || StringUtils.endsWith(file.getName(), JCR_XML_SUFFIX)) {
- return parse(JCR_XML_PARSER, file);
- }
- else if (StringUtils.endsWith(file.getName(), XML_SUFFIX) && !StringUtils.endsWith(file.getName(), JCR_XML_SUFFIX)) {
+ case XML:
return parse(XML_PARSER, file);
+ case JCR_XML:
+ return parse(JCR_XML_PARSER, file);
+ default:
+ throw new IllegalArgumentException("Unexpected content type: " + contentType);
}
}
catch (Throwable ex) {
diff --git a/src/test/java/org/apache/sling/fsprovider/internal/FileVaultContentTest.java b/src/test/java/org/apache/sling/fsprovider/internal/FileVaultContentTest.java
index 13a0bcf..7eadfbc 100644
--- a/src/test/java/org/apache/sling/fsprovider/internal/FileVaultContentTest.java
+++ b/src/test/java/org/apache/sling/fsprovider/internal/FileVaultContentTest.java
@@ -107,7 +107,7 @@ public class FileVaultContentTest {
public void testListChildren() {
Resource en = sampleContent.getChild("en");
List<Resource> children = ImmutableList.copyOf(en.listChildren());
- assertEquals(2, children.size());
+ assertEquals(3, children.size());
Resource child1 = children.get(0);
assertEquals("jcr:content", child1.getName());
@@ -117,7 +117,10 @@ public class FileVaultContentTest {
assertEquals("tools", child2.getName());
assertEquals("app:Page", child2.getResourceType());
- // child3 (conference) is hidden because of filter
+ Resource child3 = children.get(2);
+ assertEquals("extra", child3.getName());
+
+ // another child (conference) is hidden because of filter
}
@Test
@@ -136,10 +139,25 @@ public class FileVaultContentTest {
assertNotNull(sampleContent.getChild("en/conference"));
assertNotNull(context.resourceResolver().getResource("/content/samples/en/conference/page2"));
assertNotNull(sampleContent.getChild("en/conference/page2"));
-
+
// list children with mixed content
Resource enResource = sampleContent.getChild("en");
- assertThat(enResource, ResourceMatchers.containsChildren("jcr:content", "tools", "conference"));
+ assertThat(enResource, ResourceMatchers.containsChildren("jcr:content", "tools", "extra", "conference"));
}
+ @Test
+ public void testExtraContent() throws RepositoryException {
+ Resource extraContent = sampleContent.getChild("en/extra/extracontent");
+ assertNotNull(extraContent);
+ assertEquals("apps/app1/components/comp1", extraContent.getResourceType());
+
+ Resource layout = extraContent.getChild("layout");
+ assertNotNull(layout);
+ assertEquals("apps/app1/components/comp2", layout.getResourceType());
+
+ Resource binaryFile = sampleContent.getChild("en/extra/binaryfile.xml");
+ assertNotNull(binaryFile);
+ assertEquals("nt:file", binaryFile.getResourceType());
+ }
+
}
diff --git a/src/test/resources/vaultfs-test/jcr_root/content/samples/en/.content.xml b/src/test/resources/vaultfs-test/jcr_root/content/samples/en/.content.xml
index 83b8626..c394cf9 100644
--- a/src/test/resources/vaultfs-test/jcr_root/content/samples/en/.content.xml
+++ b/src/test/resources/vaultfs-test/jcr_root/content/samples/en/.content.xml
@@ -188,4 +188,8 @@
</jcr:content>
<tools />
<conference />
+ <extra jcr:primaryType="nt:unstructured">
+ <extracontent/>
+ <binaryfile.xml/>
+ </extra>
</jcr:root>
diff --git a/src/test/resources/vaultfs-test/jcr_root/content/samples/en/extra/binaryfile.xml b/src/test/resources/vaultfs-test/jcr_root/content/samples/en/extra/binaryfile.xml
new file mode 100644
index 0000000..63b5974
--- /dev/null
+++ b/src/test/resources/vaultfs-test/jcr_root/content/samples/en/extra/binaryfile.xml
@@ -0,0 +1,28 @@
+<?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.
+-->
+<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
+ jcr:primaryType="nt:unstructured"
+ sling:resourceType="apps/app1/components/comp1">
+ <layout
+ jcr:primaryType="nt:unstructured"
+ sling:resourceType="apps/app1/components/comp2"/>
+ <field jcr:primaryType="nt:unstructured"/>
+ <action jcr:primaryType="nt:unstructured"/>
+</jcr:root>
diff --git a/src/test/resources/vaultfs-test/jcr_root/content/samples/en/extra/binaryfile.xml.dir/.content.xml b/src/test/resources/vaultfs-test/jcr_root/content/samples/en/extra/binaryfile.xml.dir/.content.xml
new file mode 100644
index 0000000..c0ce9be
--- /dev/null
+++ b/src/test/resources/vaultfs-test/jcr_root/content/samples/en/extra/binaryfile.xml.dir/.content.xml
@@ -0,0 +1,25 @@
+<?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.
+-->
+<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
+ jcr:primaryType="nt:file">
+ <jcr:content
+ jcr:mimeType="application/xml"
+ jcr:primaryType="nt:resource" />
+</jcr:root>
diff --git a/src/test/resources/vaultfs-test/jcr_root/content/samples/en/extra/extracontent.xml b/src/test/resources/vaultfs-test/jcr_root/content/samples/en/extra/extracontent.xml
new file mode 100644
index 0000000..63b5974
--- /dev/null
+++ b/src/test/resources/vaultfs-test/jcr_root/content/samples/en/extra/extracontent.xml
@@ -0,0 +1,28 @@
+<?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.
+-->
+<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
+ jcr:primaryType="nt:unstructured"
+ sling:resourceType="apps/app1/components/comp1">
+ <layout
+ jcr:primaryType="nt:unstructured"
+ sling:resourceType="apps/app1/components/comp2"/>
+ <field jcr:primaryType="nt:unstructured"/>
+ <action jcr:primaryType="nt:unstructured"/>
+</jcr:root>
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-fsresource] 02/08: update to next
development version until release version is available on maven central
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.fsresource-1.4.8
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-fsresource.git
commit 2932d0625be245251a68c2ac7c0e257668c1da2f
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Fri Jun 23 13:48:35 2017 +0000
update to next development version until release version is available on maven central
git-svn-id: https://svn.apache.org/repos/asf/sling/branches/fsresource-1.x@1799670 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index 9a9158f..074d571 100644
--- a/pom.xml
+++ b/pom.xml
@@ -148,7 +148,7 @@
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.jcr.contentparser</artifactId>
- <version>1.2.4</version>
+ <version>1.2.5-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-fsresource] 01/08: [maven-release-plugin]
prepare for next development iteration
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.fsresource-1.4.8
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-fsresource.git
commit 75223a862589c02c747b2c398584d63a6c39f77f
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Fri Jun 23 13:47:22 2017 +0000
[maven-release-plugin] prepare for next development iteration
git-svn-id: https://svn.apache.org/repos/asf/sling/branches/fsresource-1.x@1799669 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/pom.xml b/pom.xml
index 087df1a..9a9158f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,7 +28,7 @@
<artifactId>org.apache.sling.fsresource</artifactId>
<packaging>bundle</packaging>
- <version>1.4.6</version>
+ <version>1.4.7-SNAPSHOT</version>
<name>Apache Sling File System Resource Provider</name>
<description>
@@ -36,9 +36,9 @@
</description>
<scm>
- <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.fsresource-1.4.6</connection>
- <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.fsresource-1.4.6</developerConnection>
- <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.fsresource-1.4.6</url>
+ <connection>scm:svn:http://svn.apache.org/repos/asf/sling/branches/fsresource-1.x</connection>
+ <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/branches/fsresource-1.x</developerConnection>
+ <url>http://svn.apache.org/viewvc/sling/branches/fsresource-1.x</url>
</scm>
<build>
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-fsresource] 03/08: update dependency
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.fsresource-1.4.8
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-fsresource.git
commit a17999f2eb37955ef5e203b6927880b03985cd96
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Mon Jun 26 17:29:42 2017 +0000
update dependency
git-svn-id: https://svn.apache.org/repos/asf/sling/branches/fsresource-1.x@1799959 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index 074d571..9a9158f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -148,7 +148,7 @@
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.jcr.contentparser</artifactId>
- <version>1.2.5-SNAPSHOT</version>
+ <version>1.2.4</version>
<scope>compile</scope>
</dependency>
<dependency>
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-fsresource] 06/08: fix javadoc error
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.fsresource-1.4.8
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-fsresource.git
commit 33078973bc560e8dad4bbada2511e00e31186edf
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Sat Jul 15 09:51:07 2017 +0000
fix javadoc error
git-svn-id: https://svn.apache.org/repos/asf/sling/branches/fsresource-1.x@1802009 13f79535-47bb-0310-9956-ffa450edef68
---
src/main/java/org/apache/sling/fsprovider/internal/mapper/Escape.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/main/java/org/apache/sling/fsprovider/internal/mapper/Escape.java b/src/main/java/org/apache/sling/fsprovider/internal/mapper/Escape.java
index b28280f..ef234a9 100644
--- a/src/main/java/org/apache/sling/fsprovider/internal/mapper/Escape.java
+++ b/src/main/java/org/apache/sling/fsprovider/internal/mapper/Escape.java
@@ -79,7 +79,7 @@ public final class Escape {
/**
* Converts resource name to file name.
* Allows all characters, but URL-encodes characters that are in the list of {@link #RESERVED_CHARS}.
- * @param name Resource name or path
+ * @param path Resource name or path
* @return File name or path
*/
public static String resourceToFileName(String path) {
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-fsresource] 08/08: [maven-release-plugin]
copy for tag org.apache.sling.fsresource-1.4.8
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.fsresource-1.4.8
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-fsresource.git
commit 89e35c4d10263ef6466867283d9a6b874ef59b11
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Sat Jul 15 09:53:49 2017 +0000
[maven-release-plugin] copy for tag org.apache.sling.fsresource-1.4.8
git-svn-id: https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.fsresource-1.4.8@1802015 13f79535-47bb-0310-9956-ffa450edef68
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-fsresource] 04/08: SLING-7007 fsresource:
Support URL-encoded file names
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.fsresource-1.4.8
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-fsresource.git
commit ded2b952c9c1e4542144bc555eab7badc9c07ca1
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Wed Jul 12 16:46:11 2017 +0000
SLING-7007 fsresource: Support URL-encoded file names
git-svn-id: https://svn.apache.org/repos/asf/sling/branches/fsresource-1.x@1801751 13f79535-47bb-0310-9956-ffa450edef68
---
.../internal/mapper/ContentFileResourceMapper.java | 2 +-
.../sling/fsprovider/internal/mapper/Escape.java | 104 +++++++++++++++++++++
.../internal/mapper/FileResourceMapper.java | 4 +-
.../sling/fsprovider/internal/FilesFolderTest.java | 5 +-
.../sling/fsprovider/internal/JcrMixedTest.java | 4 +-
.../fsprovider/internal/JcrXmlContentTest.java | 4 +-
.../sling/fsprovider/internal/JsonContentTest.java | 11 ++-
.../sling/fsprovider/internal/TestUtils.java | 4 +-
.../fsprovider/internal/mapper/EscapeTest.java | 46 +++++++++
.../folder1/{file1b.txt => sling%3Afile1b.txt} | 0
.../{content2.json => sling%3Acontent2.json} | 0
11 files changed, 171 insertions(+), 13 deletions(-)
diff --git a/src/main/java/org/apache/sling/fsprovider/internal/mapper/ContentFileResourceMapper.java b/src/main/java/org/apache/sling/fsprovider/internal/mapper/ContentFileResourceMapper.java
index 20739d6..bbf2af6 100644
--- a/src/main/java/org/apache/sling/fsprovider/internal/mapper/ContentFileResourceMapper.java
+++ b/src/main/java/org/apache/sling/fsprovider/internal/mapper/ContentFileResourceMapper.java
@@ -131,7 +131,7 @@ public final class ContentFileResourceMapper implements FsResourceMapper {
if (!StringUtils.startsWith(path, providerRootPrefix)) {
return null;
}
- String relPath = path.substring(providerRootPrefix.length());
+ String relPath = Escape.resourceToFileName(path.substring(providerRootPrefix.length()));
for (String filenameSuffix : contentFileExtensions.getSuffixes()) {
File file = new File(providerFile, relPath + filenameSuffix);
if (file.exists()) {
diff --git a/src/main/java/org/apache/sling/fsprovider/internal/mapper/Escape.java b/src/main/java/org/apache/sling/fsprovider/internal/mapper/Escape.java
new file mode 100644
index 0000000..b28280f
--- /dev/null
+++ b/src/main/java/org/apache/sling/fsprovider/internal/mapper/Escape.java
@@ -0,0 +1,104 @@
+/*
+ * 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.fsprovider.internal.mapper;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.net.URLEncoder;
+import java.util.BitSet;
+
+import org.apache.commons.lang3.CharEncoding;
+
+/**
+ * Manages deescaping for platform file names to resource names.
+ */
+public final class Escape {
+
+ /**
+ * List of characters typically prohibited on unix and windows file systems.
+ * "/" is not included because it is neither allowed in resource nor in file names on any system.
+ */
+ private static final char[] RESERVED_CHARS = {
+ '<',
+ '>',
+ ':',
+ '"',
+ '\\',
+ '|',
+ '?',
+ '*',
+ 0x00
+ };
+ private static final BitSet RESERVED_CHARS_SET = new BitSet();
+ static {
+ for (int i=0; i<RESERVED_CHARS.length; i++) {
+ RESERVED_CHARS_SET.set(RESERVED_CHARS[i]);
+ }
+ }
+
+ private Escape() {
+ // static methods only
+ }
+
+ /**
+ * Convert file name to resource name.
+ * Applies same rules as Apache Sling JCR ContentLoader.
+ * @param path File name or path
+ * @return Resource name or path
+ */
+ public static String fileToResourceName(String path) {
+ // check for encoded characters (%xx)
+ // has encoded characters, need to decode
+ if (path.indexOf('%') >= 0) {
+ try {
+ return URLDecoder.decode(path, "UTF-8");
+ }
+ catch (UnsupportedEncodingException ex) {
+ throw new RuntimeException("Unsupported encoding.", ex);
+ }
+ }
+ return path;
+ }
+
+ /**
+ * Converts resource name to file name.
+ * Allows all characters, but URL-encodes characters that are in the list of {@link #RESERVED_CHARS}.
+ * @param name Resource name or path
+ * @return File name or path
+ */
+ public static String resourceToFileName(String path) {
+ try {
+ StringBuilder result = new StringBuilder();
+ for (int i=0; i<path.length(); i++) {
+ char c = path.charAt(i);
+ if (RESERVED_CHARS_SET.get(c)) {
+ result.append(URLEncoder.encode(String.valueOf(c), CharEncoding.UTF_8));
+ }
+ else {
+ result.append(c);
+ }
+ }
+ return result.toString();
+ }
+ catch (UnsupportedEncodingException ex) {
+ throw new RuntimeException("Unsupported encoding.", ex);
+ }
+ }
+
+}
diff --git a/src/main/java/org/apache/sling/fsprovider/internal/mapper/FileResourceMapper.java b/src/main/java/org/apache/sling/fsprovider/internal/mapper/FileResourceMapper.java
index 47404f8..e29b408 100644
--- a/src/main/java/org/apache/sling/fsprovider/internal/mapper/FileResourceMapper.java
+++ b/src/main/java/org/apache/sling/fsprovider/internal/mapper/FileResourceMapper.java
@@ -121,7 +121,7 @@ public final class FileResourceMapper implements FsResourceMapper {
@Override
public Object transform(Object input) {
File file = (File)input;
- String path = parentPath + "/" + file.getName();
+ String path = parentPath + "/" + Escape.fileToResourceName(file.getName());
return new FileResource(resolver, path, file, contentFileExtensions, contentFileCache, fsMode);
}
});
@@ -140,7 +140,7 @@ public final class FileResourceMapper implements FsResourceMapper {
return providerFile;
}
if (path.startsWith(providerRootPrefix)) {
- String relPath = path.substring(providerRootPrefix.length());
+ String relPath = Escape.resourceToFileName(path.substring(providerRootPrefix.length()));
File file = new File(providerFile, relPath);
if (file.exists() && !contentFileExtensions.matchesSuffix(file)) {
return file;
diff --git a/src/test/java/org/apache/sling/fsprovider/internal/FilesFolderTest.java b/src/test/java/org/apache/sling/fsprovider/internal/FilesFolderTest.java
index c1f3470..7ebc089 100644
--- a/src/test/java/org/apache/sling/fsprovider/internal/FilesFolderTest.java
+++ b/src/test/java/org/apache/sling/fsprovider/internal/FilesFolderTest.java
@@ -63,10 +63,11 @@ public class FilesFolderTest {
@Test
public void testFiles() {
assertFile(fsroot, "folder1/file1a.txt", "file1a");
- assertFile(fsroot, "folder1/file1b.txt", "file1b");
+ assertFile(fsroot, "folder1/sling:file1b.txt", "file1b");
assertFile(fsroot, "folder1/folder11/file11a.txt", "file11a");
assertFile(fsroot, "folder2/content.json", null);
assertFile(fsroot, "folder2/content/file2content.txt", "file2content");
+ assertFile(fsroot, "folder2/content/sling:content2.json", null);
assertFile(fsroot, "folder3/content.jcr.xml", null);
}
@@ -74,7 +75,7 @@ public class FilesFolderTest {
public void testListChildren() {
assertThat(root, ResourceMatchers.containsChildren("fs-test"));
assertThat(fsroot, ResourceMatchers.hasChildren("folder1", "folder2", "folder3"));
- assertThat(fsroot.getChild("folder1"), ResourceMatchers.hasChildren("folder11", "file1a.txt", "file1b.txt"));
+ assertThat(fsroot.getChild("folder1"), ResourceMatchers.hasChildren("folder11", "file1a.txt", "sling:file1b.txt"));
assertThat(fsroot.getChild("folder2"), ResourceMatchers.hasChildren("folder21", "content.json"));
assertFalse(fsroot.getChild("folder1/file1a.txt").listChildren().hasNext());
}
diff --git a/src/test/java/org/apache/sling/fsprovider/internal/JcrMixedTest.java b/src/test/java/org/apache/sling/fsprovider/internal/JcrMixedTest.java
index 9a220d9..b3e4d3b 100644
--- a/src/test/java/org/apache/sling/fsprovider/internal/JcrMixedTest.java
+++ b/src/test/java/org/apache/sling/fsprovider/internal/JcrMixedTest.java
@@ -82,7 +82,7 @@ public class JcrMixedTest {
@Test
public void testFiles() {
assertFile(fsroot, "folder1/file1a.txt", "file1a");
- assertFile(fsroot, "folder1/file1b.txt", "file1b");
+ assertFile(fsroot, "folder1/sling:file1b.txt", "file1b");
assertFile(fsroot, "folder1/folder11/file11a.txt", "file11a");
assertFile(fsroot, "folder2/content.json", null);
@@ -97,7 +97,7 @@ public class JcrMixedTest {
public void testListChildren() {
assertThat(root, ResourceMatchers.containsChildren("fs-test"));
assertThat(fsroot, ResourceMatchers.hasChildren("folder1", "folder2", "folder99"));
- assertThat(fsroot.getChild("folder1"), ResourceMatchers.hasChildren("file1a.txt", "file1b.txt", "file1c.txt"));
+ assertThat(fsroot.getChild("folder1"), ResourceMatchers.hasChildren("file1a.txt", "sling:file1b.txt", "file1c.txt"));
}
}
diff --git a/src/test/java/org/apache/sling/fsprovider/internal/JcrXmlContentTest.java b/src/test/java/org/apache/sling/fsprovider/internal/JcrXmlContentTest.java
index 7bb6cee..45ec86f 100644
--- a/src/test/java/org/apache/sling/fsprovider/internal/JcrXmlContentTest.java
+++ b/src/test/java/org/apache/sling/fsprovider/internal/JcrXmlContentTest.java
@@ -81,7 +81,7 @@ public class JcrXmlContentTest {
@Test
public void testFiles() {
assertFile(fsroot, "folder1/file1a.txt", "file1a");
- assertFile(fsroot, "folder1/file1b.txt", "file1b");
+ assertFile(fsroot, "folder1/sling:file1b.txt", "file1b");
assertFile(fsroot, "folder1/folder11/file11a.txt", "file11a");
assertFile(fsroot, "folder2/content.json", null);
assertNull(fsroot.getChild("folder3/content.jcr.xml"));
@@ -91,7 +91,7 @@ public class JcrXmlContentTest {
public void testListChildren() {
assertThat(root, ResourceMatchers.containsChildren("fs-test"));
assertThat(fsroot, ResourceMatchers.hasChildren("folder1", "folder2"));
- assertThat(fsroot.getChild("folder1"), ResourceMatchers.hasChildren("folder11", "file1a.txt", "file1b.txt"));
+ assertThat(fsroot.getChild("folder1"), ResourceMatchers.hasChildren("folder11", "file1a.txt", "sling:file1b.txt"));
assertThat(fsroot.getChild("folder2"), ResourceMatchers.hasChildren("folder21", "content"));
}
diff --git a/src/test/java/org/apache/sling/fsprovider/internal/JsonContentTest.java b/src/test/java/org/apache/sling/fsprovider/internal/JsonContentTest.java
index 553080f..02298c2 100644
--- a/src/test/java/org/apache/sling/fsprovider/internal/JsonContentTest.java
+++ b/src/test/java/org/apache/sling/fsprovider/internal/JsonContentTest.java
@@ -91,7 +91,7 @@ public class JsonContentTest {
@Test
public void testFiles() {
assertFile(fsroot, "folder1/file1a.txt", "file1a");
- assertFile(fsroot, "folder1/file1b.txt", "file1b");
+ assertFile(fsroot, "folder1/sling:file1b.txt", "file1b");
assertFile(fsroot, "folder1/folder11/file11a.txt", "file11a");
assertNull(fsroot.getChild("folder2/content.json"));
assertFile(fsroot, "folder2/content/file2content.txt", "file2content");
@@ -102,7 +102,7 @@ public class JsonContentTest {
public void testListChildren() {
assertThat(root, ResourceMatchers.containsChildren("fs-test"));
assertThat(fsroot, ResourceMatchers.hasChildren("folder1", "folder2"));
- assertThat(fsroot.getChild("folder1"), ResourceMatchers.hasChildren("folder11", "file1a.txt", "file1b.txt"));
+ assertThat(fsroot.getChild("folder1"), ResourceMatchers.hasChildren("folder11", "file1a.txt", "sling:file1b.txt"));
assertThat(fsroot.getChild("folder2"), ResourceMatchers.hasChildren("folder21", "content"));
}
@@ -285,4 +285,11 @@ public class JsonContentTest {
assertEquals("en", node.getProperty("jcr:language").getString());
}
+ @Test
+ public void testContent2() throws RepositoryException {
+ Resource content2 = fsroot.getChild("folder2/content/sling:content2");
+ assertNotNull(content2);
+ assertEquals("app:Page", content2.getResourceType());
+ }
+
}
diff --git a/src/test/java/org/apache/sling/fsprovider/internal/TestUtils.java b/src/test/java/org/apache/sling/fsprovider/internal/TestUtils.java
index d077b34..05a5524 100644
--- a/src/test/java/org/apache/sling/fsprovider/internal/TestUtils.java
+++ b/src/test/java/org/apache/sling/fsprovider/internal/TestUtils.java
@@ -39,6 +39,7 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.sling.api.SlingConstants;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.fsprovider.internal.FileMonitor.ResourceChange;
+import org.apache.sling.fsprovider.internal.mapper.Escape;
import org.apache.sling.hamcrest.ResourceMatchers;
import org.apache.sling.testing.mock.osgi.MapUtil;
import org.apache.sling.testing.mock.osgi.context.AbstractContextPlugin;
@@ -85,8 +86,7 @@ class TestUtils {
assertEquals("nt:file", file.getResourceType());
assertNull(file.getResourceSuperType());
- assertEquals(file.getName(), file.adaptTo(File.class).getName());
- assertTrue(StringUtils.contains(file.adaptTo(URL.class).toString(), file.getName()));
+ assertEquals(file.getName(), Escape.fileToResourceName(file.adaptTo(File.class).getName()));
if (content != null) {
try {
diff --git a/src/test/java/org/apache/sling/fsprovider/internal/mapper/EscapeTest.java b/src/test/java/org/apache/sling/fsprovider/internal/mapper/EscapeTest.java
new file mode 100644
index 0000000..a44bda4
--- /dev/null
+++ b/src/test/java/org/apache/sling/fsprovider/internal/mapper/EscapeTest.java
@@ -0,0 +1,46 @@
+/*
+ * 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.fsprovider.internal.mapper;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+public class EscapeTest {
+
+ @Test
+ public void testFileToResourceName() {
+ assertEquals("abc", Escape.fileToResourceName("abc"));
+ assertEquals("abc.txt", Escape.fileToResourceName("abc.txt"));
+ assertEquals("xyz:abc.txt", Escape.fileToResourceName("xyz%3Aabc.txt"));
+ assertEquals("a<>:\"/\\|?*b", Escape.fileToResourceName("a%3C%3E%3A%22/%5C%7C%3F%2Ab"));
+ assertEquals("", Escape.fileToResourceName(""));
+ }
+
+ @Test
+ public void testResourceToFileName() {
+ assertEquals("abc", Escape.resourceToFileName("abc"));
+ assertEquals("abc.txt", Escape.resourceToFileName("abc.txt"));
+ assertEquals("xyz%3Aabc.txt", Escape.resourceToFileName("xyz:abc.txt"));
+ // URLEncoder does not encode '*'
+ assertEquals("a%3C%3E%3A%22/%5C%7C%3F*b", Escape.resourceToFileName("a<>:\"/\\|?*b"));
+ assertEquals("", Escape.resourceToFileName(""));
+ }
+
+}
diff --git a/src/test/resources/fs-test/folder1/file1b.txt b/src/test/resources/fs-test/folder1/sling%3Afile1b.txt
similarity index 100%
rename from src/test/resources/fs-test/folder1/file1b.txt
rename to src/test/resources/fs-test/folder1/sling%3Afile1b.txt
diff --git a/src/test/resources/fs-test/folder2/content/content2.json b/src/test/resources/fs-test/folder2/content/sling%3Acontent2.json
similarity index 100%
rename from src/test/resources/fs-test/folder2/content/content2.json
rename to src/test/resources/fs-test/folder2/content/sling%3Acontent2.json
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.