Merge pull request #3 from apache/feature/json-config-writeback
SLING-8419 write-back configurations in JSON format
diff --git a/pom.xml b/pom.xml
index 1ecbead..f1eb0d2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -62,18 +62,15 @@
<instructions>
<!-- As we're using JCR 2.0 for testing we explicitly have to
import version 1.0 here
- We need at least 3.1.2 as this allows reading comments from a config
-->
<Import-Package>
javax.jcr.*;version=1.0,
- org.apache.sling.installer.api;version="[3.1.2,4)",
*
</Import-Package>
<Private-Package>org.apache.sling.installer.provider.jcr.impl.*</Private-Package>
<Sling-Nodetypes>SLING-INF/nodetypes/osgiconfig.cnd</Sling-Nodetypes>
<Sling-Namespaces>sling=http://sling.apache.org/jcr/sling/1.0</Sling-Namespaces>
<Embed-Dependency>
- org.apache.felix.configadmin;inline="org/apache/felix/cm/file/ConfigurationHandler.*",
org.apache.sling.commons.osgi;inline="org/apache/sling/commons/osgi/PropertiesUtil.*"
</Embed-Dependency>
</instructions>
@@ -93,19 +90,12 @@
<version>1.0.0</version>
<scope>provided</scope>
</dependency>
- <!-- We use a class from the config admin implementation to write config files -->
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.configadmin</artifactId>
- <version>1.8.6</version>
- <scope>provided</scope>
- </dependency>
<dependency>
<!-- this version must embed the same version of org.apache.felix.configadmin as this pom.xml to be able to read
the .config files being generated by the write back feature -->
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.installer.core</artifactId>
- <version>3.6.6</version>
+ <version>3.9.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
diff --git a/src/main/java/org/apache/sling/installer/provider/jcr/impl/JcrInstaller.java b/src/main/java/org/apache/sling/installer/provider/jcr/impl/JcrInstaller.java
index aa19d2e..f16c567 100644
--- a/src/main/java/org/apache/sling/installer/provider/jcr/impl/JcrInstaller.java
+++ b/src/main/java/org/apache/sling/installer/provider/jcr/impl/JcrInstaller.java
@@ -52,6 +52,8 @@
import org.apache.sling.installer.api.OsgiInstaller;
import org.apache.sling.installer.api.UpdateHandler;
import org.apache.sling.installer.api.UpdateResult;
+import org.apache.sling.installer.api.serializer.ConfigurationSerializer;
+import org.apache.sling.installer.api.serializer.ConfigurationSerializerFactory;
import org.apache.sling.jcr.api.SlingRepository;
import org.apache.sling.serviceusermapping.ServiceUserMapped;
import org.apache.sling.settings.SlingSettingsService;
@@ -775,9 +777,10 @@
}
// write to a byte array stream
- final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
baos.write("# Configuration created by Apache Sling JCR Installer\n".getBytes("UTF-8"));
- ConfigurationHandler.write(baos, dict);
+ ConfigurationSerializer serializer = ConfigurationSerializerFactory.create(ConfigurationSerializerFactory.Format.JSON);
+ serializer.serialize(dict, baos);
baos.close();
// get or create file node