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/18 09:45:25 UTC
[sling-whiteboard] branch issue/SLING-8570 created (now 6725b61)
This is an automated email from the ASF dual-hosted git repository.
radu pushed a change to branch issue/SLING-8570
in repository https://gitbox.apache.org/repos/asf/sling-whiteboard.git.
at 6725b61 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 6725b61 SLING-8570 - Extract a generic Content Parser API from org.apache.sling.jcr.contentparser with pluggable implementations
The 1 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-whiteboard] 01/01: 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 issue/SLING-8570
in repository https://gitbox.apache.org/repos/asf/sling-whiteboard.git
commit 6725b610b2cb926112516741cfed97ed2c588e4d
Author: Radu Cotescu <ra...@apache.org>
AuthorDate: Thu Jul 18 11:45:09 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
---
.../org-apache-sling-contentparser-api/README.md | 3 +-
.../sling/contentparser/api/ContentParser.java | 38 +++++----------
.../sling/contentparser/api/ParserOptions.java | 31 ++----------
.../org-apache-sling-contentparser-json/README.md | 2 +-
.../org-apache-sling-contentparser-json/pom.xml | 5 ++
.../contentparser/json/JSONParserFeature.java} | 4 +-
.../contentparser/json/JSONParserOptions.java | 57 ++++++++++++++++++++++
...onContentParser.java => JSONContentParser.java} | 22 ++++++---
...TicksConverter.java => JSONTicksConverter.java} | 4 +-
.../sling/contentparser/json/package-info.java} | 20 ++------
...tParserTest.java => JSONContentParserTest.java} | 26 +++++-----
.../README.md | 2 +-
...ContentParser.java => JCRXMLContentParser.java} | 6 +--
...arserTest.java => JCRXMLContentParserTest.java} | 8 +--
.../org-apache-sling-contentparser-xml/README.md | 2 +-
...XmlContentParser.java => XMLContentParser.java} | 6 +--
...ntParserTest.java => XMLContentParserTest.java} | 4 +-
17 files changed, 130 insertions(+), 110 deletions(-)
diff --git a/contentparser/org-apache-sling-contentparser-api/README.md b/contentparser/org-apache-sling-contentparser-api/README.md
index ab05675..b8d102b 100644
--- a/contentparser/org-apache-sling-contentparser-api/README.md
+++ b/contentparser/org-apache-sling-contentparser-api/README.md
@@ -8,8 +8,7 @@ continuation of the one provided by the [Apache Sling JCR Content Parser](https:
1. the API is now available in the `org.apache.sling.contentparser.api` package;
2. there is no replacement for the `org.apache.sling.jcr.contentparser.ContentParserFactory`; to obtain a `ContentParser`, given that
they are exposed as OSGi services, one has to filter on the `ContentParser.SERVICE_PROPERTY_CONTENT_TYPE` service registration property,
-to select the appropriate file format (see `ContentParser.JSON_CONTENT_TYPE`, `ContentParser.XML_CONTENT_TYPE` and
-`ContentParser.JCR_XML_CONTENT_TYPE`);
+to select the appropriate file format;
3. as a consequence of 2., the `ParserOptions` are now passed directly to the `ContentParser#parse` method.
Implementations of the API are made available from separate bundles:
diff --git a/contentparser/org-apache-sling-contentparser-api/src/main/java/org/apache/sling/contentparser/api/ContentParser.java b/contentparser/org-apache-sling-contentparser-api/src/main/java/org/apache/sling/contentparser/api/ContentParser.java
index 1a684ca..2738088 100644
--- a/contentparser/org-apache-sling-contentparser-api/src/main/java/org/apache/sling/contentparser/api/ContentParser.java
+++ b/contentparser/org-apache-sling-contentparser-api/src/main/java/org/apache/sling/contentparser/api/ContentParser.java
@@ -31,37 +31,23 @@ import org.osgi.annotation.versioning.ProviderType;
@ProviderType
public interface ContentParser {
- /**
- * JSON content descriptor file.
- *
- * @see <a href="https://sling.apache.org/documentation/bundles/content-loading-jcr-contentloader.html#json-descriptor-files">JCR
- * ContentLoader JSON descriptor files</a>
- */
- String JSON_CONTENT_TYPE = "json";
/**
- * XML content descriptor file.
+ * OSGi service registration property indicating the content type this {@code ContentParser} supports. The simplest way to retrieve a
+ * {@code ContentParser} for a certain content type is to apply a filter on the service reference:
*
- * @see <a href="https://sling.apache.org/documentation/bundles/content-loading-jcr-contentloader.html#xml-descriptor-files">JCR
- * ContentLoader XML descriptor files</a>
- */
- String XML_CONTENT_TYPE = "xml";
-
- /**
- * JCR XML content (FileVault XML),aAlso known as extended document view XML. Extends the regular document view as specified by JCR 2.0
- * with specifics like multi-value and type information.
+ * <pre>
+ * {@literal @}Reference(target = "(" + ContentParser.SERVICE_PROPERTY_CONTENT_TYPE + "=" + _value_ + ")")
+ * private ContentParser parser;
+ * </pre>
*
- * @see <a href="https://docs.adobe.com/content/docs/en/spec/jcr/2.0/7_Export.html#7.3%20Document%20View">JCR 2.0, 7.3 Document View</a>
- * @see <a href="http://jackrabbit.apache.org/filevault/">Jackrabbit FileVault</a>
- */
- String JCR_XML_CONTENT_TYPE = "jcr.xml";
-
- /**
- * OSGi service registration property indicating the content type this {@code ContentParser} supports.
+ * If multiple services are registered for the same content type, the above code snippet will provide you with the service
+ * implementation with the highest ranking. However, if a certain implementation is needed, an additional filter can be added:
*
- * @see #JSON_CONTENT_TYPE
- * @see #XML_CONTENT_TYPE
- * @see #JCR_XML_CONTENT_TYPE
+ * <pre>
+ * {@literal @}Reference(target = "(&(" + ContentParser.SERVICE_PROPERTY_CONTENT_TYPE + "=" + _value_ + ")(component.name=" + _class_name_ + "))")
+ * private ContentParser parser;
+ * </pre>
*/
String SERVICE_PROPERTY_CONTENT_TYPE = "org.apache.sling.contentparser.content_type";
diff --git a/contentparser/org-apache-sling-contentparser-api/src/main/java/org/apache/sling/contentparser/api/ParserOptions.java b/contentparser/org-apache-sling-contentparser-api/src/main/java/org/apache/sling/contentparser/api/ParserOptions.java
index ebf80f0..c28ffe7 100644
--- a/contentparser/org-apache-sling-contentparser-api/src/main/java/org/apache/sling/contentparser/api/ParserOptions.java
+++ b/contentparser/org-apache-sling-contentparser-api/src/main/java/org/apache/sling/contentparser/api/ParserOptions.java
@@ -20,17 +20,17 @@ package org.apache.sling.contentparser.api;
import java.util.Arrays;
import java.util.Collections;
-import java.util.EnumSet;
import java.util.HashSet;
import java.util.Set;
import org.osgi.annotation.versioning.ProviderType;
/**
- * Options for content parsers.
+ * Generic options for content parsers. Parser implementations can extend this class to provide additional options, valid only in the
+ * context of those implementations.
*/
@ProviderType
-public final class ParserOptions {
+public class ParserOptions {
/**
* Default primary type.
@@ -57,18 +57,13 @@ public final class ParserOptions {
"security:principals"
)));
- /**
- * List of JSON parser features activated by default.
- */
- public static final EnumSet<JsonParserFeature> DEFAULT_JSON_PARSER_FEATURES
- = EnumSet.of(JsonParserFeature.COMMENTS);
+
private String defaultPrimaryType = DEFAULT_PRIMARY_TYPE;
private boolean detectCalendarValues;
private Set<String> ignorePropertyNames = Collections.emptySet();
private Set<String> ignoreResourceNames = DEFAULT_IGNORE_RESOURCE_NAMES;
private Set<String> removePropertyNamePrefixes = DEFAULT_REMOVE_PROPERTY_NAME_PREFIXES;
- private EnumSet<JsonParserFeature> jsonParserFeatures = DEFAULT_JSON_PARSER_FEATURES;
/**
* Default "jcr:primaryType" property for resources that have no explicit value for this value.
@@ -148,24 +143,6 @@ public final class ParserOptions {
return removePropertyNamePrefixes;
}
- /**
- * Set set of features the JSON parser should apply when parsing files.
- *
- * @param value JSON parser features
- * @return this
- */
- public ParserOptions jsonParserFeatures(EnumSet<JsonParserFeature> value) {
- this.jsonParserFeatures = value;
- return this;
- }
-
- public ParserOptions jsonParserFeatures(JsonParserFeature... value) {
- this.jsonParserFeatures = EnumSet.copyOf(Arrays.asList(value));
- return this;
- }
- public EnumSet<JsonParserFeature> getJsonParserFeatures() {
- return jsonParserFeatures;
- }
}
diff --git a/contentparser/org-apache-sling-contentparser-json/README.md b/contentparser/org-apache-sling-contentparser-json/README.md
index 0359394..1b07e37 100644
--- a/contentparser/org-apache-sling-contentparser-json/README.md
+++ b/contentparser/org-apache-sling-contentparser-json/README.md
@@ -9,6 +9,6 @@ To obtain a reference to the JSON content parser just filter on the `ContentPars
property:
```java
- @Reference(target = "(" + ContentParser.SERVICE_PROPERTY_CONTENT_TYPE + "=" + ContentParser.JSON_CONTENT_TYPE + ")")
+ @Reference(target = "(" + ContentParser.SERVICE_PROPERTY_CONTENT_TYPE + "=json)")
private ContentParser jsonParser;
```
diff --git a/contentparser/org-apache-sling-contentparser-json/pom.xml b/contentparser/org-apache-sling-contentparser-json/pom.xml
index 9099d50..9ae7111 100644
--- a/contentparser/org-apache-sling-contentparser-json/pom.xml
+++ b/contentparser/org-apache-sling-contentparser-json/pom.xml
@@ -79,6 +79,11 @@
<scope>provided</scope>
</dependency>
<dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.annotation.versioning</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.contentparser.testutils</artifactId>
<version>0.9.0-SNAPSHOT</version>
diff --git a/contentparser/org-apache-sling-contentparser-api/src/main/java/org/apache/sling/contentparser/api/JsonParserFeature.java b/contentparser/org-apache-sling-contentparser-json/src/main/java/org/apache/sling/contentparser/json/JSONParserFeature.java
similarity index 94%
copy from contentparser/org-apache-sling-contentparser-api/src/main/java/org/apache/sling/contentparser/api/JsonParserFeature.java
copy to contentparser/org-apache-sling-contentparser-json/src/main/java/org/apache/sling/contentparser/json/JSONParserFeature.java
index 58c3e2b..3d2b5f8 100644
--- a/contentparser/org-apache-sling-contentparser-api/src/main/java/org/apache/sling/contentparser/api/JsonParserFeature.java
+++ b/contentparser/org-apache-sling-contentparser-json/src/main/java/org/apache/sling/contentparser/json/JSONParserFeature.java
@@ -16,12 +16,12 @@
~ specific language governing permissions and limitations
~ under the License.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-package org.apache.sling.contentparser.api;
+package org.apache.sling.contentparser.json;
/**
* Feature flags for parsing JSON files.
*/
-public enum JsonParserFeature {
+public enum JSONParserFeature {
/**
* Support comments (/* ... */) in JSON files.
diff --git a/contentparser/org-apache-sling-contentparser-json/src/main/java/org/apache/sling/contentparser/json/JSONParserOptions.java b/contentparser/org-apache-sling-contentparser-json/src/main/java/org/apache/sling/contentparser/json/JSONParserOptions.java
new file mode 100644
index 0000000..8090f44
--- /dev/null
+++ b/contentparser/org-apache-sling-contentparser-json/src/main/java/org/apache/sling/contentparser/json/JSONParserOptions.java
@@ -0,0 +1,57 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ 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.json;
+
+import java.util.Arrays;
+import java.util.EnumSet;
+
+import org.apache.sling.contentparser.api.ParserOptions;
+import org.osgi.annotation.versioning.ConsumerType;
+
+@ConsumerType
+public final class JSONParserOptions extends ParserOptions {
+
+ /**
+ * List of JSON parser features activated by default.
+ */
+ public static final EnumSet<JSONParserFeature> DEFAULT_JSON_PARSER_FEATURES
+ = EnumSet.of(JSONParserFeature.COMMENTS);
+
+ private EnumSet<JSONParserFeature> features = DEFAULT_JSON_PARSER_FEATURES;
+
+ /**
+ * Set set of features the JSON parser should apply when parsing files.
+ *
+ * @param value JSON parser features
+ * @return this
+ */
+ public JSONParserOptions withFeatures(EnumSet<JSONParserFeature> value) {
+ this.features = value;
+ return this;
+ }
+
+ public JSONParserOptions withFeatures(JSONParserFeature... value) {
+ this.features = EnumSet.copyOf(Arrays.asList(value));
+ return this;
+ }
+
+ public EnumSet<JSONParserFeature> getFeatures() {
+ return features;
+ }
+}
diff --git a/contentparser/org-apache-sling-contentparser-json/src/main/java/org/apache/sling/contentparser/json/internal/JsonContentParser.java b/contentparser/org-apache-sling-contentparser-json/src/main/java/org/apache/sling/contentparser/json/internal/JSONContentParser.java
similarity index 91%
rename from contentparser/org-apache-sling-contentparser-json/src/main/java/org/apache/sling/contentparser/json/internal/JsonContentParser.java
rename to contentparser/org-apache-sling-contentparser-json/src/main/java/org/apache/sling/contentparser/json/internal/JSONContentParser.java
index 33f048e..831ee22 100644
--- a/contentparser/org-apache-sling-contentparser-json/src/main/java/org/apache/sling/contentparser/json/internal/JsonContentParser.java
+++ b/contentparser/org-apache-sling-contentparser-json/src/main/java/org/apache/sling/contentparser/json/internal/JSONContentParser.java
@@ -42,22 +42,32 @@ import javax.json.stream.JsonParsingException;
import org.apache.commons.io.IOUtils;
import org.apache.sling.contentparser.api.ContentHandler;
import org.apache.sling.contentparser.api.ContentParser;
-import org.apache.sling.contentparser.api.JsonParserFeature;
import org.apache.sling.contentparser.api.ParseException;
import org.apache.sling.contentparser.api.ParserHelper;
import org.apache.sling.contentparser.api.ParserOptions;
+import org.apache.sling.contentparser.json.JSONParserFeature;
+import org.apache.sling.contentparser.json.JSONParserOptions;
import org.osgi.service.component.annotations.Component;
@Component(
property = {
- ContentParser.SERVICE_PROPERTY_CONTENT_TYPE + "=" + ContentParser.JSON_CONTENT_TYPE
+ ContentParser.SERVICE_PROPERTY_CONTENT_TYPE + "=json"
}
)
-public class JsonContentParser implements ContentParser {
+public class JSONContentParser implements ContentParser {
@Override
public void parse(ContentHandler handler, InputStream is, ParserOptions parserOptions) throws ParseException {
- final boolean jsonQuoteTicks = parserOptions.getJsonParserFeatures().contains(JsonParserFeature.QUOTE_TICK);
+ final boolean jsonQuoteTicks;
+ final boolean supportComments;
+ if (parserOptions instanceof JSONParserOptions) {
+ JSONParserOptions jsonParserOptions = (JSONParserOptions) parserOptions;
+ jsonQuoteTicks = jsonParserOptions.getFeatures().contains(JSONParserFeature.QUOTE_TICK);
+ supportComments = jsonParserOptions.getFeatures().contains(JSONParserFeature.COMMENTS);
+ } else {
+ jsonQuoteTicks = false;
+ supportComments = false;
+ }
/*
* Implementation note: This parser uses JsonReader instead of the (more memory-efficient)
@@ -66,7 +76,7 @@ public class JsonContentParser implements ContentParser {
*/
final JsonReaderFactory jsonReaderFactory =
Json.createReaderFactory(
- parserOptions.getJsonParserFeatures().contains(JsonParserFeature.COMMENTS) ?
+ supportComments ?
new HashMap<String, Object>() {{
put("org.apache.johnzon.supports-comments", true);
}} :
@@ -93,7 +103,7 @@ public class JsonContentParser implements ContentParser {
}
// convert ticks to double quotes
- jsonString = JsonTicksConverter.tickToDoubleQuote(jsonString);
+ jsonString = JSONTicksConverter.tickToDoubleQuote(jsonString);
try (JsonReader reader = jsonReaderFactory.createReader(new StringReader(jsonString))) {
return reader.readObject();
diff --git a/contentparser/org-apache-sling-contentparser-json/src/main/java/org/apache/sling/contentparser/json/internal/JsonTicksConverter.java b/contentparser/org-apache-sling-contentparser-json/src/main/java/org/apache/sling/contentparser/json/internal/JSONTicksConverter.java
similarity index 98%
rename from contentparser/org-apache-sling-contentparser-json/src/main/java/org/apache/sling/contentparser/json/internal/JsonTicksConverter.java
rename to contentparser/org-apache-sling-contentparser-json/src/main/java/org/apache/sling/contentparser/json/internal/JSONTicksConverter.java
index 15b6553..83d0c07 100644
--- a/contentparser/org-apache-sling-contentparser-json/src/main/java/org/apache/sling/contentparser/json/internal/JsonTicksConverter.java
+++ b/contentparser/org-apache-sling-contentparser-json/src/main/java/org/apache/sling/contentparser/json/internal/JSONTicksConverter.java
@@ -29,9 +29,9 @@ package org.apache.sling.contentparser.json.internal;
* After the conversion they are always escaped.</li>
* </ul>
*/
-final class JsonTicksConverter {
+final class JSONTicksConverter {
- private JsonTicksConverter() {
+ private JSONTicksConverter() {
// static methods only
}
diff --git a/contentparser/org-apache-sling-contentparser-api/src/main/java/org/apache/sling/contentparser/api/JsonParserFeature.java b/contentparser/org-apache-sling-contentparser-json/src/main/java/org/apache/sling/contentparser/json/package-info.java
similarity index 72%
rename from contentparser/org-apache-sling-contentparser-api/src/main/java/org/apache/sling/contentparser/api/JsonParserFeature.java
rename to contentparser/org-apache-sling-contentparser-json/src/main/java/org/apache/sling/contentparser/json/package-info.java
index 58c3e2b..7266666 100644
--- a/contentparser/org-apache-sling-contentparser-api/src/main/java/org/apache/sling/contentparser/api/JsonParserFeature.java
+++ b/contentparser/org-apache-sling-contentparser-json/src/main/java/org/apache/sling/contentparser/json/package-info.java
@@ -16,21 +16,7 @@
~ specific language governing permissions and limitations
~ under the License.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-package org.apache.sling.contentparser.api;
+@Version("1.0.0")
+package org.apache.sling.contentparser.json;
-/**
- * Feature flags for parsing JSON files.
- */
-public enum JsonParserFeature {
-
- /**
- * Support comments (/* ... */) in JSON files.
- */
- COMMENTS,
-
- /**
- * Support ticks (') additional to double quotes (") as quoting symbol for JSON names and strings.
- */
- QUOTE_TICK
-
-}
+import org.osgi.annotation.versioning.Version;
diff --git a/contentparser/org-apache-sling-contentparser-json/src/test/java/org/apache/sling/contentparser/json/internal/JsonContentParserTest.java b/contentparser/org-apache-sling-contentparser-json/src/test/java/org/apache/sling/contentparser/json/internal/JSONContentParserTest.java
similarity index 92%
rename from contentparser/org-apache-sling-contentparser-json/src/test/java/org/apache/sling/contentparser/json/internal/JsonContentParserTest.java
rename to contentparser/org-apache-sling-contentparser-json/src/test/java/org/apache/sling/contentparser/json/internal/JSONContentParserTest.java
index f82c8a4..658151d 100644
--- a/contentparser/org-apache-sling-contentparser-json/src/test/java/org/apache/sling/contentparser/json/internal/JsonContentParserTest.java
+++ b/contentparser/org-apache-sling-contentparser-json/src/test/java/org/apache/sling/contentparser/json/internal/JSONContentParserTest.java
@@ -29,9 +29,9 @@ import java.util.Map;
import java.util.TimeZone;
import org.apache.sling.contentparser.api.ContentParser;
-import org.apache.sling.contentparser.api.JsonParserFeature;
import org.apache.sling.contentparser.api.ParseException;
-import org.apache.sling.contentparser.api.ParserOptions;
+import org.apache.sling.contentparser.json.JSONParserFeature;
+import org.apache.sling.contentparser.json.JSONParserOptions;
import org.apache.sling.contentparser.testutils.TestUtils;
import org.apache.sling.contentparser.testutils.mapsupport.ContentElement;
import org.junit.Before;
@@ -42,7 +42,7 @@ import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-public class JsonContentParserTest {
+public class JSONContentParserTest {
private File file;
private ContentParser contentParser;
@@ -50,19 +50,19 @@ public class JsonContentParserTest {
@Before
public void setUp() {
file = new File("src/test/resources/content-test/content.json");
- contentParser = new JsonContentParser();
+ contentParser = new JSONContentParser();
}
@Test
public void testPageJcrPrimaryType() throws Exception {
- ContentElement content = TestUtils.parse(contentParser, file);
+ ContentElement content = TestUtils.parse(contentParser, new JSONParserOptions(), file);
assertEquals("app:Page", content.getProperties().get("jcr:primaryType"));
}
@Test
public void testDataTypes() throws Exception {
- ContentElement content = TestUtils.parse(contentParser, file);
+ ContentElement content = TestUtils.parse(contentParser, new JSONParserOptions(), file);
ContentElement child = content.getChild("toolbar/profiles/jcr:content");
assertNotNull("Expected child at toolbar/profiles/jcr:content", child);
Map<String, Object> props = child.getProperties();
@@ -79,7 +79,7 @@ public class JsonContentParserTest {
@Test
public void testContentProperties() throws Exception {
- ContentElement content = TestUtils.parse(contentParser, file);
+ ContentElement content = TestUtils.parse(contentParser, new JSONParserOptions(), file);
ContentElement child = content.getChild("jcr:content/header");
assertNotNull("Expected child at jcr:content/header", child);
Map<String, Object> props = child.getProperties();
@@ -88,7 +88,7 @@ public class JsonContentParserTest {
@Test
public void testCalendar() throws Exception {
- ContentElement content = TestUtils.parse(contentParser, new ParserOptions().detectCalendarValues(true), file);
+ ContentElement content = TestUtils.parse(contentParser, new JSONParserOptions().detectCalendarValues(true), file);
ContentElement child = content.getChild("jcr:content");
assertNotNull("Expected child at jcr:content", child);
Map<String, Object> props = child.getProperties();
@@ -109,7 +109,7 @@ public class JsonContentParserTest {
@Test
public void testIso8601Calendar() throws Exception {
- ContentElement content = TestUtils.parse(contentParser, new ParserOptions().detectCalendarValues(true), file);
+ ContentElement content = TestUtils.parse(contentParser, new JSONParserOptions().detectCalendarValues(true), file);
ContentElement child = content.getChild("jcr:content");
assertNotNull("Expected child at jcr:content", child);
Map<String, Object> props = child.getProperties();
@@ -128,7 +128,7 @@ public class JsonContentParserTest {
@Test
public void testUTF8Chars() throws Exception {
- ContentElement content = TestUtils.parse(contentParser, file);
+ ContentElement content = TestUtils.parse(contentParser, new JSONParserOptions(), file);
ContentElement child = content.getChild("jcr:content");
assertNotNull("Expected child at jcr:content", child);
Map<String, Object> props = child.getProperties();
@@ -154,7 +154,7 @@ public class JsonContentParserTest {
public void testIgnoreResourcesProperties() throws Exception {
ContentElement content = TestUtils.parse(
contentParser,
- new ParserOptions().ignoreResourceNames(Collections
+ new JSONParserOptions().ignoreResourceNames(Collections
.unmodifiableSet(new HashSet<>(Arrays.asList("header", "newslist", "security:acl", "security:principals"))))
.ignorePropertyNames(Collections.unmodifiableSet(new HashSet<>(Arrays.asList("jcr:title")))), file);
ContentElement child = content.getChild("jcr:content");
@@ -172,7 +172,7 @@ public class JsonContentParserTest {
@Test
public void testGetChild() throws Exception {
- ContentElement content = TestUtils.parse(contentParser, file);
+ ContentElement content = TestUtils.parse(contentParser, new JSONParserOptions(), file);
assertNull(content.getName());
ContentElement deepChild = content.getChild("jcr:content/par/image/file/jcr:content");
assertNotNull("Expected child at jcr:content/par/image/file/jcr:content", deepChild);
@@ -188,7 +188,7 @@ public class JsonContentParserTest {
@Test(expected = ParseException.class)
public void testFailsWithoutCommentsEnabled() throws Exception {
- TestUtils.parse(contentParser, new ParserOptions().jsonParserFeatures(EnumSet.noneOf(JsonParserFeature.class)), file);
+ TestUtils.parse(contentParser, new JSONParserOptions().withFeatures(EnumSet.noneOf(JSONParserFeature.class)), file);
}
}
diff --git a/contentparser/org-apache-sling-contentparser-xml-jcr/README.md b/contentparser/org-apache-sling-contentparser-xml-jcr/README.md
index 5bc2b92..ac471af 100644
--- a/contentparser/org-apache-sling-contentparser-xml-jcr/README.md
+++ b/contentparser/org-apache-sling-contentparser-xml-jcr/README.md
@@ -9,6 +9,6 @@ To obtain a reference to the JackRabbit FileVault XMLL content parser just filte
property:
```java
- @Reference(target = "(" + ContentParser.SERVICE_PROPERTY_CONTENT_TYPE + "=" + ContentParser.JCR_XML_CONTENT_TYPE + ")")
+ @Reference(target = "(" + ContentParser.SERVICE_PROPERTY_CONTENT_TYPE + "=jcr-xml)")
private ContentParser jcrXmlParser;
```
diff --git a/contentparser/org-apache-sling-contentparser-xml-jcr/src/main/java/org/apache/sling/contentparser/xml/jcr/internal/JcrXmlContentParser.java b/contentparser/org-apache-sling-contentparser-xml-jcr/src/main/java/org/apache/sling/contentparser/xml/jcr/internal/JCRXMLContentParser.java
similarity index 98%
rename from contentparser/org-apache-sling-contentparser-xml-jcr/src/main/java/org/apache/sling/contentparser/xml/jcr/internal/JcrXmlContentParser.java
rename to contentparser/org-apache-sling-contentparser-xml-jcr/src/main/java/org/apache/sling/contentparser/xml/jcr/internal/JCRXMLContentParser.java
index 1e01575..d402ac6 100644
--- a/contentparser/org-apache-sling-contentparser-xml-jcr/src/main/java/org/apache/sling/contentparser/xml/jcr/internal/JcrXmlContentParser.java
+++ b/contentparser/org-apache-sling-contentparser-xml-jcr/src/main/java/org/apache/sling/contentparser/xml/jcr/internal/JCRXMLContentParser.java
@@ -46,14 +46,14 @@ import org.xml.sax.helpers.DefaultHandler;
@Component(
service = ContentParser.class,
property = {
- ContentParser.SERVICE_PROPERTY_CONTENT_TYPE + "=" + ContentParser.JCR_XML_CONTENT_TYPE
+ ContentParser.SERVICE_PROPERTY_CONTENT_TYPE + "=jcr-xml"
}
)
-public final class JcrXmlContentParser implements ContentParser {
+public final class JCRXMLContentParser implements ContentParser {
private final SAXParserFactory saxParserFactory;
- public JcrXmlContentParser() {
+ public JCRXMLContentParser() {
saxParserFactory = SAXParserFactory.newInstance();
saxParserFactory.setNamespaceAware(true);
}
diff --git a/contentparser/org-apache-sling-contentparser-xml-jcr/src/test/java/org/apache/sling/contentparser/xml/jcr/internal/JcrXmlContentParserTest.java b/contentparser/org-apache-sling-contentparser-xml-jcr/src/test/java/org/apache/sling/contentparser/xml/jcr/internal/JCRXMLContentParserTest.java
similarity index 96%
rename from contentparser/org-apache-sling-contentparser-xml-jcr/src/test/java/org/apache/sling/contentparser/xml/jcr/internal/JcrXmlContentParserTest.java
rename to contentparser/org-apache-sling-contentparser-xml-jcr/src/test/java/org/apache/sling/contentparser/xml/jcr/internal/JCRXMLContentParserTest.java
index 0c2a826..349a991 100644
--- a/contentparser/org-apache-sling-contentparser-xml-jcr/src/test/java/org/apache/sling/contentparser/xml/jcr/internal/JcrXmlContentParserTest.java
+++ b/contentparser/org-apache-sling-contentparser-xml-jcr/src/test/java/org/apache/sling/contentparser/xml/jcr/internal/JCRXMLContentParserTest.java
@@ -41,7 +41,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
-public class JcrXmlContentParserTest {
+public class JCRXMLContentParserTest {
private File file;
private ContentParser underTest;
@@ -49,7 +49,7 @@ public class JcrXmlContentParserTest {
@Before
public void setUp() {
file = new File("src/test/resources/content-test/content.jcr.xml");
- underTest = new JcrXmlContentParser();
+ underTest = new JCRXMLContentParser();
}
@Test
@@ -96,8 +96,8 @@ public class JcrXmlContentParserTest {
@Test
public void testDecodeName() {
- assertEquals("jcr:title", JcrXmlContentParser.decodeName("jcr:" + ISO9075.encode("title")));
- assertEquals("sling:123", JcrXmlContentParser.decodeName("sling:" + ISO9075.encode("123")));
+ assertEquals("jcr:title", JCRXMLContentParser.decodeName("jcr:" + ISO9075.encode("title")));
+ assertEquals("sling:123", JCRXMLContentParser.decodeName("sling:" + ISO9075.encode("123")));
}
@Test
diff --git a/contentparser/org-apache-sling-contentparser-xml/README.md b/contentparser/org-apache-sling-contentparser-xml/README.md
index e320a8c..fa0f697 100644
--- a/contentparser/org-apache-sling-contentparser-xml/README.md
+++ b/contentparser/org-apache-sling-contentparser-xml/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/contentparser/org-apache-sling-contentparser-xml/src/main/java/org/apache/sling/contentparser/xml/internal/XmlContentParser.java b/contentparser/org-apache-sling-contentparser-xml/src/main/java/org/apache/sling/contentparser/xml/internal/XMLContentParser.java
similarity index 98%
rename from contentparser/org-apache-sling-contentparser-xml/src/main/java/org/apache/sling/contentparser/xml/internal/XmlContentParser.java
rename to contentparser/org-apache-sling-contentparser-xml/src/main/java/org/apache/sling/contentparser/xml/internal/XMLContentParser.java
index 5c18539..f99b4e6 100644
--- a/contentparser/org-apache-sling-contentparser-xml/src/main/java/org/apache/sling/contentparser/xml/internal/XmlContentParser.java
+++ b/contentparser/org-apache-sling-contentparser-xml/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/contentparser/org-apache-sling-contentparser-xml/src/test/java/org/apache/sling/contentparser/xml/internal/XmlContentParserTest.java b/contentparser/org-apache-sling-contentparser-xml/src/test/java/org/apache/sling/contentparser/xml/internal/XMLContentParserTest.java
similarity index 98%
rename from contentparser/org-apache-sling-contentparser-xml/src/test/java/org/apache/sling/contentparser/xml/internal/XmlContentParserTest.java
rename to contentparser/org-apache-sling-contentparser-xml/src/test/java/org/apache/sling/contentparser/xml/internal/XMLContentParserTest.java
index 5da18c3..a533b03 100644
--- a/contentparser/org-apache-sling-contentparser-xml/src/test/java/org/apache/sling/contentparser/xml/internal/XmlContentParserTest.java
+++ b/contentparser/org-apache-sling-contentparser-xml/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