You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by si...@apache.org on 2019/03/04 14:16:46 UTC

[sling-whiteboard] branch master updated: [cp2fm] finalized XML handling

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

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


The following commit(s) were added to refs/heads/master by this push:
     new e534a08  [cp2fm] finalized XML handling
e534a08 is described below

commit e534a08d430cbc26090afaffc6ce22fd89f93acd
Author: Simo Tripodi <st...@adobe.com>
AuthorDate: Mon Mar 4 15:15:47 2019 +0100

    [cp2fm] finalized XML handling
---
 content-package-2-feature-model/pom.xml            |  6 ++++++
 .../handlers/XmlConfigurationEntryHandler.java     | 24 ++++++++++++++--------
 2 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/content-package-2-feature-model/pom.xml b/content-package-2-feature-model/pom.xml
index 6c2f643..38cf1eb 100644
--- a/content-package-2-feature-model/pom.xml
+++ b/content-package-2-feature-model/pom.xml
@@ -154,6 +154,12 @@
       <version>1.9.12</version>
       <scope>provided</scope>
     </dependency>
+    <dependency>
+      <groupId>org.apache.jackrabbit</groupId>
+      <artifactId>jackrabbit-api</artifactId>
+      <version>2.19.1</version>
+      <scope>provided</scope>
+    </dependency>
   </dependencies>
 
   <build>
diff --git a/content-package-2-feature-model/src/main/java/org/apache/sling/cp2fm/handlers/XmlConfigurationEntryHandler.java b/content-package-2-feature-model/src/main/java/org/apache/sling/cp2fm/handlers/XmlConfigurationEntryHandler.java
index 7d7a4f2..0f7bfdf 100644
--- a/content-package-2-feature-model/src/main/java/org/apache/sling/cp2fm/handlers/XmlConfigurationEntryHandler.java
+++ b/content-package-2-feature-model/src/main/java/org/apache/sling/cp2fm/handlers/XmlConfigurationEntryHandler.java
@@ -18,7 +18,6 @@ package org.apache.sling.cp2fm.handlers;
 
 import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE;
 
-import java.io.IOException;
 import java.io.InputStream;
 import java.util.Dictionary;
 import java.util.Hashtable;
@@ -26,7 +25,7 @@ import java.util.Hashtable;
 import javax.xml.parsers.SAXParser;
 import javax.xml.parsers.SAXParserFactory;
 
-import org.apache.felix.utils.properties.ConfigurationHandler;
+import org.apache.jackrabbit.vault.util.DocViewProperty;
 import org.xml.sax.Attributes;
 import org.xml.sax.SAXException;
 import org.xml.sax.helpers.DefaultHandler;
@@ -35,9 +34,7 @@ public final class XmlConfigurationEntryHandler extends AbstractSingleConfigurat
 
     private static final String JCR_ROOT = "jcr:root";
 
-    private static final String JCR_PREFIX = "jcr:";
-
-    private static final String XMLNS_PREFIX = "xmlns:";
+    private static final String SLING_OSGICONFIG = "sling:OsgiConfig";
 
     private final SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
 
@@ -66,14 +63,25 @@ public final class XmlConfigurationEntryHandler extends AbstractSingleConfigurat
                 throws SAXException {
             String primaryType = attributes.getValue(JCR_PRIMARYTYPE);
 
-            if (JCR_ROOT.equals(qName) && primaryType != null && !primaryType.isEmpty()) {
+            if (JCR_ROOT.equals(qName) && SLING_OSGICONFIG.equals(primaryType)) {
                 for (int i = 0; i < attributes.getLength(); i++) {
                     String attributeQName = attributes.getQName(i);
 
-                    if (!attributeQName.startsWith(JCR_PREFIX) && !attributeQName.startsWith(XMLNS_PREFIX)) {
+                    // ignore jcr: and similar properties
+                    if (attributeQName.indexOf(':') == -1) {
                         String attributeValue = attributes.getValue(i);
 
-                        configuration.put(attributeQName, attributeValue);
+                        if (attributeValue != null && !attributeValue.isEmpty()) {
+                            DocViewProperty property = DocViewProperty.parse(attributeQName, attributeValue);
+
+                            if (property.values.length > 0) {
+                                if (property.isMulti) {
+                                    configuration.put(attributeQName, property.values);
+                                } else {
+                                    configuration.put(attributeQName, property.values[0]);
+                                }
+                            }
+                        }
                     }
                 }
             }