You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by js...@apache.org on 2018/01/11 10:27:48 UTC
[sling-org-apache-sling-fsresource] branch master updated:
SLING-7372 - File system resource provider should support deep ValueMap
access
This is an automated email from the ASF dual-hosted git repository.
jsedding pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-fsresource.git
The following commit(s) were added to refs/heads/master by this push:
new c3adbae SLING-7372 - File system resource provider should support deep ValueMap access
c3adbae is described below
commit c3adbae490d72d207fa1a8d565f230543012fbb5
Author: Julian Sedding <js...@apache.org>
AuthorDate: Wed Jan 10 17:13:17 2018 +0100
SLING-7372 - File system resource provider should support deep ValueMap access
---
.../sling/fsprovider/internal/mapper/ContentFileResource.java | 3 ++-
.../apache/sling/fsprovider/internal/mapper/FileResource.java | 3 ++-
.../org/apache/sling/fsprovider/internal/FilesFolderTest.java | 10 ++++++++++
.../apache/sling/fsprovider/internal/JcrXmlContentTest.java | 7 +++++++
.../org/apache/sling/fsprovider/internal/JsonContentTest.java | 10 ++++++++++
5 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/src/main/java/org/apache/sling/fsprovider/internal/mapper/ContentFileResource.java b/src/main/java/org/apache/sling/fsprovider/internal/mapper/ContentFileResource.java
index 40549c5..eb8c938 100644
--- a/src/main/java/org/apache/sling/fsprovider/internal/mapper/ContentFileResource.java
+++ b/src/main/java/org/apache/sling/fsprovider/internal/mapper/ContentFileResource.java
@@ -26,6 +26,7 @@ import org.apache.sling.api.resource.AbstractResource;
import org.apache.sling.api.resource.ResourceMetadata;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.resource.ValueMap;
+import org.apache.sling.api.wrappers.DeepReadValueMapDecorator;
import org.apache.sling.fsprovider.internal.mapper.jcr.FsNode;
/**
@@ -104,7 +105,7 @@ public final class ContentFileResource extends AbstractResource {
return (AdapterType)this.contentFile;
}
else if (type == ValueMap.class) {
- return (AdapterType)contentFile.getValueMap();
+ return (AdapterType)new DeepReadValueMapDecorator(this, contentFile.getValueMap());
}
else if (type == Node.class) {
// support a subset of JCR API for content file resources
diff --git a/src/main/java/org/apache/sling/fsprovider/internal/mapper/FileResource.java b/src/main/java/org/apache/sling/fsprovider/internal/mapper/FileResource.java
index 873aba8..d67f0eb 100644
--- a/src/main/java/org/apache/sling/fsprovider/internal/mapper/FileResource.java
+++ b/src/main/java/org/apache/sling/fsprovider/internal/mapper/FileResource.java
@@ -40,6 +40,7 @@ import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceMetadata;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.resource.ValueMap;
+import org.apache.sling.api.wrappers.DeepReadValueMapDecorator;
import org.apache.sling.fsprovider.internal.ContentFileExtensions;
import org.apache.sling.fsprovider.internal.FsResourceProvider;
import org.apache.sling.fsprovider.internal.mapper.jcr.FsNode;
@@ -248,7 +249,7 @@ public final class FileResource extends AbstractResource {
}
}
- valueMap = new ValueMapDecorator(props);
+ valueMap = new DeepReadValueMapDecorator(this, new ValueMapDecorator(props));
}
}
return valueMap;
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 7ebc089..a704a77 100644
--- a/src/test/java/org/apache/sling/fsprovider/internal/FilesFolderTest.java
+++ b/src/test/java/org/apache/sling/fsprovider/internal/FilesFolderTest.java
@@ -20,10 +20,12 @@ package org.apache.sling.fsprovider.internal;
import static org.apache.sling.fsprovider.internal.TestUtils.assertFile;
import static org.apache.sling.fsprovider.internal.TestUtils.assertFolder;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ValueMap;
import org.apache.sling.fsprovider.internal.TestUtils.RegisterFsResourcePlugin;
import org.apache.sling.hamcrest.ResourceMatchers;
import org.apache.sling.testing.mock.sling.ResourceResolverType;
@@ -80,4 +82,12 @@ public class FilesFolderTest {
assertFalse(fsroot.getChild("folder1/file1a.txt").listChildren().hasNext());
}
+ @Test
+ public void testDeepValueMapAccess() throws Exception {
+ Resource underTest = fsroot.getChild("folder1");
+ ValueMap properties = underTest.getValueMap();
+ String type = properties.get("folder11/jcr:primaryType", String.class);
+ assertEquals("nt:folder", type);
+ }
+
}
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 1b8e2a9..3f51c1c 100644
--- a/src/test/java/org/apache/sling/fsprovider/internal/JcrXmlContentTest.java
+++ b/src/test/java/org/apache/sling/fsprovider/internal/JcrXmlContentTest.java
@@ -167,4 +167,11 @@ public class JcrXmlContentTest {
assertEquals("nt:folder", child2.getValueMap().get("jcr:primaryType", String.class));
}
+ @Test
+ public void testDeepValueMapAccess() throws Exception {
+ Resource underTest = fsroot.getChild("folder3/content/jcr:content");
+ ValueMap properties = underTest.getValueMap();
+ String headline = properties.get("content/contentheadline/headline", String.class);
+ assertEquals("Extended Call for Papers", headline);
+ }
}
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 eb4276e..ce21a72 100644
--- a/src/test/java/org/apache/sling/fsprovider/internal/JsonContentTest.java
+++ b/src/test/java/org/apache/sling/fsprovider/internal/JsonContentTest.java
@@ -289,4 +289,14 @@ public class JsonContentTest {
assertEquals("app:Page", content2.getResourceType());
}
+ @Test
+ public void testDeepValueMapAccess() throws Exception {
+ Resource underTest = fsroot.getChild("folder2/content/toolbar");
+ ValueMap properties = underTest.getValueMap();
+ String toolbarTitle = properties.get("jcr:content/jcr:title", String.class);
+ assertEquals("Toolbar", toolbarTitle);
+
+ String profilesTitle = properties.get("profiles/jcr:content/jcr:title", String.class);
+ assertEquals("Profiles", profilesTitle);
+ }
}
--
To stop receiving notification emails like this one, please contact
['"commits@sling.apache.org" <co...@sling.apache.org>'].