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 cf06bb0  [cp2fm] added XML Properties support
cf06bb0 is described below

commit cf06bb0c435c7ba0f3f0bcd336a62b9ee630221b
Author: Simo Tripodi <[email protected]>
AuthorDate: Wed Mar 6 17:32:31 2019 +0100

    [cp2fm] added XML Properties support
---
 .../PropertiesConfigurationEntryHandler.java       | 16 +++++++++++++++-
 .../handlers/ConfigurationEntryHandlerTest.java    |  3 ++-
 ...eusermapping.impl.ServiceUserMapperImpl.xml.cfg | 22 ++++++++++++++++++++++
 3 files changed, 39 insertions(+), 2 deletions(-)

diff --git 
a/content-package-2-feature-model/src/main/java/org/apache/sling/cp2fm/handlers/PropertiesConfigurationEntryHandler.java
 
b/content-package-2-feature-model/src/main/java/org/apache/sling/cp2fm/handlers/PropertiesConfigurationEntryHandler.java
index 2628da8..cc60a8e 100644
--- 
a/content-package-2-feature-model/src/main/java/org/apache/sling/cp2fm/handlers/PropertiesConfigurationEntryHandler.java
+++ 
b/content-package-2-feature-model/src/main/java/org/apache/sling/cp2fm/handlers/PropertiesConfigurationEntryHandler.java
@@ -16,6 +16,7 @@
  */
 package org.apache.sling.cp2fm.handlers;
 
+import java.io.BufferedInputStream;
 import java.io.InputStream;
 import java.util.Dictionary;
 import java.util.Enumeration;
@@ -31,7 +32,20 @@ public final class PropertiesConfigurationEntryHandler 
extends AbstractConfigura
     @Override
     protected Dictionary<String, Object> parseConfiguration(String name, 
InputStream input) throws Exception {
         final Properties properties = new Properties();
-        properties.load(input);
+
+        try (final BufferedInputStream in = new BufferedInputStream(input)) {
+            in.mark(1);
+
+            boolean isXml = '<' == in.read();
+
+            in.reset();
+
+            if (isXml) {
+                properties.loadFromXML(in);
+            } else {
+                properties.load(in);
+            }
+        }
 
         Dictionary<String, Object> configuration = new Hashtable<>();
         final Enumeration<Object> i = properties.keys();
diff --git 
a/content-package-2-feature-model/src/test/java/org/apache/sling/cp2fm/handlers/ConfigurationEntryHandlerTest.java
 
b/content-package-2-feature-model/src/test/java/org/apache/sling/cp2fm/handlers/ConfigurationEntryHandlerTest.java
index e682545..eaf8b4c 100644
--- 
a/content-package-2-feature-model/src/test/java/org/apache/sling/cp2fm/handlers/ConfigurationEntryHandlerTest.java
+++ 
b/content-package-2-feature-model/src/test/java/org/apache/sling/cp2fm/handlers/ConfigurationEntryHandlerTest.java
@@ -88,7 +88,8 @@ public class ConfigurationEntryHandlerTest {
             { EXPECTED_PID + ".cfg", new PropertiesConfigurationEntryHandler() 
},
             { EXPECTED_PID + ".cfg.json", new JsonConfigurationEntryHandler() 
},
             { EXPECTED_PID + ".config", new ConfigurationEntryHandler() },
-            { EXPECTED_PID + ".xml", new XmlConfigurationEntryHandler() }
+            { EXPECTED_PID + ".xml", new XmlConfigurationEntryHandler() },
+            { EXPECTED_PID + ".xml.cfg", new 
PropertiesConfigurationEntryHandler() }
         });
     }
 
diff --git 
a/content-package-2-feature-model/src/test/resources/org/apache/sling/cp2fm/handlers/org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.xml.cfg
 
b/content-package-2-feature-model/src/test/resources/org/apache/sling/cp2fm/handlers/org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.xml.cfg
new file mode 100644
index 0000000..05ce515
--- /dev/null
+++ 
b/content-package-2-feature-model/src/test/resources/org/apache/sling/cp2fm/handlers/org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.xml.cfg
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd";>
+<!--
+ 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.
+-->
+<properties>
+  <entry key="user.default">admin</entry>
+  <entry 
key="user.mapping">[com.adobe.acs.acs-aem-samples-bundle=admin,com.adobe.acs.acs-aem-samples-bundle:sample-service=oauthservice]</entry>
+</properties>

Reply via email to