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:46:37 UTC

[sling-org-apache-sling-jcr-contentparser] annotated tag org.apache.sling.jcr.contentparser-1.0.0 created (now 445977b)

This is an automated email from the ASF dual-hosted git repository.

rombert pushed a change to annotated tag org.apache.sling.jcr.contentparser-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-contentparser.git.


      at 445977b  (tag)
 tagging 20fe2f7ae4cb7e47649d300395ee5434e48d3215 (commit)
      by Stefan Seifert
      on Mon Mar 20 11:15:14 2017 +0000

- Log -----------------------------------------------------------------
org.apache.sling.jcr.contentparser-1.0.0
-----------------------------------------------------------------------

This annotated tag includes the following new commits:

     new 4b0d14e  SLING-6592 File System Content File Parser
     new 081596f  SLING-6592 use DocViewProperty from vault-core to parse jcr xml property values fix artifactid
     new 0969aab  SLING-6592 use enum instead of string constants
     new 210691d  use Sling Parent 30
     new 14aec84  SLING-6592 BigDecimal support
     new ad3f2d6  svn:ignore
     new d1d3c2a  added ignored test for same name property and sub resource
     new d81cfcd  SLING-6592 move and rename to jcr/contentparser, change java package and class names accordingly
     new 6cefe40  SLING-6592 remove parse(File) method from API
     new c8c0f23  SLING-6592 switch to Stream API for content parsing, remove content representation API
     new 4080f48  add readme
     new b27f542  add osgi versioning annotations
     new e14c280  [maven-release-plugin] prepare release org.apache.sling.jcr.contentparser-1.0.0
     new 20fe2f7  [maven-release-plugin] copy for tag org.apache.sling.jcr.contentparser-1.0.0

The 14 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-jcr-contentparser] 05/14: SLING-6592 BigDecimal support

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.jcr.contentparser-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-contentparser.git

commit 14aec8451473b17caa8e3942bb89cf9fcf89cba8
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Fri Mar 10 13:43:24 2017 +0000

    SLING-6592 BigDecimal support
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/fscontentparser@1786339 13f79535-47bb-0310-9956-ffa450edef68
---
 .../apache/sling/fscontentparser/impl/JcrXmlValueConverter.java  | 9 +++++----
 .../apache/sling/fscontentparser/impl/JsonContentFileParser.java | 2 +-
 .../sling/fscontentparser/impl/JcrXmlContentFileParserTest.java  | 3 ++-
 .../sling/fscontentparser/impl/JcrXmlValueConverterTest.java     | 5 +++--
 .../sling/fscontentparser/impl/JsonContentFileParserTest.java    | 5 +++--
 5 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/src/main/java/org/apache/sling/fscontentparser/impl/JcrXmlValueConverter.java b/src/main/java/org/apache/sling/fscontentparser/impl/JcrXmlValueConverter.java
index 8e9fad4..cb65b30 100644
--- a/src/main/java/org/apache/sling/fscontentparser/impl/JcrXmlValueConverter.java
+++ b/src/main/java/org/apache/sling/fscontentparser/impl/JcrXmlValueConverter.java
@@ -19,6 +19,7 @@
 package org.apache.sling.fscontentparser.impl;
 
 import java.lang.reflect.Array;
+import java.math.BigDecimal;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.Calendar;
@@ -85,9 +86,9 @@ class JcrXmlValueConverter {
             case PropertyType.LONG:
                 return Long.valueOf(value);
             case PropertyType.DOUBLE:
-            case PropertyType.DECIMAL:
-                // TODO: specific handling for BigDecimal? not properly supported in ValueMapDecorator until very recent Sling API versions
                 return Double.valueOf(value);
+            case PropertyType.DECIMAL:
+                return new BigDecimal(value);
             case PropertyType.DATE:
                 return ISO8601.parse(value);
             case PropertyType.REFERENCE:
@@ -126,9 +127,9 @@ class JcrXmlValueConverter {
             case PropertyType.LONG:
                 return Long.class;
             case PropertyType.DOUBLE:
-            case PropertyType.DECIMAL:
-                // TODO: specific handling for BigDecimal? not properly supported in ValueMapDecorator until very recent Sling API versions
                 return Double.class;
+            case PropertyType.DECIMAL:
+                return BigDecimal.class;
             case PropertyType.DATE:
                 return Calendar.class;
             case PropertyType.REFERENCE:
diff --git a/src/main/java/org/apache/sling/fscontentparser/impl/JsonContentFileParser.java b/src/main/java/org/apache/sling/fscontentparser/impl/JsonContentFileParser.java
index 47b3c18..4dca092 100644
--- a/src/main/java/org/apache/sling/fscontentparser/impl/JsonContentFileParser.java
+++ b/src/main/java/org/apache/sling/fscontentparser/impl/JsonContentFileParser.java
@@ -113,7 +113,7 @@ public final class JsonContentFileParser implements ContentFileParser {
                     return numberValue.longValue();
                 }
                 else {
-                    return numberValue.doubleValue();
+                    return numberValue.bigDecimalValue();
                 }
             case TRUE:
                 return true;
diff --git a/src/test/java/org/apache/sling/fscontentparser/impl/JcrXmlContentFileParserTest.java b/src/test/java/org/apache/sling/fscontentparser/impl/JcrXmlContentFileParserTest.java
index d89917e..8678b30 100644
--- a/src/test/java/org/apache/sling/fscontentparser/impl/JcrXmlContentFileParserTest.java
+++ b/src/test/java/org/apache/sling/fscontentparser/impl/JcrXmlContentFileParserTest.java
@@ -25,6 +25,7 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 
 import java.io.File;
+import java.math.BigDecimal;
 import java.util.Calendar;
 import java.util.Map;
 import java.util.TimeZone;
@@ -75,7 +76,7 @@ public class JcrXmlContentFileParserTest {
         assertEquals("en", props.get("jcr:title"));
         assertEquals(true, props.get("includeAside"));
         assertEquals((Long)1234567890123L, props.get("longProp"));
-        assertEquals((Double)1.2345d, (Double)props.get("decimalProp"), 0.00001d);
+        assertEquals(new BigDecimal("1.2345"), props.get("decimalProp"));
         
         assertArrayEquals(new String[] { "aa", "bb", "cc" }, (String[])props.get("stringPropMulti"));
         assertArrayEquals(new Long[] { 1234567890123L, 55L }, (Long[])props.get("longPropMulti"));
diff --git a/src/test/java/org/apache/sling/fscontentparser/impl/JcrXmlValueConverterTest.java b/src/test/java/org/apache/sling/fscontentparser/impl/JcrXmlValueConverterTest.java
index 2f02aae..a3b51ab 100644
--- a/src/test/java/org/apache/sling/fscontentparser/impl/JcrXmlValueConverterTest.java
+++ b/src/test/java/org/apache/sling/fscontentparser/impl/JcrXmlValueConverterTest.java
@@ -23,6 +23,7 @@ import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNull;
 
+import java.math.BigDecimal;
 import java.net.URI;
 import java.util.Calendar;
 import java.util.UUID;
@@ -85,12 +86,12 @@ public class JcrXmlValueConverterTest {
 
     @Test
     public void testDouble() {
-        assertEquals(1.234d, parseValue(NAME, "{Decimal}1.234"));
+        assertEquals(new BigDecimal("1.234"), parseValue(NAME, "{Decimal}1.234"));
     }
 
     @Test
     public void testDoubleArray() {
-        assertArrayEquals(new Object[] { 1.234d, 2.345d }, (Object[]) parseValue(NAME, "{Decimal}[1.234,2.345]"));
+        assertArrayEquals(new Object[] { new BigDecimal("1.234"), new BigDecimal("2.345") }, (Object[]) parseValue(NAME, "{Decimal}[1.234,2.345]"));
     }
 
     @Test
diff --git a/src/test/java/org/apache/sling/fscontentparser/impl/JsonContentFileParserTest.java b/src/test/java/org/apache/sling/fscontentparser/impl/JsonContentFileParserTest.java
index 074cf67..6a0b8f6 100644
--- a/src/test/java/org/apache/sling/fscontentparser/impl/JsonContentFileParserTest.java
+++ b/src/test/java/org/apache/sling/fscontentparser/impl/JsonContentFileParserTest.java
@@ -25,6 +25,7 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 
 import java.io.File;
+import java.math.BigDecimal;
 import java.util.Calendar;
 import java.util.Map;
 import java.util.TimeZone;
@@ -65,11 +66,11 @@ public class JsonContentFileParserTest {
         assertEquals(true, props.get("hideInNav"));
 
         assertEquals(1234567890123L, props.get("longProp"));
-        assertEquals(1.2345d, (Double) props.get("decimalProp"), 0.00001d);
+        assertEquals(new BigDecimal("1.2345"), props.get("decimalProp"));
         assertEquals(true, props.get("booleanProp"));
 
         assertArrayEquals(new Long[] { 1234567890123L, 55L }, (Long[]) props.get("longPropMulti"));
-        assertArrayEquals(new Double[] { 1.2345d, 1.1d }, (Double[]) props.get("decimalPropMulti"));
+        assertArrayEquals(new BigDecimal[] { new BigDecimal("1.2345"), new BigDecimal("1.1") }, (BigDecimal[]) props.get("decimalPropMulti"));
         assertArrayEquals(new Boolean[] { true, false }, (Boolean[]) props.get("booleanPropMulti"));
     }
 

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-jcr-contentparser] 10/14: SLING-6592 switch to Stream API for content parsing, remove content representation API

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.jcr.contentparser-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-contentparser.git

commit c8c0f239df205626b411aad50cd1371ceb5c169c
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Fri Mar 17 20:59:21 2017 +0000

    SLING-6592 switch to Stream API for content parsing, remove content representation API
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/contentparser@1787499 13f79535-47bb-0310-9956-ffa450edef68
---
 .../{ContentParser.java => ContentHandler.java}    | 21 +++----
 .../sling/jcr/contentparser/ContentParser.java     |  9 ++-
 .../jcr/contentparser/ContentParserFactory.java    |  2 +-
 .../sling/jcr/contentparser/ContentType.java       |  2 +-
 .../sling/jcr/contentparser/ParserOptions.java     |  4 +-
 .../contentparser/impl/JcrXmlContentParser.java    | 67 ++++++++++++++-------
 .../jcr/contentparser/impl/JsonContentParser.java  | 44 ++++++++++----
 .../sling/jcr/contentparser/impl/ParserHelper.java | 13 +++-
 .../sling/jcr/contentparser/package-info.java      |  2 +-
 .../impl/JcrXmlContentParserTest.java              | 55 ++++++++++-------
 .../contentparser/impl/JsonContentParserTest.java  | 61 ++++++++++++-------
 .../sling/jcr/contentparser/impl/TestUtils.java    | 27 ++-------
 .../impl/mapsupport/ContentElement.java}           | 44 +++++++-------
 .../impl/mapsupport/ContentElementHandler.java     | 69 ++++++++++++++++++++++
 .../impl/mapsupport/ContentElementImpl.java        | 68 +++++++++++++++++++++
 15 files changed, 348 insertions(+), 140 deletions(-)

diff --git a/src/main/java/org/apache/sling/jcr/contentparser/ContentParser.java b/src/main/java/org/apache/sling/jcr/contentparser/ContentHandler.java
similarity index 62%
copy from src/main/java/org/apache/sling/jcr/contentparser/ContentParser.java
copy to src/main/java/org/apache/sling/jcr/contentparser/ContentHandler.java
index 1d9595a..7582338 100644
--- a/src/main/java/org/apache/sling/jcr/contentparser/ContentParser.java
+++ b/src/main/java/org/apache/sling/jcr/contentparser/ContentHandler.java
@@ -18,23 +18,20 @@
  */
 package org.apache.sling.jcr.contentparser;
 
-import java.io.IOException;
-import java.io.InputStream;
 import java.util.Map;
 
 /**
- * Parses repository content from a file.
- * Implementations have to be thread-safe.
+ * Handler that gets notified while parsing content with {@link ContentParser}.
+ * The resources are always reported in order of their paths as found in the content fragment.
+ * Parents are always reported before their children.
  */
-public interface ContentParser {
+public interface ContentHandler {
 
     /**
-     * Parse content.
-     * @param is Stream with serialized content
-     * @return Content as Map
-     * @throws IOException When I/O error occurs.
-     * @throws ParseException When parsing error occurs.
+     * Resource found in parsed content.
+     * @param path Path of resource inside the content fragment. The root resource from the content fragment has a path "/".
+     * @param properties Resource properties
      */
-    Map<String,Object> parse(InputStream is) throws IOException, ParseException;
-
+    void resource(String path, Map<String,Object> properties);
+    
 }
diff --git a/src/main/java/org/apache/sling/jcr/contentparser/ContentParser.java b/src/main/java/org/apache/sling/jcr/contentparser/ContentParser.java
index 1d9595a..fa6877d 100644
--- a/src/main/java/org/apache/sling/jcr/contentparser/ContentParser.java
+++ b/src/main/java/org/apache/sling/jcr/contentparser/ContentParser.java
@@ -20,7 +20,6 @@ package org.apache.sling.jcr.contentparser;
 
 import java.io.IOException;
 import java.io.InputStream;
-import java.util.Map;
 
 /**
  * Parses repository content from a file.
@@ -29,12 +28,12 @@ import java.util.Map;
 public interface ContentParser {
 
     /**
-     * Parse content.
-     * @param is Stream with serialized content
-     * @return Content as Map
+     * Parse content in a "stream-based" way. Each resource that is found in the content is reported to the contentHandler.
+     * @param contentHandler Content handler that accepts the parsed content.
+     * @param inputStream Stream with serialized content
      * @throws IOException When I/O error occurs.
      * @throws ParseException When parsing error occurs.
      */
-    Map<String,Object> parse(InputStream is) throws IOException, ParseException;
+    void parse(ContentHandler contentHandler, InputStream inputStream) throws IOException, ParseException;
 
 }
diff --git a/src/main/java/org/apache/sling/jcr/contentparser/ContentParserFactory.java b/src/main/java/org/apache/sling/jcr/contentparser/ContentParserFactory.java
index 7ae64e2..7357ec5 100644
--- a/src/main/java/org/apache/sling/jcr/contentparser/ContentParserFactory.java
+++ b/src/main/java/org/apache/sling/jcr/contentparser/ContentParserFactory.java
@@ -22,7 +22,7 @@ import org.apache.sling.jcr.contentparser.impl.JcrXmlContentParser;
 import org.apache.sling.jcr.contentparser.impl.JsonContentParser;
 
 /**
- * Factory for content file parsers.
+ * Factory for content parsers.
  */
 public final class ContentParserFactory {
 
diff --git a/src/main/java/org/apache/sling/jcr/contentparser/ContentType.java b/src/main/java/org/apache/sling/jcr/contentparser/ContentType.java
index 167722f..acba05d 100644
--- a/src/main/java/org/apache/sling/jcr/contentparser/ContentType.java
+++ b/src/main/java/org/apache/sling/jcr/contentparser/ContentType.java
@@ -29,7 +29,7 @@ public enum ContentType {
     JSON("json"),
 
     /**
-     * JCR XML content.
+     * JCR XML content (FileVault XML).
      */
     JCR_XML("jcr.xml");
 
diff --git a/src/main/java/org/apache/sling/jcr/contentparser/ParserOptions.java b/src/main/java/org/apache/sling/jcr/contentparser/ParserOptions.java
index 0911dac..4dba088 100644
--- a/src/main/java/org/apache/sling/jcr/contentparser/ParserOptions.java
+++ b/src/main/java/org/apache/sling/jcr/contentparser/ParserOptions.java
@@ -24,7 +24,7 @@ import java.util.HashSet;
 import java.util.Set;
 
 /**
- * Options for content filer parser.
+ * Options for content parser.
  */
 public final class ParserOptions {
     
@@ -60,7 +60,7 @@ public final class ParserOptions {
     }
 
     /**
-     * Some content file formats like JSON do not contain information to identify date/time values.
+     * Some content formats like JSON do not contain information to identify date/time values.
      * Instead they have to be detected by heuristics by trying to parse every string value.
      * This mode is disabled by default.
      * @param value Activate calendar value detection
diff --git a/src/main/java/org/apache/sling/jcr/contentparser/impl/JcrXmlContentParser.java b/src/main/java/org/apache/sling/jcr/contentparser/impl/JcrXmlContentParser.java
index 2af30e7..9b9486c 100644
--- a/src/main/java/org/apache/sling/jcr/contentparser/impl/JcrXmlContentParser.java
+++ b/src/main/java/org/apache/sling/jcr/contentparser/impl/JcrXmlContentParser.java
@@ -20,16 +20,20 @@ package org.apache.sling.jcr.contentparser.impl;
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.ArrayDeque;
+import java.util.Deque;
 import java.util.HashMap;
-import java.util.LinkedHashMap;
+import java.util.HashSet;
 import java.util.Map;
-import java.util.Stack;
+import java.util.Set;
 
 import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.parsers.SAXParser;
 import javax.xml.parsers.SAXParserFactory;
 
+import org.apache.commons.lang3.StringUtils;
 import org.apache.jackrabbit.util.ISO9075;
+import org.apache.sling.jcr.contentparser.ContentHandler;
 import org.apache.sling.jcr.contentparser.ContentParser;
 import org.apache.sling.jcr.contentparser.ParseException;
 import org.apache.sling.jcr.contentparser.ParserOptions;
@@ -54,15 +58,14 @@ public final class JcrXmlContentParser implements ContentParser {
     }
     
     @Override
-    public Map<String,Object> parse(InputStream is) throws IOException, ParseException {
+    public void parse(ContentHandler handler, InputStream is) throws IOException, ParseException {
         try {
-            XmlHandler xmlHandler = new XmlHandler();
+            XmlHandler xmlHandler = new XmlHandler(handler);
             SAXParser parser = saxParserFactory.newSAXParser();
             parser.parse(is, xmlHandler);
             if (xmlHandler.hasError()) {
                 throw xmlHandler.getError();
             }
-            return xmlHandler.getContent();
         }
         catch (ParserConfigurationException | SAXException ex) {
             throw new ParseException("Error parsing JCR XML content.", ex);
@@ -82,12 +85,13 @@ public final class JcrXmlContentParser implements ContentParser {
      * Parses XML stream to Map.
      */
     class XmlHandler extends DefaultHandler {
-        private final Map<String,Object> content = new LinkedHashMap<>();
-        private final Stack<Map<String,Object>> elements = new Stack<>();
+        private final ContentHandler contentHandler;
+        private final Deque<String> paths = new ArrayDeque<>();
+        private final Set<String> ignoredPaths = new HashSet<>();
         private SAXParseException error;
         
-        public Map<String,Object> getContent() {
-            return content;
+        public XmlHandler(ContentHandler contentHandler) {
+            this.contentHandler = contentHandler;
         }
         
         public boolean hasError() {
@@ -102,36 +106,55 @@ public final class JcrXmlContentParser implements ContentParser {
         public void startElement(String uri, String localName, String qName, Attributes attributes)
                 throws SAXException {
             
-            // prepare map for element
-            Map<String,Object> element;
-            if (elements.isEmpty()) {
-                element = content;
+            String resourceName = decodeName(qName);
+
+            // generate path for element
+            String path;
+            if (paths.isEmpty()) {
+                path = "/";
             }
             else {
-                element = new HashMap<>();
-                String resourceName = decodeName(qName);
-                if (!helper.ignoreResource(resourceName)) {
-                    elements.peek().put(resourceName, element);
+                path = helper.concatenatePath(paths.peek(), resourceName);
+                if (helper.ignoreResource(resourceName)) {
+                    ignoredPaths.add(path);
                 }
             }
-            elements.push(element);
+            paths.push(path);
+            
+            // skip further processing if this path or a parent path is ignored
+            if (isIgnoredPath(path)) {
+                return;
+            }
             
-            // get attributes
+            // get properties
+            Map<String,Object> properties = new HashMap<>();
             for (int i=0; i<attributes.getLength(); i++) {
                 String propertyName = helper.cleanupPropertyName(decodeName(attributes.getQName(i)));
                 if (!helper.ignoreProperty(propertyName)) {
                     Object value = JcrXmlValueConverter.parseValue(propertyName, attributes.getValue(i));
                     if (value != null) {
-                        element.put(propertyName, value);
+                        properties.put(propertyName, value);
                     }
                 }
             }
+            helper.ensureDefaultPrimaryType(properties);
+            contentHandler.resource(path, properties);
+        }
+        
+        private boolean isIgnoredPath(String path) {
+            if (StringUtils.isEmpty(path)) {
+                return false;
+            }
+            if (ignoredPaths.contains(path)) {
+                return true;
+            }
+            String parentPath = StringUtils.substringBeforeLast(path, "/");
+            return isIgnoredPath(parentPath);
         }
 
         @Override
         public void endElement(String uri, String localName, String qName) throws SAXException {
-            Map<String,Object> element = elements.pop();
-            helper.ensureDefaultPrimaryType(element);
+            paths.pop();
         }
 
         @Override
diff --git a/src/main/java/org/apache/sling/jcr/contentparser/impl/JsonContentParser.java b/src/main/java/org/apache/sling/jcr/contentparser/impl/JsonContentParser.java
index a17e91e..093fbec 100644
--- a/src/main/java/org/apache/sling/jcr/contentparser/impl/JsonContentParser.java
+++ b/src/main/java/org/apache/sling/jcr/contentparser/impl/JsonContentParser.java
@@ -35,6 +35,7 @@ import javax.json.JsonString;
 import javax.json.JsonValue;
 import javax.json.stream.JsonParsingException;
 
+import org.apache.sling.jcr.contentparser.ContentHandler;
 import org.apache.sling.jcr.contentparser.ContentParser;
 import org.apache.sling.jcr.contentparser.ParseException;
 import org.apache.sling.jcr.contentparser.ParserOptions;
@@ -45,7 +46,12 @@ import org.apache.sling.jcr.contentparser.ParserOptions;
  */
 public final class JsonContentParser implements ContentParser {
     
-    private final ParserHelper helper;    
+    private final ParserHelper helper;
+    /*
+     * Implementation note: This parser uses JsonReader instead of the (more memory-efficient) 
+     * JsonParser Stream API because otherwise it would not be possible to report parent resources
+     * including all properties properly before their children.
+     */
     private final JsonReaderFactory jsonReaderFactory;
     
     public JsonContentParser(ParserOptions options) {
@@ -57,22 +63,25 @@ public final class JsonContentParser implements ContentParser {
     }
     
     @Override
-    public Map<String,Object> parse(InputStream is) throws IOException, ParseException {
+    public void parse(ContentHandler handler, InputStream is) throws IOException, ParseException {
         try (JsonReader reader = jsonReaderFactory.createReader(is)) {
-            return toMap(reader.readObject());
+            parse(handler, reader.readObject(), "/");
         }
         catch (JsonParsingException ex) {
             throw new ParseException("Error parsing JSON content.", ex);
         }
     }
-    
-    private Map<String,Object> toMap(JsonObject object) {
-        Map<String,Object> map = new LinkedHashMap<>();
+
+    private void parse(ContentHandler handler, JsonObject object, String path) {
+        // parse JSON object
+        Map<String,Object> properties = new HashMap<>();
+        Map<String,JsonObject> children = new LinkedHashMap<>();
         for (Map.Entry<String, JsonValue> entry : object.entrySet()) {
             String childName = entry.getKey();
             Object value = convertValue(entry.getValue());
+            boolean isResource = (value instanceof JsonObject);
             boolean ignore = false;
-            if (value instanceof Map) {
+            if (isResource) {
                 ignore = helper.ignoreResource(childName);
             }
             else {
@@ -80,11 +89,24 @@ public final class JsonContentParser implements ContentParser {
                 ignore = helper.ignoreProperty(childName);
             }
             if (!ignore) {
-                map.put(childName, value);
+                if (isResource) {
+                    children.put(childName, (JsonObject)value);
+                }
+                else {
+                    properties.put(childName, value);
+                }
             }
         }
-        helper.ensureDefaultPrimaryType(map);
-        return map;
+        helper.ensureDefaultPrimaryType(properties);
+        
+        // report current JSON object
+        handler.resource(path, properties);
+        
+        // parse and report children
+        for (Map.Entry<String,JsonObject> entry : children.entrySet()) {
+            String childPath = helper.concatenatePath(path, entry.getKey());;
+            parse(handler, entry.getValue(), childPath);
+        }
     }
     
     private Object convertValue(JsonValue value) {
@@ -120,7 +142,7 @@ public final class JsonContentParser implements ContentParser {
                 }
                 return helper.convertSingleTypeArray(values);
             case OBJECT:
-                return toMap((JsonObject)value);
+                return (JsonObject)value;
             default:
                 throw new ParseException("Unexpected JSON value type: " + value.getValueType());
         }
diff --git a/src/main/java/org/apache/sling/jcr/contentparser/impl/ParserHelper.java b/src/main/java/org/apache/sling/jcr/contentparser/impl/ParserHelper.java
index 160cd0e..69b0f48 100644
--- a/src/main/java/org/apache/sling/jcr/contentparser/impl/ParserHelper.java
+++ b/src/main/java/org/apache/sling/jcr/contentparser/impl/ParserHelper.java
@@ -27,6 +27,8 @@ import java.util.Locale;
 import java.util.Map;
 import java.util.Set;
 
+import javax.json.JsonObject;
+
 import org.apache.commons.lang3.StringUtils;
 import org.apache.sling.jcr.contentparser.ParseException;
 import org.apache.sling.jcr.contentparser.ParserOptions;
@@ -113,7 +115,7 @@ class ParserHelper {
             if (value == null) {
                 throw new ParseException("Multivalue array must not contain null values.");
             }
-            if (value instanceof Map) {
+            if (value instanceof Map || value instanceof JsonObject) {
                 throw new ParseException("Multivalue array must not contain maps/objects.");
             }
             if (itemType == null) {
@@ -131,4 +133,13 @@ class ParserHelper {
         return convertedArray;
     }
     
+    public String concatenatePath(String parentPath, String name) {
+        if (StringUtils.endsWith(parentPath, "/")) {
+            return parentPath + name;
+        }
+        else {
+            return parentPath + "/" + name;
+        }
+    }
+    
 }
diff --git a/src/main/java/org/apache/sling/jcr/contentparser/package-info.java b/src/main/java/org/apache/sling/jcr/contentparser/package-info.java
index 21b7f41..1b6b2a8 100644
--- a/src/main/java/org/apache/sling/jcr/contentparser/package-info.java
+++ b/src/main/java/org/apache/sling/jcr/contentparser/package-info.java
@@ -17,7 +17,7 @@
  * under the License.
  */
 /**
- * Parser for repository content stored in files (e.g. JSON, JCR XML).
+ * Parser for repository content serialized e.g. as JSON or JCR XML.
  */
 @org.osgi.annotation.versioning.Version("1.0.0")
 package org.apache.sling.jcr.contentparser;
diff --git a/src/test/java/org/apache/sling/jcr/contentparser/impl/JcrXmlContentParserTest.java b/src/test/java/org/apache/sling/jcr/contentparser/impl/JcrXmlContentParserTest.java
index 1faaf4e..99eca51 100644
--- a/src/test/java/org/apache/sling/jcr/contentparser/impl/JcrXmlContentParserTest.java
+++ b/src/test/java/org/apache/sling/jcr/contentparser/impl/JcrXmlContentParserTest.java
@@ -18,7 +18,6 @@
  */
 package org.apache.sling.jcr.contentparser.impl;
 
-import static org.apache.sling.jcr.contentparser.impl.TestUtils.getDeep;
 import static org.apache.sling.jcr.contentparser.impl.TestUtils.parse;
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
@@ -37,8 +36,8 @@ import org.apache.sling.jcr.contentparser.ContentParserFactory;
 import org.apache.sling.jcr.contentparser.ContentType;
 import org.apache.sling.jcr.contentparser.ParseException;
 import org.apache.sling.jcr.contentparser.ParserOptions;
+import org.apache.sling.jcr.contentparser.impl.mapsupport.ContentElement;
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 
 import com.google.common.collect.ImmutableSet;
@@ -52,14 +51,13 @@ public class JcrXmlContentParserTest {
         file = new File("src/test/resources/content-test/content.jcr.xml");
     }
 
-    @SuppressWarnings("unchecked")
     @Test
     public void testParseJcrXml() throws Exception {
         ContentParser underTest = ContentParserFactory.create(ContentType.JCR_XML);
-        Map<String,Object> content = parse(underTest, file);
+        ContentElement content = parse(underTest, file);
         assertNotNull(content);
-        assertEquals("app:Page", content.get("jcr:primaryType"));
-        assertEquals("app:PageContent", ((Map<String,Object>)content.get("jcr:content")).get("jcr:primaryType"));
+        assertEquals("app:Page", content.getProperties().get("jcr:primaryType"));
+        assertEquals("app:PageContent", content.getChild("jcr:content").getProperties().get("jcr:primaryType"));
     }
 
     @Test(expected=ParseException.class)
@@ -72,8 +70,8 @@ public class JcrXmlContentParserTest {
     @Test
     public void testDataTypes() throws Exception {
         ContentParser underTest = ContentParserFactory.create(ContentType.JCR_XML);
-        Map<String,Object> content = parse(underTest, file);
-        Map<String,Object> props = getDeep(content, "jcr:content");
+        ContentElement content = parse(underTest, file);
+        Map<String,Object> props = content.getChild("jcr:content").getProperties();
         
         assertEquals("en", props.get("jcr:title"));
         assertEquals(true, props.get("includeAside"));
@@ -105,26 +103,43 @@ public class JcrXmlContentParserTest {
         ContentParser underTest = ContentParserFactory.create(ContentType.JCR_XML, new ParserOptions()
                 .ignoreResourceNames(ImmutableSet.of("teaserbar", "aside"))
                 .ignorePropertyNames(ImmutableSet.of("longProp", "jcr:title")));
-        Map<String,Object> content = parse(underTest, file);
-        Map<String,Object> props = getDeep(content, "jcr:content");
+        ContentElement content = parse(underTest, file);
+        ContentElement child = content.getChild("jcr:content");
         
-        assertEquals("HOME", props.get("navTitle"));
-        assertNull(props.get("jcr:title"));
-        assertNull(props.get("longProp"));
+        assertEquals("HOME", child.getProperties().get("navTitle"));
+        assertNull(child.getProperties().get("jcr:title"));
+        assertNull(child.getProperties().get("longProp"));
         
-        assertNull(props.get("teaserbar"));
-        assertNull(props.get("aside"));
-        assertNotNull(props.get("content"));
+        assertNull(child.getChildren().get("teaserbar"));
+        assertNull(child.getChildren().get("aside"));
+        assertNotNull(child.getChildren().get("content"));
+    }
+
+    @Test
+    public void testGetChild() throws Exception {
+        ContentParser underTest = ContentParserFactory.create(ContentType.JCR_XML);
+        ContentElement content = parse(underTest, file);
+        assertNull(content.getName());
+        
+        ContentElement deepChild = content.getChild("jcr:content/teaserbar/teaserbaritem");
+        assertEquals("teaserbaritem", deepChild.getName());
+        assertEquals("samples/sample-app/components/content/teaserbar/teaserbarItem", deepChild.getProperties().get("sling:resourceType"));
+
+        ContentElement invalidChild = content.getChild("non/existing/path");
+        assertNull(invalidChild);
+
+        invalidChild = content.getChild("/jcr:content");
+        assertNull(invalidChild);
     }
 
     @Test
-    @Ignore
     public void testSameNamePropertyAndSubResource() throws Exception {
         ContentParser underTest = ContentParserFactory.create(ContentType.JCR_XML);
-        Map<String,Object> content = parse(underTest, file);
-        Map<String,Object> props = getDeep(content, "jcr:content/teaserbar");
+        ContentElement content = parse(underTest, file);
+        ContentElement child = content.getChild("jcr:content/teaserbar");
         // teaserbaritem is a direct property as well as a sub resource
-        assertEquals("test", props.get("teaserbaritem"));
+        assertEquals("test", child.getProperties().get("teaserbaritem"));
+        assertNotNull(child.getChildren().get("teaserbaritem"));
     }
 
 }
diff --git a/src/test/java/org/apache/sling/jcr/contentparser/impl/JsonContentParserTest.java b/src/test/java/org/apache/sling/jcr/contentparser/impl/JsonContentParserTest.java
index 3aa9531..706cb6e 100644
--- a/src/test/java/org/apache/sling/jcr/contentparser/impl/JsonContentParserTest.java
+++ b/src/test/java/org/apache/sling/jcr/contentparser/impl/JsonContentParserTest.java
@@ -18,7 +18,6 @@
  */
 package org.apache.sling.jcr.contentparser.impl;
 
-import static org.apache.sling.jcr.contentparser.impl.TestUtils.getDeep;
 import static org.apache.sling.jcr.contentparser.impl.TestUtils.parse;
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
@@ -36,6 +35,7 @@ import org.apache.sling.jcr.contentparser.ContentParserFactory;
 import org.apache.sling.jcr.contentparser.ContentType;
 import org.apache.sling.jcr.contentparser.ParseException;
 import org.apache.sling.jcr.contentparser.ParserOptions;
+import org.apache.sling.jcr.contentparser.impl.mapsupport.ContentElement;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -53,17 +53,17 @@ public class JsonContentParserTest {
     @Test
     public void testPageJcrPrimaryType() throws Exception {
         ContentParser underTest = ContentParserFactory.create(ContentType.JSON);
-        Map<String, Object> content = parse(underTest, file);
+        ContentElement content = parse(underTest, file);
 
-        assertEquals("app:Page", content.get("jcr:primaryType"));
+        assertEquals("app:Page", content.getProperties().get("jcr:primaryType"));
     }
 
     @Test
     public void testDataTypes() throws Exception {
         ContentParser underTest = ContentParserFactory.create(ContentType.JSON);
-        Map<String, Object> content = parse(underTest, file);
+        ContentElement content = parse(underTest, file);
 
-        Map<String, Object> props = getDeep(content, "toolbar/profiles/jcr:content");
+        Map<String, Object> props = content.getChild("toolbar/profiles/jcr:content").getProperties();
         assertEquals(true, props.get("hideInNav"));
 
         assertEquals(1234567890123L, props.get("longProp"));
@@ -78,9 +78,9 @@ public class JsonContentParserTest {
     @Test
     public void testContentProperties() throws Exception {
         ContentParser underTest = ContentParserFactory.create(ContentType.JSON);
-        Map<String, Object> content = parse(underTest, file);
+        ContentElement content = parse(underTest, file);
 
-        Map<String, Object> props = getDeep(content, "jcr:content/header");
+        Map<String, Object> props = content.getChild("jcr:content/header").getProperties();
         assertEquals("/content/dam/sample/header.png", props.get("imageReference"));
     }
 
@@ -88,9 +88,9 @@ public class JsonContentParserTest {
     public void testCalendar() throws Exception {
         ContentParser underTest = ContentParserFactory.create(ContentType.JSON,
                 new ParserOptions().detectCalendarValues(true));
-        Map<String, Object> content = parse(underTest, file);
+        ContentElement content = parse(underTest, file);
 
-        Map<String, Object> props = getDeep(content, "jcr:content");
+        Map<String, Object> props = content.getChild("jcr:content").getProperties();
 
         Calendar calendar = (Calendar) props.get("app:lastModified");
         assertNotNull(calendar);
@@ -109,9 +109,9 @@ public class JsonContentParserTest {
     @Test
     public void testUTF8Chars() throws Exception {
         ContentParser underTest = ContentParserFactory.create(ContentType.JSON);
-        Map<String, Object> content = parse(underTest, file);
+        ContentElement content = parse(underTest, file);
 
-        Map<String, Object> props = getDeep(content, "jcr:content");
+        Map<String, Object> props = content.getChild("jcr:content").getProperties();
 
         assertEquals("äöü߀", props.get("utf8Property"));
     }
@@ -120,7 +120,7 @@ public class JsonContentParserTest {
     public void testParseInvalidJson() throws Exception {
         file = new File("src/test/resources/invalid-test/invalid.json");
         ContentParser underTest = ContentParserFactory.create(ContentType.JSON);
-        Map<String, Object> content = parse(underTest, file);
+        ContentElement content = parse(underTest, file);
         assertNull(content);
     }
 
@@ -128,7 +128,7 @@ public class JsonContentParserTest {
     public void testParseInvalidJsonWithObjectList() throws Exception {
         file = new File("src/test/resources/invalid-test/contentWithObjectList.json");
         ContentParser underTest = ContentParserFactory.create(ContentType.JSON);
-        Map<String, Object> content = parse(underTest, file);
+        ContentElement content = parse(underTest, file);
         assertNull(content);
     }
 
@@ -137,18 +137,35 @@ public class JsonContentParserTest {
         ContentParser underTest = ContentParserFactory.create(ContentType.JSON,
                 new ParserOptions().ignoreResourceNames(ImmutableSet.of("header", "newslist"))
                         .ignorePropertyNames(ImmutableSet.of("jcr:title")));
-        Map<String, Object> content = parse(underTest, file);
-        Map<String, Object> props = getDeep(content, "jcr:content");
+        ContentElement content = parse(underTest, file);
+        ContentElement child = content.getChild("jcr:content");
 
-        assertEquals("Sample Homepage", props.get("pageTitle"));
-        assertNull(props.get("jcr:title"));
+        assertEquals("Sample Homepage", child.getProperties().get("pageTitle"));
+        assertNull(child.getProperties().get("jcr:title"));
 
-        assertNull(props.get("header"));
-        assertNull(props.get("newslist"));
-        assertNotNull(props.get("lead"));
+        assertNull(child.getChildren().get("header"));
+        assertNull(child.getChildren().get("newslist"));
+        assertNotNull(child.getChildren().get("lead"));
 
-        assertEquals("abc", props.get("refpro1"));
-        assertEquals("def", props.get("pathprop1"));
+        assertEquals("abc", child.getProperties().get("refpro1"));
+        assertEquals("def", child.getProperties().get("pathprop1"));
+    }
+
+    @Test
+    public void testGetChild() throws Exception {
+        ContentParser underTest = ContentParserFactory.create(ContentType.JSON);
+        ContentElement content = parse(underTest, file);
+        assertNull(content.getName());
+        
+        ContentElement deepChild = content.getChild("jcr:content/par/image/file/jcr:content");
+        assertEquals("jcr:content", deepChild.getName());
+        assertEquals("nt:resource", deepChild.getProperties().get("jcr:primaryType"));
+
+        ContentElement invalidChild = content.getChild("non/existing/path");
+        assertNull(invalidChild);
+
+        invalidChild = content.getChild("/jcr:content");
+        assertNull(invalidChild);
     }
 
 }
diff --git a/src/test/java/org/apache/sling/jcr/contentparser/impl/TestUtils.java b/src/test/java/org/apache/sling/jcr/contentparser/impl/TestUtils.java
index f91c5ee..be395b9 100644
--- a/src/test/java/org/apache/sling/jcr/contentparser/impl/TestUtils.java
+++ b/src/test/java/org/apache/sling/jcr/contentparser/impl/TestUtils.java
@@ -22,10 +22,10 @@ import java.io.BufferedInputStream;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
-import java.util.Map;
 
-import org.apache.commons.lang3.StringUtils;
 import org.apache.sling.jcr.contentparser.ContentParser;
+import org.apache.sling.jcr.contentparser.impl.mapsupport.ContentElement;
+import org.apache.sling.jcr.contentparser.impl.mapsupport.ContentElementHandler;
 
 public final class TestUtils {
     
@@ -33,27 +33,12 @@ public final class TestUtils {
         // static methods only
     }
 
-    @SuppressWarnings("unchecked")
-    public static Map<String, Object> getDeep(Map<String, Object> map, String path) {
-      String name = StringUtils.substringBefore(path, "/");
-      Object object = map.get(name);
-      if (object == null || !(object instanceof Map)) {
-        return null;
-      }
-      String remainingPath = StringUtils.substringAfter(path, "/");
-      Map<String, Object> childMap = (Map<String, Object>)object;
-      if (StringUtils.isEmpty(remainingPath)) {
-        return childMap;
-      }
-      else {
-        return getDeep(childMap, remainingPath);
-      }
-    }
-    
-    public static Map<String,Object> parse(ContentParser contentParser, File file) throws IOException {
+    public static ContentElement parse(ContentParser contentParser, File file) throws IOException {
         try (FileInputStream fis = new FileInputStream(file);
                 BufferedInputStream bis = new BufferedInputStream(fis)) {
-            return contentParser.parse(bis);
+            ContentElementHandler handler = new ContentElementHandler();
+            contentParser.parse(handler, bis);
+            return handler.getRoot();
         }
     }
     
diff --git a/src/main/java/org/apache/sling/jcr/contentparser/ContentType.java b/src/test/java/org/apache/sling/jcr/contentparser/impl/mapsupport/ContentElement.java
similarity index 50%
copy from src/main/java/org/apache/sling/jcr/contentparser/ContentType.java
copy to src/test/java/org/apache/sling/jcr/contentparser/impl/mapsupport/ContentElement.java
index 167722f..6584487 100644
--- a/src/main/java/org/apache/sling/jcr/contentparser/ContentType.java
+++ b/src/test/java/org/apache/sling/jcr/contentparser/impl/mapsupport/ContentElement.java
@@ -16,35 +16,37 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.sling.jcr.contentparser;
+package org.apache.sling.jcr.contentparser.impl.mapsupport;
+
+import java.util.Map;
 
 /**
- * Content types.
+ * Represents a resource or node in the content hierarchy.
  */
-public enum ContentType {
+public interface ContentElement {
 
     /**
-     * JSON content.
+     * @return Resource name. The root resource has no name (null).
      */
-    JSON("json"),
-
+    String getName();
+    
     /**
-     * JCR XML content.
+     * Properties of this resource.
+     * @return Properties (keys, values)
      */
-    JCR_XML("jcr.xml");
-
-
-    private final String extension;
-
-    private ContentType(String extension) {
-        this.extension = extension;
-    }
-
+    Map<String, Object> getProperties();
+    
     /**
-     * @return Extension
+     * Get children of current resource. The Map preserves the ordering of children.
+     * @return Children (child names, child objects)
      */
-    public String getExtension() {
-        return extension;
-    }
-
+    Map<String, ContentElement> getChildren();
+    
+    /**
+     * Get child or descendant
+     * @param path Relative path to address child or one of it's descendants (use "/" as hierarchy separator).
+     * @return Child or null if no child found with this path
+     */
+    ContentElement getChild(String path);
+    
 }
diff --git a/src/test/java/org/apache/sling/jcr/contentparser/impl/mapsupport/ContentElementHandler.java b/src/test/java/org/apache/sling/jcr/contentparser/impl/mapsupport/ContentElementHandler.java
new file mode 100644
index 0000000..190adad
--- /dev/null
+++ b/src/test/java/org/apache/sling/jcr/contentparser/impl/mapsupport/ContentElementHandler.java
@@ -0,0 +1,69 @@
+/*
+ * 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.contentparser.impl.mapsupport;
+
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.sling.jcr.contentparser.ContentHandler;
+
+/**
+ * {@link ContentHandler} implementation that produces a tree of {@link ContentElement} items.
+ */
+public class ContentElementHandler implements ContentHandler {
+    
+    private ContentElement root;
+    private Pattern PATH_PATTERN = Pattern.compile("^((/[^/]+)*)(/([^/]+))$"); 
+
+    @Override
+    public void resource(String path, Map<String, Object> properties) {
+        if (StringUtils.equals(path, "/")) {
+            root = new ContentElementImpl(null, properties);
+        }
+        else {
+            if (root == null) {
+                throw new RuntimeException("Root resource not set.");
+            }
+            Matcher matcher = PATH_PATTERN.matcher(path);
+            if (!matcher.matches()) {
+                throw new RuntimeException("Unexpected path:" + path);
+            }
+            String relativeParentPath = StringUtils.stripStart(matcher.group(1), "/");
+            String name = matcher.group(4);
+            ContentElement parent;
+            if (StringUtils.isEmpty(relativeParentPath)) {
+                parent = root;
+            }
+            else {
+                parent = root.getChild(relativeParentPath);
+            }
+            if (parent == null) {
+                throw new RuntimeException("Parent '" + relativeParentPath + "' does not exist.");
+            }
+            parent.getChildren().put(name, new ContentElementImpl(name, properties));
+        }
+    }
+    
+    public ContentElement getRoot() {
+        return root;
+    }
+
+}
diff --git a/src/test/java/org/apache/sling/jcr/contentparser/impl/mapsupport/ContentElementImpl.java b/src/test/java/org/apache/sling/jcr/contentparser/impl/mapsupport/ContentElementImpl.java
new file mode 100644
index 0000000..3956c98
--- /dev/null
+++ b/src/test/java/org/apache/sling/jcr/contentparser/impl/mapsupport/ContentElementImpl.java
@@ -0,0 +1,68 @@
+/*
+ * 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.contentparser.impl.mapsupport;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import org.apache.commons.lang3.StringUtils;
+
+final class ContentElementImpl implements ContentElement {
+    
+    private final String name;
+    private final Map<String, Object> properties;
+    private final Map<String, ContentElement> children = new LinkedHashMap<>();
+    
+    public ContentElementImpl(String name, Map<String, Object> properties) {
+        this.name = name;
+        this.properties = properties;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public Map<String, Object> getProperties() {
+        return properties;
+    }
+
+    @Override
+    public Map<String, ContentElement> getChildren() {
+        return children;
+    }
+
+    @Override
+    public ContentElement getChild(String path) {
+        String name = StringUtils.substringBefore(path, "/");
+        ContentElement child = children.get(name);
+        if (child == null) {
+          return null;
+        }
+        String remainingPath = StringUtils.substringAfter(path, "/");
+        if (StringUtils.isEmpty(remainingPath)) {
+          return child;
+        }
+        else {
+          return child.getChild(remainingPath);
+        }
+    }
+
+}

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-jcr-contentparser] 01/14: SLING-6592 File System Content File Parser

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.jcr.contentparser-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-contentparser.git

commit 4b0d14efb263148502bbbfd0c6a83331af70abf2
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Thu Mar 2 17:17:18 2017 +0000

    SLING-6592 File System Content File Parser
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/fscontentparser@1785165 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml                                            | 120 ++++++++++
 .../fscontentparser/ContentFileExtension.java      |  40 ++++
 .../sling/fscontentparser/ContentFileParser.java   |  50 ++++
 .../fscontentparser/ContentFileParserFactory.java  |  59 +++++
 .../sling/fscontentparser/ParseException.java      |  42 ++++
 .../sling/fscontentparser/ParserOptions.java       | 116 +++++++++
 .../impl/JcrXmlContentFileParser.java              | 159 +++++++++++++
 .../fscontentparser/impl/JcrXmlValueConverter.java | 168 +++++++++++++
 .../impl/JsonContentFileParser.java                | 138 +++++++++++
 .../sling/fscontentparser/impl/ParserHelper.java   | 134 +++++++++++
 .../apache/sling/fscontentparser/package-info.java |  23 ++
 .../impl/JcrXmlContentFileParserTest.java          | 117 +++++++++
 .../impl/JcrXmlValueConverterTest.java             | 105 ++++++++
 .../impl/JsonContentFileParserTest.java            | 152 ++++++++++++
 .../fscontentparser/impl/ParserHelperTest.java     | 199 ++++++++++++++++
 .../sling/fscontentparser/impl/TestUtils.java      |  48 ++++
 src/test/resources/content-test/content.jcr.xml    | 193 +++++++++++++++
 src/test/resources/content-test/content.json       | 264 +++++++++++++++++++++
 .../invalid-test/contentWithObjectList.json        |  14 ++
 src/test/resources/invalid-test/invalid.jcr.xml    |   1 +
 src/test/resources/invalid-test/invalid.json       |   1 +
 21 files changed, 2143 insertions(+)

diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..da20dc3
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,120 @@
+<?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>30-SNAPSHOT</version>
+        <relativePath />
+    </parent>
+
+    <artifactId>org.apache.sling.fscontentparser</artifactId>
+    <packaging>bundle</packaging>
+    <version>1.0.0-SNAPSHOT</version>
+
+    <name>Apache Sling File System Content File Parser</name>
+    <description>
+        Parser for repository content stored in files (e.g. JSON, JCR XML).
+    </description>
+
+    <scm>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/bundles/commons/fscontentparser</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/fscontentparser</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/trunk/bundles/commons/fscontentparser</url>
+    </scm>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        <!-- Embed the nessecary parts of the jackrabbit-jcr-commons bundle as described in http://njbartlett.name/2014/05/26/static-linking.html -->
+                        <Conditional-Package>org.apache.jackrabbit.util</Conditional-Package>
+                        <Import-Package>
+                          !org.apache.jackrabbit.*,
+                          *
+                        </Import-Package>
+                    </instructions>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.rat</groupId>
+                <artifactId>apache-rat-plugin</artifactId>
+                <configuration>
+                    <excludes>
+                      <exclude>src/test/resources/content-test/**</exclude>
+                      <exclude>src/test/resources/invalid-test/**</exclude>
+                    </excludes>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+    <dependencies>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-lang3</artifactId>
+            <version>3.3.2</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>commons-collections</groupId>
+            <artifactId>commons-collections</artifactId>
+            <version>3.2.1</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.johnzon</groupId>
+            <artifactId>johnzon-core</artifactId>
+            <version>1.0.0</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-json_1.0_spec</artifactId>
+            <version>1.0-alpha-1</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.jackrabbit</groupId>
+            <artifactId>jackrabbit-jcr-commons</artifactId>
+            <version>2.8.0</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>com.google.guava</groupId>
+            <artifactId>guava</artifactId>
+            <version>15.0</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+</project>
diff --git a/src/main/java/org/apache/sling/fscontentparser/ContentFileExtension.java b/src/main/java/org/apache/sling/fscontentparser/ContentFileExtension.java
new file mode 100644
index 0000000..a33a4b8
--- /dev/null
+++ b/src/main/java/org/apache/sling/fscontentparser/ContentFileExtension.java
@@ -0,0 +1,40 @@
+/*
+ * 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.fscontentparser;
+
+/**
+ * Content file types.
+ */
+public final class ContentFileExtension {
+    
+    /**
+     * JSON content files.
+     */
+    public static final String JSON = "json";
+
+    /**
+     * JCR XML content files.
+     */
+    public static final String JCR_XML = "jcr.xml";
+        
+    private ContentFileExtension() {
+        // constants only
+    }
+    
+}
diff --git a/src/main/java/org/apache/sling/fscontentparser/ContentFileParser.java b/src/main/java/org/apache/sling/fscontentparser/ContentFileParser.java
new file mode 100644
index 0000000..4aa32e5
--- /dev/null
+++ b/src/main/java/org/apache/sling/fscontentparser/ContentFileParser.java
@@ -0,0 +1,50 @@
+/*
+ * 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.fscontentparser;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Map;
+
+/**
+ * Parses repository content from a file.
+ * Implementations have to be thread-safe.
+ */
+public interface ContentFileParser {
+
+    /**
+     * Parse content file.
+     * @param file File
+     * @return Content
+     * @throws IOException When I/O error occurs.
+     * @throws ParseException When parsing error occurs.
+     */
+    Map<String,Object> parse(File file) throws IOException, ParseException;
+    
+    /**
+     * Parse content file.
+     * @param file File
+     * @return Content
+     * @throws IOException When I/O error occurs.
+     * @throws ParseException When parsing error occurs.
+     */
+    Map<String,Object> parse(InputStream is) throws IOException, ParseException;
+
+}
diff --git a/src/main/java/org/apache/sling/fscontentparser/ContentFileParserFactory.java b/src/main/java/org/apache/sling/fscontentparser/ContentFileParserFactory.java
new file mode 100644
index 0000000..d4ebe95
--- /dev/null
+++ b/src/main/java/org/apache/sling/fscontentparser/ContentFileParserFactory.java
@@ -0,0 +1,59 @@
+/*
+ * 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.fscontentparser;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.sling.fscontentparser.impl.JcrXmlContentFileParser;
+import org.apache.sling.fscontentparser.impl.JsonContentFileParser;
+
+/**
+ * Factory for content file parsers.
+ */
+public final class ContentFileParserFactory {
+
+    private ContentFileParserFactory() {
+        // static methods only
+    }
+    
+    /**
+     * Create content file parser.
+     * @param fileExtension File extension from {@link ContentFileExtension}.
+     * @return Content file parser
+     */
+    public static ContentFileParser create(String fileExtension) {
+        return create(fileExtension, new ParserOptions());
+    }
+    
+    /**
+     * Create content file parser.
+     * @param fileExtension File extension from {@link ContentFileExtension}.
+     * @param options Parser options
+     * @return Content file parser
+     */
+    public static ContentFileParser create(String fileExtension, ParserOptions options) {
+        if (StringUtils.equals(fileExtension, ContentFileExtension.JSON)) {
+            return new JsonContentFileParser(options);
+        }
+        else if (StringUtils.equals(fileExtension, ContentFileExtension.JCR_XML)) {
+            return new JcrXmlContentFileParser(options);
+        }
+        throw new IllegalArgumentException("Unsupported file extension: " + fileExtension);
+    }
+    
+}
diff --git a/src/main/java/org/apache/sling/fscontentparser/ParseException.java b/src/main/java/org/apache/sling/fscontentparser/ParseException.java
new file mode 100644
index 0000000..13bdab1
--- /dev/null
+++ b/src/main/java/org/apache/sling/fscontentparser/ParseException.java
@@ -0,0 +1,42 @@
+/*
+ * 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.fscontentparser;
+
+/**
+ * Parsing exception.
+ */
+public final class ParseException extends RuntimeException {
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * @param message Message
+     */
+    public ParseException(String message) {
+        super(message);
+    }
+    
+    /**
+     * @param message Message
+     * @param cause Cause
+     */
+    public ParseException(String message, Throwable cause) {
+        super(message, cause);
+    }
+    
+}
diff --git a/src/main/java/org/apache/sling/fscontentparser/ParserOptions.java b/src/main/java/org/apache/sling/fscontentparser/ParserOptions.java
new file mode 100644
index 0000000..9f5fbcb
--- /dev/null
+++ b/src/main/java/org/apache/sling/fscontentparser/ParserOptions.java
@@ -0,0 +1,116 @@
+/*
+ * 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.fscontentparser;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Options for content filer parser.
+ */
+public final class ParserOptions {
+    
+    /**
+     * Default primary type.
+     */
+    public static final String DEFAULT_PRIMARY_TYPE = "nt:unstructured";
+
+    /**
+     * Default list of prefixes to remove from property names.
+     */
+    public static final Set<String> DEFAULT_REMOVE_PROPERTY_NAME_PREFIXES
+            = Collections.unmodifiableSet(new HashSet<>(Arrays.asList("jcr:reference:", "jcr:path:")));
+    
+    private String defaultPrimaryType = DEFAULT_PRIMARY_TYPE;
+    private boolean detectCalendarValues;
+    private Set<String> ignorePropertyNames;
+    private Set<String> ignoreResourceNames;
+    private Set<String> removePropertyNamePrefixes = DEFAULT_REMOVE_PROPERTY_NAME_PREFIXES;
+    
+    /**
+     * Default "jcr:primaryType" property for resources that have no explicit value for this value.
+     * If set to null, not default type is applied.
+     * @param value Default primary type.
+     * @return this
+     */
+    public ParserOptions defaultPrimaryType(String value) {
+        this.defaultPrimaryType = value;
+        return this;
+    }
+    public String getDefaultPrimaryType() {
+        return defaultPrimaryType;
+    }
+
+    /**
+     * Some content file formats like JSON do not contain information to identify date/time values.
+     * Instead they have to be detected by heuristics by trying to parse every string value.
+     * This mode is disabled by default.
+     * @param value Activate calendar value detection
+     * @return this
+     */
+    public ParserOptions detectCalendarValues(boolean value) {
+        this.detectCalendarValues = value;
+        return this;
+    }
+    public boolean isDetectCalendarValues() {
+        return detectCalendarValues;
+    }
+
+    /**
+     * Set a list of property names that should be ignored when parsing the content file.
+     * @param value List of property names 
+     * @return this
+     */
+    public ParserOptions ignorePropertyNames(Set<String> value) {
+        this.ignorePropertyNames = value;
+        return this;
+    }
+    public Set<String> getIgnorePropertyNames() {
+        return ignorePropertyNames;
+    }
+
+    /**
+     * Set a list of resource/node names that should be ignored when parsing the content file.
+     * @param value List of resource/node names
+     * @return this
+     */
+    public ParserOptions ignoreResourceNames(Set<String> value) {
+        this.ignoreResourceNames = value;
+        return this;
+    }
+    public Set<String> getIgnoreResourceNames() {
+        return ignoreResourceNames;
+    }
+
+    /**
+     * Set a list of property name prefixes that should be removed automatically from the property name. 
+     * @param value List of property name prefixes
+     * @return this
+     */
+    public ParserOptions removePropertyNamePrefixes(Set<String> value) {
+        this.removePropertyNamePrefixes = value;
+        return this;
+    }
+    public Set<String> getRemovePropertyNamePrefixes() {
+        return removePropertyNamePrefixes;
+    }
+    
+}
diff --git a/src/main/java/org/apache/sling/fscontentparser/impl/JcrXmlContentFileParser.java b/src/main/java/org/apache/sling/fscontentparser/impl/JcrXmlContentFileParser.java
new file mode 100644
index 0000000..060308e
--- /dev/null
+++ b/src/main/java/org/apache/sling/fscontentparser/impl/JcrXmlContentFileParser.java
@@ -0,0 +1,159 @@
+/*
+ * 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.fscontentparser.impl;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Stack;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.apache.jackrabbit.util.ISO9075;
+import org.apache.sling.fscontentparser.ContentFileParser;
+import org.apache.sling.fscontentparser.ParseException;
+import org.apache.sling.fscontentparser.ParserOptions;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.helpers.DefaultHandler;
+
+/**
+ * Parses JCR XML files that contains content fragments.
+ * Instance of this class is thread-safe.
+ */
+public final class JcrXmlContentFileParser implements ContentFileParser {
+    
+    private final ParserHelper helper;    
+    private final SAXParserFactory saxParserFactory;
+    
+    public JcrXmlContentFileParser(ParserOptions options) {
+        this.helper = new ParserHelper(options);
+        saxParserFactory = SAXParserFactory.newInstance();
+        saxParserFactory.setNamespaceAware(true);
+    }
+    
+    @Override
+    public Map<String,Object> parse(File file) throws IOException, ParseException {
+        try (FileInputStream fis = new FileInputStream(file)) {
+            return parse(fis);
+        }
+    }
+    
+    @Override
+    public Map<String,Object> parse(InputStream is) throws IOException, ParseException {
+        try {
+            XmlHandler xmlHandler = new XmlHandler();
+            SAXParser parser = saxParserFactory.newSAXParser();
+            parser.parse(is, xmlHandler);
+            if (xmlHandler.hasError()) {
+                throw xmlHandler.getError();
+            }
+            return xmlHandler.getContent();
+        }
+        catch (ParserConfigurationException | SAXException ex) {
+            throw new ParseException("Error parsing JCR XML content.", ex);
+        }
+    }
+    
+    /**
+     * Decodes element or attribute names.
+     * @param qname qname
+     * @return Decoded name
+     */
+    static String decodeName(String qname) {
+        return ISO9075.decode(qname);
+    }
+    
+    /**
+     * Parses XML stream to Map.
+     */
+    class XmlHandler extends DefaultHandler {
+        private final Map<String,Object> content = new LinkedHashMap<>();
+        private final Stack<Map<String,Object>> elements = new Stack<>();
+        private SAXParseException error;
+        
+        public Map<String,Object> getContent() {
+            return content;
+        }
+        
+        public boolean hasError() {
+            return error != null;
+        }
+        
+        public SAXParseException getError() {
+            return error;
+        }
+
+        @Override
+        public void startElement(String uri, String localName, String qName, Attributes attributes)
+                throws SAXException {
+            
+            // prepare map for element
+            Map<String,Object> element;
+            if (elements.isEmpty()) {
+                element = content;
+            }
+            else {
+                element = new HashMap<>();
+                String resourceName = decodeName(qName);
+                if (!helper.ignoreResource(resourceName)) {
+                    elements.peek().put(resourceName, element);
+                }
+            }
+            elements.push(element);
+            
+            // get attributes
+            for (int i=0; i<attributes.getLength(); i++) {
+                String propertyName = helper.cleanupPropertyName(decodeName(attributes.getQName(i)));
+                if (!helper.ignoreProperty(propertyName)) {
+                    Object value = JcrXmlValueConverter.parseValue(attributes.getValue(i));
+                    if (value instanceof Object[]) {
+                        value = helper.convertSingleTypeArray((Object[])value);
+                    }
+                    element.put(propertyName, value);
+                }
+            }
+        }
+
+        @Override
+        public void endElement(String uri, String localName, String qName) throws SAXException {
+            Map<String,Object> element = elements.pop();
+            helper.ensureDefaultPrimaryType(element);
+        }
+
+        @Override
+        public void error(SAXParseException ex) throws SAXException {
+            this.error = ex;
+        }
+
+        @Override
+        public void fatalError(SAXParseException ex) throws SAXException {
+            this.error = ex;
+        }
+        
+    }
+    
+}
diff --git a/src/main/java/org/apache/sling/fscontentparser/impl/JcrXmlValueConverter.java b/src/main/java/org/apache/sling/fscontentparser/impl/JcrXmlValueConverter.java
new file mode 100644
index 0000000..b3a817e
--- /dev/null
+++ b/src/main/java/org/apache/sling/fscontentparser/impl/JcrXmlValueConverter.java
@@ -0,0 +1,168 @@
+/*
+ * 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.fscontentparser.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.commons.lang3.ArrayUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.jackrabbit.util.ISO8601;
+
+/**
+ * Parses JCR XML files that contains content fragments.
+ */
+class JcrXmlValueConverter {
+    
+    private static final Pattern TYPE_PREFIX = Pattern.compile("^\\{([^\\{\\}]+)\\}(.+)$");
+    private static final Pattern VALUE_ARRAY = Pattern.compile("^\\[(.*)\\]$");
+    
+    private JcrXmlValueConverter() {
+        // static methods only
+    }
+    
+    /**
+     * Parse JSON value from XML Attribute.
+     * @param value XML attribute value
+     * @return Value object
+     */
+    public static Object parseValue(final String rawValue) {
+        String value = rawValue;
+        String[] valueArray = null;
+        
+        if (rawValue == null) {
+            return null;
+        }
+        
+        // detect type prefix
+        String typePrefix = null;
+        Matcher typePrefixMatcher = TYPE_PREFIX.matcher(value);
+        if (typePrefixMatcher.matches()) {
+            typePrefix = typePrefixMatcher.group(1);
+            value = typePrefixMatcher.group(2);
+        }
+        
+        // check for array
+        Matcher arrayMatcher = VALUE_ARRAY.matcher(value);
+        if (arrayMatcher.matches()) {
+            value = null;
+            valueArray = splitPreserveAllTokens(arrayMatcher.group(1), ',');
+        }
+
+        // convert values
+        if (valueArray != null) {
+            Object[] result = new Object[valueArray.length];
+            for (int i=0; i<valueArray.length; i++) {
+                result[i] = convertValue(valueArray[i], typePrefix, true);
+            }
+            return result;
+        }
+        else {
+            return convertValue(value, typePrefix, false);
+        }
+    }
+    
+    /**
+     * Split string preserving all tokens - but ignore separators that are escaped with \.
+     * @param str Combined string
+     * @param sep Separator
+     * @return Tokens
+     */
+    private static String[] splitPreserveAllTokens(String str, char sep) {
+        final int len = str.length();
+        if (len == 0) {
+            return ArrayUtils.EMPTY_STRING_ARRAY;
+        }
+        final List<String> list = new ArrayList<String>();
+        int i = 0, start = 0;
+        boolean match = false;
+        boolean lastMatch = false;
+        boolean escaped = false;
+        while (i < len) {
+            if (str.charAt(i) == '\\' && !escaped) {
+                escaped = true;
+            }
+            else {
+                if (str.charAt(i) == sep && !escaped) {
+                    lastMatch = true;
+                    list.add(str.substring(start, i));
+                    match = false;
+                    start = ++i;
+                    continue;
+                }
+                lastMatch = false;
+                match = true;
+                escaped = false;
+            }
+            i++;
+        }
+        if (match || lastMatch) {
+            list.add(str.substring(start, i));
+        }
+        return list.toArray(new String[list.size()]);        
+    }
+    
+    /**
+     * Parse value depending on type prefix.
+     * @param value Value
+     * @param typePrefix Type prefix
+     * @param inArray Value is in array
+     * @return Value object
+     */
+    private static Object convertValue(final String value, final String typePrefix, final boolean inArray) {
+        if (typePrefix == null || StringUtils.equals(typePrefix, "Name")) {
+            return deescapeStringValue(value, inArray);
+        }
+        else if (StringUtils.equals(typePrefix, "Boolean")) {
+            return Boolean.valueOf(value);
+        }
+        else if (StringUtils.equals(typePrefix, "Long")) {
+            return Long.valueOf(value);
+        }
+        else if (StringUtils.equals(typePrefix, "Decimal")) {
+            return Double.valueOf(value);
+        }
+        else if (StringUtils.equals(typePrefix, "Date")) {
+            return ISO8601.parse(value);
+        }
+        else {
+            throw new IllegalArgumentException("Unexpected type prefix: " + typePrefix);
+        }
+    }
+    
+    /**
+     * De-escape string value.
+     * @param value Escaped string value
+     * @param inArray In array
+     * @return De-escaped string value
+     */
+    private static String deescapeStringValue(final String value, final boolean inArray) {
+        String descapedValue = value;
+        if (inArray) {
+          descapedValue = StringUtils.replace(descapedValue, "\\,", ",");
+        }
+        else if (StringUtils.startsWith(descapedValue, "\\{") || StringUtils.startsWith(descapedValue, "\\[")) {
+            descapedValue = descapedValue.substring(1);
+        }
+        return StringUtils.replace(descapedValue, "\\\\", "\\");
+    }
+        
+}
diff --git a/src/main/java/org/apache/sling/fscontentparser/impl/JsonContentFileParser.java b/src/main/java/org/apache/sling/fscontentparser/impl/JsonContentFileParser.java
new file mode 100644
index 0000000..47b3c18
--- /dev/null
+++ b/src/main/java/org/apache/sling/fscontentparser/impl/JsonContentFileParser.java
@@ -0,0 +1,138 @@
+/*
+ * 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.fscontentparser.impl;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Calendar;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import javax.json.Json;
+import javax.json.JsonArray;
+import javax.json.JsonNumber;
+import javax.json.JsonObject;
+import javax.json.JsonReader;
+import javax.json.JsonReaderFactory;
+import javax.json.JsonString;
+import javax.json.JsonValue;
+import javax.json.stream.JsonParsingException;
+
+import org.apache.sling.fscontentparser.ContentFileParser;
+import org.apache.sling.fscontentparser.ParseException;
+import org.apache.sling.fscontentparser.ParserOptions;
+
+/**
+ * Parses JSON files that contains content fragments.
+ * Instance of this class is thread-safe.
+ */
+public final class JsonContentFileParser implements ContentFileParser {
+    
+    private final ParserHelper helper;    
+    private final JsonReaderFactory jsonReaderFactory;
+    
+    public JsonContentFileParser(ParserOptions options) {
+        this.helper = new ParserHelper(options);
+        // allow comments in JSON files
+        Map<String,Object> jsonReaderFactoryConfig = new HashMap<>();
+        jsonReaderFactoryConfig.put("org.apache.johnzon.supports-comments", true);
+        jsonReaderFactory = Json.createReaderFactory(jsonReaderFactoryConfig);
+    }
+    
+    @Override
+    public Map<String,Object> parse(File file) throws IOException, ParseException {
+        try (FileInputStream fis = new FileInputStream(file)) {
+            return parse(fis);
+        }
+    }
+    
+    @Override
+    public Map<String,Object> parse(InputStream is) throws IOException, ParseException {
+        try (JsonReader reader = jsonReaderFactory.createReader(is)) {
+            return toMap(reader.readObject());
+        }
+        catch (JsonParsingException ex) {
+            throw new ParseException("Error parsing JSON content.", ex);
+        }
+    }
+    
+    private Map<String,Object> toMap(JsonObject object) {
+        Map<String,Object> map = new LinkedHashMap<>();
+        for (Map.Entry<String, JsonValue> entry : object.entrySet()) {
+            String childName = entry.getKey();
+            Object value = convertValue(entry.getValue());
+            boolean ignore = false;
+            if (value instanceof Map) {
+                ignore = helper.ignoreResource(childName);
+            }
+            else {
+                childName = helper.cleanupPropertyName(childName);
+                ignore = helper.ignoreProperty(childName);
+            }
+            if (!ignore) {
+                map.put(childName, value);
+            }
+        }
+        helper.ensureDefaultPrimaryType(map);
+        return map;
+    }
+    
+    private Object convertValue(JsonValue value) {
+        switch (value.getValueType()) {
+            case STRING:
+                String stringValue = ((JsonString)value).getString();
+                Calendar calendarValue = helper.tryParseCalendar(stringValue);
+                if (calendarValue != null) {
+                    return calendarValue;
+                }
+                else {
+                    return stringValue;
+                }
+            case NUMBER:
+                JsonNumber numberValue = (JsonNumber)value;
+                if (numberValue.isIntegral()) {
+                    return numberValue.longValue();
+                }
+                else {
+                    return numberValue.doubleValue();
+                }
+            case TRUE:
+                return true;
+            case FALSE:
+                return false;
+            case NULL:
+                return null;
+            case ARRAY:
+                JsonArray arrayValue = (JsonArray)value;
+                Object[] values = new Object[arrayValue.size()];
+                for (int i=0; i<values.length; i++) {
+                    values[i] = convertValue(arrayValue.get(i));
+                }
+                return helper.convertSingleTypeArray(values);
+            case OBJECT:
+                return toMap((JsonObject)value);
+            default:
+                throw new ParseException("Unexpected JSON value type: " + value.getValueType());
+        }
+    }
+    
+}
diff --git a/src/main/java/org/apache/sling/fscontentparser/impl/ParserHelper.java b/src/main/java/org/apache/sling/fscontentparser/impl/ParserHelper.java
new file mode 100644
index 0000000..0f54015
--- /dev/null
+++ b/src/main/java/org/apache/sling/fscontentparser/impl/ParserHelper.java
@@ -0,0 +1,134 @@
+/*
+ * 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.fscontentparser.impl;
+
+import java.lang.reflect.Array;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.sling.fscontentparser.ParseException;
+import org.apache.sling.fscontentparser.ParserOptions;
+
+/**
+ * Helper parsing logic based on parser options.
+ */
+class ParserHelper {
+
+    static final String JCR_PRIMARYTYPE = "jcr:primaryType";
+
+    static final String ECMA_DATE_FORMAT = "EEE MMM dd yyyy HH:mm:ss 'GMT'Z";
+    static final Locale DATE_FORMAT_LOCALE = Locale.US;
+
+    private final ParserOptions options;
+    private final DateFormat calendarFormat;
+
+    public ParserHelper(ParserOptions options) {
+        this.options = options;
+        if (options.isDetectCalendarValues()) {
+            this.calendarFormat = new SimpleDateFormat(ECMA_DATE_FORMAT, DATE_FORMAT_LOCALE);
+        }
+        else {
+            this.calendarFormat = null;
+        }
+    }
+
+    public void ensureDefaultPrimaryType(Map<String, Object> map) {
+        String defaultPrimaryType = options.getDefaultPrimaryType();
+        if (defaultPrimaryType != null) {
+            if (!map.containsKey(JCR_PRIMARYTYPE)) {
+                map.put(JCR_PRIMARYTYPE, defaultPrimaryType);
+            }
+        }
+    }
+
+    public Calendar tryParseCalendar(String value) {
+        if (options.isDetectCalendarValues() && !StringUtils.isBlank(value)) {
+            synchronized (calendarFormat) {
+                try {
+                    Date date = calendarFormat.parse(value);
+                    Calendar calendar = Calendar.getInstance();
+                    calendar.setTime(date);
+                    return calendar;
+                }
+                catch (java.text.ParseException ex) {
+                    // ignore
+                }
+            }
+        }
+        return null;
+    }
+    
+    public boolean ignoreProperty(String propertyName) {
+        return ignoreNames(options.getIgnorePropertyNames(), propertyName);
+    }
+    
+    public boolean ignoreResource(String resourceName) {
+        return ignoreNames(options.getIgnoreResourceNames(), resourceName);
+    }
+    
+    private boolean ignoreNames(Set<String> names, String name) {
+        return names != null && names.contains(name);
+    }
+
+    public String cleanupPropertyName(String propertyName) {
+        Set<String> prefixes = options.getRemovePropertyNamePrefixes();
+        if (prefixes != null) {
+            for (String prefix : prefixes) {
+                if (StringUtils.startsWith(propertyName, prefix)) {
+                    return StringUtils.substringAfter(propertyName, prefix);
+                  }
+            }
+        }
+        return propertyName;
+    }
+    
+    public Object convertSingleTypeArray(Object[] values) {
+        if (values.length == 0) {
+            return values;
+        }
+        Class<?> itemType = null;
+        for (Object value : values) {
+            if (value == null) {
+                throw new ParseException("Multivalue array must not contain null values.");
+            }
+            if (value instanceof Map) {
+                throw new ParseException("Multivalue array must not contain maps/objects.");
+            }
+            if (itemType == null) {
+                itemType = value.getClass();
+            }
+            else if (itemType != value.getClass()) {
+                throw new ParseException("Multivalue array must not contain values with different types "
+                        + "(" + itemType.getName() + ", " + value.getClass().getName() + ").");
+            }
+        }
+        Object convertedArray = Array.newInstance(itemType, values.length);
+        for (int i=0; i<values.length; i++) {
+            Array.set(convertedArray, i, values[i]);
+        }
+        return convertedArray;
+    }
+    
+}
diff --git a/src/main/java/org/apache/sling/fscontentparser/package-info.java b/src/main/java/org/apache/sling/fscontentparser/package-info.java
new file mode 100644
index 0000000..4179ffd
--- /dev/null
+++ b/src/main/java/org/apache/sling/fscontentparser/package-info.java
@@ -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.
+ */
+/**
+ * Parser for repository content stored in files (e.g. JSON, JCR XML).
+ */
+@org.osgi.annotation.versioning.Version("1.0.0")
+package org.apache.sling.fscontentparser;
diff --git a/src/test/java/org/apache/sling/fscontentparser/impl/JcrXmlContentFileParserTest.java b/src/test/java/org/apache/sling/fscontentparser/impl/JcrXmlContentFileParserTest.java
new file mode 100644
index 0000000..78f02c8
--- /dev/null
+++ b/src/test/java/org/apache/sling/fscontentparser/impl/JcrXmlContentFileParserTest.java
@@ -0,0 +1,117 @@
+/*
+ * 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.fscontentparser.impl;
+
+import static org.apache.sling.fscontentparser.impl.TestUtils.getDeep;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import java.io.File;
+import java.util.Calendar;
+import java.util.Map;
+import java.util.TimeZone;
+
+import org.apache.jackrabbit.util.ISO9075;
+import org.apache.sling.fscontentparser.ContentFileExtension;
+import org.apache.sling.fscontentparser.ContentFileParser;
+import org.apache.sling.fscontentparser.ContentFileParserFactory;
+import org.apache.sling.fscontentparser.ParseException;
+import org.apache.sling.fscontentparser.ParserOptions;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.google.common.collect.ImmutableSet;
+
+public class JcrXmlContentFileParserTest {
+
+    private File file;
+
+    @Before
+    public void setUp() throws Exception {
+        file = new File("src/test/resources/content-test/content.jcr.xml");
+    }
+
+    @SuppressWarnings("unchecked")
+    @Test
+    public void testParseJcrXml() throws Exception {
+        ContentFileParser underTest = ContentFileParserFactory.create(ContentFileExtension.JCR_XML);
+        Map<String,Object> content = underTest.parse(file);
+        assertNotNull(content);
+        assertEquals("app:Page", content.get("jcr:primaryType"));
+        assertEquals("app:PageContent", ((Map<String,Object>)content.get("jcr:content")).get("jcr:primaryType"));
+    }
+
+    @Test(expected=ParseException.class)
+    public void testParseInvalidJcrXml() throws Exception {
+        file = new File("src/test/resources/invalid-test/invalid.jcr.xml");
+        ContentFileParser underTest = ContentFileParserFactory.create(ContentFileExtension.JCR_XML);
+        underTest.parse(file);
+    }
+
+    @Test
+    public void testDataTypes() throws Exception {
+        ContentFileParser underTest = ContentFileParserFactory.create(ContentFileExtension.JCR_XML);
+        Map<String,Object> content = underTest.parse(file);
+        Map<String,Object> props = getDeep(content, "jcr:content");
+        
+        assertEquals("en", props.get("jcr:title"));
+        assertEquals(true, props.get("includeAside"));
+        assertEquals((Long)1234567890123L, props.get("longProp"));
+        assertEquals((Double)1.2345d, (Double)props.get("decimalProp"), 0.00001d);
+        
+        assertArrayEquals(new String[] { "aa", "bb", "cc" }, (String[])props.get("stringPropMulti"));
+        assertArrayEquals(new Long[] { 1234567890123L, 55L }, (Long[])props.get("longPropMulti"));
+        
+        Calendar calendar = (Calendar)props.get("dateProp");
+        calendar.setTimeZone(TimeZone.getTimeZone("GMT+2"));
+        assertEquals(2014, calendar.get(Calendar.YEAR));
+        assertEquals(9, calendar.get(Calendar.MONTH) + 1);
+        assertEquals(19, calendar.get(Calendar.DAY_OF_MONTH));
+        assertEquals(21, calendar.get(Calendar.HOUR_OF_DAY));
+        assertEquals(20, calendar.get(Calendar.MINUTE));
+        assertEquals(26, calendar.get(Calendar.SECOND));
+        assertEquals(812, calendar.get(Calendar.MILLISECOND));
+    }
+
+    @Test
+    public void testDecodeName() {
+        assertEquals("jcr:title", JcrXmlContentFileParser.decodeName("jcr:" + ISO9075.encode("title")));
+        assertEquals("sling:123", JcrXmlContentFileParser.decodeName("sling:" + ISO9075.encode("123")));
+    }
+
+    @Test
+    public void testIgnoreResourcesProperties() throws Exception {
+        ContentFileParser underTest = ContentFileParserFactory.create(ContentFileExtension.JCR_XML, new ParserOptions()
+                .ignoreResourceNames(ImmutableSet.of("teaserbar", "aside"))
+                .ignorePropertyNames(ImmutableSet.of("longProp", "jcr:title")));
+        Map<String,Object> content = underTest.parse(file);
+        Map<String,Object> props = getDeep(content, "jcr:content");
+        
+        assertEquals("HOME", props.get("navTitle"));
+        assertNull(props.get("jcr:title"));
+        assertNull(props.get("longProp"));
+        
+        assertNull(props.get("teaserbar"));
+        assertNull(props.get("aside"));
+        assertNotNull(props.get("content"));
+    }
+
+}
diff --git a/src/test/java/org/apache/sling/fscontentparser/impl/JcrXmlValueConverterTest.java b/src/test/java/org/apache/sling/fscontentparser/impl/JcrXmlValueConverterTest.java
new file mode 100644
index 0000000..bddf053
--- /dev/null
+++ b/src/test/java/org/apache/sling/fscontentparser/impl/JcrXmlValueConverterTest.java
@@ -0,0 +1,105 @@
+/*
+ * 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.fscontentparser.impl;
+
+import static org.apache.sling.fscontentparser.impl.JcrXmlValueConverter.parseValue;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import java.util.Calendar;
+
+import org.junit.Test;
+
+public class JcrXmlValueConverterTest {
+
+    @Test
+    public void testNull() {
+        assertNull(parseValue(null));
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void testInvalid() {
+        parseValue("{InvalidType}xyz");
+    }
+
+    @Test
+    public void testString() {
+        assertEquals("myString", parseValue("myString"));
+        assertEquals("prop", "myString [ ] { } \\ ,", parseValue("myString [ ] { } \\\\ ,"));
+        assertEquals("{myString}", parseValue("\\{myString}"));
+        assertEquals("aaa{myString}", parseValue("aaa{myString}"));
+        assertEquals("[myString]", parseValue("\\[myString]"));
+        assertEquals("aaa[myString]", parseValue("aaa[myString]"));
+    }
+
+    @Test
+    public void testStringArray() {
+        assertArrayEquals(new Object[] { "myString1", "myString2" }, (Object[]) parseValue("[myString1,myString2]"));
+        assertArrayEquals(new Object[] { "myString1,[]\\äöü߀", "myString2", "myString3 [ ] { } \\ ,", "", "[myString5]", "{myString6}" },
+                (Object[]) parseValue("[myString1\\,[]\\\\äöü߀,myString2,myString3 [ ] { } \\\\ \\,,,[myString5],{myString6}]"));
+    }
+
+    @Test
+    public void testBoolean() {
+        assertEquals(true, parseValue("{Boolean}true"));
+        assertEquals(false, parseValue("{Boolean}false"));
+    }
+
+    @Test
+    public void testBooleanArray() {
+        assertArrayEquals(new Object[] { true, false }, (Object[]) parseValue("{Boolean}[true,false]"));
+    }
+
+    @Test
+    public void testLong() {
+        assertEquals(1L, parseValue("{Long}1"));
+        assertEquals(10000000000L, parseValue("{Long}10000000000"));
+    }
+
+    @Test
+    public void testLongArray() {
+        assertArrayEquals(new Object[] { 1L, 2L }, (Object[]) parseValue("{Long}[1,2]"));
+        assertArrayEquals(new Object[] { 10000000000L, 20000000000L }, (Object[]) parseValue("{Long}[10000000000,20000000000]"));
+    }
+
+    @Test
+    public void testDouble() {
+        assertEquals(1.234d, parseValue("{Decimal}1.234"));
+    }
+
+    @Test
+    public void testDoubleArray() {
+        assertArrayEquals(new Object[] { 1.234d, 2.345d }, (Object[]) parseValue("{Decimal}[1.234,2.345]"));
+    }
+
+    @Test
+    public void testCalendar() {
+        Calendar value = (Calendar)parseValue("{Date}2010-09-05T15:10:20.000Z");
+        assertEquals(2010, value.get(Calendar.YEAR));
+        assertEquals(8, value.get(Calendar.MONTH));
+        assertEquals(5, value.get(Calendar.DAY_OF_MONTH));
+    }
+
+    @Test
+    public void testStringArrayRepPrivileges() {
+        assertArrayEquals(new Object[] { "rep:write", "crx:replicate", "jcr:read" }, (Object[]) parseValue("{Name}[rep:write,crx:replicate,jcr:read]"));
+    }
+
+}
diff --git a/src/test/java/org/apache/sling/fscontentparser/impl/JsonContentFileParserTest.java b/src/test/java/org/apache/sling/fscontentparser/impl/JsonContentFileParserTest.java
new file mode 100644
index 0000000..175e3bf
--- /dev/null
+++ b/src/test/java/org/apache/sling/fscontentparser/impl/JsonContentFileParserTest.java
@@ -0,0 +1,152 @@
+/*
+ * 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.fscontentparser.impl;
+
+import static org.apache.sling.fscontentparser.impl.TestUtils.getDeep;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import java.io.File;
+import java.util.Calendar;
+import java.util.Map;
+import java.util.TimeZone;
+
+import org.apache.sling.fscontentparser.ContentFileExtension;
+import org.apache.sling.fscontentparser.ContentFileParser;
+import org.apache.sling.fscontentparser.ContentFileParserFactory;
+import org.apache.sling.fscontentparser.ParseException;
+import org.apache.sling.fscontentparser.ParserOptions;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.google.common.collect.ImmutableSet;
+
+public class JsonContentFileParserTest {
+
+    private File file;
+
+    @Before
+    public void setUp() {
+        file = new File("src/test/resources/content-test/content.json");
+    }
+
+    @Test
+    public void testPageJcrPrimaryType() throws Exception {
+        ContentFileParser underTest = ContentFileParserFactory.create(ContentFileExtension.JSON);
+        Map<String, Object> content = underTest.parse(file);
+
+        assertEquals("app:Page", content.get("jcr:primaryType"));
+    }
+
+    @Test
+    public void testDataTypes() throws Exception {
+        ContentFileParser underTest = ContentFileParserFactory.create(ContentFileExtension.JSON);
+        Map<String, Object> content = underTest.parse(file);
+
+        Map<String, Object> props = getDeep(content, "toolbar/profiles/jcr:content");
+        assertEquals(true, props.get("hideInNav"));
+
+        assertEquals(1234567890123L, props.get("longProp"));
+        assertEquals(1.2345d, (Double) props.get("decimalProp"), 0.00001d);
+        assertEquals(true, props.get("booleanProp"));
+
+        assertArrayEquals(new Long[] { 1234567890123L, 55L }, (Long[]) props.get("longPropMulti"));
+        assertArrayEquals(new Double[] { 1.2345d, 1.1d }, (Double[]) props.get("decimalPropMulti"));
+        assertArrayEquals(new Boolean[] { true, false }, (Boolean[]) props.get("booleanPropMulti"));
+    }
+
+    @Test
+    public void testContentProperties() throws Exception {
+        ContentFileParser underTest = ContentFileParserFactory.create(ContentFileExtension.JSON);
+        Map<String, Object> content = underTest.parse(file);
+
+        Map<String, Object> props = getDeep(content, "jcr:content/header");
+        assertEquals("/content/dam/sample/header.png", props.get("imageReference"));
+    }
+
+    @Test
+    public void testCalendar() throws Exception {
+        ContentFileParser underTest = ContentFileParserFactory.create(ContentFileExtension.JSON,
+                new ParserOptions().detectCalendarValues(true));
+        Map<String, Object> content = underTest.parse(file);
+
+        Map<String, Object> props = getDeep(content, "jcr:content");
+
+        Calendar calendar = (Calendar) props.get("app:lastModified");
+        assertNotNull(calendar);
+
+        calendar.setTimeZone(TimeZone.getTimeZone("GMT+2"));
+
+        assertEquals(2014, calendar.get(Calendar.YEAR));
+        assertEquals(4, calendar.get(Calendar.MONTH) + 1);
+        assertEquals(22, calendar.get(Calendar.DAY_OF_MONTH));
+
+        assertEquals(15, calendar.get(Calendar.HOUR_OF_DAY));
+        assertEquals(11, calendar.get(Calendar.MINUTE));
+        assertEquals(24, calendar.get(Calendar.SECOND));
+    }
+
+    @Test
+    public void testUTF8Chars() throws Exception {
+        ContentFileParser underTest = ContentFileParserFactory.create(ContentFileExtension.JSON);
+        Map<String, Object> content = underTest.parse(file);
+
+        Map<String, Object> props = getDeep(content, "jcr:content");
+
+        assertEquals("äöü߀", props.get("utf8Property"));
+    }
+
+    @Test(expected = ParseException.class)
+    public void testParseInvalidJson() throws Exception {
+        file = new File("src/test/resources/invalid-test/invalid.json");
+        ContentFileParser underTest = ContentFileParserFactory.create(ContentFileExtension.JSON);
+        Map<String, Object> content = underTest.parse(file);
+        assertNull(content);
+    }
+
+    @Test(expected = ParseException.class)
+    public void testParseInvalidJsonWithObjectList() throws Exception {
+        file = new File("src/test/resources/invalid-test/contentWithObjectList.json");
+        ContentFileParser underTest = ContentFileParserFactory.create(ContentFileExtension.JSON);
+        Map<String, Object> content = underTest.parse(file);
+        assertNull(content);
+    }
+
+    @Test
+    public void testIgnoreResourcesProperties() throws Exception {
+        ContentFileParser underTest = ContentFileParserFactory.create(ContentFileExtension.JSON,
+                new ParserOptions().ignoreResourceNames(ImmutableSet.of("header", "newslist"))
+                        .ignorePropertyNames(ImmutableSet.of("jcr:title")));
+        Map<String, Object> content = underTest.parse(file);
+        Map<String, Object> props = getDeep(content, "jcr:content");
+
+        assertEquals("Sample Homepage", props.get("pageTitle"));
+        assertNull(props.get("jcr:title"));
+
+        assertNull(props.get("header"));
+        assertNull(props.get("newslist"));
+        assertNotNull(props.get("lead"));
+
+        assertEquals("abc", props.get("refpro1"));
+        assertEquals("def", props.get("pathprop1"));
+    }
+
+}
diff --git a/src/test/java/org/apache/sling/fscontentparser/impl/ParserHelperTest.java b/src/test/java/org/apache/sling/fscontentparser/impl/ParserHelperTest.java
new file mode 100644
index 0000000..a162a9a
--- /dev/null
+++ b/src/test/java/org/apache/sling/fscontentparser/impl/ParserHelperTest.java
@@ -0,0 +1,199 @@
+/*
+ * 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.fscontentparser.impl;
+
+import static org.apache.sling.fscontentparser.ParserOptions.DEFAULT_PRIMARY_TYPE;
+import static org.apache.sling.fscontentparser.impl.ParserHelper.JCR_PRIMARYTYPE;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Calendar;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.TimeZone;
+
+import org.apache.sling.fscontentparser.ParseException;
+import org.apache.sling.fscontentparser.ParserOptions;
+import org.junit.Test;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+
+public class ParserHelperTest {
+
+    @Test
+    public void testEnsureDefaultPrimaryType() {
+        Map<String,Object> content = new HashMap<>();
+        content.put("prop1", "value1");
+
+        ParserHelper underTest = new ParserHelper(new ParserOptions());
+        underTest.ensureDefaultPrimaryType(content);
+        
+        assertEquals(ImmutableMap.<String,Object>of("prop1", "value1", JCR_PRIMARYTYPE, DEFAULT_PRIMARY_TYPE), content);
+    }
+
+    @Test
+    public void testEnsureDefaultPrimaryType_Disabled() {
+        Map<String,Object> content = new HashMap<>();
+        content.put("prop1", "value1");
+
+        ParserHelper underTest = new ParserHelper(new ParserOptions().defaultPrimaryType(null));
+        underTest.ensureDefaultPrimaryType(content);
+        
+        assertEquals(ImmutableMap.<String,Object>of("prop1", "value1"), content);
+    }
+
+    @Test
+    public void testEnsureDefaultPrimaryType_AlreadySet() {
+        Map<String,Object> content = new HashMap<>();
+        content.put("prop1", "value1");
+        content.put(JCR_PRIMARYTYPE, "type1");
+
+        ParserHelper underTest = new ParserHelper(new ParserOptions());
+        underTest.ensureDefaultPrimaryType(content);
+        
+        assertEquals(ImmutableMap.<String,Object>of("prop1", "value1", JCR_PRIMARYTYPE, "type1"), content);
+    }
+
+    @Test
+    public void testTryParseCalendar() {
+        ParserHelper underTest = new ParserHelper(new ParserOptions().detectCalendarValues(true));
+        
+        Calendar value = underTest.tryParseCalendar("Tue Apr 22 2014 15:11:24 GMT+0200");
+        assertNotNull(value);
+
+        value.setTimeZone(TimeZone.getTimeZone("GMT+2"));
+
+        assertEquals(2014, value.get(Calendar.YEAR));
+        assertEquals(4, value.get(Calendar.MONTH) + 1);
+        assertEquals(22, value.get(Calendar.DAY_OF_MONTH));
+
+        assertEquals(15, value.get(Calendar.HOUR_OF_DAY));
+        assertEquals(11, value.get(Calendar.MINUTE));
+        assertEquals(24, value.get(Calendar.SECOND));
+    }
+
+    @Test
+    public void testTryParseCalendar_Invalid() {
+        ParserHelper underTest = new ParserHelper(new ParserOptions().detectCalendarValues(true));
+        
+        Calendar value = underTest.tryParseCalendar("hello world");
+        assertNull(value);
+
+        value = underTest.tryParseCalendar("");
+        assertNull(value);
+
+        value = underTest.tryParseCalendar(null);
+        assertNull(value);
+    }
+
+    @Test
+    public void testTryParseCalendar_Disabled() {
+        ParserHelper underTest = new ParserHelper(new ParserOptions());
+        
+        Calendar value = underTest.tryParseCalendar("Tue Apr 22 2014 15:11:24 GMT+0200");
+        assertNull(value);
+    }
+
+    @Test
+    public void testIgnoreProperty() {
+        ParserHelper underTest = new ParserHelper(new ParserOptions().ignorePropertyNames(ImmutableSet.of("prop1", "jcr:prop2")));
+        
+        assertTrue(underTest.ignoreProperty("prop1"));
+        assertTrue(underTest.ignoreProperty("jcr:prop2"));
+        assertFalse(underTest.ignoreProperty("prop3"));
+    }
+
+    @Test
+    public void testIgnoreProperty_Disabled() {
+        ParserHelper underTest = new ParserHelper(new ParserOptions());
+        
+        assertFalse(underTest.ignoreProperty("prop1"));
+        assertFalse(underTest.ignoreProperty("jcr:prop2"));
+        assertFalse(underTest.ignoreProperty("prop3"));
+    }
+
+    @Test
+    public void testIgnoreResource() {
+        ParserHelper underTest = new ParserHelper(new ParserOptions().ignoreResourceNames(ImmutableSet.of("node1", "jcr:node2")));
+        
+        assertTrue(underTest.ignoreResource("node1"));
+        assertTrue(underTest.ignoreResource("jcr:node2"));
+        assertFalse(underTest.ignoreResource("node3"));
+    }
+
+    @Test
+    public void testIgnoreResource_Disabled() {
+        ParserHelper underTest = new ParserHelper(new ParserOptions());
+        
+        assertFalse(underTest.ignoreResource("node1"));
+        assertFalse(underTest.ignoreResource("jcr:node2"));
+        assertFalse(underTest.ignoreResource("node3"));
+    }
+
+    @Test
+    public void testCleanupPropertyName() {
+        ParserHelper underTest = new ParserHelper(new ParserOptions());
+
+        assertEquals("prop1", underTest.cleanupPropertyName("jcr:reference:prop1"));
+        assertEquals("prop2", underTest.cleanupPropertyName("jcr:path:prop2"));
+        assertEquals("jcr:xyz:prop3", underTest.cleanupPropertyName("jcr:xyz:prop3"));
+    }
+
+    @Test
+    public void testCleanupPropertyName_Disabled() {
+        ParserHelper underTest = new ParserHelper(new ParserOptions().removePropertyNamePrefixes(null));
+
+        assertEquals("jcr:reference:prop1", underTest.cleanupPropertyName("jcr:reference:prop1"));
+        assertEquals("jcr:path:prop2", underTest.cleanupPropertyName("jcr:path:prop2"));
+        assertEquals("jcr:xyz:prop3", underTest.cleanupPropertyName("jcr:xyz:prop3"));
+    }
+
+    @Test
+    public void testConvertSingleTypeArray() {
+        ParserHelper underTest = new ParserHelper(new ParserOptions());
+
+        assertArrayEquals(new Object[0], (Object[])underTest.convertSingleTypeArray(new Object[0]));
+        assertArrayEquals(new String[] {"value1","value2"}, (String[])underTest.convertSingleTypeArray(new Object[] {"value1","value2"}));
+        assertArrayEquals(new Long[] {1L,2L}, (Long[])underTest.convertSingleTypeArray(new Object[] {1L,2L}));
+    }
+
+    @Test(expected=ParseException.class)
+    public void testConvertSingleTypeArray_WithNull() {
+        ParserHelper underTest = new ParserHelper(new ParserOptions());
+        underTest.convertSingleTypeArray(new Object[] {"value1",null});
+    }
+
+    @Test(expected=ParseException.class)
+    public void testConvertSingleTypeArray_Map() {
+        ParserHelper underTest = new ParserHelper(new ParserOptions());
+        underTest.convertSingleTypeArray(new Object[] {ImmutableMap.<String,Object>of("prop1", "value1")});
+    }
+
+    @Test(expected=ParseException.class)
+    public void testConvertSingleTypeArray_MixedType() {
+        ParserHelper underTest = new ParserHelper(new ParserOptions());
+        underTest.convertSingleTypeArray(new Object[] {"value1",1L});
+    }
+
+}
diff --git a/src/test/java/org/apache/sling/fscontentparser/impl/TestUtils.java b/src/test/java/org/apache/sling/fscontentparser/impl/TestUtils.java
new file mode 100644
index 0000000..eb416a7
--- /dev/null
+++ b/src/test/java/org/apache/sling/fscontentparser/impl/TestUtils.java
@@ -0,0 +1,48 @@
+/*
+ * 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.fscontentparser.impl;
+
+import java.util.Map;
+
+import org.apache.commons.lang3.StringUtils;
+
+public final class TestUtils {
+    
+    private TestUtils() {
+        // static methods only
+    }
+
+    @SuppressWarnings("unchecked")
+    public static Map<String, Object> getDeep(Map<String, Object> map, String path) {
+      String name = StringUtils.substringBefore(path, "/");
+      Object object = map.get(name);
+      if (object == null || !(object instanceof Map)) {
+        return null;
+      }
+      String remainingPath = StringUtils.substringAfter(path, "/");
+      Map<String, Object> childMap = (Map<String, Object>)object;
+      if (StringUtils.isEmpty(remainingPath)) {
+        return childMap;
+      }
+      else {
+        return getDeep(childMap, remainingPath);
+      }
+    }
+    
+}
diff --git a/src/test/resources/content-test/content.jcr.xml b/src/test/resources/content-test/content.jcr.xml
new file mode 100644
index 0000000..274cfe7
--- /dev/null
+++ b/src/test/resources/content-test/content.jcr.xml
@@ -0,0 +1,193 @@
+<?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:app="http://sample.com/jcr/app/1.0" xmlns:mix="http://www.jcp.org/jcr/mix/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0" xmlns:sling="http://sling.apache.org/jcr/sling/1.0"
+    jcr:primaryType="app:Page">
+  <jcr:content
+      jcr:primaryType="app:PageContent"
+      jcr:title="en"
+      sling:resourceType="samples/sample-app/components/content/page/homepage"
+      includeAside="{Boolean}true"
+      includeAsideBar="{Boolean}true"
+      includeTeaserBar="{Boolean}true"
+      includeTeaserbar="{Boolean}true"
+      inheritAside="{Boolean}false"
+      inheritTeaserbar="{Boolean}false"
+      longProp="{Long}1234567890123"
+      decimalProp="{Decimal}1.2345"
+      longPropMulti="{Long}[1234567890123,55]"
+      stringPropMulti="[aa,bb,cc]"
+      dateProp="{Date}2014-09-19T21:20:26.812+02:00"
+      navTitle="HOME"
+      pageTitle="Sample Site">
+    <teaserbar
+        jcr:primaryType="nt:unstructured"
+        sling:resourceType="samples/sample-app/components/content/teaserbar/teaserbarParsys">
+      <teaserbaritem
+          jcr:primaryType="nt:unstructured"
+          sling:resourceType="samples/sample-app/components/content/teaserbar/teaserbarItem"
+          linkContentRef="/content/samples/en/conference"
+          linkMediaDownload="{Boolean}false"
+          linkTitle="This should help you with your decision"
+          linkType="internal"
+          linkWindowFeatures="default"
+          linkWindowTarget="_self"
+          mediaRef="/content/dam/samples/content/user.png"
+          teaserContent="Still not convinced to attend? Need persuasion? Facts for your boss?"
+          title="Why to attend" />
+      <teaserbaritem_0
+          jcr:primaryType="nt:unstructured"
+          sling:resourceType="samples/sample-app/components/content/teaserbar/teaserbarItem"
+          linkContentRef="/content/samples/en/venue"
+          linkMediaDownload="{Boolean}false"
+          linkTitle="More information"
+          linkType="internal"
+          linkWindowFeatures="default"
+          linkWindowTarget="_self"
+          mediaRef="/content/dam/samples/content/location.png"
+          teaserContent="Take a look at the new venue for 2013. The Kulturbrauerei in the Prenzlauer Berg district."
+          title="Location" />
+      <teaserbaritem_1
+          jcr:primaryType="nt:unstructured"
+          sling:resourceType="samples/sample-app/components/content/teaserbar/teaserbarItem"
+          linkContentRef="/content/samples/en/conference/call-for-papers"
+          linkMediaDownload="{Boolean}false"
+          linkTitle="Submit your proposal here"
+          linkType="internal"
+          linkWindowFeatures="default"
+          linkWindowTarget="_self"
+          mediaRef="/content/dam/samples/content/talk.png"
+          teaserContent="If you have insight and experiences with Apache Sling and want to share them? We are actually asking for your participation!"
+          title="Want to share?" />
+      <teaserbaritem_2
+          jcr:primaryType="nt:unstructured"
+          sling:resourceType="samples/sample-app/components/content/teaserbar/teaserbarItem"
+          linkContentRef="/content/samples/en/archive"
+          linkMediaDownload="{Boolean}false"
+          linkTitle="Dive into the archive"
+          linkType="internal"
+          linkWindowFeatures="default"
+          linkWindowTarget="_self"
+          mediaRef="/content/dam/samples/content/archive.png"
+          teaserContent="adaptTo() is not a new event. Take a look at what was said and done previously."
+          title="Take a look back" />
+    </teaserbar>
+    <aside
+        jcr:primaryType="nt:unstructured"
+        sling:resourceType="samples/sample-app/components/content/aside/asideParsys">
+      <asidesponsorteaser
+          jcr:primaryType="nt:unstructured"
+          sling:resourceType="samples/sample-app/components/content/aside/asideSponsorTeaser"
+          title="Sponsors">
+        <images
+            jcr:primaryType="nt:unstructured"
+            sling:resourceType="samples/sample-app/components/content/aside/asideSponsorTeaserParsys">
+          <asidesponsorteaserit_0
+              jcr:primaryType="nt:unstructured"
+              sling:resourceType="samples/sample-app/components/content/aside/asideSponsorTeaserItem"
+              imageHeight="41"
+              imageWidth="200"
+              linkExternalRef="http://www.pro-vision.de"
+              linkType="external"
+              linkWindowFeatures="default"
+              linkWindowTarget="_blank"
+              mediaRef="/content/dam/samples/content/provision-logo.png" />
+        </images>
+      </asidesponsorteaser>
+      <asidesocialteaser
+          jcr:primaryType="nt:unstructured"
+          sling:resourceType="samples/sample-app/components/content/aside/asideSocialTeaser"
+          title="Follow us">
+        <images
+            jcr:primaryType="nt:unstructured"
+            sling:resourceType="samples/sample-app/components/content/aside/asideSponsorTeaserParsys">
+          <asidesocialteaserite
+              jcr:primaryType="nt:unstructured"
+              sling:resourceType="samples/sample-app/components/content/aside/asideSocialTeaserItem"
+              linkExternalRef="http://twitter.com/adaptto"
+              linkMediaDownload="{Boolean}false"
+              linkTitle="@adaptTo"
+              linkType="external"
+              linkWindowFeatures="default"
+              linkWindowTarget="_blank"
+              mediaRef="/content/dam/samples/content/twitter-icon.png"
+              title="on twitter" />
+        </images>
+      </asidesocialteaser>
+    </aside>
+    <content
+        jcr:primaryType="nt:unstructured"
+        sling:resourceType="sample/wcm/parsys/components/parsys">
+      <contentrichtext
+          jcr:primaryType="nt:unstructured"
+          sling:resourceType="samples/sample-app/components/content/common/contentRichText"
+          text="&lt;p&gt;adaptTo() is a meetup in Berlin focused on Apache Sling including Apache Jackrabbit and Apache Felix and is addressed to all using this stack or parts of it.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a data=&quot;{&amp;quot;linkType&amp;quot;:&amp;quot;internal&amp;quot;,&amp;quot;linkContentRef&amp;quot;:&amp;quot;/content/samples/handler/en/conference&amp;quot;,&amp;quot;linkWindowTarget&amp;quot;:&amp;quot;_self&amp;quot;,&amp;quot;linkWindowFeatures&amp;quot;:&amp;quot;defa [...]
+      <contentheadline
+          jcr:primaryType="nt:unstructured"
+          sling:resourceType="samples/sample-app/components/content/common/contentHeadline"
+          headline="Extended Call for Papers"
+          smaller="{Boolean}true" />
+      <contentrichtext_0
+          jcr:primaryType="nt:unstructured"
+          sling:resourceType="samples/sample-app/components/content/common/contentRichText"
+          text="&lt;p&gt;Although we got some great submissions for adaptTo() 2013, we still have some slots for further sessions. Therefore we extend the timeslot for submissions to the call for papers and for feedback by two weeks. This means you still can submit you submissions till 06.05.2013. We're looking forward to get more of your great talks.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a data=&quot;{&amp;quot;linkType&amp;quot;:&amp;quot;internal&amp;quot;,&amp;quot;linkContentRef&amp;quot;:&amp [...]
+    </content>
+    <stage
+        jcr:primaryType="nt:unstructured"
+        sling:resourceType="sample/wcm/parsys/components/parsys">
+      <stageheader
+          jcr:primaryType="nt:unstructured"
+          sling:resourceType="samples/sample-app/components/content/stage/stageheader"
+          linkMediaDownload="{Boolean}false"
+          linkType="internal"
+          linkWindowFeatures="default"
+          linkWindowTarget="_self"
+          mediaRef="/content/dam/samples/content/stageheader-outside2.jpg"
+          subtitle="23.–25. September 2013&#xA;Kulturbrauerei Berlin"
+          title="adaptTo() 2013">
+        <links
+            jcr:primaryType="nt:unstructured"
+            sling:resourceType="samples/sample-app/components/content/stage/stageheaderParsys">
+          <stageheaderlinkitem
+              jcr:primaryType="nt:unstructured"
+              sling:resourceType="samples/sample-app/components/content/stage/stageheaderLinkItem"
+              linkContentRef="/content/samples/en/tickets"
+              linkMediaDownload="{Boolean}false"
+              linkTitle="Get tickets now"
+              linkType="internal"
+              linkWindowFeatures="default"
+              linkWindowTarget="_self" />
+          <stageheaderlinkitem_0
+              jcr:primaryType="nt:unstructured"
+              sling:resourceType="samples/sample-app/components/content/stage/stageheaderLinkItem"
+              linkContentRef="/content/samples/en/conference/call-for-papers"
+              linkMediaDownload="{Boolean}false"
+              linkTitle="Submit paper"
+              linkType="internal"
+              linkWindowFeatures="default"
+              linkWindowTarget="_self" />
+        </links>
+      </stageheader>
+    </stage>
+    <image
+        jcr:primaryType="nt:unstructured" />
+  </jcr:content>
+  <tools />
+  <conference />
+</jcr:root>
diff --git a/src/test/resources/content-test/content.json b/src/test/resources/content-test/content.json
new file mode 100644
index 0000000..c30d34e
--- /dev/null
+++ b/src/test/resources/content-test/content.json
@@ -0,0 +1,264 @@
+/* Comment example */
+{
+  "jcr:primaryType": "app:Page",
+  "jcr:createdBy": "admin",
+  "jcr:created": "Thu Aug 07 2014 16:32:59 GMT+0200",
+  /* Comment example */
+  "jcr:content": {
+    "jcr:primaryType": "app:PageContent",  /* Comment example */
+    "jcr:createdBy": "admin",
+    "jcr:title": "English",
+    "app:template": "sample/templates/homepage",
+    "jcr:created": "Thu Aug 07 2014 16:32:59 GMT+0200",
+    "app:lastModified": "Tue Apr 22 2014 15:11:24 GMT+0200",
+    "dateISO8601String": "2014-04-22T15:11:24.000+02:00",
+    "pageTitle": "Sample Homepage",
+    "sling:resourceType": "sample/components/homepage",
+    "sling:resourceSuperType": "sample/components/supertype",
+    "app:designPath": "/etc/designs/sample",
+    "app:lastModifiedBy": "admin",
+    "utf8Property": "äöü߀",
+    "jcr:reference:refpro1": "abc",
+    "jcr:path:pathprop1": "def",
+    "par": {
+      "jcr:primaryType": "nt:unstructured",
+      "sling:resourceType": "foundation/components/parsys",
+      "colctrl": {
+        "jcr:primaryType": "nt:unstructured",
+        "jcr:createdBy": "admin",
+        "jcr:lastModifiedBy": "admin",
+        "layout": "2;colctrl-lt0",
+        "jcr:created": "Mon Aug 23 2010 22:02:24 GMT+0200",
+        "jcr:lastModified": "Mon Aug 23 2010 22:02:35 GMT+0200",
+        "sling:resourceType": "foundation/components/parsys/colctrl"
+      },
+      "image": {
+        "jcr:primaryType": "nt:unstructured",
+        "jcr:createdBy": "admin",
+        "fileReference": "/content/dam/sample/portraits/jane_doe.jpg",
+        "jcr:lastModifiedBy": "admin",
+        "jcr:created": "Mon Aug 23 2010 22:03:39 GMT+0200",
+        "width": "340",
+        "jcr:lastModified": "Sun Oct 31 2010 21:39:50 GMT+0100",
+        "sling:resourceType": "foundation/components/image",
+        "file": {
+          "jcr:primaryType": "nt:file",
+          "jcr:createdBy": "admin",
+          "jcr:created": "Thu Aug 07 2014 16:32:59 GMT+0200",
+          "jcr:content": {
+            "jcr:primaryType": "nt:resource",
+            "jcr:lastModifiedBy": "anonymous",
+            "jcr:mimeType": "image/jpeg",
+            "jcr:lastModified": "Thu Aug 07 2014 16:32:59 GMT+0200",
+            ":jcr:data": 24377,
+            "jcr:uuid": "eda76d00-b2cd-4b59-878f-c33f71ceaddc"
+          }
+        }
+      },
+      "title_1": {
+        "jcr:primaryType": "nt:unstructured",
+        "jcr:createdBy": "admin",
+        "jcr:title": "Strategic Consulting",
+        "jcr:lastModifiedBy": "admin",
+        "jcr:created": "Mon Aug 23 2010 22:12:08 GMT+0200",
+        "jcr:lastModified": "Wed Oct 27 2010 21:33:24 GMT+0200",
+        "sling:resourceType": "sample/components/title"
+      },
+      "text_1": {
+        "jcr:primaryType": "nt:unstructured",
+        "jcr:createdBy": "admin",
+        "jcr:lastModifiedBy": "admin",
+        "jcr:created": "Sun Oct 31 2010 21:48:04 GMT+0100",
+        "text": "<p><span class=\"Apple-style-span\" style=\"font-size: 12px;\">In&nbsp;today's competitive market, organizations can face several key geometric challenges:<\/span><\/p>\n<ul>\n<li><span class=\"Apple-style-span\" style=\"font-size: 12px;\">Polyhedral Sectioning<\/span><\/li>\n<li><span class=\"Apple-style-span\" style=\"font-size: 12px;\">Triangulation&nbsp;<\/span><\/li>\n<li><span class=\"Apple-style-span\" style=\"font-size: 12px;\">Trigonometric Calculation<\/span><\ [...]
+        "jcr:lastModified": "Sun Oct 31 2010 21:49:06 GMT+0100",
+        "sling:resourceType": "foundation/components/text",
+        "textIsRich": "true"
+      },
+      "col_break12825937554040": {
+        "jcr:primaryType": "nt:unstructured",
+        "controlType": "break",
+        "sling:resourceType": "foundation/components/parsys/colctrl"
+      },
+      "image_0": {
+        "jcr:primaryType": "nt:unstructured",
+        "jcr:createdBy": "admin",
+        "fileReference": "/content/dam/sample/offices/clean_room.jpg",
+        "height": "226",
+        "jcr:lastModifiedBy": "admin",
+        "jcr:created": "Mon Aug 23 2010 22:04:46 GMT+0200",
+        "jcr:lastModified": "Fri Nov 05 2010 10:38:15 GMT+0100",
+        "sling:resourceType": "foundation/components/image",
+        "imageRotate": "0",
+        "file": {
+          "jcr:primaryType": "nt:file",
+          "jcr:createdBy": "admin",
+          "jcr:created": "Thu Aug 07 2014 16:32:59 GMT+0200",
+          "jcr:content": {
+            "jcr:primaryType": "nt:resource",
+            "jcr:lastModifiedBy": "anonymous",
+            "jcr:mimeType": "image/jpeg",
+            "jcr:lastModified": "Thu Aug 07 2014 16:32:59 GMT+0200",
+            ":jcr:data": 21142,
+            "jcr:uuid": "6139077f-191f-4337-aaef-55456ebe6784"
+          }
+        }
+      },
+      "title_2": {
+        "jcr:createdBy": "admin",
+        "jcr:title": "Shape Technology",
+        "jcr:lastModifiedBy": "admin",
+        "jcr:created": "Mon Aug 23 2010 22:12:13 GMT+0200",
+        "jcr:lastModified": "Tue Oct 26 2010 21:16:29 GMT+0200",
+        "sling:resourceType": "sample/components/title"
+      },
+      "text_0": {
+        "jcr:primaryType": "nt:unstructured",
+        "jcr:createdBy": "admin",
+        "jcr:lastModifiedBy": "admin",
+        "jcr:created": "Mon Aug 23 2010 22:16:30 GMT+0200",
+        "text": "<p>The Sample investment in R&amp;D has done more than solidify our industry leadership role, we have now outpaced our competitors to such an extent that we are in an altogether new space.<\/p>\n<p>This is why our high quality polygons and polyhedra provide the only turnkey solutions across the whole range of euclidean geometry. And our mathematicians are working on the next generation of fractal curves to bring you shapes that are unthinkable today.<\/p>\n<p><\/p>\n<p>< [...]
+        "jcr:lastModified": "Mon Nov 08 2010 20:39:00 GMT+0100",
+        "sling:resourceType": "foundation/components/text",
+        "textIsRich": "true"
+      },
+      "col_end12825937444810": {
+        "jcr:primaryType": "nt:unstructured",
+        "controlType": "end",
+        "sling:resourceType": "foundation/components/parsys/colctrl"
+      }
+    },
+    "header": {
+      "jcr:primaryType": "nt:unstructured",
+      "jcr:title": "trust our experience\r\nto manage your business",
+      "imageReference": "/content/dam/sample/header.png",
+      "text": "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nunc eget neque. Nunc condimentum ipsum et orci. Aenean est. Cras eget diam. read more",
+      "sling:resourceType": "sample/components/header"
+    },
+    "newslist": {
+      "jcr:primaryType": "nt:unstructured",
+      "headline": "trust our experience\nto manage your business",
+      "text": "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nunc eget neque. Nunc condimentum ipsum et orci. Aenean est. Cras eget diam. read more",
+      "sling:resourceType": "sample/components/listchildren",
+      "listroot": "/content/sample/en/about/news"
+    },
+    "lead": {
+      "jcr:primaryType": "nt:unstructured",
+      "jcr:title": "World Leader in Applied Geometry ",
+      "jcr:lastModifiedBy": "admin",
+      "text": "Lead Text",
+      "title": "Lead Title",
+      "jcr:description": "Sample has been selling and servicing shapes for over 2000 years. From our beginnings as a small vendor of squares and rectangles we have grown our business into a leading global provider of platonic solids and fractals. Join us as we lead geometry into the future.",
+      "jcr:lastModified": "Wed Jan 19 2011 14:35:29 GMT+0100",
+      "sling:resourceType": "sample/components/lead",
+      "app:annotations": {"jcr:primaryType": "nt:unstructured"}
+    },
+    "image": {
+      "jcr:primaryType": "nt:unstructured",
+      "jcr:lastModifiedBy": "admin",
+      "jcr:lastModified": "Wed Oct 27 2010 21:30:59 GMT+0200",
+      "imageRotate": "0"
+    },
+    "carousel": {
+      "jcr:primaryType": "nt:unstructured",
+      "playSpeed": "6000",
+      "jcr:lastModifiedBy": "admin",
+      "pages": [
+        "/content/sample/en/events/techsummit",
+        "/content/sample/en/events/userconf",
+        "/content/sample/en/events/shapecon",
+        "/content/sample/en/events/dsc"
+      ],
+      "jcr:lastModified": "Tue Oct 05 2010 14:14:27 GMT+0200",
+      "transTime": "1000",
+      "sling:resourceType": "foundation/components/carousel",
+      "listFrom": "static"
+    },
+    "rightpar": {
+      "jcr:primaryType": "nt:unstructured",
+      "sling:resourceType": "foundation/components/parsys",
+      "teaser": {
+        "jcr:primaryType": "nt:unstructured",
+        "jcr:createdBy": "admin",
+        "jcr:lastModifiedBy": "admin",
+        "jcr:created": "Tue Jan 25 2011 11:30:09 GMT+0100",
+        "campaignpath": "/content/campaigns/sample",
+        "jcr:lastModified": "Wed Feb 02 2011 08:40:30 GMT+0100",
+        "sling:resourceType": "personalization/components/teaser"
+      }
+    }
+  },
+  "toolbar": {
+    "jcr:primaryType": "app:Page",
+    "jcr:createdBy": "admin",
+    "jcr:created": "Thu Aug 07 2014 16:33:00 GMT+0200",
+    "jcr:content": {
+      "jcr:primaryType": "app:PageContent",
+      "subtitle": "Contains the toolbar",
+      "jcr:createdBy": "admin",
+      "jcr:title": "Toolbar",
+      "app:template": "sample/templates/contentpage",
+      "jcr:created": "Thu Aug 07 2014 16:33:00 GMT+0200",
+      "app:lastModified": "Wed Aug 25 2010 22:51:02 GMT+0200",
+      "hideInNav": "true",
+      "sling:resourceType": "sample/components/contentpage",
+      "app:lastModifiedBy": "admin",
+      "par": {
+        "jcr:primaryType": "nt:unstructured",
+        "sling:resourceType": "foundation/components/parsys"
+      },
+      "rightpar": {
+        "jcr:primaryType": "nt:unstructured",
+        "sling:resourceType": "foundation/components/iparsys",
+        "iparsys_fake_par": {
+          "jcr:primaryType": "nt:unstructured",
+          "sling:resourceType": "foundation/components/iparsys/par"
+        }
+      }
+    },
+    "profiles": {
+      "jcr:primaryType": "app:Page",
+      "jcr:createdBy": "admin",
+      "jcr:created": "Thu Aug 07 2014 16:33:00 GMT+0200",
+      "jcr:content": {
+        "jcr:primaryType": "app:PageContent",
+        "jcr:mixinTypes": ["type1","type2"],
+        "jcr:createdBy": "admin",
+        "jcr:title": "Profiles",
+        "app:template": "sample/templates/contentpage",
+        "jcr:created": "Thu Aug 07 2014 16:33:00 GMT+0200",
+        "app:lastModified": "Thu Nov 05 2009 20:27:13 GMT+0100",
+        "hideInNav": true,
+        "sling:resourceType": "sample/components/contentpage",
+        "app:lastModifiedBy": "admin",
+        "longProp": 1234567890123,
+        "decimalProp": 1.2345,
+        "booleanProp": true,
+        "longPropMulti": [1234567890123,55],
+        "decimalPropMulti": [1.2345,1.1],
+        "booleanPropMulti": [true,false],
+        "stringPropMulti": ["aa","bb","cc"],
+        "par": {
+          "jcr:primaryType": "nt:unstructured",
+          "sling:resourceType": "foundation/components/parsys",
+          "textimage": {
+            "jcr:primaryType": "nt:unstructured",
+            "sling:resourceType": "foundation/components/textimage"
+          },
+          "mygadgets": {
+            "jcr:primaryType": "nt:unstructured",
+            "gadgets": "http://customer.meteogroup.de/meteogroup/gadgets/wetter24.xml\nhttp://germanweatherradar.googlecode.com/svn/trunk/german-weather-radar.xml\nhttp://www.digitalpowered.info/gadget/ski.pictures.xml\nhttp://www.canbuffi.de/gadgets/clock/clock.xml",
+            "sling:resourceType": "personalization/components/mygadgets"
+          }
+        },
+        "rightpar": {
+          "jcr:primaryType": "nt:unstructured",
+          "sling:resourceType": "foundation/components/iparsys",
+          "iparsys_fake_par": {
+            "jcr:primaryType": "nt:unstructured",
+            "sling:resourceType": "foundation/components/iparsys/par"
+          }
+        }
+      }
+    }
+  }
+}
diff --git a/src/test/resources/invalid-test/contentWithObjectList.json b/src/test/resources/invalid-test/contentWithObjectList.json
new file mode 100644
index 0000000..e4527a0
--- /dev/null
+++ b/src/test/resources/invalid-test/contentWithObjectList.json
@@ -0,0 +1,14 @@
+{
+  "prop1": "value1",
+  "childObject": {
+    "prop2": "value2"
+  },
+  "childObjectList": [
+    {
+      "prop1": "value1"
+    },
+    {
+      "prop2": "value2"
+    }
+  ]
+}
diff --git a/src/test/resources/invalid-test/invalid.jcr.xml b/src/test/resources/invalid-test/invalid.jcr.xml
new file mode 100644
index 0000000..7df8a70
--- /dev/null
+++ b/src/test/resources/invalid-test/invalid.jcr.xml
@@ -0,0 +1 @@
+This is invalid xml.
diff --git a/src/test/resources/invalid-test/invalid.json b/src/test/resources/invalid-test/invalid.json
new file mode 100644
index 0000000..59fc86c
--- /dev/null
+++ b/src/test/resources/invalid-test/invalid.json
@@ -0,0 +1 @@
+This is invalid json.

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-jcr-contentparser] 04/14: use Sling Parent 30

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.jcr.contentparser-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-contentparser.git

commit 210691d1012659c28a79c1ac19021bb22910d141
Author: Oliver Lietz <ol...@apache.org>
AuthorDate: Mon Mar 6 10:22:30 2017 +0000

    use Sling Parent 30
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/fscontentparser@1785621 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 6b42222..1f775e7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.apache.sling</groupId>
         <artifactId>sling</artifactId>
-        <version>30-SNAPSHOT</version>
+        <version>30</version>
         <relativePath />
     </parent>
 

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-jcr-contentparser] 11/14: add readme

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.jcr.contentparser-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-contentparser.git

commit 4080f487182bcf63f4e3d30f35b5221b9471a1bf
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Mon Mar 20 11:06:04 2017 +0000

    add readme
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/contentparser@1787713 13f79535-47bb-0310-9956-ffa450edef68
---
 README.txt | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/README.txt b/README.txt
new file mode 100644
index 0000000..d0888d9
--- /dev/null
+++ b/README.txt
@@ -0,0 +1,26 @@
+Apache Sling Content Parser
+
+Parser for JCR repository content stored in files (e.g. JSON, FileVault XML).
+
+Getting Started
+===============
+
+This component uses a Maven 3 (http://maven.apache.org/) build
+environment. It requires a Java 7 JDK (or higher) and Maven (http://maven.apache.org/)
+3.3.9 or later. We recommend to use the latest Maven version.
+
+If you have Maven installed, you can compile and
+package the jar using the following command:
+
+    mvn package
+
+See the Maven 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/sling/trunk/bundles/jcr/contentparser
+
+See the Subversion documentation for other source control features.

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-jcr-contentparser] 08/14: SLING-6592 move and rename to jcr/contentparser, change java package and class names accordingly

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.jcr.contentparser-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-contentparser.git

commit d81cfcd25575599aa1f9fc9d7b7689d30478de77
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Tue Mar 14 10:41:47 2017 +0000

    SLING-6592 move and rename to jcr/contentparser, change java package and class names accordingly
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/contentparser@1786869 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml                                            | 12 ++++----
 .../contentparser/ContentParser.java}              | 10 +++----
 .../contentparser/ContentParserFactory.java}       | 32 +++++++++++-----------
 .../contentparser/ContentType.java}                | 12 ++++----
 .../contentparser}/ParseException.java             |  2 +-
 .../contentparser}/ParserOptions.java              |  2 +-
 .../contentparser/impl/JcrXmlContentParser.java}   | 12 ++++----
 .../contentparser}/impl/JcrXmlValueConverter.java  |  2 +-
 .../contentparser/impl/JsonContentParser.java}     | 12 ++++----
 .../contentparser}/impl/ParserHelper.java          |  6 ++--
 .../contentparser}/package-info.java               |  2 +-
 .../impl/JcrXmlContentParserTest.java}             | 30 ++++++++++----------
 .../impl/JcrXmlValueConverterTest.java             |  4 +--
 .../contentparser/impl/JsonContentParserTest.java} | 32 +++++++++++-----------
 .../contentparser}/impl/ParserHelperTest.java      | 10 +++----
 .../contentparser}/impl/TestUtils.java             |  2 +-
 16 files changed, 91 insertions(+), 91 deletions(-)

diff --git a/pom.xml b/pom.xml
index 1f775e7..e092a3a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -26,19 +26,19 @@
         <relativePath />
     </parent>
 
-    <artifactId>org.apache.sling.commons.fscontentparser</artifactId>
+    <artifactId>org.apache.sling.jcr.contentparser</artifactId>
     <packaging>bundle</packaging>
     <version>1.0.0-SNAPSHOT</version>
 
-    <name>Apache Sling File System Content File Parser</name>
+    <name>Apache Sling Content Parser</name>
     <description>
-        Parser for repository content stored in files (e.g. JSON, JCR XML).
+        Parser for JCR repository content stored in files (e.g. JSON, FileVault XML).
     </description>
 
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/bundles/commons/fscontentparser</connection>
-        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/fscontentparser</developerConnection>
-        <url>http://svn.apache.org/viewvc/sling/trunk/bundles/commons/fscontentparser</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/contentparser</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/contentparser</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/contentparser</url>
     </scm>
 
     <build>
diff --git a/src/main/java/org/apache/sling/fscontentparser/ContentFileParser.java b/src/main/java/org/apache/sling/jcr/contentparser/ContentParser.java
similarity index 89%
rename from src/main/java/org/apache/sling/fscontentparser/ContentFileParser.java
rename to src/main/java/org/apache/sling/jcr/contentparser/ContentParser.java
index 4aa32e5..cb6d013 100644
--- a/src/main/java/org/apache/sling/fscontentparser/ContentFileParser.java
+++ b/src/main/java/org/apache/sling/jcr/contentparser/ContentParser.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.sling.fscontentparser;
+package org.apache.sling.jcr.contentparser;
 
 import java.io.File;
 import java.io.IOException;
@@ -27,7 +27,7 @@ import java.util.Map;
  * Parses repository content from a file.
  * Implementations have to be thread-safe.
  */
-public interface ContentFileParser {
+public interface ContentParser {
 
     /**
      * Parse content file.
@@ -39,9 +39,9 @@ public interface ContentFileParser {
     Map<String,Object> parse(File file) throws IOException, ParseException;
     
     /**
-     * Parse content file.
-     * @param file File
-     * @return Content
+     * Parse content.
+     * @param is Stream with serialized content
+     * @return Content as Map
      * @throws IOException When I/O error occurs.
      * @throws ParseException When parsing error occurs.
      */
diff --git a/src/main/java/org/apache/sling/fscontentparser/ContentFileParserFactory.java b/src/main/java/org/apache/sling/jcr/contentparser/ContentParserFactory.java
similarity index 60%
rename from src/main/java/org/apache/sling/fscontentparser/ContentFileParserFactory.java
rename to src/main/java/org/apache/sling/jcr/contentparser/ContentParserFactory.java
index 7fc66e7..7ae64e2 100644
--- a/src/main/java/org/apache/sling/fscontentparser/ContentFileParserFactory.java
+++ b/src/main/java/org/apache/sling/jcr/contentparser/ContentParserFactory.java
@@ -16,43 +16,43 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.sling.fscontentparser;
+package org.apache.sling.jcr.contentparser;
 
-import org.apache.sling.fscontentparser.impl.JcrXmlContentFileParser;
-import org.apache.sling.fscontentparser.impl.JsonContentFileParser;
+import org.apache.sling.jcr.contentparser.impl.JcrXmlContentParser;
+import org.apache.sling.jcr.contentparser.impl.JsonContentParser;
 
 /**
  * Factory for content file parsers.
  */
-public final class ContentFileParserFactory {
+public final class ContentParserFactory {
 
-    private ContentFileParserFactory() {
+    private ContentParserFactory() {
         // static methods only
     }
     
     /**
-     * Create content file parser.
-     * @param type Content file type
-     * @return Content file parser
+     * Create content parser.
+     * @param type Content type
+     * @return Content parser
      */
-    public static ContentFileParser create(ContentFileType type) {
+    public static ContentParser create(ContentType type) {
         return create(type, new ParserOptions());
     }
     
     /**
-     * Create content file parser.
-     * @param type Content file type
+     * Create content parser.
+     * @param type Content type
      * @param options Parser options
-     * @return Content file parser
+     * @return Content parser
      */
-    public static ContentFileParser create(ContentFileType type, ParserOptions options) {
+    public static ContentParser create(ContentType type, ParserOptions options) {
         switch (type) {
             case JSON:
-                return new JsonContentFileParser(options);
+                return new JsonContentParser(options);
             case JCR_XML:
-                return new JcrXmlContentFileParser(options);
+                return new JcrXmlContentParser(options);
             default:
-                throw new IllegalArgumentException("Unsupported file extension: " + type);
+                throw new IllegalArgumentException("Unsupported type: " + type);
         }
     }
     
diff --git a/src/main/java/org/apache/sling/fscontentparser/ContentFileType.java b/src/main/java/org/apache/sling/jcr/contentparser/ContentType.java
similarity index 84%
rename from src/main/java/org/apache/sling/fscontentparser/ContentFileType.java
rename to src/main/java/org/apache/sling/jcr/contentparser/ContentType.java
index 72ca467..167722f 100644
--- a/src/main/java/org/apache/sling/fscontentparser/ContentFileType.java
+++ b/src/main/java/org/apache/sling/jcr/contentparser/ContentType.java
@@ -16,27 +16,27 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.sling.fscontentparser;
+package org.apache.sling.jcr.contentparser;
 
 /**
- * Content file types.
+ * Content types.
  */
-public enum ContentFileType {
+public enum ContentType {
 
     /**
-     * JSON content files.
+     * JSON content.
      */
     JSON("json"),
 
     /**
-     * JCR XML content files.
+     * JCR XML content.
      */
     JCR_XML("jcr.xml");
 
 
     private final String extension;
 
-    private ContentFileType(String extension) {
+    private ContentType(String extension) {
         this.extension = extension;
     }
 
diff --git a/src/main/java/org/apache/sling/fscontentparser/ParseException.java b/src/main/java/org/apache/sling/jcr/contentparser/ParseException.java
similarity index 96%
rename from src/main/java/org/apache/sling/fscontentparser/ParseException.java
rename to src/main/java/org/apache/sling/jcr/contentparser/ParseException.java
index 13bdab1..4df0160 100644
--- a/src/main/java/org/apache/sling/fscontentparser/ParseException.java
+++ b/src/main/java/org/apache/sling/jcr/contentparser/ParseException.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.sling.fscontentparser;
+package org.apache.sling.jcr.contentparser;
 
 /**
  * Parsing exception.
diff --git a/src/main/java/org/apache/sling/fscontentparser/ParserOptions.java b/src/main/java/org/apache/sling/jcr/contentparser/ParserOptions.java
similarity index 98%
rename from src/main/java/org/apache/sling/fscontentparser/ParserOptions.java
rename to src/main/java/org/apache/sling/jcr/contentparser/ParserOptions.java
index 9f5fbcb..0911dac 100644
--- a/src/main/java/org/apache/sling/fscontentparser/ParserOptions.java
+++ b/src/main/java/org/apache/sling/jcr/contentparser/ParserOptions.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.sling.fscontentparser;
+package org.apache.sling.jcr.contentparser;
 
 import java.util.Arrays;
 import java.util.Collections;
diff --git a/src/main/java/org/apache/sling/fscontentparser/impl/JcrXmlContentFileParser.java b/src/main/java/org/apache/sling/jcr/contentparser/impl/JcrXmlContentParser.java
similarity index 93%
rename from src/main/java/org/apache/sling/fscontentparser/impl/JcrXmlContentFileParser.java
rename to src/main/java/org/apache/sling/jcr/contentparser/impl/JcrXmlContentParser.java
index c97317e..dde8c16 100644
--- a/src/main/java/org/apache/sling/fscontentparser/impl/JcrXmlContentFileParser.java
+++ b/src/main/java/org/apache/sling/jcr/contentparser/impl/JcrXmlContentParser.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.sling.fscontentparser.impl;
+package org.apache.sling.jcr.contentparser.impl;
 
 import java.io.File;
 import java.io.FileInputStream;
@@ -32,9 +32,9 @@ import javax.xml.parsers.SAXParser;
 import javax.xml.parsers.SAXParserFactory;
 
 import org.apache.jackrabbit.util.ISO9075;
-import org.apache.sling.fscontentparser.ContentFileParser;
-import org.apache.sling.fscontentparser.ParseException;
-import org.apache.sling.fscontentparser.ParserOptions;
+import org.apache.sling.jcr.contentparser.ContentParser;
+import org.apache.sling.jcr.contentparser.ParseException;
+import org.apache.sling.jcr.contentparser.ParserOptions;
 import org.xml.sax.Attributes;
 import org.xml.sax.SAXException;
 import org.xml.sax.SAXParseException;
@@ -44,12 +44,12 @@ import org.xml.sax.helpers.DefaultHandler;
  * Parses JCR XML files that contains content fragments.
  * Instance of this class is thread-safe.
  */
-public final class JcrXmlContentFileParser implements ContentFileParser {
+public final class JcrXmlContentParser implements ContentParser {
     
     private final ParserHelper helper;    
     private final SAXParserFactory saxParserFactory;
     
-    public JcrXmlContentFileParser(ParserOptions options) {
+    public JcrXmlContentParser(ParserOptions options) {
         this.helper = new ParserHelper(options);
         saxParserFactory = SAXParserFactory.newInstance();
         saxParserFactory.setNamespaceAware(true);
diff --git a/src/main/java/org/apache/sling/fscontentparser/impl/JcrXmlValueConverter.java b/src/main/java/org/apache/sling/jcr/contentparser/impl/JcrXmlValueConverter.java
similarity index 99%
rename from src/main/java/org/apache/sling/fscontentparser/impl/JcrXmlValueConverter.java
rename to src/main/java/org/apache/sling/jcr/contentparser/impl/JcrXmlValueConverter.java
index cb65b30..f4cdfc4 100644
--- a/src/main/java/org/apache/sling/fscontentparser/impl/JcrXmlValueConverter.java
+++ b/src/main/java/org/apache/sling/jcr/contentparser/impl/JcrXmlValueConverter.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.sling.fscontentparser.impl;
+package org.apache.sling.jcr.contentparser.impl;
 
 import java.lang.reflect.Array;
 import java.math.BigDecimal;
diff --git a/src/main/java/org/apache/sling/fscontentparser/impl/JsonContentFileParser.java b/src/main/java/org/apache/sling/jcr/contentparser/impl/JsonContentParser.java
similarity index 93%
rename from src/main/java/org/apache/sling/fscontentparser/impl/JsonContentFileParser.java
rename to src/main/java/org/apache/sling/jcr/contentparser/impl/JsonContentParser.java
index 4dca092..b070701 100644
--- a/src/main/java/org/apache/sling/fscontentparser/impl/JsonContentFileParser.java
+++ b/src/main/java/org/apache/sling/jcr/contentparser/impl/JsonContentParser.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.sling.fscontentparser.impl;
+package org.apache.sling.jcr.contentparser.impl;
 
 import java.io.File;
 import java.io.FileInputStream;
@@ -37,20 +37,20 @@ import javax.json.JsonString;
 import javax.json.JsonValue;
 import javax.json.stream.JsonParsingException;
 
-import org.apache.sling.fscontentparser.ContentFileParser;
-import org.apache.sling.fscontentparser.ParseException;
-import org.apache.sling.fscontentparser.ParserOptions;
+import org.apache.sling.jcr.contentparser.ContentParser;
+import org.apache.sling.jcr.contentparser.ParseException;
+import org.apache.sling.jcr.contentparser.ParserOptions;
 
 /**
  * Parses JSON files that contains content fragments.
  * Instance of this class is thread-safe.
  */
-public final class JsonContentFileParser implements ContentFileParser {
+public final class JsonContentParser implements ContentParser {
     
     private final ParserHelper helper;    
     private final JsonReaderFactory jsonReaderFactory;
     
-    public JsonContentFileParser(ParserOptions options) {
+    public JsonContentParser(ParserOptions options) {
         this.helper = new ParserHelper(options);
         // allow comments in JSON files
         Map<String,Object> jsonReaderFactoryConfig = new HashMap<>();
diff --git a/src/main/java/org/apache/sling/fscontentparser/impl/ParserHelper.java b/src/main/java/org/apache/sling/jcr/contentparser/impl/ParserHelper.java
similarity index 96%
rename from src/main/java/org/apache/sling/fscontentparser/impl/ParserHelper.java
rename to src/main/java/org/apache/sling/jcr/contentparser/impl/ParserHelper.java
index 0f54015..160cd0e 100644
--- a/src/main/java/org/apache/sling/fscontentparser/impl/ParserHelper.java
+++ b/src/main/java/org/apache/sling/jcr/contentparser/impl/ParserHelper.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.sling.fscontentparser.impl;
+package org.apache.sling.jcr.contentparser.impl;
 
 import java.lang.reflect.Array;
 import java.text.DateFormat;
@@ -28,8 +28,8 @@ import java.util.Map;
 import java.util.Set;
 
 import org.apache.commons.lang3.StringUtils;
-import org.apache.sling.fscontentparser.ParseException;
-import org.apache.sling.fscontentparser.ParserOptions;
+import org.apache.sling.jcr.contentparser.ParseException;
+import org.apache.sling.jcr.contentparser.ParserOptions;
 
 /**
  * Helper parsing logic based on parser options.
diff --git a/src/main/java/org/apache/sling/fscontentparser/package-info.java b/src/main/java/org/apache/sling/jcr/contentparser/package-info.java
similarity index 95%
rename from src/main/java/org/apache/sling/fscontentparser/package-info.java
rename to src/main/java/org/apache/sling/jcr/contentparser/package-info.java
index 4179ffd..21b7f41 100644
--- a/src/main/java/org/apache/sling/fscontentparser/package-info.java
+++ b/src/main/java/org/apache/sling/jcr/contentparser/package-info.java
@@ -20,4 +20,4 @@
  * Parser for repository content stored in files (e.g. JSON, JCR XML).
  */
 @org.osgi.annotation.versioning.Version("1.0.0")
-package org.apache.sling.fscontentparser;
+package org.apache.sling.jcr.contentparser;
diff --git a/src/test/java/org/apache/sling/fscontentparser/impl/JcrXmlContentFileParserTest.java b/src/test/java/org/apache/sling/jcr/contentparser/impl/JcrXmlContentParserTest.java
similarity index 78%
rename from src/test/java/org/apache/sling/fscontentparser/impl/JcrXmlContentFileParserTest.java
rename to src/test/java/org/apache/sling/jcr/contentparser/impl/JcrXmlContentParserTest.java
index cf78f49..d99a025 100644
--- a/src/test/java/org/apache/sling/fscontentparser/impl/JcrXmlContentFileParserTest.java
+++ b/src/test/java/org/apache/sling/jcr/contentparser/impl/JcrXmlContentParserTest.java
@@ -16,9 +16,9 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.sling.fscontentparser.impl;
+package org.apache.sling.jcr.contentparser.impl;
 
-import static org.apache.sling.fscontentparser.impl.TestUtils.getDeep;
+import static org.apache.sling.jcr.contentparser.impl.TestUtils.getDeep;
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
@@ -31,18 +31,18 @@ import java.util.Map;
 import java.util.TimeZone;
 
 import org.apache.jackrabbit.util.ISO9075;
-import org.apache.sling.fscontentparser.ContentFileType;
-import org.apache.sling.fscontentparser.ContentFileParser;
-import org.apache.sling.fscontentparser.ContentFileParserFactory;
-import org.apache.sling.fscontentparser.ParseException;
-import org.apache.sling.fscontentparser.ParserOptions;
+import org.apache.sling.jcr.contentparser.ContentParser;
+import org.apache.sling.jcr.contentparser.ContentParserFactory;
+import org.apache.sling.jcr.contentparser.ContentType;
+import org.apache.sling.jcr.contentparser.ParseException;
+import org.apache.sling.jcr.contentparser.ParserOptions;
 import org.junit.Before;
 import org.junit.Ignore;
 import org.junit.Test;
 
 import com.google.common.collect.ImmutableSet;
 
-public class JcrXmlContentFileParserTest {
+public class JcrXmlContentParserTest {
 
     private File file;
 
@@ -54,7 +54,7 @@ public class JcrXmlContentFileParserTest {
     @SuppressWarnings("unchecked")
     @Test
     public void testParseJcrXml() throws Exception {
-        ContentFileParser underTest = ContentFileParserFactory.create(ContentFileType.JCR_XML);
+        ContentParser underTest = ContentParserFactory.create(ContentType.JCR_XML);
         Map<String,Object> content = underTest.parse(file);
         assertNotNull(content);
         assertEquals("app:Page", content.get("jcr:primaryType"));
@@ -64,13 +64,13 @@ public class JcrXmlContentFileParserTest {
     @Test(expected=ParseException.class)
     public void testParseInvalidJcrXml() throws Exception {
         file = new File("src/test/resources/invalid-test/invalid.jcr.xml");
-        ContentFileParser underTest = ContentFileParserFactory.create(ContentFileType.JCR_XML);
+        ContentParser underTest = ContentParserFactory.create(ContentType.JCR_XML);
         underTest.parse(file);
     }
 
     @Test
     public void testDataTypes() throws Exception {
-        ContentFileParser underTest = ContentFileParserFactory.create(ContentFileType.JCR_XML);
+        ContentParser underTest = ContentParserFactory.create(ContentType.JCR_XML);
         Map<String,Object> content = underTest.parse(file);
         Map<String,Object> props = getDeep(content, "jcr:content");
         
@@ -95,13 +95,13 @@ public class JcrXmlContentFileParserTest {
 
     @Test
     public void testDecodeName() {
-        assertEquals("jcr:title", JcrXmlContentFileParser.decodeName("jcr:" + ISO9075.encode("title")));
-        assertEquals("sling:123", JcrXmlContentFileParser.decodeName("sling:" + ISO9075.encode("123")));
+        assertEquals("jcr:title", JcrXmlContentParser.decodeName("jcr:" + ISO9075.encode("title")));
+        assertEquals("sling:123", JcrXmlContentParser.decodeName("sling:" + ISO9075.encode("123")));
     }
 
     @Test
     public void testIgnoreResourcesProperties() throws Exception {
-        ContentFileParser underTest = ContentFileParserFactory.create(ContentFileType.JCR_XML, new ParserOptions()
+        ContentParser underTest = ContentParserFactory.create(ContentType.JCR_XML, new ParserOptions()
                 .ignoreResourceNames(ImmutableSet.of("teaserbar", "aside"))
                 .ignorePropertyNames(ImmutableSet.of("longProp", "jcr:title")));
         Map<String,Object> content = underTest.parse(file);
@@ -119,7 +119,7 @@ public class JcrXmlContentFileParserTest {
     @Test
     @Ignore
     public void testSameNamePropertyAndSubResource() throws Exception {
-        ContentFileParser underTest = ContentFileParserFactory.create(ContentFileType.JCR_XML);
+        ContentParser underTest = ContentParserFactory.create(ContentType.JCR_XML);
         Map<String,Object> content = underTest.parse(file);
         Map<String,Object> props = getDeep(content, "jcr:content/teaserbar");
         // teaserbaritem is a direct property as well as a sub resource
diff --git a/src/test/java/org/apache/sling/fscontentparser/impl/JcrXmlValueConverterTest.java b/src/test/java/org/apache/sling/jcr/contentparser/impl/JcrXmlValueConverterTest.java
similarity index 97%
rename from src/test/java/org/apache/sling/fscontentparser/impl/JcrXmlValueConverterTest.java
rename to src/test/java/org/apache/sling/jcr/contentparser/impl/JcrXmlValueConverterTest.java
index a3b51ab..c3ec747 100644
--- a/src/test/java/org/apache/sling/fscontentparser/impl/JcrXmlValueConverterTest.java
+++ b/src/test/java/org/apache/sling/jcr/contentparser/impl/JcrXmlValueConverterTest.java
@@ -16,9 +16,9 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.sling.fscontentparser.impl;
+package org.apache.sling.jcr.contentparser.impl;
 
-import static org.apache.sling.fscontentparser.impl.JcrXmlValueConverter.parseValue;
+import static org.apache.sling.jcr.contentparser.impl.JcrXmlValueConverter.parseValue;
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNull;
diff --git a/src/test/java/org/apache/sling/fscontentparser/impl/JsonContentFileParserTest.java b/src/test/java/org/apache/sling/jcr/contentparser/impl/JsonContentParserTest.java
similarity index 80%
rename from src/test/java/org/apache/sling/fscontentparser/impl/JsonContentFileParserTest.java
rename to src/test/java/org/apache/sling/jcr/contentparser/impl/JsonContentParserTest.java
index 6a0b8f6..a98757a 100644
--- a/src/test/java/org/apache/sling/fscontentparser/impl/JsonContentFileParserTest.java
+++ b/src/test/java/org/apache/sling/jcr/contentparser/impl/JsonContentParserTest.java
@@ -16,9 +16,9 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.sling.fscontentparser.impl;
+package org.apache.sling.jcr.contentparser.impl;
 
-import static org.apache.sling.fscontentparser.impl.TestUtils.getDeep;
+import static org.apache.sling.jcr.contentparser.impl.TestUtils.getDeep;
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
@@ -30,17 +30,17 @@ import java.util.Calendar;
 import java.util.Map;
 import java.util.TimeZone;
 
-import org.apache.sling.fscontentparser.ContentFileType;
-import org.apache.sling.fscontentparser.ContentFileParser;
-import org.apache.sling.fscontentparser.ContentFileParserFactory;
-import org.apache.sling.fscontentparser.ParseException;
-import org.apache.sling.fscontentparser.ParserOptions;
+import org.apache.sling.jcr.contentparser.ContentParser;
+import org.apache.sling.jcr.contentparser.ContentParserFactory;
+import org.apache.sling.jcr.contentparser.ContentType;
+import org.apache.sling.jcr.contentparser.ParseException;
+import org.apache.sling.jcr.contentparser.ParserOptions;
 import org.junit.Before;
 import org.junit.Test;
 
 import com.google.common.collect.ImmutableSet;
 
-public class JsonContentFileParserTest {
+public class JsonContentParserTest {
 
     private File file;
 
@@ -51,7 +51,7 @@ public class JsonContentFileParserTest {
 
     @Test
     public void testPageJcrPrimaryType() throws Exception {
-        ContentFileParser underTest = ContentFileParserFactory.create(ContentFileType.JSON);
+        ContentParser underTest = ContentParserFactory.create(ContentType.JSON);
         Map<String, Object> content = underTest.parse(file);
 
         assertEquals("app:Page", content.get("jcr:primaryType"));
@@ -59,7 +59,7 @@ public class JsonContentFileParserTest {
 
     @Test
     public void testDataTypes() throws Exception {
-        ContentFileParser underTest = ContentFileParserFactory.create(ContentFileType.JSON);
+        ContentParser underTest = ContentParserFactory.create(ContentType.JSON);
         Map<String, Object> content = underTest.parse(file);
 
         Map<String, Object> props = getDeep(content, "toolbar/profiles/jcr:content");
@@ -76,7 +76,7 @@ public class JsonContentFileParserTest {
 
     @Test
     public void testContentProperties() throws Exception {
-        ContentFileParser underTest = ContentFileParserFactory.create(ContentFileType.JSON);
+        ContentParser underTest = ContentParserFactory.create(ContentType.JSON);
         Map<String, Object> content = underTest.parse(file);
 
         Map<String, Object> props = getDeep(content, "jcr:content/header");
@@ -85,7 +85,7 @@ public class JsonContentFileParserTest {
 
     @Test
     public void testCalendar() throws Exception {
-        ContentFileParser underTest = ContentFileParserFactory.create(ContentFileType.JSON,
+        ContentParser underTest = ContentParserFactory.create(ContentType.JSON,
                 new ParserOptions().detectCalendarValues(true));
         Map<String, Object> content = underTest.parse(file);
 
@@ -107,7 +107,7 @@ public class JsonContentFileParserTest {
 
     @Test
     public void testUTF8Chars() throws Exception {
-        ContentFileParser underTest = ContentFileParserFactory.create(ContentFileType.JSON);
+        ContentParser underTest = ContentParserFactory.create(ContentType.JSON);
         Map<String, Object> content = underTest.parse(file);
 
         Map<String, Object> props = getDeep(content, "jcr:content");
@@ -118,7 +118,7 @@ public class JsonContentFileParserTest {
     @Test(expected = ParseException.class)
     public void testParseInvalidJson() throws Exception {
         file = new File("src/test/resources/invalid-test/invalid.json");
-        ContentFileParser underTest = ContentFileParserFactory.create(ContentFileType.JSON);
+        ContentParser underTest = ContentParserFactory.create(ContentType.JSON);
         Map<String, Object> content = underTest.parse(file);
         assertNull(content);
     }
@@ -126,14 +126,14 @@ public class JsonContentFileParserTest {
     @Test(expected = ParseException.class)
     public void testParseInvalidJsonWithObjectList() throws Exception {
         file = new File("src/test/resources/invalid-test/contentWithObjectList.json");
-        ContentFileParser underTest = ContentFileParserFactory.create(ContentFileType.JSON);
+        ContentParser underTest = ContentParserFactory.create(ContentType.JSON);
         Map<String, Object> content = underTest.parse(file);
         assertNull(content);
     }
 
     @Test
     public void testIgnoreResourcesProperties() throws Exception {
-        ContentFileParser underTest = ContentFileParserFactory.create(ContentFileType.JSON,
+        ContentParser underTest = ContentParserFactory.create(ContentType.JSON,
                 new ParserOptions().ignoreResourceNames(ImmutableSet.of("header", "newslist"))
                         .ignorePropertyNames(ImmutableSet.of("jcr:title")));
         Map<String, Object> content = underTest.parse(file);
diff --git a/src/test/java/org/apache/sling/fscontentparser/impl/ParserHelperTest.java b/src/test/java/org/apache/sling/jcr/contentparser/impl/ParserHelperTest.java
similarity index 95%
rename from src/test/java/org/apache/sling/fscontentparser/impl/ParserHelperTest.java
rename to src/test/java/org/apache/sling/jcr/contentparser/impl/ParserHelperTest.java
index a162a9a..f9e72da 100644
--- a/src/test/java/org/apache/sling/fscontentparser/impl/ParserHelperTest.java
+++ b/src/test/java/org/apache/sling/jcr/contentparser/impl/ParserHelperTest.java
@@ -16,10 +16,10 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.sling.fscontentparser.impl;
+package org.apache.sling.jcr.contentparser.impl;
 
-import static org.apache.sling.fscontentparser.ParserOptions.DEFAULT_PRIMARY_TYPE;
-import static org.apache.sling.fscontentparser.impl.ParserHelper.JCR_PRIMARYTYPE;
+import static org.apache.sling.jcr.contentparser.ParserOptions.DEFAULT_PRIMARY_TYPE;
+import static org.apache.sling.jcr.contentparser.impl.ParserHelper.JCR_PRIMARYTYPE;
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
@@ -32,8 +32,8 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.TimeZone;
 
-import org.apache.sling.fscontentparser.ParseException;
-import org.apache.sling.fscontentparser.ParserOptions;
+import org.apache.sling.jcr.contentparser.ParseException;
+import org.apache.sling.jcr.contentparser.ParserOptions;
 import org.junit.Test;
 
 import com.google.common.collect.ImmutableMap;
diff --git a/src/test/java/org/apache/sling/fscontentparser/impl/TestUtils.java b/src/test/java/org/apache/sling/jcr/contentparser/impl/TestUtils.java
similarity index 96%
rename from src/test/java/org/apache/sling/fscontentparser/impl/TestUtils.java
rename to src/test/java/org/apache/sling/jcr/contentparser/impl/TestUtils.java
index eb416a7..bd3bb10 100644
--- a/src/test/java/org/apache/sling/fscontentparser/impl/TestUtils.java
+++ b/src/test/java/org/apache/sling/jcr/contentparser/impl/TestUtils.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.sling.fscontentparser.impl;
+package org.apache.sling.jcr.contentparser.impl;
 
 import java.util.Map;
 

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-jcr-contentparser] 06/14: svn:ignore

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.jcr.contentparser-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-contentparser.git

commit ad3f2d66fa1f331b3e012f17876e78855a16deb0
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Mon Mar 13 13:07:07 2017 +0000

    svn:ignore
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/fscontentparser@1786678 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-jcr-contentparser] 03/14: SLING-6592 use enum instead of string constants

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.jcr.contentparser-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-contentparser.git

commit 0969aab040265db91b0d447124f7981dda358a87
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Thu Mar 2 21:54:49 2017 +0000

    SLING-6592 use enum instead of string constants
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/fscontentparser@1785198 13f79535-47bb-0310-9956-ffa450edef68
---
 .../fscontentparser/ContentFileParserFactory.java  | 24 ++++++++++----------
 ...tentFileExtension.java => ContentFileType.java} | 26 +++++++++++++++-------
 .../impl/JcrXmlContentFileParserTest.java          | 10 ++++-----
 .../impl/JsonContentFileParserTest.java            | 18 +++++++--------
 4 files changed, 44 insertions(+), 34 deletions(-)

diff --git a/src/main/java/org/apache/sling/fscontentparser/ContentFileParserFactory.java b/src/main/java/org/apache/sling/fscontentparser/ContentFileParserFactory.java
index d4ebe95..7fc66e7 100644
--- a/src/main/java/org/apache/sling/fscontentparser/ContentFileParserFactory.java
+++ b/src/main/java/org/apache/sling/fscontentparser/ContentFileParserFactory.java
@@ -18,7 +18,6 @@
  */
 package org.apache.sling.fscontentparser;
 
-import org.apache.commons.lang3.StringUtils;
 import org.apache.sling.fscontentparser.impl.JcrXmlContentFileParser;
 import org.apache.sling.fscontentparser.impl.JsonContentFileParser;
 
@@ -33,27 +32,28 @@ public final class ContentFileParserFactory {
     
     /**
      * Create content file parser.
-     * @param fileExtension File extension from {@link ContentFileExtension}.
+     * @param type Content file type
      * @return Content file parser
      */
-    public static ContentFileParser create(String fileExtension) {
-        return create(fileExtension, new ParserOptions());
+    public static ContentFileParser create(ContentFileType type) {
+        return create(type, new ParserOptions());
     }
     
     /**
      * Create content file parser.
-     * @param fileExtension File extension from {@link ContentFileExtension}.
+     * @param type Content file type
      * @param options Parser options
      * @return Content file parser
      */
-    public static ContentFileParser create(String fileExtension, ParserOptions options) {
-        if (StringUtils.equals(fileExtension, ContentFileExtension.JSON)) {
-            return new JsonContentFileParser(options);
+    public static ContentFileParser create(ContentFileType type, ParserOptions options) {
+        switch (type) {
+            case JSON:
+                return new JsonContentFileParser(options);
+            case JCR_XML:
+                return new JcrXmlContentFileParser(options);
+            default:
+                throw new IllegalArgumentException("Unsupported file extension: " + type);
         }
-        else if (StringUtils.equals(fileExtension, ContentFileExtension.JCR_XML)) {
-            return new JcrXmlContentFileParser(options);
-        }
-        throw new IllegalArgumentException("Unsupported file extension: " + fileExtension);
     }
     
 }
diff --git a/src/main/java/org/apache/sling/fscontentparser/ContentFileExtension.java b/src/main/java/org/apache/sling/fscontentparser/ContentFileType.java
similarity index 76%
rename from src/main/java/org/apache/sling/fscontentparser/ContentFileExtension.java
rename to src/main/java/org/apache/sling/fscontentparser/ContentFileType.java
index a33a4b8..72ca467 100644
--- a/src/main/java/org/apache/sling/fscontentparser/ContentFileExtension.java
+++ b/src/main/java/org/apache/sling/fscontentparser/ContentFileType.java
@@ -21,20 +21,30 @@ package org.apache.sling.fscontentparser;
 /**
  * Content file types.
  */
-public final class ContentFileExtension {
-    
+public enum ContentFileType {
+
     /**
      * JSON content files.
      */
-    public static final String JSON = "json";
+    JSON("json"),
 
     /**
      * JCR XML content files.
      */
-    public static final String JCR_XML = "jcr.xml";
-        
-    private ContentFileExtension() {
-        // constants only
+    JCR_XML("jcr.xml");
+
+
+    private final String extension;
+
+    private ContentFileType(String extension) {
+        this.extension = extension;
     }
-    
+
+    /**
+     * @return Extension
+     */
+    public String getExtension() {
+        return extension;
+    }
+
 }
diff --git a/src/test/java/org/apache/sling/fscontentparser/impl/JcrXmlContentFileParserTest.java b/src/test/java/org/apache/sling/fscontentparser/impl/JcrXmlContentFileParserTest.java
index 78f02c8..d89917e 100644
--- a/src/test/java/org/apache/sling/fscontentparser/impl/JcrXmlContentFileParserTest.java
+++ b/src/test/java/org/apache/sling/fscontentparser/impl/JcrXmlContentFileParserTest.java
@@ -30,7 +30,7 @@ import java.util.Map;
 import java.util.TimeZone;
 
 import org.apache.jackrabbit.util.ISO9075;
-import org.apache.sling.fscontentparser.ContentFileExtension;
+import org.apache.sling.fscontentparser.ContentFileType;
 import org.apache.sling.fscontentparser.ContentFileParser;
 import org.apache.sling.fscontentparser.ContentFileParserFactory;
 import org.apache.sling.fscontentparser.ParseException;
@@ -52,7 +52,7 @@ public class JcrXmlContentFileParserTest {
     @SuppressWarnings("unchecked")
     @Test
     public void testParseJcrXml() throws Exception {
-        ContentFileParser underTest = ContentFileParserFactory.create(ContentFileExtension.JCR_XML);
+        ContentFileParser underTest = ContentFileParserFactory.create(ContentFileType.JCR_XML);
         Map<String,Object> content = underTest.parse(file);
         assertNotNull(content);
         assertEquals("app:Page", content.get("jcr:primaryType"));
@@ -62,13 +62,13 @@ public class JcrXmlContentFileParserTest {
     @Test(expected=ParseException.class)
     public void testParseInvalidJcrXml() throws Exception {
         file = new File("src/test/resources/invalid-test/invalid.jcr.xml");
-        ContentFileParser underTest = ContentFileParserFactory.create(ContentFileExtension.JCR_XML);
+        ContentFileParser underTest = ContentFileParserFactory.create(ContentFileType.JCR_XML);
         underTest.parse(file);
     }
 
     @Test
     public void testDataTypes() throws Exception {
-        ContentFileParser underTest = ContentFileParserFactory.create(ContentFileExtension.JCR_XML);
+        ContentFileParser underTest = ContentFileParserFactory.create(ContentFileType.JCR_XML);
         Map<String,Object> content = underTest.parse(file);
         Map<String,Object> props = getDeep(content, "jcr:content");
         
@@ -99,7 +99,7 @@ public class JcrXmlContentFileParserTest {
 
     @Test
     public void testIgnoreResourcesProperties() throws Exception {
-        ContentFileParser underTest = ContentFileParserFactory.create(ContentFileExtension.JCR_XML, new ParserOptions()
+        ContentFileParser underTest = ContentFileParserFactory.create(ContentFileType.JCR_XML, new ParserOptions()
                 .ignoreResourceNames(ImmutableSet.of("teaserbar", "aside"))
                 .ignorePropertyNames(ImmutableSet.of("longProp", "jcr:title")));
         Map<String,Object> content = underTest.parse(file);
diff --git a/src/test/java/org/apache/sling/fscontentparser/impl/JsonContentFileParserTest.java b/src/test/java/org/apache/sling/fscontentparser/impl/JsonContentFileParserTest.java
index 175e3bf..074cf67 100644
--- a/src/test/java/org/apache/sling/fscontentparser/impl/JsonContentFileParserTest.java
+++ b/src/test/java/org/apache/sling/fscontentparser/impl/JsonContentFileParserTest.java
@@ -29,7 +29,7 @@ import java.util.Calendar;
 import java.util.Map;
 import java.util.TimeZone;
 
-import org.apache.sling.fscontentparser.ContentFileExtension;
+import org.apache.sling.fscontentparser.ContentFileType;
 import org.apache.sling.fscontentparser.ContentFileParser;
 import org.apache.sling.fscontentparser.ContentFileParserFactory;
 import org.apache.sling.fscontentparser.ParseException;
@@ -50,7 +50,7 @@ public class JsonContentFileParserTest {
 
     @Test
     public void testPageJcrPrimaryType() throws Exception {
-        ContentFileParser underTest = ContentFileParserFactory.create(ContentFileExtension.JSON);
+        ContentFileParser underTest = ContentFileParserFactory.create(ContentFileType.JSON);
         Map<String, Object> content = underTest.parse(file);
 
         assertEquals("app:Page", content.get("jcr:primaryType"));
@@ -58,7 +58,7 @@ public class JsonContentFileParserTest {
 
     @Test
     public void testDataTypes() throws Exception {
-        ContentFileParser underTest = ContentFileParserFactory.create(ContentFileExtension.JSON);
+        ContentFileParser underTest = ContentFileParserFactory.create(ContentFileType.JSON);
         Map<String, Object> content = underTest.parse(file);
 
         Map<String, Object> props = getDeep(content, "toolbar/profiles/jcr:content");
@@ -75,7 +75,7 @@ public class JsonContentFileParserTest {
 
     @Test
     public void testContentProperties() throws Exception {
-        ContentFileParser underTest = ContentFileParserFactory.create(ContentFileExtension.JSON);
+        ContentFileParser underTest = ContentFileParserFactory.create(ContentFileType.JSON);
         Map<String, Object> content = underTest.parse(file);
 
         Map<String, Object> props = getDeep(content, "jcr:content/header");
@@ -84,7 +84,7 @@ public class JsonContentFileParserTest {
 
     @Test
     public void testCalendar() throws Exception {
-        ContentFileParser underTest = ContentFileParserFactory.create(ContentFileExtension.JSON,
+        ContentFileParser underTest = ContentFileParserFactory.create(ContentFileType.JSON,
                 new ParserOptions().detectCalendarValues(true));
         Map<String, Object> content = underTest.parse(file);
 
@@ -106,7 +106,7 @@ public class JsonContentFileParserTest {
 
     @Test
     public void testUTF8Chars() throws Exception {
-        ContentFileParser underTest = ContentFileParserFactory.create(ContentFileExtension.JSON);
+        ContentFileParser underTest = ContentFileParserFactory.create(ContentFileType.JSON);
         Map<String, Object> content = underTest.parse(file);
 
         Map<String, Object> props = getDeep(content, "jcr:content");
@@ -117,7 +117,7 @@ public class JsonContentFileParserTest {
     @Test(expected = ParseException.class)
     public void testParseInvalidJson() throws Exception {
         file = new File("src/test/resources/invalid-test/invalid.json");
-        ContentFileParser underTest = ContentFileParserFactory.create(ContentFileExtension.JSON);
+        ContentFileParser underTest = ContentFileParserFactory.create(ContentFileType.JSON);
         Map<String, Object> content = underTest.parse(file);
         assertNull(content);
     }
@@ -125,14 +125,14 @@ public class JsonContentFileParserTest {
     @Test(expected = ParseException.class)
     public void testParseInvalidJsonWithObjectList() throws Exception {
         file = new File("src/test/resources/invalid-test/contentWithObjectList.json");
-        ContentFileParser underTest = ContentFileParserFactory.create(ContentFileExtension.JSON);
+        ContentFileParser underTest = ContentFileParserFactory.create(ContentFileType.JSON);
         Map<String, Object> content = underTest.parse(file);
         assertNull(content);
     }
 
     @Test
     public void testIgnoreResourcesProperties() throws Exception {
-        ContentFileParser underTest = ContentFileParserFactory.create(ContentFileExtension.JSON,
+        ContentFileParser underTest = ContentFileParserFactory.create(ContentFileType.JSON,
                 new ParserOptions().ignoreResourceNames(ImmutableSet.of("header", "newslist"))
                         .ignorePropertyNames(ImmutableSet.of("jcr:title")));
         Map<String, Object> content = underTest.parse(file);

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-jcr-contentparser] 12/14: add osgi versioning annotations

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.jcr.contentparser-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-contentparser.git

commit b27f542dece618a857b3fa2fd4d13c0e4ec77fce
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Mon Mar 20 11:10:08 2017 +0000

    add osgi versioning annotations
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/contentparser@1787714 13f79535-47bb-0310-9956-ffa450edef68
---
 src/main/java/org/apache/sling/jcr/contentparser/ContentHandler.java   | 3 +++
 src/main/java/org/apache/sling/jcr/contentparser/ContentParser.java    | 3 +++
 .../java/org/apache/sling/jcr/contentparser/ContentParserFactory.java  | 2 ++
 src/main/java/org/apache/sling/jcr/contentparser/ContentType.java      | 3 +++
 src/main/java/org/apache/sling/jcr/contentparser/ParseException.java   | 3 +++
 src/main/java/org/apache/sling/jcr/contentparser/ParserOptions.java    | 3 +++
 6 files changed, 17 insertions(+)

diff --git a/src/main/java/org/apache/sling/jcr/contentparser/ContentHandler.java b/src/main/java/org/apache/sling/jcr/contentparser/ContentHandler.java
index 7582338..8c88d84 100644
--- a/src/main/java/org/apache/sling/jcr/contentparser/ContentHandler.java
+++ b/src/main/java/org/apache/sling/jcr/contentparser/ContentHandler.java
@@ -20,11 +20,14 @@ package org.apache.sling.jcr.contentparser;
 
 import java.util.Map;
 
+import org.osgi.annotation.versioning.ConsumerType;
+
 /**
  * Handler that gets notified while parsing content with {@link ContentParser}.
  * The resources are always reported in order of their paths as found in the content fragment.
  * Parents are always reported before their children.
  */
+@ConsumerType
 public interface ContentHandler {
 
     /**
diff --git a/src/main/java/org/apache/sling/jcr/contentparser/ContentParser.java b/src/main/java/org/apache/sling/jcr/contentparser/ContentParser.java
index fa6877d..4876986 100644
--- a/src/main/java/org/apache/sling/jcr/contentparser/ContentParser.java
+++ b/src/main/java/org/apache/sling/jcr/contentparser/ContentParser.java
@@ -21,10 +21,13 @@ package org.apache.sling.jcr.contentparser;
 import java.io.IOException;
 import java.io.InputStream;
 
+import org.osgi.annotation.versioning.ProviderType;
+
 /**
  * Parses repository content from a file.
  * Implementations have to be thread-safe.
  */
+@ProviderType
 public interface ContentParser {
 
     /**
diff --git a/src/main/java/org/apache/sling/jcr/contentparser/ContentParserFactory.java b/src/main/java/org/apache/sling/jcr/contentparser/ContentParserFactory.java
index 7357ec5..33ca999 100644
--- a/src/main/java/org/apache/sling/jcr/contentparser/ContentParserFactory.java
+++ b/src/main/java/org/apache/sling/jcr/contentparser/ContentParserFactory.java
@@ -20,10 +20,12 @@ package org.apache.sling.jcr.contentparser;
 
 import org.apache.sling.jcr.contentparser.impl.JcrXmlContentParser;
 import org.apache.sling.jcr.contentparser.impl.JsonContentParser;
+import org.osgi.annotation.versioning.ProviderType;
 
 /**
  * Factory for content parsers.
  */
+@ProviderType
 public final class ContentParserFactory {
 
     private ContentParserFactory() {
diff --git a/src/main/java/org/apache/sling/jcr/contentparser/ContentType.java b/src/main/java/org/apache/sling/jcr/contentparser/ContentType.java
index acba05d..41665ee 100644
--- a/src/main/java/org/apache/sling/jcr/contentparser/ContentType.java
+++ b/src/main/java/org/apache/sling/jcr/contentparser/ContentType.java
@@ -18,9 +18,12 @@
  */
 package org.apache.sling.jcr.contentparser;
 
+import org.osgi.annotation.versioning.ProviderType;
+
 /**
  * Content types.
  */
+@ProviderType
 public enum ContentType {
 
     /**
diff --git a/src/main/java/org/apache/sling/jcr/contentparser/ParseException.java b/src/main/java/org/apache/sling/jcr/contentparser/ParseException.java
index 4df0160..38970b8 100644
--- a/src/main/java/org/apache/sling/jcr/contentparser/ParseException.java
+++ b/src/main/java/org/apache/sling/jcr/contentparser/ParseException.java
@@ -18,9 +18,12 @@
  */
 package org.apache.sling.jcr.contentparser;
 
+import org.osgi.annotation.versioning.ProviderType;
+
 /**
  * Parsing exception.
  */
+@ProviderType
 public final class ParseException extends RuntimeException {
     private static final long serialVersionUID = 1L;
 
diff --git a/src/main/java/org/apache/sling/jcr/contentparser/ParserOptions.java b/src/main/java/org/apache/sling/jcr/contentparser/ParserOptions.java
index 4dba088..4fe6192 100644
--- a/src/main/java/org/apache/sling/jcr/contentparser/ParserOptions.java
+++ b/src/main/java/org/apache/sling/jcr/contentparser/ParserOptions.java
@@ -23,9 +23,12 @@ import java.util.Collections;
 import java.util.HashSet;
 import java.util.Set;
 
+import org.osgi.annotation.versioning.ProviderType;
+
 /**
  * Options for content parser.
  */
+@ProviderType
 public final class ParserOptions {
     
     /**

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-jcr-contentparser] 13/14: [maven-release-plugin] prepare release org.apache.sling.jcr.contentparser-1.0.0

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.jcr.contentparser-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-contentparser.git

commit e14c280f7df09df6d23a21be275b2cef938f56ec
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Mon Mar 20 11:15:01 2017 +0000

    [maven-release-plugin] prepare release org.apache.sling.jcr.contentparser-1.0.0
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/contentparser@1787716 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index e092a3a..e740ebd 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,7 +28,7 @@
 
     <artifactId>org.apache.sling.jcr.contentparser</artifactId>
     <packaging>bundle</packaging>
-    <version>1.0.0-SNAPSHOT</version>
+    <version>1.0.0</version>
 
     <name>Apache Sling Content Parser</name>
     <description>
@@ -36,9 +36,9 @@
     </description>
 
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/contentparser</connection>
-        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/contentparser</developerConnection>
-        <url>http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/contentparser</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.jcr.contentparser-1.0.0</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.jcr.contentparser-1.0.0</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.jcr.contentparser-1.0.0</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-jcr-contentparser] 14/14: [maven-release-plugin] copy for tag org.apache.sling.jcr.contentparser-1.0.0

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.jcr.contentparser-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-contentparser.git

commit 20fe2f7ae4cb7e47649d300395ee5434e48d3215
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Mon Mar 20 11:15:14 2017 +0000

    [maven-release-plugin] copy for tag org.apache.sling.jcr.contentparser-1.0.0
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.jcr.contentparser-1.0.0@1787717 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-jcr-contentparser] 09/14: SLING-6592 remove parse(File) method from API

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.jcr.contentparser-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-contentparser.git

commit 6cefe40f28d63bc9975e384ff24acc3146672813
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Tue Mar 14 10:57:31 2017 +0000

    SLING-6592 remove parse(File) method from API
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/contentparser@1786876 13f79535-47bb-0310-9956-ffa450edef68
---
 .../apache/sling/jcr/contentparser/ContentParser.java   | 10 ----------
 .../jcr/contentparser/impl/JcrXmlContentParser.java     |  9 ---------
 .../sling/jcr/contentparser/impl/JsonContentParser.java |  9 ---------
 .../jcr/contentparser/impl/JcrXmlContentParserTest.java | 11 ++++++-----
 .../jcr/contentparser/impl/JsonContentParserTest.java   | 17 +++++++++--------
 .../apache/sling/jcr/contentparser/impl/TestUtils.java  | 12 ++++++++++++
 6 files changed, 27 insertions(+), 41 deletions(-)

diff --git a/src/main/java/org/apache/sling/jcr/contentparser/ContentParser.java b/src/main/java/org/apache/sling/jcr/contentparser/ContentParser.java
index cb6d013..1d9595a 100644
--- a/src/main/java/org/apache/sling/jcr/contentparser/ContentParser.java
+++ b/src/main/java/org/apache/sling/jcr/contentparser/ContentParser.java
@@ -18,7 +18,6 @@
  */
 package org.apache.sling.jcr.contentparser;
 
-import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.Map;
@@ -30,15 +29,6 @@ import java.util.Map;
 public interface ContentParser {
 
     /**
-     * Parse content file.
-     * @param file File
-     * @return Content
-     * @throws IOException When I/O error occurs.
-     * @throws ParseException When parsing error occurs.
-     */
-    Map<String,Object> parse(File file) throws IOException, ParseException;
-    
-    /**
      * Parse content.
      * @param is Stream with serialized content
      * @return Content as Map
diff --git a/src/main/java/org/apache/sling/jcr/contentparser/impl/JcrXmlContentParser.java b/src/main/java/org/apache/sling/jcr/contentparser/impl/JcrXmlContentParser.java
index dde8c16..2af30e7 100644
--- a/src/main/java/org/apache/sling/jcr/contentparser/impl/JcrXmlContentParser.java
+++ b/src/main/java/org/apache/sling/jcr/contentparser/impl/JcrXmlContentParser.java
@@ -18,8 +18,6 @@
  */
 package org.apache.sling.jcr.contentparser.impl;
 
-import java.io.File;
-import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.HashMap;
@@ -56,13 +54,6 @@ public final class JcrXmlContentParser implements ContentParser {
     }
     
     @Override
-    public Map<String,Object> parse(File file) throws IOException, ParseException {
-        try (FileInputStream fis = new FileInputStream(file)) {
-            return parse(fis);
-        }
-    }
-    
-    @Override
     public Map<String,Object> parse(InputStream is) throws IOException, ParseException {
         try {
             XmlHandler xmlHandler = new XmlHandler();
diff --git a/src/main/java/org/apache/sling/jcr/contentparser/impl/JsonContentParser.java b/src/main/java/org/apache/sling/jcr/contentparser/impl/JsonContentParser.java
index b070701..a17e91e 100644
--- a/src/main/java/org/apache/sling/jcr/contentparser/impl/JsonContentParser.java
+++ b/src/main/java/org/apache/sling/jcr/contentparser/impl/JsonContentParser.java
@@ -18,8 +18,6 @@
  */
 package org.apache.sling.jcr.contentparser.impl;
 
-import java.io.File;
-import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.Calendar;
@@ -59,13 +57,6 @@ public final class JsonContentParser implements ContentParser {
     }
     
     @Override
-    public Map<String,Object> parse(File file) throws IOException, ParseException {
-        try (FileInputStream fis = new FileInputStream(file)) {
-            return parse(fis);
-        }
-    }
-    
-    @Override
     public Map<String,Object> parse(InputStream is) throws IOException, ParseException {
         try (JsonReader reader = jsonReaderFactory.createReader(is)) {
             return toMap(reader.readObject());
diff --git a/src/test/java/org/apache/sling/jcr/contentparser/impl/JcrXmlContentParserTest.java b/src/test/java/org/apache/sling/jcr/contentparser/impl/JcrXmlContentParserTest.java
index d99a025..1faaf4e 100644
--- a/src/test/java/org/apache/sling/jcr/contentparser/impl/JcrXmlContentParserTest.java
+++ b/src/test/java/org/apache/sling/jcr/contentparser/impl/JcrXmlContentParserTest.java
@@ -19,6 +19,7 @@
 package org.apache.sling.jcr.contentparser.impl;
 
 import static org.apache.sling.jcr.contentparser.impl.TestUtils.getDeep;
+import static org.apache.sling.jcr.contentparser.impl.TestUtils.parse;
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
@@ -55,7 +56,7 @@ public class JcrXmlContentParserTest {
     @Test
     public void testParseJcrXml() throws Exception {
         ContentParser underTest = ContentParserFactory.create(ContentType.JCR_XML);
-        Map<String,Object> content = underTest.parse(file);
+        Map<String,Object> content = parse(underTest, file);
         assertNotNull(content);
         assertEquals("app:Page", content.get("jcr:primaryType"));
         assertEquals("app:PageContent", ((Map<String,Object>)content.get("jcr:content")).get("jcr:primaryType"));
@@ -65,13 +66,13 @@ public class JcrXmlContentParserTest {
     public void testParseInvalidJcrXml() throws Exception {
         file = new File("src/test/resources/invalid-test/invalid.jcr.xml");
         ContentParser underTest = ContentParserFactory.create(ContentType.JCR_XML);
-        underTest.parse(file);
+        parse(underTest, file);
     }
 
     @Test
     public void testDataTypes() throws Exception {
         ContentParser underTest = ContentParserFactory.create(ContentType.JCR_XML);
-        Map<String,Object> content = underTest.parse(file);
+        Map<String,Object> content = parse(underTest, file);
         Map<String,Object> props = getDeep(content, "jcr:content");
         
         assertEquals("en", props.get("jcr:title"));
@@ -104,7 +105,7 @@ public class JcrXmlContentParserTest {
         ContentParser underTest = ContentParserFactory.create(ContentType.JCR_XML, new ParserOptions()
                 .ignoreResourceNames(ImmutableSet.of("teaserbar", "aside"))
                 .ignorePropertyNames(ImmutableSet.of("longProp", "jcr:title")));
-        Map<String,Object> content = underTest.parse(file);
+        Map<String,Object> content = parse(underTest, file);
         Map<String,Object> props = getDeep(content, "jcr:content");
         
         assertEquals("HOME", props.get("navTitle"));
@@ -120,7 +121,7 @@ public class JcrXmlContentParserTest {
     @Ignore
     public void testSameNamePropertyAndSubResource() throws Exception {
         ContentParser underTest = ContentParserFactory.create(ContentType.JCR_XML);
-        Map<String,Object> content = underTest.parse(file);
+        Map<String,Object> content = parse(underTest, file);
         Map<String,Object> props = getDeep(content, "jcr:content/teaserbar");
         // teaserbaritem is a direct property as well as a sub resource
         assertEquals("test", props.get("teaserbaritem"));
diff --git a/src/test/java/org/apache/sling/jcr/contentparser/impl/JsonContentParserTest.java b/src/test/java/org/apache/sling/jcr/contentparser/impl/JsonContentParserTest.java
index a98757a..3aa9531 100644
--- a/src/test/java/org/apache/sling/jcr/contentparser/impl/JsonContentParserTest.java
+++ b/src/test/java/org/apache/sling/jcr/contentparser/impl/JsonContentParserTest.java
@@ -19,6 +19,7 @@
 package org.apache.sling.jcr.contentparser.impl;
 
 import static org.apache.sling.jcr.contentparser.impl.TestUtils.getDeep;
+import static org.apache.sling.jcr.contentparser.impl.TestUtils.parse;
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
@@ -52,7 +53,7 @@ public class JsonContentParserTest {
     @Test
     public void testPageJcrPrimaryType() throws Exception {
         ContentParser underTest = ContentParserFactory.create(ContentType.JSON);
-        Map<String, Object> content = underTest.parse(file);
+        Map<String, Object> content = parse(underTest, file);
 
         assertEquals("app:Page", content.get("jcr:primaryType"));
     }
@@ -60,7 +61,7 @@ public class JsonContentParserTest {
     @Test
     public void testDataTypes() throws Exception {
         ContentParser underTest = ContentParserFactory.create(ContentType.JSON);
-        Map<String, Object> content = underTest.parse(file);
+        Map<String, Object> content = parse(underTest, file);
 
         Map<String, Object> props = getDeep(content, "toolbar/profiles/jcr:content");
         assertEquals(true, props.get("hideInNav"));
@@ -77,7 +78,7 @@ public class JsonContentParserTest {
     @Test
     public void testContentProperties() throws Exception {
         ContentParser underTest = ContentParserFactory.create(ContentType.JSON);
-        Map<String, Object> content = underTest.parse(file);
+        Map<String, Object> content = parse(underTest, file);
 
         Map<String, Object> props = getDeep(content, "jcr:content/header");
         assertEquals("/content/dam/sample/header.png", props.get("imageReference"));
@@ -87,7 +88,7 @@ public class JsonContentParserTest {
     public void testCalendar() throws Exception {
         ContentParser underTest = ContentParserFactory.create(ContentType.JSON,
                 new ParserOptions().detectCalendarValues(true));
-        Map<String, Object> content = underTest.parse(file);
+        Map<String, Object> content = parse(underTest, file);
 
         Map<String, Object> props = getDeep(content, "jcr:content");
 
@@ -108,7 +109,7 @@ public class JsonContentParserTest {
     @Test
     public void testUTF8Chars() throws Exception {
         ContentParser underTest = ContentParserFactory.create(ContentType.JSON);
-        Map<String, Object> content = underTest.parse(file);
+        Map<String, Object> content = parse(underTest, file);
 
         Map<String, Object> props = getDeep(content, "jcr:content");
 
@@ -119,7 +120,7 @@ public class JsonContentParserTest {
     public void testParseInvalidJson() throws Exception {
         file = new File("src/test/resources/invalid-test/invalid.json");
         ContentParser underTest = ContentParserFactory.create(ContentType.JSON);
-        Map<String, Object> content = underTest.parse(file);
+        Map<String, Object> content = parse(underTest, file);
         assertNull(content);
     }
 
@@ -127,7 +128,7 @@ public class JsonContentParserTest {
     public void testParseInvalidJsonWithObjectList() throws Exception {
         file = new File("src/test/resources/invalid-test/contentWithObjectList.json");
         ContentParser underTest = ContentParserFactory.create(ContentType.JSON);
-        Map<String, Object> content = underTest.parse(file);
+        Map<String, Object> content = parse(underTest, file);
         assertNull(content);
     }
 
@@ -136,7 +137,7 @@ public class JsonContentParserTest {
         ContentParser underTest = ContentParserFactory.create(ContentType.JSON,
                 new ParserOptions().ignoreResourceNames(ImmutableSet.of("header", "newslist"))
                         .ignorePropertyNames(ImmutableSet.of("jcr:title")));
-        Map<String, Object> content = underTest.parse(file);
+        Map<String, Object> content = parse(underTest, file);
         Map<String, Object> props = getDeep(content, "jcr:content");
 
         assertEquals("Sample Homepage", props.get("pageTitle"));
diff --git a/src/test/java/org/apache/sling/jcr/contentparser/impl/TestUtils.java b/src/test/java/org/apache/sling/jcr/contentparser/impl/TestUtils.java
index bd3bb10..f91c5ee 100644
--- a/src/test/java/org/apache/sling/jcr/contentparser/impl/TestUtils.java
+++ b/src/test/java/org/apache/sling/jcr/contentparser/impl/TestUtils.java
@@ -18,9 +18,14 @@
  */
 package org.apache.sling.jcr.contentparser.impl;
 
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
 import java.util.Map;
 
 import org.apache.commons.lang3.StringUtils;
+import org.apache.sling.jcr.contentparser.ContentParser;
 
 public final class TestUtils {
     
@@ -45,4 +50,11 @@ public final class TestUtils {
       }
     }
     
+    public static Map<String,Object> parse(ContentParser contentParser, File file) throws IOException {
+        try (FileInputStream fis = new FileInputStream(file);
+                BufferedInputStream bis = new BufferedInputStream(fis)) {
+            return contentParser.parse(bis);
+        }
+    }
+    
 }

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-jcr-contentparser] 02/14: SLING-6592 use DocViewProperty from vault-core to parse jcr xml property values fix artifactid

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.jcr.contentparser-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-contentparser.git

commit 081596f751b5ef0474978e02d2c7d42bc3f68eeb
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Thu Mar 2 21:37:31 2017 +0000

    SLING-6592 use DocViewProperty from vault-core to parse jcr xml property values
    fix artifactid
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/fscontentparser@1785194 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml                                            |  29 ++--
 .../impl/JcrXmlContentFileParser.java              |   7 +-
 .../fscontentparser/impl/JcrXmlValueConverter.java | 192 +++++++++------------
 .../impl/JcrXmlValueConverterTest.java             |  59 ++++---
 4 files changed, 145 insertions(+), 142 deletions(-)

diff --git a/pom.xml b/pom.xml
index da20dc3..6b42222 100644
--- a/pom.xml
+++ b/pom.xml
@@ -26,7 +26,7 @@
         <relativePath />
     </parent>
 
-    <artifactId>org.apache.sling.fscontentparser</artifactId>
+    <artifactId>org.apache.sling.commons.fscontentparser</artifactId>
     <packaging>bundle</packaging>
     <version>1.0.0-SNAPSHOT</version>
 
@@ -47,16 +47,6 @@
                 <groupId>org.apache.felix</groupId>
                 <artifactId>maven-bundle-plugin</artifactId>
                 <extensions>true</extensions>
-                <configuration>
-                    <instructions>
-                        <!-- Embed the nessecary parts of the jackrabbit-jcr-commons bundle as described in http://njbartlett.name/2014/05/26/static-linking.html -->
-                        <Conditional-Package>org.apache.jackrabbit.util</Conditional-Package>
-                        <Import-Package>
-                          !org.apache.jackrabbit.*,
-                          *
-                        </Import-Package>
-                    </instructions>
-                </configuration>
             </plugin>
             <plugin>
                 <groupId>org.apache.rat</groupId>
@@ -100,12 +90,29 @@
             <scope>compile</scope>
         </dependency>
         <dependency>
+            <groupId>javax.jcr</groupId>
+            <artifactId>jcr</artifactId>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.jackrabbit</groupId>
+            <artifactId>jackrabbit-api</artifactId>
+            <version>2.8.0</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
             <groupId>org.apache.jackrabbit</groupId>
             <artifactId>jackrabbit-jcr-commons</artifactId>
             <version>2.8.0</version>
             <scope>compile</scope>
         </dependency>
         <dependency>
+            <groupId>org.apache.jackrabbit.vault</groupId>
+            <artifactId>org.apache.jackrabbit.vault</artifactId>
+            <version>3.1.18</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
             <scope>test</scope>
diff --git a/src/main/java/org/apache/sling/fscontentparser/impl/JcrXmlContentFileParser.java b/src/main/java/org/apache/sling/fscontentparser/impl/JcrXmlContentFileParser.java
index 060308e..c97317e 100644
--- a/src/main/java/org/apache/sling/fscontentparser/impl/JcrXmlContentFileParser.java
+++ b/src/main/java/org/apache/sling/fscontentparser/impl/JcrXmlContentFileParser.java
@@ -129,11 +129,10 @@ public final class JcrXmlContentFileParser implements ContentFileParser {
             for (int i=0; i<attributes.getLength(); i++) {
                 String propertyName = helper.cleanupPropertyName(decodeName(attributes.getQName(i)));
                 if (!helper.ignoreProperty(propertyName)) {
-                    Object value = JcrXmlValueConverter.parseValue(attributes.getValue(i));
-                    if (value instanceof Object[]) {
-                        value = helper.convertSingleTypeArray((Object[])value);
+                    Object value = JcrXmlValueConverter.parseValue(propertyName, attributes.getValue(i));
+                    if (value != null) {
+                        element.put(propertyName, value);
                     }
-                    element.put(propertyName, value);
                 }
             }
         }
diff --git a/src/main/java/org/apache/sling/fscontentparser/impl/JcrXmlValueConverter.java b/src/main/java/org/apache/sling/fscontentparser/impl/JcrXmlValueConverter.java
index b3a817e..8e9fad4 100644
--- a/src/main/java/org/apache/sling/fscontentparser/impl/JcrXmlValueConverter.java
+++ b/src/main/java/org/apache/sling/fscontentparser/impl/JcrXmlValueConverter.java
@@ -18,23 +18,22 @@
  */
 package org.apache.sling.fscontentparser.impl;
 
-import java.util.ArrayList;
-import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
+import java.lang.reflect.Array;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Calendar;
+import java.util.UUID;
+
+import javax.jcr.PropertyType;
 
-import org.apache.commons.lang3.ArrayUtils;
-import org.apache.commons.lang3.StringUtils;
 import org.apache.jackrabbit.util.ISO8601;
+import org.apache.jackrabbit.vault.util.DocViewProperty;
 
 /**
  * Parses JCR XML files that contains content fragments.
  */
 class JcrXmlValueConverter {
     
-    private static final Pattern TYPE_PREFIX = Pattern.compile("^\\{([^\\{\\}]+)\\}(.+)$");
-    private static final Pattern VALUE_ARRAY = Pattern.compile("^\\[(.*)\\]$");
-    
     private JcrXmlValueConverter() {
         // static methods only
     }
@@ -44,125 +43,106 @@ class JcrXmlValueConverter {
      * @param value XML attribute value
      * @return Value object
      */
-    public static Object parseValue(final String rawValue) {
-        String value = rawValue;
-        String[] valueArray = null;
-        
-        if (rawValue == null) {
+    public static Object parseValue(final String name, final String value) {
+        if (value == null) {
             return null;
         }
+        DocViewProperty prop = DocViewProperty.parse(name, value);
         
-        // detect type prefix
-        String typePrefix = null;
-        Matcher typePrefixMatcher = TYPE_PREFIX.matcher(value);
-        if (typePrefixMatcher.matches()) {
-            typePrefix = typePrefixMatcher.group(1);
-            value = typePrefixMatcher.group(2);
-        }
-        
-        // check for array
-        Matcher arrayMatcher = VALUE_ARRAY.matcher(value);
-        if (arrayMatcher.matches()) {
-            value = null;
-            valueArray = splitPreserveAllTokens(arrayMatcher.group(1), ',');
-        }
-
         // convert values
-        if (valueArray != null) {
-            Object[] result = new Object[valueArray.length];
-            for (int i=0; i<valueArray.length; i++) {
-                result[i] = convertValue(valueArray[i], typePrefix, true);
+        if (prop.isMulti) {
+            Class<?> arrayType = getType(prop.type);
+            if (arrayType == null) {
+                return null;
+            }
+            Object result = Array.newInstance(arrayType, prop.values.length);
+            for (int i=0; i<prop.values.length; i++) {
+                Array.set(result, i, convertValue(prop.values[i], prop.type, true));
             }
             return result;
         }
         else {
-            return convertValue(value, typePrefix, false);
+            return convertValue(prop.values[0], prop.type, false);
         }
     }
     
     /**
-     * Split string preserving all tokens - but ignore separators that are escaped with \.
-     * @param str Combined string
-     * @param sep Separator
-     * @return Tokens
-     */
-    private static String[] splitPreserveAllTokens(String str, char sep) {
-        final int len = str.length();
-        if (len == 0) {
-            return ArrayUtils.EMPTY_STRING_ARRAY;
-        }
-        final List<String> list = new ArrayList<String>();
-        int i = 0, start = 0;
-        boolean match = false;
-        boolean lastMatch = false;
-        boolean escaped = false;
-        while (i < len) {
-            if (str.charAt(i) == '\\' && !escaped) {
-                escaped = true;
-            }
-            else {
-                if (str.charAt(i) == sep && !escaped) {
-                    lastMatch = true;
-                    list.add(str.substring(start, i));
-                    match = false;
-                    start = ++i;
-                    continue;
-                }
-                lastMatch = false;
-                match = true;
-                escaped = false;
-            }
-            i++;
-        }
-        if (match || lastMatch) {
-            list.add(str.substring(start, i));
-        }
-        return list.toArray(new String[list.size()]);        
-    }
-    
-    /**
      * Parse value depending on type prefix.
      * @param value Value
-     * @param typePrefix Type prefix
+     * @param type Type
      * @param inArray Value is in array
      * @return Value object
      */
-    private static Object convertValue(final String value, final String typePrefix, final boolean inArray) {
-        if (typePrefix == null || StringUtils.equals(typePrefix, "Name")) {
-            return deescapeStringValue(value, inArray);
-        }
-        else if (StringUtils.equals(typePrefix, "Boolean")) {
-            return Boolean.valueOf(value);
-        }
-        else if (StringUtils.equals(typePrefix, "Long")) {
-            return Long.valueOf(value);
-        }
-        else if (StringUtils.equals(typePrefix, "Decimal")) {
-            return Double.valueOf(value);
-        }
-        else if (StringUtils.equals(typePrefix, "Date")) {
-            return ISO8601.parse(value);
-        }
-        else {
-            throw new IllegalArgumentException("Unexpected type prefix: " + typePrefix);
+    private static Object convertValue(final String value, final int type, final boolean inArray) {
+        switch (type) {
+            case PropertyType.UNDEFINED:
+            case PropertyType.STRING:
+            case PropertyType.NAME:
+            case PropertyType.PATH:
+                return value;
+            case PropertyType.BOOLEAN:
+                return Boolean.valueOf(value);
+            case PropertyType.LONG:
+                return Long.valueOf(value);
+            case PropertyType.DOUBLE:
+            case PropertyType.DECIMAL:
+                // TODO: specific handling for BigDecimal? not properly supported in ValueMapDecorator until very recent Sling API versions
+                return Double.valueOf(value);
+            case PropertyType.DATE:
+                return ISO8601.parse(value);
+            case PropertyType.REFERENCE:
+            case PropertyType.WEAKREFERENCE:
+                return UUID.fromString(value);
+            case PropertyType.URI:
+                try {
+                    return new URI(value);
+                }
+                catch (URISyntaxException ex) {
+                    throw new IllegalArgumentException("Unexpected URI syntax: " + value);
+                }
+            case PropertyType.BINARY:
+                // not supported - ignore value
+                return null;
+            default:
+                throw new IllegalArgumentException("Unexpected type: " + PropertyType.nameFromValue(type));
+            
         }
     }
     
     /**
-     * De-escape string value.
-     * @param value Escaped string value
-     * @param inArray In array
-     * @return De-escaped string value
+     * Get java type for given JCR type.
+     * @param type Type
+     * @return Type
      */
-    private static String deescapeStringValue(final String value, final boolean inArray) {
-        String descapedValue = value;
-        if (inArray) {
-          descapedValue = StringUtils.replace(descapedValue, "\\,", ",");
+    private static Class<?> getType(final int type) {
+        switch (type) {
+            case PropertyType.UNDEFINED:
+            case PropertyType.STRING:
+            case PropertyType.NAME:
+            case PropertyType.PATH:
+                return String.class;
+            case PropertyType.BOOLEAN:
+                return Boolean.class;
+            case PropertyType.LONG:
+                return Long.class;
+            case PropertyType.DOUBLE:
+            case PropertyType.DECIMAL:
+                // TODO: specific handling for BigDecimal? not properly supported in ValueMapDecorator until very recent Sling API versions
+                return Double.class;
+            case PropertyType.DATE:
+                return Calendar.class;
+            case PropertyType.REFERENCE:
+            case PropertyType.WEAKREFERENCE:
+                return UUID.class;
+            case PropertyType.URI:
+                return URI.class;
+            case PropertyType.BINARY:
+                // not supported - ignore value
+                return null;
+            default:
+                throw new IllegalArgumentException("Unexpected type: " + PropertyType.nameFromValue(type));
+            
         }
-        else if (StringUtils.startsWith(descapedValue, "\\{") || StringUtils.startsWith(descapedValue, "\\[")) {
-            descapedValue = descapedValue.substring(1);
-        }
-        return StringUtils.replace(descapedValue, "\\\\", "\\");
     }
-        
+    
 }
diff --git a/src/test/java/org/apache/sling/fscontentparser/impl/JcrXmlValueConverterTest.java b/src/test/java/org/apache/sling/fscontentparser/impl/JcrXmlValueConverterTest.java
index bddf053..2f02aae 100644
--- a/src/test/java/org/apache/sling/fscontentparser/impl/JcrXmlValueConverterTest.java
+++ b/src/test/java/org/apache/sling/fscontentparser/impl/JcrXmlValueConverterTest.java
@@ -23,75 +23,79 @@ import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNull;
 
+import java.net.URI;
 import java.util.Calendar;
+import java.util.UUID;
 
 import org.junit.Test;
 
 public class JcrXmlValueConverterTest {
+    
+    private static final String NAME = "prop1";
 
     @Test
     public void testNull() {
-        assertNull(parseValue(null));
+        assertNull(parseValue(NAME, null));
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testInvalid() {
-        parseValue("{InvalidType}xyz");
+        parseValue(NAME, "{InvalidType}xyz");
     }
 
     @Test
     public void testString() {
-        assertEquals("myString", parseValue("myString"));
-        assertEquals("prop", "myString [ ] { } \\ ,", parseValue("myString [ ] { } \\\\ ,"));
-        assertEquals("{myString}", parseValue("\\{myString}"));
-        assertEquals("aaa{myString}", parseValue("aaa{myString}"));
-        assertEquals("[myString]", parseValue("\\[myString]"));
-        assertEquals("aaa[myString]", parseValue("aaa[myString]"));
+        assertEquals("myString", parseValue(NAME, "myString"));
+        assertEquals("prop", "myString [ ] { } \\ ,", parseValue(NAME, "myString [ ] { } \\\\ ,"));
+        assertEquals("{myString}", parseValue(NAME, "\\{myString}"));
+        assertEquals("aaa{myString}", parseValue(NAME, "aaa{myString}"));
+        assertEquals("[myString]", parseValue(NAME, "\\[myString]"));
+        assertEquals("aaa[myString]", parseValue(NAME, "aaa[myString]"));
     }
 
     @Test
     public void testStringArray() {
-        assertArrayEquals(new Object[] { "myString1", "myString2" }, (Object[]) parseValue("[myString1,myString2]"));
+        assertArrayEquals(new Object[] { "myString1", "myString2" }, (Object[]) parseValue(NAME, "[myString1,myString2]"));
         assertArrayEquals(new Object[] { "myString1,[]\\äöü߀", "myString2", "myString3 [ ] { } \\ ,", "", "[myString5]", "{myString6}" },
-                (Object[]) parseValue("[myString1\\,[]\\\\äöü߀,myString2,myString3 [ ] { } \\\\ \\,,,[myString5],{myString6}]"));
+                (Object[]) parseValue(NAME, "[myString1\\,[]\\\\äöü߀,myString2,myString3 [ ] { } \\\\ \\,,,[myString5],{myString6}]"));
     }
 
     @Test
     public void testBoolean() {
-        assertEquals(true, parseValue("{Boolean}true"));
-        assertEquals(false, parseValue("{Boolean}false"));
+        assertEquals(true, parseValue(NAME, "{Boolean}true"));
+        assertEquals(false, parseValue(NAME, "{Boolean}false"));
     }
 
     @Test
     public void testBooleanArray() {
-        assertArrayEquals(new Object[] { true, false }, (Object[]) parseValue("{Boolean}[true,false]"));
+        assertArrayEquals(new Object[] { true, false }, (Object[]) parseValue(NAME, "{Boolean}[true,false]"));
     }
 
     @Test
     public void testLong() {
-        assertEquals(1L, parseValue("{Long}1"));
-        assertEquals(10000000000L, parseValue("{Long}10000000000"));
+        assertEquals(1L, parseValue(NAME, "{Long}1"));
+        assertEquals(10000000000L, parseValue(NAME, "{Long}10000000000"));
     }
 
     @Test
     public void testLongArray() {
-        assertArrayEquals(new Object[] { 1L, 2L }, (Object[]) parseValue("{Long}[1,2]"));
-        assertArrayEquals(new Object[] { 10000000000L, 20000000000L }, (Object[]) parseValue("{Long}[10000000000,20000000000]"));
+        assertArrayEquals(new Object[] { 1L, 2L }, (Object[]) parseValue(NAME, "{Long}[1,2]"));
+        assertArrayEquals(new Object[] { 10000000000L, 20000000000L }, (Object[]) parseValue(NAME, "{Long}[10000000000,20000000000]"));
     }
 
     @Test
     public void testDouble() {
-        assertEquals(1.234d, parseValue("{Decimal}1.234"));
+        assertEquals(1.234d, parseValue(NAME, "{Decimal}1.234"));
     }
 
     @Test
     public void testDoubleArray() {
-        assertArrayEquals(new Object[] { 1.234d, 2.345d }, (Object[]) parseValue("{Decimal}[1.234,2.345]"));
+        assertArrayEquals(new Object[] { 1.234d, 2.345d }, (Object[]) parseValue(NAME, "{Decimal}[1.234,2.345]"));
     }
 
     @Test
     public void testCalendar() {
-        Calendar value = (Calendar)parseValue("{Date}2010-09-05T15:10:20.000Z");
+        Calendar value = (Calendar)parseValue(NAME, "{Date}2010-09-05T15:10:20.000Z");
         assertEquals(2010, value.get(Calendar.YEAR));
         assertEquals(8, value.get(Calendar.MONTH));
         assertEquals(5, value.get(Calendar.DAY_OF_MONTH));
@@ -99,7 +103,20 @@ public class JcrXmlValueConverterTest {
 
     @Test
     public void testStringArrayRepPrivileges() {
-        assertArrayEquals(new Object[] { "rep:write", "crx:replicate", "jcr:read" }, (Object[]) parseValue("{Name}[rep:write,crx:replicate,jcr:read]"));
+        assertArrayEquals(new Object[] { "rep:write", "crx:replicate", "jcr:read" }, (Object[]) parseValue(NAME, "{Name}[rep:write,crx:replicate,jcr:read]"));
+    }
+
+    @Test
+    public void testReference() {
+        UUID uuid = UUID.randomUUID();
+        UUID value = (UUID)parseValue(NAME, "{Reference}" + uuid.toString());
+        assertEquals(uuid, value);
+    }
+
+    @Test
+    public void testURI() {
+        URI value = (URI)parseValue(NAME, "{URI}http://www.jodelkaiser.de/");
+        assertEquals("http://www.jodelkaiser.de/", value.toString());
     }
 
 }

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-jcr-contentparser] 07/14: added ignored test for same name property and sub resource

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.jcr.contentparser-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-contentparser.git

commit d1d3c2ab68b79b29349fcfd24eb2f759da42c05f
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Mon Mar 13 14:07:30 2017 +0000

    added ignored test for same name property and sub resource
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/fscontentparser@1786694 13f79535-47bb-0310-9956-ffa450edef68
---
 .../fscontentparser/impl/JcrXmlContentFileParserTest.java     | 11 +++++++++++
 src/test/resources/content-test/content.jcr.xml               |  3 ++-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/src/test/java/org/apache/sling/fscontentparser/impl/JcrXmlContentFileParserTest.java b/src/test/java/org/apache/sling/fscontentparser/impl/JcrXmlContentFileParserTest.java
index 8678b30..cf78f49 100644
--- a/src/test/java/org/apache/sling/fscontentparser/impl/JcrXmlContentFileParserTest.java
+++ b/src/test/java/org/apache/sling/fscontentparser/impl/JcrXmlContentFileParserTest.java
@@ -37,6 +37,7 @@ import org.apache.sling.fscontentparser.ContentFileParserFactory;
 import org.apache.sling.fscontentparser.ParseException;
 import org.apache.sling.fscontentparser.ParserOptions;
 import org.junit.Before;
+import org.junit.Ignore;
 import org.junit.Test;
 
 import com.google.common.collect.ImmutableSet;
@@ -115,4 +116,14 @@ public class JcrXmlContentFileParserTest {
         assertNotNull(props.get("content"));
     }
 
+    @Test
+    @Ignore
+    public void testSameNamePropertyAndSubResource() throws Exception {
+        ContentFileParser underTest = ContentFileParserFactory.create(ContentFileType.JCR_XML);
+        Map<String,Object> content = underTest.parse(file);
+        Map<String,Object> props = getDeep(content, "jcr:content/teaserbar");
+        // teaserbaritem is a direct property as well as a sub resource
+        assertEquals("test", props.get("teaserbaritem"));
+    }
+
 }
diff --git a/src/test/resources/content-test/content.jcr.xml b/src/test/resources/content-test/content.jcr.xml
index 274cfe7..7d97cc0 100644
--- a/src/test/resources/content-test/content.jcr.xml
+++ b/src/test/resources/content-test/content.jcr.xml
@@ -38,7 +38,8 @@
       pageTitle="Sample Site">
     <teaserbar
         jcr:primaryType="nt:unstructured"
-        sling:resourceType="samples/sample-app/components/content/teaserbar/teaserbarParsys">
+        sling:resourceType="samples/sample-app/components/content/teaserbar/teaserbarParsys"
+        teaserbaritem="test">
       <teaserbaritem
           jcr:primaryType="nt:unstructured"
           sling:resourceType="samples/sample-app/components/content/teaserbar/teaserbarItem"

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.