SLING-7372 - File system resource provider should support deep ValueMap access
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.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 @@
             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.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 @@
                     }
                 }
                 
-                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 @@
 
 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 @@
         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 @@
         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 @@
         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);
+    }
 }