You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ss...@apache.org on 2017/06/14 17:22:04 UTC
svn commit: r1798723 - in /sling/trunk/bundles/jcr/contentparser/src:
main/java/org/apache/sling/jcr/contentparser/
main/java/org/apache/sling/jcr/contentparser/impl/
test/java/org/apache/sling/jcr/contentparser/impl/
test/resources/content-test/
Author: sseifert
Date: Wed Jun 14 17:22:03 2017
New Revision: 1798723
URL: http://svn.apache.org/viewvc?rev=1798723&view=rev
Log:
SLING-6960 JCR Content Parser: Ignore security:acl and security:principals nodes
Modified:
sling/trunk/bundles/jcr/contentparser/src/main/java/org/apache/sling/jcr/contentparser/ParserOptions.java
sling/trunk/bundles/jcr/contentparser/src/main/java/org/apache/sling/jcr/contentparser/impl/JsonContentParser.java
sling/trunk/bundles/jcr/contentparser/src/main/java/org/apache/sling/jcr/contentparser/package-info.java
sling/trunk/bundles/jcr/contentparser/src/test/java/org/apache/sling/jcr/contentparser/impl/JsonContentParserTest.java
sling/trunk/bundles/jcr/contentparser/src/test/resources/content-test/content.json
Modified: sling/trunk/bundles/jcr/contentparser/src/main/java/org/apache/sling/jcr/contentparser/ParserOptions.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/contentparser/src/main/java/org/apache/sling/jcr/contentparser/ParserOptions.java?rev=1798723&r1=1798722&r2=1798723&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/contentparser/src/main/java/org/apache/sling/jcr/contentparser/ParserOptions.java (original)
+++ sling/trunk/bundles/jcr/contentparser/src/main/java/org/apache/sling/jcr/contentparser/ParserOptions.java Wed Jun 14 17:22:03 2017
@@ -49,6 +49,15 @@ public final class ParserOptions {
)));
/**
+ * Default list of resource names that should be ignored.
+ */
+ public static final Set<String> DEFAULT_IGNORE_RESOURCE_NAMES
+ = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(
+ "security:acl",
+ "security:principals"
+ )));
+
+ /**
* List of JSON parser features activated by default.
*/
public static final EnumSet<JsonParserFeature> DEFAULT_JSON_PARSER_FEATURES
@@ -57,7 +66,7 @@ public final class ParserOptions {
private String defaultPrimaryType = DEFAULT_PRIMARY_TYPE;
private boolean detectCalendarValues;
private Set<String> ignorePropertyNames;
- private Set<String> ignoreResourceNames;
+ 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;
Modified: sling/trunk/bundles/jcr/contentparser/src/main/java/org/apache/sling/jcr/contentparser/impl/JsonContentParser.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/contentparser/src/main/java/org/apache/sling/jcr/contentparser/impl/JsonContentParser.java?rev=1798723&r1=1798722&r2=1798723&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/contentparser/src/main/java/org/apache/sling/jcr/contentparser/impl/JsonContentParser.java (original)
+++ sling/trunk/bundles/jcr/contentparser/src/main/java/org/apache/sling/jcr/contentparser/impl/JsonContentParser.java Wed Jun 14 17:22:03 2017
@@ -117,15 +117,28 @@ public final class JsonContentParser imp
Map<String,JsonObject> children = new LinkedHashMap<>();
for (Map.Entry<String, JsonValue> entry : object.entrySet()) {
String childName = entry.getKey();
- Object value = convertValue(entry.getValue());
- boolean isResource = (value instanceof JsonObject);
+ Object value = null;
boolean ignore = false;
- if (isResource) {
- ignore = helper.ignoreResource(childName);
+ try {
+ value = convertValue(entry.getValue());
+ }
+ catch (ParseException ex) {
+ if (helper.ignoreResource(childName) || helper.ignoreProperty(helper.cleanupPropertyName(childName))) {
+ ignore = true;
+ }
+ else {
+ throw ex;
+ }
}
- else {
- childName = helper.cleanupPropertyName(childName);
- ignore = helper.ignoreProperty(childName);
+ boolean isResource = (value instanceof JsonObject);
+ if (!ignore) {
+ if (isResource) {
+ ignore = helper.ignoreResource(childName);
+ }
+ else {
+ childName = helper.cleanupPropertyName(childName);
+ ignore = helper.ignoreProperty(childName);
+ }
}
if (!ignore) {
if (isResource) {
Modified: sling/trunk/bundles/jcr/contentparser/src/main/java/org/apache/sling/jcr/contentparser/package-info.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/contentparser/src/main/java/org/apache/sling/jcr/contentparser/package-info.java?rev=1798723&r1=1798722&r2=1798723&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/contentparser/src/main/java/org/apache/sling/jcr/contentparser/package-info.java (original)
+++ sling/trunk/bundles/jcr/contentparser/src/main/java/org/apache/sling/jcr/contentparser/package-info.java Wed Jun 14 17:22:03 2017
@@ -19,5 +19,5 @@
/**
* Parser for repository content serialized e.g. as JSON or JCR XML.
*/
-@org.osgi.annotation.versioning.Version("1.2.0")
+@org.osgi.annotation.versioning.Version("1.3.0")
package org.apache.sling.jcr.contentparser;
Modified: sling/trunk/bundles/jcr/contentparser/src/test/java/org/apache/sling/jcr/contentparser/impl/JsonContentParserTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/contentparser/src/test/java/org/apache/sling/jcr/contentparser/impl/JsonContentParserTest.java?rev=1798723&r1=1798722&r2=1798723&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/contentparser/src/test/java/org/apache/sling/jcr/contentparser/impl/JsonContentParserTest.java (original)
+++ sling/trunk/bundles/jcr/contentparser/src/test/java/org/apache/sling/jcr/contentparser/impl/JsonContentParserTest.java Wed Jun 14 17:22:03 2017
@@ -137,7 +137,7 @@ public class JsonContentParserTest {
@Test
public void testIgnoreResourcesProperties() throws Exception {
ContentParser underTest = ContentParserFactory.create(ContentType.JSON,
- new ParserOptions().ignoreResourceNames(ImmutableSet.of("header", "newslist"))
+ new ParserOptions().ignoreResourceNames(ImmutableSet.of("header", "newslist", "security:acl", "security:principals"))
.ignorePropertyNames(ImmutableSet.of("jcr:title")));
ContentElement content = parse(underTest, file);
ContentElement child = content.getChild("jcr:content");
Modified: sling/trunk/bundles/jcr/contentparser/src/test/resources/content-test/content.json
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/contentparser/src/test/resources/content-test/content.json?rev=1798723&r1=1798722&r2=1798723&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/contentparser/src/test/resources/content-test/content.json (original)
+++ sling/trunk/bundles/jcr/contentparser/src/test/resources/content-test/content.json Wed Jun 14 17:22:03 2017
@@ -20,6 +20,16 @@
"utf8Property": "äöüÃâ¬",
"jcr:reference:refpro1": "abc",
"jcr:path:pathprop1": "def",
+ /* should be ignored */
+ "security:acl": [
+ { "principal": "TestGroup1", "granted": ["jcr:read","jcr:write"] },
+ { "principal": "TestUser1", "granted": ["jcr:read"], "denied": ["jcr:write"] }
+ ],
+ /* should be ignored */
+ "security:principals": [
+ { "name": "TestUser1", "password": "mypassword", "extraProp1": "extraProp1Value" },
+ { "name": "TestGroup1", "isgroup": "true", "members": ["TestUser1"], "extraProp1": "extraProp1Value" }
+ ],
"par": {
"jcr:primaryType": "nt:unstructured",
"sling:resourceType": "foundation/components/parsys",