You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ra...@apache.org on 2019/07/22 09:50:44 UTC

[sling-org-apache-sling-contentparser-xml] branch master created (now c3beddb)

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

radu pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-contentparser-xml.git.


      at c3beddb  SLING-8570 - Extract a generic Content Parser API from org.apache.sling.jcr.contentparser with pluggable implementations

This branch includes the following new commits:

     new 09e33ef  SLING-8570 - Extract a generic Content Parser API from org.apache.sling.jcr.contentparser with pluggable implementations
     new 7179289  SLING-8570 - Extract a generic Content Parser API from org.apache.sling.jcr.contentparser with pluggable implementations
     new 8f884c4  SLING-8570 - Extract a generic Content Parser API from org.apache.sling.jcr.contentparser with pluggable implementations
     new de2f254  SLING-8570 - Extract a generic Content Parser API from org.apache.sling.jcr.contentparser with pluggable implementations
     new 0592e54  SLING-8570 - Extract a generic Content Parser API from org.apache.sling.jcr.contentparser with pluggable implementations
     new c3beddb  SLING-8570 - Extract a generic Content Parser API from org.apache.sling.jcr.contentparser with pluggable implementations

The 6 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.



[sling-org-apache-sling-contentparser-xml] 02/06: SLING-8570 - Extract a generic Content Parser API from org.apache.sling.jcr.contentparser with pluggable implementations

Posted by ra...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

radu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-contentparser-xml.git

commit 7179289cfce7392f09bdb7f61f9208fb64bb18a6
Author: Radu Cotescu <ra...@apache.org>
AuthorDate: Mon Jul 15 12:02:03 2019 +0200

    SLING-8570 - Extract a generic Content Parser API from org.apache.sling.jcr.contentparser with pluggable implementations
    
    * added parser for JCR-flavoured XML
    * made the ParserHelper compatible with both Java 8 and Java 11
    * reduced the number of dependencies for all modules
---
 pom.xml                                            | 27 ----------
 .../xml/internal/XmlContentParserTest.java         | 62 ++++++++++++----------
 2 files changed, 34 insertions(+), 55 deletions(-)

diff --git a/pom.xml b/pom.xml
index d2063ac..b9a0237 100644
--- a/pom.xml
+++ b/pom.xml
@@ -50,12 +50,6 @@
             <scope>provided</scope>
         </dependency>
         <dependency>
-            <groupId>commons-io</groupId>
-            <artifactId>commons-io</artifactId>
-            <version>2.6</version>
-            <scope>provided</scope>
-        </dependency>
-        <dependency>
             <groupId>org.apache.commons</groupId>
             <artifactId>commons-lang3</artifactId>
             <version>3.8</version>
@@ -67,21 +61,6 @@
             <scope>provided</scope>
         </dependency>
         <dependency>
-            <groupId>org.osgi</groupId>
-            <artifactId>org.osgi.service.component</artifactId>
-            <scope>provided</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.osgi</groupId>
-            <artifactId>org.osgi.framework</artifactId>
-            <scope>provided</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-api</artifactId>
-            <scope>provided</scope>
-        </dependency>
-        <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.contentparser.testutils</artifactId>
             <version>0.9.0-SNAPSHOT</version>
@@ -92,11 +71,5 @@
             <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/test/java/org/apache/sling/contentparser/xml/internal/XmlContentParserTest.java b/src/test/java/org/apache/sling/contentparser/xml/internal/XmlContentParserTest.java
index 111ac73..5da18c3 100644
--- a/src/test/java/org/apache/sling/contentparser/xml/internal/XmlContentParserTest.java
+++ b/src/test/java/org/apache/sling/contentparser/xml/internal/XmlContentParserTest.java
@@ -20,20 +20,21 @@ package org.apache.sling.contentparser.xml.internal;
 
 import java.io.File;
 import java.math.BigDecimal;
+import java.util.Arrays;
 import java.util.Calendar;
+import java.util.Collections;
+import java.util.HashSet;
 import java.util.Map;
 import java.util.TimeZone;
 
 import org.apache.sling.contentparser.api.ContentParser;
 import org.apache.sling.contentparser.api.ParseException;
 import org.apache.sling.contentparser.api.ParserOptions;
+import org.apache.sling.contentparser.testutils.TestUtils;
 import org.apache.sling.contentparser.testutils.mapsupport.ContentElement;
 import org.junit.Before;
 import org.junit.Test;
 
-import com.google.common.collect.ImmutableSet;
-
-import static org.apache.sling.contentparser.testutils.TestUtils.parse;
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
@@ -52,16 +53,17 @@ public class XmlContentParserTest {
 
     @Test
     public void testPageJcrPrimaryType() throws Exception {
-        ContentElement content = parse(underTest, file);
+        ContentElement content = TestUtils.parse(underTest, file);
 
         assertEquals("app:Page", content.getProperties().get("jcr:primaryType"));
     }
 
     @Test
     public void testDataTypes() throws Exception {
-        ContentElement content = parse(underTest, file);
-
-        Map<String, Object> props = content.getChild("toolbar/profiles/jcr:content").getProperties();
+        ContentElement content = TestUtils.parse(underTest, file);
+        ContentElement child = content.getChild("toolbar/profiles/jcr:content");
+        assertNotNull("Expected child at path toolbar/profiles/jcr:content", child);
+        Map<String, Object> props = child.getProperties();
         assertEquals(true, props.get("hideInNav"));
 
         assertEquals(1234567890123L, props.get("longProp"));
@@ -75,17 +77,19 @@ public class XmlContentParserTest {
 
     @Test
     public void testContentProperties() throws Exception {
-        ContentElement content = parse(underTest, file);
-
-        Map<String, Object> props = content.getChild("jcr:content/header").getProperties();
+        ContentElement content = TestUtils.parse(underTest, file);
+        ContentElement child = content.getChild("jcr:content/header");
+        assertNotNull("Expected child at jcr:content/header", child);
+        Map<String, Object> props = child.getProperties();
         assertEquals("/content/dam/sample/header.png", props.get("imageReference"));
     }
 
     @Test
     public void testCalendar() throws Exception {
-        ContentElement content = parse(underTest, new ParserOptions().detectCalendarValues(true), file);
-
-        Map<String, Object> props = content.getChild("jcr:content").getProperties();
+        ContentElement content = TestUtils.parse(underTest, new ParserOptions().detectCalendarValues(true), file);
+        ContentElement child = content.getChild("jcr:content");
+        assertNotNull("Expected child at jcr:content", child);
+        Map<String, Object> props = child.getProperties();
 
         Calendar calendar = (Calendar) props.get("app:lastModified");
         assertNotNull(calendar);
@@ -103,11 +107,10 @@ public class XmlContentParserTest {
 
     @Test
     public void testUTF8Chars() throws Exception {
-
-        ContentElement content = parse(underTest, file);
-
-        Map<String, Object> props = content.getChild("jcr:content").getProperties();
-
+        ContentElement content = TestUtils.parse(underTest, file);
+        ContentElement child = content.getChild("jcr:content");
+        assertNotNull("Expected child at jcr:content", child);
+        Map<String, Object> props = child.getProperties();
         assertEquals("äöü߀", props.get("utf8Property"));
     }
 
@@ -115,7 +118,7 @@ public class XmlContentParserTest {
     public void testParseInvalidJson() throws Exception {
         file = new File("src/test/resources/invalid-test/invalid.json");
 
-        ContentElement content = parse(underTest, file);
+        ContentElement content = TestUtils.parse(underTest, file);
         assertNull(content);
     }
 
@@ -123,34 +126,37 @@ public class XmlContentParserTest {
     public void testParseInvalidJsonWithObjectList() throws Exception {
         file = new File("src/test/resources/invalid-test/contentWithObjectList.json");
 
-        ContentElement content = parse(underTest, file);
+        ContentElement content = TestUtils.parse(underTest, file);
         assertNull(content);
     }
 
     @Test
     public void testIgnoreResourcesProperties() throws Exception {
-        ContentElement content = parse(underTest,  new ParserOptions().ignoreResourceNames(ImmutableSet.of("header", "newslist"))
-                .ignorePropertyNames(ImmutableSet.of("jcr:title")), file);
+        ContentElement content = TestUtils.parse(underTest,
+                new ParserOptions().ignoreResourceNames(Collections.unmodifiableSet(new HashSet<>(Arrays.asList("header", "newslist"))))
+                        .ignorePropertyNames(Collections.unmodifiableSet(new HashSet<>(Arrays.asList("jcr:title")))), file);
         ContentElement child = content.getChild("jcr:content");
+        assertNotNull("Expected child at jcr:content", child);
+        Map<String, Object> props = child.getProperties();
 
-        assertEquals("Sample Homepage", child.getProperties().get("pageTitle"));
-        assertNull(child.getProperties().get("jcr:title"));
+        assertEquals("Sample Homepage", props.get("pageTitle"));
+        assertEquals("abc", props.get("refpro1"));
+        assertEquals("def", props.get("pathprop1"));
+        assertNull(props.get("jcr:title"));
 
         assertNull(child.getChildren().get("header"));
         assertNull(child.getChildren().get("newslist"));
         assertNotNull(child.getChildren().get("lead"));
-
-        assertEquals("abc", child.getProperties().get("refpro1"));
-        assertEquals("def", child.getProperties().get("pathprop1"));
     }
 
     @Test
     public void testGetChild() throws Exception {
 
-        ContentElement content = parse(underTest, file);
+        ContentElement content = TestUtils.parse(underTest, file);
         assertNull(content.getName());
 
         ContentElement deepChild = content.getChild("jcr:content/par/image/file/jcr:content");
+        assertNotNull("Expected a child at path jcr:content/par/image/file/jcr:content", deepChild);
         assertEquals("jcr:content", deepChild.getName());
         assertEquals("nt:resource", deepChild.getProperties().get("jcr:primaryType"));
 


[sling-org-apache-sling-contentparser-xml] 03/06: SLING-8570 - Extract a generic Content Parser API from org.apache.sling.jcr.contentparser with pluggable implementations

Posted by ra...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

radu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-contentparser-xml.git

commit 8f884c4070a7e7eb3eef50f999f2004b5e4c46b1
Author: Radu Cotescu <ra...@apache.org>
AuthorDate: Mon Jul 15 13:53:24 2019 +0200

    SLING-8570 - Extract a generic Content Parser API from org.apache.sling.jcr.contentparser with pluggable implementations
    
    * configured bnd-baseline-maven-plugin to not fail the build when
    there's no artifact available for the baseline analysis
---
 pom.xml | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/pom.xml b/pom.xml
index b9a0237..51ac22e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -42,6 +42,18 @@
         <tag>HEAD</tag>
     </scm>
 
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>biz.aQute.bnd</groupId>
+                <artifactId>bnd-baseline-maven-plugin</artifactId>
+                <configuration>
+                    <failOnMissing>false</failOnMissing>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
     <dependencies>
         <dependency>
             <groupId>org.apache.sling</groupId>


[sling-org-apache-sling-contentparser-xml] 06/06: SLING-8570 - Extract a generic Content Parser API from org.apache.sling.jcr.contentparser with pluggable implementations

Posted by ra...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

radu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-contentparser-xml.git

commit c3beddb8e3ffb3cb4e260e66c7e8598320c34946
Author: Radu Cotescu <co...@adobe.com>
AuthorDate: Mon Jul 22 11:50:15 2019 +0200

    SLING-8570 - Extract a generic Content Parser API from org.apache.sling.jcr.contentparser with pluggable implementations
    
    * added Jenkinsfile and updated links in README
---
 Jenkinsfile | 20 ++++++++++++++++++++
 README.md   |  2 +-
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/Jenkinsfile b/Jenkinsfile
new file mode 100644
index 0000000..3882176
--- /dev/null
+++ b/Jenkinsfile
@@ -0,0 +1,20 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ 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.
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+// please rebuild
+slingOsgiBundleBuild()
diff --git a/README.md b/README.md
index fa0f697..8d27194 100644
--- a/README.md
+++ b/README.md
@@ -3,7 +3,7 @@ Apache Sling Content Parser for XML
 This module is part of the [Apache Sling](https://sling.apache.org) project.
 
 The Apache Sling Content Parser for XML provides support for parsing XML files into Apache Sling resource trees, by implementing the 
-API provided by the [`org.apache.sling.contentparser.api`](https://github.com/apache/sling-whiteboard/tree/master/contentparser/org-apache-sling-contentparser-api) bundle.
+API provided by the [`org.apache.sling.contentparser.api`](https://github.com/apache/sling-org-apache-sling-contentparser-api) bundle.
 
 To obtain a reference to the XML content parser just filter on the `ContentParser.SERVICE_PROPERTY_CONTENT_TYPE` service registration 
 property:


[sling-org-apache-sling-contentparser-xml] 04/06: SLING-8570 - Extract a generic Content Parser API from org.apache.sling.jcr.contentparser with pluggable implementations

Posted by ra...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

radu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-contentparser-xml.git

commit de2f2547fc065602a6ed21cfae6cff4ee317ff3a
Author: Radu Cotescu <ra...@apache.org>
AuthorDate: Wed Jul 17 09:59:05 2019 +0200

    SLING-8570 - Extract a generic Content Parser API from org.apache.sling.jcr.contentparser with pluggable implementations
    
    * added README, CODE_OF_CONDUCT, CONTRIBUTING, LICENSE and .gitignore files
    to each module
---
 .gitignore         |  17 +++++
 CODE_OF_CONDUCT.md |  22 ++++++
 CONTRIBUTING.md    |  24 +++++++
 LICENSE            | 202 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 README.md          |  14 ++++
 5 files changed, 279 insertions(+)

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..5b783ed
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,17 @@
+/target
+.idea
+.classpath
+.metadata
+.project
+.settings
+.externalToolBuilders
+maven-eclipse.xml
+*.swp
+*.iml
+*.ipr
+*.iws
+*.bak
+.vlt
+.DS_Store
+jcr.log
+atlassian-ide-plugin.xml
diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md
new file mode 100644
index 0000000..0fa18e5
--- /dev/null
+++ b/CODE_OF_CONDUCT.md
@@ -0,0 +1,22 @@
+<!--/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+  ~ 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.
+  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/-->
+Apache Software Foundation Code of Conduct
+====
+
+Being an Apache project, Apache Sling adheres to the Apache Software Foundation's [Code of Conduct](https://www.apache.org/foundation/policies/conduct.html).
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 0000000..ac82a1a
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,24 @@
+<!--/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+  ~ 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.
+  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/-->
+Contributing
+====
+
+Thanks for choosing to contribute!
+
+You will find all the necessary details about how you can do this at https://sling.apache.org/contributing.html.
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..d645695
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,202 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..e320a8c
--- /dev/null
+++ b/README.md
@@ -0,0 +1,14 @@
+Apache Sling Content Parser for XML
+====
+This module is part of the [Apache Sling](https://sling.apache.org) project.
+
+The Apache Sling Content Parser for XML provides support for parsing XML files into Apache Sling resource trees, by implementing the 
+API provided by the [`org.apache.sling.contentparser.api`](https://github.com/apache/sling-whiteboard/tree/master/contentparser/org-apache-sling-contentparser-api) bundle.
+
+To obtain a reference to the XML content parser just filter on the `ContentParser.SERVICE_PROPERTY_CONTENT_TYPE` service registration 
+property:
+
+```java
+    @Reference(target = "(" + ContentParser.SERVICE_PROPERTY_CONTENT_TYPE + "=" + ContentParser.XML_CONTENT_TYPE + ")")
+    private ContentParser xmlParser;
+``` 


[sling-org-apache-sling-contentparser-xml] 01/06: SLING-8570 - Extract a generic Content Parser API from org.apache.sling.jcr.contentparser with pluggable implementations

Posted by ra...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

radu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-contentparser-xml.git

commit 09e33ef939ce1428d97e73787e2f7f2362d5aa44
Author: Radu Cotescu <ra...@apache.org>
AuthorDate: Fri Jul 12 16:33:23 2019 +0200

    SLING-8570 - Extract a generic Content Parser API from org.apache.sling.jcr.contentparser with pluggable implementations
    
    * extracted a test utils module, which can be used by all contentparser
    implementations
    * added a XML Content Parser implementation
---
 pom.xml                                            | 102 +++++++
 .../xml/internal/XmlContentParser.java             | 224 ++++++++++++++
 .../xml/internal/XmlContentParserTest.java         | 164 ++++++++++
 src/test/resources/content-test/content.xml        | 334 +++++++++++++++++++++
 .../invalid-test/contentWithObjectList.json        |  14 +
 src/test/resources/invalid-test/invalid.json       |   1 +
 6 files changed, 839 insertions(+)

diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..d2063ac
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,102 @@
+<?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-bundle-parent</artifactId>
+        <version>35</version>
+        <relativePath/>
+    </parent>
+
+    <artifactId>org.apache.sling.contentparser.xml</artifactId>
+    <version>0.9.0-SNAPSHOT</version>
+
+    <name>Apache Sling Content Parser for XML</name>
+    <description>
+        Apache Sling Content Parser for resource trees stored in XML files
+    </description>
+
+    <scm>
+        <connection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-contentparser-xml.git</connection>
+        <developerConnection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-contentparser-xml.git</developerConnection>
+        <url>https://gitbox.apache.org/repos/asf?p=sling-org-apache-sling-contentparser-xml.git</url>
+        <tag>HEAD</tag>
+    </scm>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.contentparser.api</artifactId>
+            <version>0.9.0-SNAPSHOT</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>commons-io</groupId>
+            <artifactId>commons-io</artifactId>
+            <version>2.6</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-lang3</artifactId>
+            <version>3.8</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.service.component.annotations</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.service.component</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.framework</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.contentparser.testutils</artifactId>
+            <version>0.9.0-SNAPSHOT</version>
+            <scope>test</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/contentparser/xml/internal/XmlContentParser.java b/src/main/java/org/apache/sling/contentparser/xml/internal/XmlContentParser.java
new file mode 100644
index 0000000..5c18539
--- /dev/null
+++ b/src/main/java/org/apache/sling/contentparser/xml/internal/XmlContentParser.java
@@ -0,0 +1,224 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ 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.contentparser.xml.internal;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.sling.contentparser.api.ContentHandler;
+import org.apache.sling.contentparser.api.ContentParser;
+import org.apache.sling.contentparser.api.ParseException;
+import org.apache.sling.contentparser.api.ParserHelper;
+import org.apache.sling.contentparser.api.ParserOptions;
+import org.osgi.service.component.annotations.Component;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
+/**
+ * Parses XML files that contains content fragments.
+ * Instance of this class is thread-safe.
+ */
+@Component(
+        property = {
+                ContentParser.SERVICE_PROPERTY_CONTENT_TYPE + "=" + ContentParser.XML_CONTENT_TYPE
+        }
+)
+public final class XmlContentParser implements ContentParser {
+
+    private static final String JCR_PRIMARY_TYPE = "jcr:primaryType";
+    private final DocumentBuilderFactory documentBuilderFactory;
+
+    public XmlContentParser() {
+        documentBuilderFactory = DocumentBuilderFactory.newInstance();
+    }
+
+    @Override
+    public void parse(ContentHandler handler, InputStream is, ParserOptions parserOptions) throws IOException, ParseException {
+        try {
+            DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
+            Document doc = documentBuilder.parse(is);
+            parse(handler, doc.getDocumentElement(), parserOptions, null);
+        } catch (ParserConfigurationException | SAXException ex) {
+            throw new ParseException("Error parsing JCR XML content.", ex);
+        }
+    }
+
+    private void parse(ContentHandler handler, Element element, ParserOptions parserOptions, String parentPath) {
+        // build node path
+        String path;
+        if (parentPath == null) {
+            path = "/";
+        } else {
+            String name = getChildText(element, "name");
+            if (StringUtils.isEmpty(name)) {
+                throw new ParseException("Child node without name detected below path " + parentPath);
+            }
+            if (parserOptions.getIgnoreResourceNames().contains(name)) {
+                return;
+            }
+            path = parentPath.endsWith("/") ? parentPath + name : parentPath + "/" + name;
+        }
+
+        Map<String, Object> properties = new HashMap<>();
+
+        // primary node type and mixins
+        String primaryType = getChildText(element, "primaryNodeType");
+        if (StringUtils.isNotBlank(primaryType) && !parserOptions.getIgnorePropertyNames().contains("jcr:primaryType")) {
+            properties.put("jcr:primaryType", primaryType);
+        }
+        String[] mixins = getChildTextArray(element, "mixinNodeType");
+        if (mixins.length > 0 && !parserOptions.getIgnorePropertyNames().contains("jcr:mixinTypes")) {
+            properties.put("jcr:mixinTypes", mixins);
+        }
+
+        // properties
+        List<Element> propertyElements = getChildren(element, "property");
+        for (Element propertyElement : propertyElements) {
+
+            // property name
+            String name = getChildText(propertyElement, "name");
+            if (StringUtils.isBlank(name)) {
+                throw new ParseException("Property without name detected at path " + path);
+            }
+            if (parserOptions.getIgnorePropertyNames().contains(name)) {
+                continue;
+            }
+
+            // property type
+            String type = getChildText(propertyElement, "type");
+            if (StringUtils.isBlank(type)) {
+                throw new ParseException("Property '" + name + "' has no type at path " + path);
+            }
+
+            // property value
+            Object value;
+            List<Element> valuesElements = getChildren(propertyElement, "values");
+            if (!valuesElements.isEmpty()) {
+                Element valuesElement = valuesElements.get(0);
+                List<Element> valueElements = getChildren(valuesElement, "value");
+                String[] stringValues = new String[valueElements.size()];
+                for (int i = 0; i < valueElements.size(); i++) {
+                    stringValues[i] = valueElements.get(i).getTextContent();
+                }
+                value = convertMultiValue(stringValues, type);
+            } else {
+                String stringValue = getChildText(propertyElement, "value");
+                value = convertValue(stringValue, type);
+            }
+            properties.put(name, value);
+        }
+
+        String defaultPrimaryType = parserOptions.getDefaultPrimaryType();
+        if (defaultPrimaryType != null) {
+            if (!properties.containsKey(JCR_PRIMARY_TYPE)) {
+                properties.put(JCR_PRIMARY_TYPE, defaultPrimaryType);
+            }
+        }
+        handler.resource(path, properties);
+
+        // child nodes
+        List<Element> nodeElements = getChildren(element, "node");
+        for (Element node : nodeElements) {
+            parse(handler, node, parserOptions, path);
+        }
+
+    }
+
+    private List<Element> getChildren(Element element, String childName) {
+        List<Element> result = new ArrayList<>();
+        NodeList children = element.getChildNodes();
+        int len = children.getLength();
+        for (int i = 0; i < len; i++) {
+            Node child = children.item(i);
+            if (child instanceof Element) {
+                Element childElement = (Element) child;
+                if (StringUtils.equals(childElement.getNodeName(), childName)) {
+                    result.add(childElement);
+                }
+            }
+        }
+        return result;
+    }
+
+    private String getChildText(Element element, String childName) {
+        List<Element> children = getChildren(element, childName);
+        if (children.isEmpty()) {
+            return null;
+        } else if (children.size() == 1) {
+            return children.get(0).getTextContent();
+        } else {
+            throw new ParseException("Found multiple elements with name '" + childName + "': " + children.size());
+        }
+    }
+
+    private String[] getChildTextArray(Element element, String childName) {
+        List<Element> children = getChildren(element, childName);
+        String[] result = new String[children.size()];
+        for (int i = 0; i < children.size(); i++) {
+            result[i] = children.get(i).getTextContent();
+        }
+        return result;
+    }
+
+    private Object convertValue(String value, String type) {
+        switch (type) {
+            case "String":
+            case "Name":
+            case "Path":
+            case "Reference":
+            case "WeakReference":
+            case "URI":
+                return value;
+            case "Long":
+                return Long.valueOf(value);
+            case "Double":
+                return Double.valueOf(value);
+            case "Date":
+                return ParserHelper.parseDate(value);
+            case "Boolean":
+                return Boolean.valueOf(value);
+            case "Decimal":
+                return new BigDecimal(value);
+            default:
+                throw new ParseException(String.format("Unsupported property type: %s.", type));
+        }
+    }
+
+    private Object convertMultiValue(String[] values, String type) {
+        Object[] result = new Object[values.length];
+        for (int i = 0; i < values.length; i++) {
+            result[i] = convertValue(values[i], type);
+        }
+        return ParserHelper.convertSingleTypeArray(result);
+    }
+
+}
diff --git a/src/test/java/org/apache/sling/contentparser/xml/internal/XmlContentParserTest.java b/src/test/java/org/apache/sling/contentparser/xml/internal/XmlContentParserTest.java
new file mode 100644
index 0000000..111ac73
--- /dev/null
+++ b/src/test/java/org/apache/sling/contentparser/xml/internal/XmlContentParserTest.java
@@ -0,0 +1,164 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ 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.contentparser.xml.internal;
+
+import java.io.File;
+import java.math.BigDecimal;
+import java.util.Calendar;
+import java.util.Map;
+import java.util.TimeZone;
+
+import org.apache.sling.contentparser.api.ContentParser;
+import org.apache.sling.contentparser.api.ParseException;
+import org.apache.sling.contentparser.api.ParserOptions;
+import org.apache.sling.contentparser.testutils.mapsupport.ContentElement;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.google.common.collect.ImmutableSet;
+
+import static org.apache.sling.contentparser.testutils.TestUtils.parse;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+public class XmlContentParserTest {
+
+    private File file;
+    private ContentParser underTest;
+
+    @Before
+    public void setUp() {
+        file = new File("src/test/resources/content-test/content.xml");
+        underTest = new XmlContentParser();
+    }
+
+    @Test
+    public void testPageJcrPrimaryType() throws Exception {
+        ContentElement content = parse(underTest, file);
+
+        assertEquals("app:Page", content.getProperties().get("jcr:primaryType"));
+    }
+
+    @Test
+    public void testDataTypes() throws Exception {
+        ContentElement content = parse(underTest, file);
+
+        Map<String, Object> props = content.getChild("toolbar/profiles/jcr:content").getProperties();
+        assertEquals(true, props.get("hideInNav"));
+
+        assertEquals(1234567890123L, props.get("longProp"));
+        assertEquals(new BigDecimal("1.2345"), props.get("decimalProp"));
+        assertEquals(true, props.get("booleanProp"));
+
+        assertArrayEquals(new Long[]{1234567890123L, 55L}, (Long[]) props.get("longPropMulti"));
+        assertArrayEquals(new BigDecimal[]{new BigDecimal("1.2345"), new BigDecimal("1.1")}, (BigDecimal[]) props.get("decimalPropMulti"));
+        assertArrayEquals(new Boolean[]{true, false}, (Boolean[]) props.get("booleanPropMulti"));
+    }
+
+    @Test
+    public void testContentProperties() throws Exception {
+        ContentElement content = parse(underTest, file);
+
+        Map<String, Object> props = content.getChild("jcr:content/header").getProperties();
+        assertEquals("/content/dam/sample/header.png", props.get("imageReference"));
+    }
+
+    @Test
+    public void testCalendar() throws Exception {
+        ContentElement content = parse(underTest, new ParserOptions().detectCalendarValues(true), file);
+
+        Map<String, Object> props = content.getChild("jcr:content").getProperties();
+
+        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 {
+
+        ContentElement content = parse(underTest, file);
+
+        Map<String, Object> props = content.getChild("jcr:content").getProperties();
+
+        assertEquals("äöü߀", props.get("utf8Property"));
+    }
+
+    @Test(expected = ParseException.class)
+    public void testParseInvalidJson() throws Exception {
+        file = new File("src/test/resources/invalid-test/invalid.json");
+
+        ContentElement content = parse(underTest, file);
+        assertNull(content);
+    }
+
+    @Test(expected = ParseException.class)
+    public void testParseInvalidJsonWithObjectList() throws Exception {
+        file = new File("src/test/resources/invalid-test/contentWithObjectList.json");
+
+        ContentElement content = parse(underTest, file);
+        assertNull(content);
+    }
+
+    @Test
+    public void testIgnoreResourcesProperties() throws Exception {
+        ContentElement content = parse(underTest,  new ParserOptions().ignoreResourceNames(ImmutableSet.of("header", "newslist"))
+                .ignorePropertyNames(ImmutableSet.of("jcr:title")), file);
+        ContentElement child = content.getChild("jcr:content");
+
+        assertEquals("Sample Homepage", child.getProperties().get("pageTitle"));
+        assertNull(child.getProperties().get("jcr:title"));
+
+        assertNull(child.getChildren().get("header"));
+        assertNull(child.getChildren().get("newslist"));
+        assertNotNull(child.getChildren().get("lead"));
+
+        assertEquals("abc", child.getProperties().get("refpro1"));
+        assertEquals("def", child.getProperties().get("pathprop1"));
+    }
+
+    @Test
+    public void testGetChild() throws Exception {
+
+        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/resources/content-test/content.xml b/src/test/resources/content-test/content.xml
new file mode 100644
index 0000000..6caed95
--- /dev/null
+++ b/src/test/resources/content-test/content.xml
@@ -0,0 +1,334 @@
+<?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.
+  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+<node>
+  <primaryNodeType>app:Page</primaryNodeType>
+  <property><name>jcr:createdBy</name><value>admin</value><type>String</type></property>
+  <property><name>jcr:created</name><value>Thu Aug 07 2014 16:32:59 GMT+0200</value><type>Date</type></property>
+  
+  <node>
+    <name>jcr:content</name>
+    <primaryNodeType>app:PageContent</primaryNodeType>
+    <property><name>jcr:createdBy</name><value>admin</value><type>String</type></property>
+    <property><name>jcr:title</name><value>English</value><type>String</type></property>
+    <property><name>app:template</name><value>sample/templates/homepage</value><type>String</type></property>
+    <property><name>jcr:created</name><value>Thu Aug 07 2014 16:32:59 GMT+0200</value><type>Date</type></property>
+    <property><name>app:lastModified</name><value>Tue Apr 22 2014 15:11:24 GMT+0200</value><type>Date</type></property>
+    <property><name>dateISO8601String</name><value>2014-04-22T15:11:24.000+02:00</value><type>Date</type></property>
+    <property><name>pageTitle</name><value>Sample Homepage</value><type>String</type></property>
+    <property><name>sling:resourceType</name><value>sample/components/homepage</value><type>String</type></property>
+    <property><name>sling:resourceSuperType</name><value>sample/components/supertype</value><type>String</type></property>
+    <property><name>app:designPath</name><value>/etc/designs/sample</value><type>String</type></property>
+    <property><name>app:lastModifiedBy</name><value>admin</value><type>String</type></property>
+    <property><name>utf8Property</name><value>äöü߀</value><type>String</type></property>
+    <property><name>refpro1</name><value>abc</value><type>Reference</type></property>
+    <property><name>pathprop1</name><value>def</value><type>Path</type></property>
+    
+    <node>
+      <name>par</name>
+      <primaryNodeType>nt:unstructured</primaryNodeType>
+      <property><name>sling:resourceType</name><value>foundation/components/parsys</value><type>String</type></property>
+      <node>
+        <name>colctrl</name>
+        <primaryNodeType>nt:unstructured</primaryNodeType>
+        <property><name>jcr:createdBy</name><value>admin</value><type>String</type></property>
+        <property><name>jcr:lastModifiedBy</name><value>admin</value><type>String</type></property>
+        <property><name>layout</name><value>2;colctrl-lt0</value><type>String</type></property>
+        <property><name>jcr:created</name><value>Mon Aug 23 2010 22:02:24 GMT+0200</value><type>Date</type></property>
+        <property><name>jcr:lastModified</name><value>Mon Aug 23 2010 22:02:35 GMT+0200</value><type>Date</type></property>
+        <property><name>sling:resourceType</name><value>foundation/components/parsys/colctrl</value><type>String</type></property>
+      </node>
+      <node>
+        <name>image</name>
+        <primaryNodeType>nt:unstructured</primaryNodeType>
+        <property><name>jcr:createdBy</name><value>admin</value><type>String</type></property>
+        <property><name>fileReference</name><value>/content/dam/sample/portraits/jane_doe.jpg</value><type>String</type></property>
+        <property><name>jcr:lastModifiedBy</name><value>admin</value><type>String</type></property>
+        <property><name>jcr:created</name><value>Mon Aug 23 2010 22:03:39 GMT+0200</value><type>Date</type></property>
+        <property><name>width</name><value>340</value><type>String</type></property>
+        <property><name>jcr:lastModified</name><value>Sun Oct 31 2010 21:39:50 GMT+0100</value><type>Date</type></property>
+        <property><name>sling:resourceTyp</name><value>foundation/components/image</value><type>String</type></property>
+        <node>
+          <name>file</name>
+          <primaryNodeType>nt:file</primaryNodeType>
+          <property><name>jcr:createdB</name><value>admin</value><type>String</type></property>
+          <property><name>jcr:created</name><value>Thu Aug 07 2014 16:32:59 GMT+0200</value><type>Date</type></property>
+          <node>
+            <name>jcr:content</name>
+            <primaryNodeType>nt:resource</primaryNodeType>
+            <property><name>jcr:lastModifiedBy</name><value>anonymous</value><type>String</type></property>
+            <property><name>jcr:mimeType</name><value>image/jpeg</value><type>String</type></property>
+            <property><name>jcr:lastModified</name><value>Thu Aug 07 2014 16:32:59 GMT+0200</value><type>Date</type></property>
+            <property><name>jcr:uuid</name><value>eda76d00-b2cd-4b59-878f-c33f71ceaddc</value><type>String</type></property>
+          </node>
+        </node>
+      </node>
+      <node>
+        <name>title_1</name>
+        <primaryNodeType>nt:unstructured</primaryNodeType>
+        <property><name>jcr:createdBy</name><value>admin</value><type>String</type></property>
+        <property><name>jcr:title</name><value>Strategic Consulting</value><type>String</type></property>
+        <property><name>jcr:lastModifiedBy</name><value>admin</value><type>String</type></property>
+        <property><name>jcr:created</name><value>Mon Aug 23 2010 22:12:08 GMT+0200</value><type>Date</type></property>
+        <property><name>jcr:lastModified</name><value>Wed Oct 27 2010 21:33:24 GMT+0200</value><type>Date</type></property>
+        <property><name>sling:resourceType</name><value>sample/components/title</value><type>String</type></property>
+      </node>
+      <node>
+        <name>text_1</name>
+        <primaryNodeType>nt:unstructured</primaryNodeType>
+        <property><name>jcr:createdBy</name><value>admin</value><type>String</type></property>
+        <property><name>jcr:lastModifiedBy</name><value>admin</value><type>String</type></property>
+        <property><name>jcr:created</name><value>Sun Oct 31 2010 21:48:04 GMT+0100</value><type>Date</type></property>
+        <property><name>text</name><value><![CDATA[<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>
+<ul>
+<li><span class="Apple-style-span" style="font-size: 12px;">Polyhedral Sectioning</span></li>
+<li><span class="Apple-style-span" style="font-size: 12px;">Triangulation&nbsp;</span></li>
+<li><span class="Apple-style-span" style="font-size: 12px;">Trigonometric Calculation</span></li>
+<li><span class="Apple-style-span" style="font-size: 12px;">Ruler and Compass Construction</span></li>
+</ul>
+<p><span class="Apple-style-span" style="font-size: 12px;"><br>
+Sample is ready to help your organization deal effectively with all these challenges through our award winning geometric consulting services.</span></p>
+<p style="font-family: tahoma, arial, helvetica, sans-serif; font-size: 12px;\"><\/p>
+]]></value><type>String</type></property>
+        <property><name>jcr:lastModified</name><value>Sun Oct 31 2010 21:49:06 GMT+0100</value><type>Date</type></property>
+        <property><name>sling:resourceType</name><value>foundation/components/text</value><type>String</type></property>
+        <property><name>textIsRich</name><value>true</value><type>String</type></property>
+      </node>
+      <node>
+        <name>col_break12825937554040</name>
+        <primaryNodeType>nt:unstructured</primaryNodeType>
+        <property><name>controlType</name><value>break</value><type>String</type></property>
+        <property><name>sling:resourceType</name><value>foundation/components/parsys/colctrl</value><type>String</type></property>
+      </node>
+      <node>
+        <name>image_0</name>
+        <primaryNodeType>nt:unstructured</primaryNodeType>
+        <property><name>jcr:createdBy</name><value>admin</value><type>String</type></property>
+        <property><name>fileReference</name><value>/content/dam/sample/offices/clean_room.jpg</value><type>String</type></property>
+        <property><name>height</name><value>226</value><type>String</type></property>
+        <property><name>jcr:lastModifiedBy</name><value>admin</value><type>String</type></property>
+        <property><name>jcr:created</name><value>Mon Aug 23 2010 22:04:46 GMT+0200</value><type>Date</type></property>
+        <property><name>jcr:lastModified</name><value>Fri Nov 05 2010 10:38:15 GMT+0100</value><type>Date</type></property>
+        <property><name>sling:resourceType</name><value>foundation/components/image</value><type>String</type></property>
+        <property><name>imageRotate</name><value>0</value><type>String</type></property>
+        <node>
+          <name>file</name>
+          <primaryNodeType>nt:file</primaryNodeType>
+          <property><name>jcr:createdBy</name><value>admin</value><type>String</type></property>
+          <property><name>jcr:created</name><value>Thu Aug 07 2014 16:32:59 GMT+0200</value><type>Date</type></property>
+          <node>
+            <name>jcr:content</name>
+            <primaryNodeType>nt:resource</primaryNodeType>
+            <property><name>jcr:lastModifiedBy</name><value>anonymous</value><type>String</type></property>
+            <property><name>jcr:mimeType</name><value>image/jpeg</value><type>String</type></property>
+            <property><name>jcr:lastModified</name><value>Thu Aug 07 2014 16:32:59 GMT+0200</value><type>String</type></property>
+            <property><name>jcr:uuid</name><value>6139077f-191f-4337-aaef-55456ebe6784</value><type>String</type></property>
+          </node>
+        </node>
+      </node>
+      <node>
+        <name>title_2</name>
+        <primaryNodeType>nt:unstructured</primaryNodeType>
+        <property><name>jcr:createdBy</name><value>admin</value><type>String</type></property>
+        <property><name>jcr:title</name><value>Shape Technology</value><type>String</type></property>
+        <property><name>jcr:lastModifiedBy</name><value>admin</value><type>String</type></property>
+        <property><name>jcr:created</name><value>Mon Aug 23 2010 22:12:13 GMT+0200</value><type>Date</type></property>
+        <property><name>jcr:lastModified</name><value>Tue Oct 26 2010 21:16:29 GMT+0200</value><type>Date</type></property>
+        <property><name>sling:resourceType</name><value>sample/components/title</value><type>String</type></property>
+      </node>
+      <node>
+        <name>text_0</name>
+        <primaryNodeType>nt:unstructured</primaryNodeType>
+        <property><name>jcr:createdBy</name><value>admin</value><type>String</type></property>
+        <property><name>jcr:lastModifiedBy</name><value>admin</value><type>String</type></property>
+        <property><name>jcr:created</name><value>Mon Aug 23 2010 22:16:30 GMT+0200</value><type>Date</type></property>
+        <property><name>text</name><value><![CDATA[<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>
+<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>
+<p></p>
+<p></p>
+]]></value><type>String</type></property>
+        <property><name>jcr:lastModified</name><value>Mon Nov 08 2010 20:39:00 GMT+0100</value><type>Date</type></property>
+        <property><name>sling:resourceType</name><value>foundation/components/text</value><type>String</type></property>
+        <property><name>textIsRich</name><value>true</value><type>String</type></property>
+      </node>
+      <node>
+        <name>col_end12825937444810</name>
+        <primaryNodeType>nt:unstructured</primaryNodeType>
+        <property><name>controlType</name><value>end</value><type>String</type></property>
+        <property><name>sling:resourceType</name><value>foundation/components/parsys/colctrl</value><type>String</type></property>
+      </node>
+    </node>
+    <node>
+      <name>header</name>
+      <primaryNodeType>nt:unstructured</primaryNodeType>
+      <property><name>jcr:title</name><value>trust our experience
+to manage your business</value><type>String</type></property>
+      <property><name>imageReference</name><value>/content/dam/sample/header.png</value><type>String</type></property>
+      <property><name>text</name><value>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nunc eget neque. Nunc condimentum ipsum et orci. Aenean est. Cras eget diam. read more</value><type>String</type></property>
+      <property><name>sling:resourceType</name><value>sample/components/header</value><type>String</type></property>
+    </node>
+    <node>
+      <name>newslist</name>
+      <primaryNodeType>nt:unstructured</primaryNodeType>
+      <property><name>headline</name><value>trust our experience
+to manage your business</value><type>String</type></property>
+      <property><name>text</name><value>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nunc eget neque. Nunc condimentum ipsum et orci. Aenean est. Cras eget diam. read more</value><type>String</type></property>
+      <property><name>sling:resourceType</name><value>sample/components/listchildren</value><type>String</type></property>
+      <property><name>listroot</name><value>/content/sample/en/about/news</value><type>String</type></property>
+    </node>
+    <node>
+      <name>lead</name>
+      <primaryNodeType>nt:unstructured</primaryNodeType>
+      <property><name>jcr:title</name><value>World Leader in Applied Geometry </value><type>String</type></property>
+      <property><name>jcr:lastModifiedBy</name><value>admin</value><type>String</type></property>
+      <property><name>text</name><value>Lead Text</value><type>String</type></property>
+      <property><name>title</name><value>Lead Title</value><type>String</type></property>
+      <property><name>jcr:description</name><value>ample 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.</value><type>String</type></property>
+      <property><name>jcr:lastModified</name><value>Wed Jan 19 2011 14:35:29 GMT+0100</value><type>Date</type></property>
+      <property><name>sling:resourceType</name><value>sample/components/lead</value><type>String</type></property>
+      <node>
+        <name>app:annotations</name>
+        <primaryNodeType>nt:unstructured</primaryNodeType>
+      </node>
+    </node>
+    <node>
+      <name>image</name>
+      <primaryNodeType>nt:unstructured</primaryNodeType>
+      <property><name>jcr:lastModifiedBy</name><value>admin</value><type>String</type></property>
+      <property><name>jcr:lastModified</name><value>Wed Oct 27 2010 21:30:59 GMT+0200</value><type>Date</type></property>
+      <property><name>imageRotate</name><value>0</value><type>String</type></property>
+    </node>
+    <node>
+      <name>carousel</name>
+      <primaryNodeType>nt:unstructured</primaryNodeType>
+      <property><name>playSpeed</name><value>6000</value><type>String</type></property>
+      <property><name>jcr:lastModifiedBy</name><value>admin</value><type>String</type></property>
+      <property><name>pages</name><values><value>/content/sample/en/events/techsummit</value><value>/content/sample/en/events/userconf</value><value>/content/sample/en/events/shapecon</value><value>/content/sample/en/events/dsc</value></values><type>String</type></property>
+      <property><name>jcr:lastModified</name><value>Tue Oct 05 2010 14:14:27 GMT+0200</value><type>Date</type></property>
+      <property><name>transTime</name><value>1000</value><type>String</type></property>
+      <property><name>sling:resourceType</name><value>foundation/components/carousel</value><type>String</type></property>
+      <property><name>listFrom</name><value>static</value><type>String</type></property>
+    </node>
+    <node>
+      <name>rightpar</name>
+      <primaryNodeType>nt:unstructured</primaryNodeType>
+      <property><name>sling:resourceType</name><value>foundation/components/parsys</value><type>String</type></property>
+      <node>
+        <name>teaser</name>
+        <primaryNodeType>nt:unstructured</primaryNodeType>
+        <property><name>jcr:createdBy</name><value>admin</value><type>String</type></property>
+        <property><name>jcr:lastModifiedBy</name><value>admin</value><type>String</type></property>
+        <property><name>jcr:created</name><value>Tue Jan 25 2011 11:30:09 GMT+0100</value><type>Date</type></property>
+        <property><name>campaignpath</name><value>/content/campaigns/sample</value><type>String</type></property>
+        <property><name>jcr:lastModified</name><value>Wed Feb 02 2011 08:40:30 GMT+0100</value><type>Date</type></property>
+        <property><name>sling:resourceTyp</name><value>personalization/components/teaser</value><type>String</type></property>
+      </node>
+    </node>
+  </node>
+  <node>
+    <name>toolbar</name>
+    <primaryNodeType>app:Page</primaryNodeType>
+    <property><name>jcr:createdBy</name><value>admin</value><type>String</type></property>
+    <property><name>jcr:created</name><value>Thu Aug 07 2014 16:33:00 GMT+0200</value><type>String</type></property>
+    <node>
+      <name>jcr:content</name>
+      <primaryNodeType>app:PageContent</primaryNodeType>
+      <property><name>subtitle</name><value>Contains the toolbar</value><type>String</type></property>
+      <property><name>jcr:createdBy</name><value>admin</value><type>String</type></property>
+      <property><name>jcr:title</name><value>Toolbar</value><type>String</type></property>
+      <property><name>app:template</name><value>sample/templates/contentpage</value><type>String</type></property>
+      <property><name>jcr:created</name><value>Thu Aug 07 2014 16:33:00 GMT+0200</value><type>String</type></property>
+      <property><name>app:lastModified</name><value>Wed Aug 25 2010 22:51:02 GMT+0200</value><type>Date</type></property>
+      <property><name>hideInNav</name><value>true</value><type>Date</type></property>
+      <property><name>sling:resourceType</name><value>sample/components/contentpage</value><type>String</type></property>
+      <property><name>app:lastModifiedBy</name><value>admin</value><type>String</type></property>
+      <node>
+        <name>par</name>
+        <primaryNodeType>nt:unstructured</primaryNodeType>
+        <property><name>sling:resourceType</name><value>foundation/components/parsys</value><type>String</type></property>
+      </node>
+      <node>
+        <name>rightpar</name>
+        <primaryNodeType>nt:unstructured</primaryNodeType>
+        <property><name>sling:resourceType</name><value>foundation/components/iparsys</value><type>String</type></property>
+        <node>
+          <name>iparsys_fake_par</name>
+          <primaryNodeType>nt:unstructured</primaryNodeType>
+          <property><name>sling:resourceType</name><value>foundation/components/iparsys/par</value><type>String</type></property>
+        </node>
+      </node>
+    </node>
+    <node>
+      <name>profiles</name>
+      <primaryNodeType>app:Page</primaryNodeType>
+      <property><name>jcr:createdBy</name><value>admin</value><type>String</type></property>
+      <property><name>jcr:created</name><value>Thu Aug 07 2014 16:33:00 GMT+0200</value><type>Date</type></property>
+      <node>
+        <name>jcr:content</name>
+        <primaryNodeType>app:PageContent</primaryNodeType>
+        <mixinNodeType>type1</mixinNodeType>
+        <mixinNodeType>type2</mixinNodeType>
+        <property><name>jcr:createdBy</name><value>admin</value><type>String</type></property>
+        <property><name>jcr:title</name><value>Profiles</value><type>String</type></property>
+        <property><name>app:template</name><value>sample/templates/contentpage</value><type>String</type></property>
+        <property><name>jcr:created</name><value>Thu Aug 07 2014 16:33:00 GMT+0200</value><type>Date</type></property>
+        <property><name>app:lastModified</name><value>Thu Nov 05 2009 20:27:13 GMT+0100</value><type>Date</type></property>
+        <property><name>hideInNav</name><value>true</value><type>Boolean</type></property>
+        <property><name>sling:resourceType</name><value>sample/components/contentpage</value><type>String</type></property>
+        <property><name>app:lastModifiedBy</name><value>admin</value><type>String</type></property>
+        <property><name>longProp</name><value>1234567890123</value><type>Long</type></property>
+        <property><name>decimalProp</name><value>1.2345</value><type>Decimal</type></property>
+        <property><name>booleanProp</name><value>true</value><type>Boolean</type></property>
+        <property><name>longPropMulti</name><values><value>1234567890123</value><value>55</value></values><type>Long</type></property>
+        <property><name>decimalPropMulti</name><values><value>1.2345</value><value>1.1</value></values><type>Decimal</type></property>
+        <property><name>booleanPropMulti</name><values><value>true</value><value>false</value></values><type>Boolean</type></property>
+        <property><name>stringPropMulti</name><values><value>aa</value><value>bb</value><value>cc</value></values><type>String</type></property>
+        <node>
+          <name>par</name>
+          <primaryNodeType>nt:unstructured</primaryNodeType>
+          <property><name>sling:resourceType</name><value>foundation/components/parsys</value><type>String</type></property>
+          <node>
+            <name>textimage</name>
+            <primaryNodeType>nt:unstructured</primaryNodeType>
+            <property><name>sling:resourceType</name><value>foundation/components/textimage</value><type>String</type></property>
+          </node>
+          <node>
+            <name>mygadgets</name>
+            <primaryNodeType>nt:unstructured</primaryNodeType>
+            <property><name>gadgets</name><value>http://customer.meteogroup.de/meteogroup/gadgets/wetter24.xml
+http://germanweatherradar.googlecode.com/svn/trunk/german-weather-radar.xml
+http://www.digitalpowered.info/gadget/ski.pictures.xml
+http://www.canbuffi.de/gadgets/clock/clock.xml</value><type>String</type></property>
+            <property><name>sling:resourceType</name><value>personalization/components/mygadgets</value><type>String</type></property>
+          </node>
+        </node>
+        <node>
+          <name>rightpar</name>
+          <primaryNodeType>nt:unstructured</primaryNodeType>
+          <property><name>sling:resourceType</name><value>foundation/components/iparsys</value><type>String</type></property>
+          <node>
+            <name>iparsys_fake_par</name>
+            <primaryNodeType>nt:unstructured</primaryNodeType>
+            <property><name>sling:resourceType</name><value>foundation/components/iparsys/par</value><type>String</type></property>
+          </node>
+        </node>
+      </node>
+    </node>
+  </node>
+</node>
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.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.


[sling-org-apache-sling-contentparser-xml] 05/06: SLING-8570 - Extract a generic Content Parser API from org.apache.sling.jcr.contentparser with pluggable implementations

Posted by ra...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

radu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-contentparser-xml.git

commit 0592e54835960528ceaad1c8bac219905092f76e
Author: Radu Cotescu <ra...@apache.org>
AuthorDate: Mon Jul 22 09:39:40 2019 +0200

    SLING-8570 - Extract a generic Content Parser API from org.apache.sling.jcr.contentparser with pluggable implementations
    
    * completely decoupled the API from implementations - the ContentParser API
    doesn't suggest any content types any more
    * removed JSON specific parser options from the ParserOptions class
    * made the ParserOptions class extendable
    * switched exported API packages to version 2.0.0, to eliminate all possible
    confusion with the older org.apache.sling.jcr.contentparser API
---
 README.md                                                           | 2 +-
 .../xml/internal/{XmlContentParser.java => XMLContentParser.java}   | 6 +++---
 .../{XmlContentParserTest.java => XMLContentParserTest.java}        | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/README.md b/README.md
index e320a8c..fa0f697 100644
--- a/README.md
+++ b/README.md
@@ -9,6 +9,6 @@ To obtain a reference to the XML content parser just filter on the `ContentParse
 property:
 
 ```java
-    @Reference(target = "(" + ContentParser.SERVICE_PROPERTY_CONTENT_TYPE + "=" + ContentParser.XML_CONTENT_TYPE + ")")
+    @Reference(target = "(" + ContentParser.SERVICE_PROPERTY_CONTENT_TYPE + "=xml)")
     private ContentParser xmlParser;
 ``` 
diff --git a/src/main/java/org/apache/sling/contentparser/xml/internal/XmlContentParser.java b/src/main/java/org/apache/sling/contentparser/xml/internal/XMLContentParser.java
similarity index 98%
rename from src/main/java/org/apache/sling/contentparser/xml/internal/XmlContentParser.java
rename to src/main/java/org/apache/sling/contentparser/xml/internal/XMLContentParser.java
index 5c18539..f99b4e6 100644
--- a/src/main/java/org/apache/sling/contentparser/xml/internal/XmlContentParser.java
+++ b/src/main/java/org/apache/sling/contentparser/xml/internal/XMLContentParser.java
@@ -49,15 +49,15 @@ import org.xml.sax.SAXException;
  */
 @Component(
         property = {
-                ContentParser.SERVICE_PROPERTY_CONTENT_TYPE + "=" + ContentParser.XML_CONTENT_TYPE
+                ContentParser.SERVICE_PROPERTY_CONTENT_TYPE + "=xml"
         }
 )
-public final class XmlContentParser implements ContentParser {
+public final class XMLContentParser implements ContentParser {
 
     private static final String JCR_PRIMARY_TYPE = "jcr:primaryType";
     private final DocumentBuilderFactory documentBuilderFactory;
 
-    public XmlContentParser() {
+    public XMLContentParser() {
         documentBuilderFactory = DocumentBuilderFactory.newInstance();
     }
 
diff --git a/src/test/java/org/apache/sling/contentparser/xml/internal/XmlContentParserTest.java b/src/test/java/org/apache/sling/contentparser/xml/internal/XMLContentParserTest.java
similarity index 98%
rename from src/test/java/org/apache/sling/contentparser/xml/internal/XmlContentParserTest.java
rename to src/test/java/org/apache/sling/contentparser/xml/internal/XMLContentParserTest.java
index 5da18c3..a533b03 100644
--- a/src/test/java/org/apache/sling/contentparser/xml/internal/XmlContentParserTest.java
+++ b/src/test/java/org/apache/sling/contentparser/xml/internal/XMLContentParserTest.java
@@ -40,7 +40,7 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 
-public class XmlContentParserTest {
+public class XMLContentParserTest {
 
     private File file;
     private ContentParser underTest;
@@ -48,7 +48,7 @@ public class XmlContentParserTest {
     @Before
     public void setUp() {
         file = new File("src/test/resources/content-test/content.xml");
-        underTest = new XmlContentParser();
+        underTest = new XMLContentParser();
     }
 
     @Test