From 7ca08a9b74778cbdb90487de5912827af484977e Mon Sep 17 00:00:00 2001 From: sseifert Date: Mon, 15 Jan 2018 11:02:10 +0100 Subject: [PATCH 01/15] =?UTF-8?q?[jgitflow-maven-plugin]=C2=A0updating=20p?= =?UTF-8?q?oms=20for=201.2.5-SNAPSHOT=20development?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- conga-sling-plugin/pom.xml | 2 +- pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/conga-sling-plugin/pom.xml b/conga-sling-plugin/pom.xml index 61e64e8..735462f 100644 --- a/conga-sling-plugin/pom.xml +++ b/conga-sling-plugin/pom.xml @@ -31,7 +31,7 @@ io.wcm.devops.conga.plugins io.wcm.devops.conga.plugins.sling - 1.2.3-SNAPSHOT + 1.2.5-SNAPSHOT jar CONGA Sling Plugin diff --git a/pom.xml b/pom.xml index d3b8413..926ef51 100644 --- a/pom.xml +++ b/pom.xml @@ -29,7 +29,7 @@ io.wcm.devops.conga.plugins io.wcm.devops.conga.plugins.sling.root - 1.2.3-SNAPSHOT + 1.2.5-SNAPSHOT pom CONGA Sling Plugin From c3b6d86174eccb0d94208cc38eb37308a4d23dea Mon Sep 17 00:00:00 2001 From: sseifert Date: Mon, 15 Jan 2018 11:04:52 +0100 Subject: [PATCH 02/15] =?UTF-8?q?[jgitflow-maven-plugin]=C2=A0updating=20d?= =?UTF-8?q?evelop=20poms=20to=20master=20versions=20to=20avoid=20merge=20c?= =?UTF-8?q?onflicts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- conga-sling-plugin/pom.xml | 2 +- pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/conga-sling-plugin/pom.xml b/conga-sling-plugin/pom.xml index 735462f..6277e86 100644 --- a/conga-sling-plugin/pom.xml +++ b/conga-sling-plugin/pom.xml @@ -31,7 +31,7 @@ io.wcm.devops.conga.plugins io.wcm.devops.conga.plugins.sling - 1.2.5-SNAPSHOT + 1.2.4 jar CONGA Sling Plugin diff --git a/pom.xml b/pom.xml index 926ef51..dd791a3 100644 --- a/pom.xml +++ b/pom.xml @@ -29,7 +29,7 @@ io.wcm.devops.conga.plugins io.wcm.devops.conga.plugins.sling.root - 1.2.5-SNAPSHOT + 1.2.4 pom CONGA Sling Plugin From 577df36e51b0a1f23f72c8f25ef9cdfc0dc892b2 Mon Sep 17 00:00:00 2001 From: sseifert Date: Mon, 15 Jan 2018 11:04:52 +0100 Subject: [PATCH 03/15] =?UTF-8?q?[jgitflow-maven-plugin]=C2=A0Updating=20d?= =?UTF-8?q?evelop=20poms=20back=20to=20pre=20merge=20state?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- conga-sling-plugin/pom.xml | 2 +- pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/conga-sling-plugin/pom.xml b/conga-sling-plugin/pom.xml index 6277e86..735462f 100644 --- a/conga-sling-plugin/pom.xml +++ b/conga-sling-plugin/pom.xml @@ -31,7 +31,7 @@ io.wcm.devops.conga.plugins io.wcm.devops.conga.plugins.sling - 1.2.4 + 1.2.5-SNAPSHOT jar CONGA Sling Plugin diff --git a/pom.xml b/pom.xml index dd791a3..926ef51 100644 --- a/pom.xml +++ b/pom.xml @@ -29,7 +29,7 @@ io.wcm.devops.conga.plugins io.wcm.devops.conga.plugins.sling.root - 1.2.4 + 1.2.5-SNAPSHOT pom CONGA Sling Plugin From 123cc12e811f3c5a98f2d9c393d6013bb7e09a35 Mon Sep 17 00:00:00 2001 From: sseifert Date: Mon, 15 Jan 2018 11:05:42 +0100 Subject: [PATCH 04/15] update dependency --- example/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/pom.xml b/example/pom.xml index 97c7420..1ab49da 100644 --- a/example/pom.xml +++ b/example/pom.xml @@ -53,7 +53,7 @@ io.wcm.devops.conga.plugins io.wcm.devops.conga.plugins.sling - 1.2.3-SNAPSHOT + 1.2.5-SNAPSHOT From d1497b797cd28e1a616faba45760fc4a3ec8dd60 Mon Sep 17 00:00:00 2001 From: sseifert Date: Tue, 10 Apr 2018 10:19:46 +0200 Subject: [PATCH 05/15] normalize whitespaces --- conga-sling-plugin/pom.xml | 2 +- example/pom.xml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/conga-sling-plugin/pom.xml b/conga-sling-plugin/pom.xml index 735462f..42ee5ff 100644 --- a/conga-sling-plugin/pom.xml +++ b/conga-sling-plugin/pom.xml @@ -47,7 +47,7 @@ conga/plugins/sling/conga-sling-plugin - + diff --git a/example/pom.xml b/example/pom.xml index 1ab49da..f755c28 100644 --- a/example/pom.xml +++ b/example/pom.xml @@ -22,7 +22,7 @@ 4.0.0 - + io.wcm.maven io.wcm.maven.global-parent @@ -37,7 +37,7 @@ CONGA Sling Plugin Example Example definitions and templates. - + @@ -52,7 +52,7 @@ io.wcm.devops.conga.plugins - io.wcm.devops.conga.plugins.sling + io.wcm.devops.conga.plugins.sling 1.2.5-SNAPSHOT From 7935b3aa7e5c71eeb78f666b9747436b42972306 Mon Sep 17 00:00:00 2001 From: sseifert Date: Tue, 10 Jul 2018 18:28:21 +0200 Subject: [PATCH 06/15] migrate unit tests to junit 5 --- conga-sling-plugin/pom.xml | 2 +- .../fileheader/OsgiConfigFileHeaderTest.java | 10 ++++---- .../ProvisioningFileHeaderTest.java | 10 ++++---- .../OsgiConfigEscapingStrategyTest.java | 12 +++++----- .../ProvisioningEscapingStrategyTest.java | 12 +++++----- ...ovisioningOsgiConfigPostProcessorTest.java | 24 +++++++++---------- .../validator/ProvisioningValidatorTest.java | 17 +++++++------ example/pom.xml | 2 +- pom.xml | 2 +- 9 files changed, 47 insertions(+), 44 deletions(-) diff --git a/conga-sling-plugin/pom.xml b/conga-sling-plugin/pom.xml index 42ee5ff..ddbd02f 100644 --- a/conga-sling-plugin/pom.xml +++ b/conga-sling-plugin/pom.xml @@ -25,7 +25,7 @@ io.wcm.devops io.wcm.devops.parent_toplevel - 1.0.10 + 1.0.11-SNAPSHOT diff --git a/conga-sling-plugin/src/test/java/io/wcm/devops/conga/plugins/sling/fileheader/OsgiConfigFileHeaderTest.java b/conga-sling-plugin/src/test/java/io/wcm/devops/conga/plugins/sling/fileheader/OsgiConfigFileHeaderTest.java index a69ad40..8bf85d1 100644 --- a/conga-sling-plugin/src/test/java/io/wcm/devops/conga/plugins/sling/fileheader/OsgiConfigFileHeaderTest.java +++ b/conga-sling-plugin/src/test/java/io/wcm/devops/conga/plugins/sling/fileheader/OsgiConfigFileHeaderTest.java @@ -19,8 +19,8 @@ */ package io.wcm.devops.conga.plugins.sling.fileheader; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.File; import java.nio.charset.StandardCharsets; @@ -28,8 +28,8 @@ import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.StringUtils; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import com.google.common.collect.ImmutableList; @@ -45,7 +45,7 @@ public class OsgiConfigFileHeaderTest { private FileHeaderPlugin underTest; - @Before + @BeforeEach public void setUp() { underTest = new PluginManagerImpl().get(OsgiConfigFileHeader.NAME, FileHeaderPlugin.class); } diff --git a/conga-sling-plugin/src/test/java/io/wcm/devops/conga/plugins/sling/fileheader/ProvisioningFileHeaderTest.java b/conga-sling-plugin/src/test/java/io/wcm/devops/conga/plugins/sling/fileheader/ProvisioningFileHeaderTest.java index 3e7a029..d21e788 100644 --- a/conga-sling-plugin/src/test/java/io/wcm/devops/conga/plugins/sling/fileheader/ProvisioningFileHeaderTest.java +++ b/conga-sling-plugin/src/test/java/io/wcm/devops/conga/plugins/sling/fileheader/ProvisioningFileHeaderTest.java @@ -19,8 +19,8 @@ */ package io.wcm.devops.conga.plugins.sling.fileheader; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.File; import java.nio.charset.StandardCharsets; @@ -28,8 +28,8 @@ import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.StringUtils; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import com.google.common.collect.ImmutableList; @@ -42,7 +42,7 @@ public class ProvisioningFileHeaderTest { private FileHeaderPlugin underTest; - @Before + @BeforeEach public void setUp() { underTest = new PluginManagerImpl().get(ProvisioningFileHeader.NAME, FileHeaderPlugin.class); } diff --git a/conga-sling-plugin/src/test/java/io/wcm/devops/conga/plugins/sling/handlebars/escaping/OsgiConfigEscapingStrategyTest.java b/conga-sling-plugin/src/test/java/io/wcm/devops/conga/plugins/sling/handlebars/escaping/OsgiConfigEscapingStrategyTest.java index 351584c..433d9bb 100644 --- a/conga-sling-plugin/src/test/java/io/wcm/devops/conga/plugins/sling/handlebars/escaping/OsgiConfigEscapingStrategyTest.java +++ b/conga-sling-plugin/src/test/java/io/wcm/devops/conga/plugins/sling/handlebars/escaping/OsgiConfigEscapingStrategyTest.java @@ -19,12 +19,12 @@ */ package io.wcm.devops.conga.plugins.sling.handlebars.escaping; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import io.wcm.devops.conga.generator.spi.handlebars.EscapingStrategyPlugin; import io.wcm.devops.conga.generator.util.PluginManagerImpl; @@ -33,7 +33,7 @@ public class OsgiConfigEscapingStrategyTest { private EscapingStrategyPlugin underTest; - @Before + @BeforeEach public void setUp() { underTest = new PluginManagerImpl().get(OsgiConfigEscapingStrategy.NAME, EscapingStrategyPlugin.class); } diff --git a/conga-sling-plugin/src/test/java/io/wcm/devops/conga/plugins/sling/handlebars/escaping/ProvisioningEscapingStrategyTest.java b/conga-sling-plugin/src/test/java/io/wcm/devops/conga/plugins/sling/handlebars/escaping/ProvisioningEscapingStrategyTest.java index cb0f5d0..ac59428 100644 --- a/conga-sling-plugin/src/test/java/io/wcm/devops/conga/plugins/sling/handlebars/escaping/ProvisioningEscapingStrategyTest.java +++ b/conga-sling-plugin/src/test/java/io/wcm/devops/conga/plugins/sling/handlebars/escaping/ProvisioningEscapingStrategyTest.java @@ -19,12 +19,12 @@ */ package io.wcm.devops.conga.plugins.sling.handlebars.escaping; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import io.wcm.devops.conga.generator.spi.handlebars.EscapingStrategyPlugin; import io.wcm.devops.conga.generator.util.PluginManagerImpl; @@ -33,7 +33,7 @@ public class ProvisioningEscapingStrategyTest { private EscapingStrategyPlugin underTest; - @Before + @BeforeEach public void setUp() { underTest = new PluginManagerImpl().get(ProvisioningEscapingStrategy.NAME, EscapingStrategyPlugin.class); } diff --git a/conga-sling-plugin/src/test/java/io/wcm/devops/conga/plugins/sling/postprocessor/ProvisioningOsgiConfigPostProcessorTest.java b/conga-sling-plugin/src/test/java/io/wcm/devops/conga/plugins/sling/postprocessor/ProvisioningOsgiConfigPostProcessorTest.java index a33fedc..9a63791 100644 --- a/conga-sling-plugin/src/test/java/io/wcm/devops/conga/plugins/sling/postprocessor/ProvisioningOsgiConfigPostProcessorTest.java +++ b/conga-sling-plugin/src/test/java/io/wcm/devops/conga/plugins/sling/postprocessor/ProvisioningOsgiConfigPostProcessorTest.java @@ -19,11 +19,11 @@ */ package io.wcm.devops.conga.plugins.sling.postprocessor; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.BufferedInputStream; import java.io.File; @@ -36,9 +36,9 @@ import org.apache.commons.io.FileUtils; import org.apache.felix.cm.file.ConfigurationHandler; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.slf4j.LoggerFactory; import io.wcm.devops.conga.generator.spi.PostProcessorPlugin; @@ -53,7 +53,7 @@ public class ProvisioningOsgiConfigPostProcessorTest { private File targetDir; - @Before + @BeforeEach public void setUp() throws IOException { underTest = new PluginManagerImpl().get(ProvisioningOsgiConfigPostProcessor.NAME, PostProcessorPlugin.class); @@ -64,7 +64,7 @@ public void setUp() throws IOException { } } - @After + @AfterEach public void tearDown() throws IOException { FileUtils.deleteDirectory(targetDir); } @@ -144,7 +144,7 @@ private void postProcess(File provisioningFile) { underTest.apply(fileContext, context); // validate - assertFalse("Provisioning file deleted", provisioningFile.exists()); + assertFalse(provisioningFile.exists(), "Provisioning file deleted"); } private Dictionary readConfig(String fileName) throws IOException { @@ -157,7 +157,7 @@ private void postProcess(File provisioningFile) { private void assertExists(String fileName) throws IOException { File file = new File(targetDir, fileName); - assertTrue("Config file found: " + file.getCanonicalPath(), file.exists()); + assertTrue(file.exists(), "Config file found: " + file.getCanonicalPath()); } } diff --git a/conga-sling-plugin/src/test/java/io/wcm/devops/conga/plugins/sling/validator/ProvisioningValidatorTest.java b/conga-sling-plugin/src/test/java/io/wcm/devops/conga/plugins/sling/validator/ProvisioningValidatorTest.java index 40fe13c..8da1cc5 100644 --- a/conga-sling-plugin/src/test/java/io/wcm/devops/conga/plugins/sling/validator/ProvisioningValidatorTest.java +++ b/conga-sling-plugin/src/test/java/io/wcm/devops/conga/plugins/sling/validator/ProvisioningValidatorTest.java @@ -19,14 +19,15 @@ */ package io.wcm.devops.conga.plugins.sling.validator; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.File; import java.nio.charset.StandardCharsets; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import io.wcm.devops.conga.generator.spi.ValidationException; import io.wcm.devops.conga.generator.spi.ValidatorPlugin; @@ -37,7 +38,7 @@ public class ProvisioningValidatorTest { private ValidatorPlugin underTest; - @Before + @BeforeEach public void setUp() { underTest = new PluginManagerImpl().get(ProvisioningValidator.NAME, ValidatorPlugin.class); } @@ -50,12 +51,14 @@ public void testValid() throws Exception { underTest.apply(fileContext, null); } - @Test(expected = ValidationException.class) + @Test public void testInvalid() throws Exception { File file = new File(getClass().getResource("/invalidProvisioning.txt").toURI()); FileContext fileContext = new FileContext().file(file).charset(StandardCharsets.UTF_8); assertTrue(underTest.accepts(fileContext, null)); - underTest.apply(fileContext, null); + assertThrows(ValidationException.class, () -> { + underTest.apply(fileContext, null); + }); } @Test diff --git a/example/pom.xml b/example/pom.xml index f755c28..3b8995a 100644 --- a/example/pom.xml +++ b/example/pom.xml @@ -26,7 +26,7 @@ io.wcm.maven io.wcm.maven.global-parent - 19 + 20-SNAPSHOT diff --git a/pom.xml b/pom.xml index 926ef51..df12234 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ io.wcm.devops io.wcm.devops.parent_toplevel - 1.0.10 + 1.0.11-SNAPSHOT From 4d26c60498014ae77f98405dc41294c2228b049d Mon Sep 17 00:00:00 2001 From: sseifert Date: Wed, 11 Jul 2018 21:26:29 +0200 Subject: [PATCH 07/15] update dependencies --- conga-sling-plugin/pom.xml | 2 +- example/pom.xml | 2 +- pom.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/conga-sling-plugin/pom.xml b/conga-sling-plugin/pom.xml index ddbd02f..e7a5b73 100644 --- a/conga-sling-plugin/pom.xml +++ b/conga-sling-plugin/pom.xml @@ -25,7 +25,7 @@ io.wcm.devops io.wcm.devops.parent_toplevel - 1.0.11-SNAPSHOT + 1.1.0 diff --git a/example/pom.xml b/example/pom.xml index 3b8995a..7186d1d 100644 --- a/example/pom.xml +++ b/example/pom.xml @@ -26,7 +26,7 @@ io.wcm.maven io.wcm.maven.global-parent - 20-SNAPSHOT + 20 diff --git a/pom.xml b/pom.xml index df12234..183803d 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ io.wcm.devops io.wcm.devops.parent_toplevel - 1.0.11-SNAPSHOT + 1.1.0 From 20a06c4d363a60dd30f4cc56b1b725b8120d3312 Mon Sep 17 00:00:00 2001 From: sseifert Date: Thu, 7 Mar 2019 10:26:36 +0100 Subject: [PATCH 08/15] add java11 build --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 9a6362e..4fe0a12 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,6 +21,7 @@ language: java jdk: - oraclejdk8 +- oraclejdk11 # Make sure travis can use container-based infrastructure sudo: false From 13ca4ef33005fcfad2e275c4511f2566da1fb0ed Mon Sep 17 00:00:00 2001 From: sseifert Date: Sun, 10 Mar 2019 12:18:03 +0100 Subject: [PATCH 09/15] Update dependencies. --- changes.xml | 6 ++++++ conga-sling-plugin/pom.xml | 4 ++-- example/pom.xml | 2 +- pom.xml | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/changes.xml b/changes.xml index 1dc3008..2f7cbff 100644 --- a/changes.xml +++ b/changes.xml @@ -23,6 +23,12 @@ xsi:schemaLocation="http://maven.apache.org/changes/1.0.0 http://maven.apache.org/plugins/maven-changes-plugin/xsd/changes-1.0.0.xsd"> + + + Update dependencies. + + + Update to latest CONGA SPI. diff --git a/conga-sling-plugin/pom.xml b/conga-sling-plugin/pom.xml index e7a5b73..89c8414 100644 --- a/conga-sling-plugin/pom.xml +++ b/conga-sling-plugin/pom.xml @@ -25,7 +25,7 @@ io.wcm.devops io.wcm.devops.parent_toplevel - 1.1.0 + 1.1.1-SNAPSHOT @@ -53,7 +53,7 @@ io.wcm.devops.conga io.wcm.devops.conga.generator - 1.5.0 + 1.10.3-SNAPSHOT compile diff --git a/example/pom.xml b/example/pom.xml index 7186d1d..6c5cbbe 100644 --- a/example/pom.xml +++ b/example/pom.xml @@ -45,7 +45,7 @@ io.wcm.devops.conga conga-maven-plugin - 1.5.0 + 1.10.3-SNAPSHOT true diff --git a/pom.xml b/pom.xml index 183803d..3f4a5a3 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ io.wcm.devops io.wcm.devops.parent_toplevel - 1.1.0 + 1.1.1-SNAPSHOT From a27227caefbf2bcf3801310a40a40d3ee5a3eb5d Mon Sep 17 00:00:00 2001 From: sseifert Date: Sun, 10 Mar 2019 17:34:50 +0100 Subject: [PATCH 10/15] use openjdk11 instead of oraclejdk11 --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4fe0a12..e7d14be 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,7 +21,7 @@ language: java jdk: - oraclejdk8 -- oraclejdk11 +- openjdk11 # Make sure travis can use container-based infrastructure sudo: false @@ -29,9 +29,9 @@ sudo: false install: "mvn -s ./.travis.maven-settings.xml clean" script: -- "mvn -s ./.travis.maven-settings.xml -Pcontinuous-integration -U -Dmaven.javadoc.skip=true install" +- "mvn -s ./.travis.maven-settings.xml -Pcontinuous-integration -U install" # Separate build for example due to dependeny on conga-maven-plugin -- "mvn -s ./.travis.maven-settings.xml -Pcontinuous-integration -U -Dmaven.javadoc.skip=true install -f example" +- "mvn -s ./.travis.maven-settings.xml -Pcontinuous-integration -U install -f example" # Remove wcm.io artefacts from repository before cache - rm -rf $HOME/.m2/repository/io/wcm From 70de1e1d3d7a1abd0e21238e1f9d3a6d4e0a950b Mon Sep 17 00:00:00 2001 From: sseifert Date: Thu, 14 Mar 2019 23:44:54 +0100 Subject: [PATCH 11/15] update dependencies --- conga-sling-plugin/pom.xml | 4 ++-- example/pom.xml | 4 ++-- pom.xml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/conga-sling-plugin/pom.xml b/conga-sling-plugin/pom.xml index 89c8414..33d2c05 100644 --- a/conga-sling-plugin/pom.xml +++ b/conga-sling-plugin/pom.xml @@ -25,7 +25,7 @@ io.wcm.devops io.wcm.devops.parent_toplevel - 1.1.1-SNAPSHOT + 1.1.2 @@ -53,7 +53,7 @@ io.wcm.devops.conga io.wcm.devops.conga.generator - 1.10.3-SNAPSHOT + 1.11.0 compile diff --git a/example/pom.xml b/example/pom.xml index 6c5cbbe..6082baf 100644 --- a/example/pom.xml +++ b/example/pom.xml @@ -26,7 +26,7 @@ io.wcm.maven io.wcm.maven.global-parent - 20 + 25 @@ -45,7 +45,7 @@ io.wcm.devops.conga conga-maven-plugin - 1.10.3-SNAPSHOT + 1.11.0 true diff --git a/pom.xml b/pom.xml index 3f4a5a3..02c5577 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ io.wcm.devops io.wcm.devops.parent_toplevel - 1.1.1-SNAPSHOT + 1.1.2 From d8510950eccdb7478922d16ce76bd756c993bd5a Mon Sep 17 00:00:00 2001 From: sseifert Date: Tue, 30 Apr 2019 13:15:23 +0200 Subject: [PATCH 12/15] Read Felix ConfigAdmin configuration files with latest version (1.9.14), but write it using the old file format form ConfigAdmin 1.8.4 to support AEM 6.1 and below. --- changes.xml | 2 +- conga-sling-plugin/pom.xml | 6 +- .../ProvisioningOsgiConfigPostProcessor.java | 4 +- .../ConfigurationHandler_ConfigAdmin184.java | 728 ++++++++++++++++++ .../plugins/sling/util/OsgiConfigUtil.java | 49 ++ 5 files changed, 783 insertions(+), 6 deletions(-) create mode 100644 conga-sling-plugin/src/main/java/io/wcm/devops/conga/plugins/sling/util/ConfigurationHandler_ConfigAdmin184.java create mode 100644 conga-sling-plugin/src/main/java/io/wcm/devops/conga/plugins/sling/util/OsgiConfigUtil.java diff --git a/changes.xml b/changes.xml index 2f7cbff..babdc75 100644 --- a/changes.xml +++ b/changes.xml @@ -25,7 +25,7 @@ - Update dependencies. + Read Felix ConfigAdmin configuration files with latest version (1.9.14), but write it using the old file format form ConfigAdmin 1.8.4 to support AEM 6.1 and below. diff --git a/conga-sling-plugin/pom.xml b/conga-sling-plugin/pom.xml index 33d2c05..c9b0481 100644 --- a/conga-sling-plugin/pom.xml +++ b/conga-sling-plugin/pom.xml @@ -61,15 +61,15 @@ org.apache.felix org.apache.felix.configadmin - - 1.8.4 + + 1.9.14 compile org.apache.sling org.apache.sling.provisioning.model - 1.4.2 + 1.8.4 compile diff --git a/conga-sling-plugin/src/main/java/io/wcm/devops/conga/plugins/sling/postprocessor/ProvisioningOsgiConfigPostProcessor.java b/conga-sling-plugin/src/main/java/io/wcm/devops/conga/plugins/sling/postprocessor/ProvisioningOsgiConfigPostProcessor.java index 0048b22..f94425b 100644 --- a/conga-sling-plugin/src/main/java/io/wcm/devops/conga/plugins/sling/postprocessor/ProvisioningOsgiConfigPostProcessor.java +++ b/conga-sling-plugin/src/main/java/io/wcm/devops/conga/plugins/sling/postprocessor/ProvisioningOsgiConfigPostProcessor.java @@ -26,7 +26,6 @@ import java.util.Dictionary; import java.util.List; -import org.apache.felix.cm.file.ConfigurationHandler; import org.apache.sling.provisioning.model.Model; import io.wcm.devops.conga.generator.GeneratorException; @@ -34,6 +33,7 @@ import io.wcm.devops.conga.generator.spi.context.FileContext; import io.wcm.devops.conga.generator.spi.context.PostProcessorContext; import io.wcm.devops.conga.plugins.sling.util.ConfigConsumer; +import io.wcm.devops.conga.plugins.sling.util.OsgiConfigUtil; import io.wcm.devops.conga.plugins.sling.util.ProvisioningUtil; /** @@ -91,7 +91,7 @@ public FileContext accept(String path, Dictionary properties) th File confFile = new File(dir, path); confFile.getParentFile().mkdirs(); try (FileOutputStream os = new FileOutputStream(confFile)) { - ConfigurationHandler.write(os, properties); + OsgiConfigUtil.write(os, properties); } return new FileContext().file(confFile).charset(StandardCharsets.UTF_8); diff --git a/conga-sling-plugin/src/main/java/io/wcm/devops/conga/plugins/sling/util/ConfigurationHandler_ConfigAdmin184.java b/conga-sling-plugin/src/main/java/io/wcm/devops/conga/plugins/sling/util/ConfigurationHandler_ConfigAdmin184.java new file mode 100644 index 0000000..1019308 --- /dev/null +++ b/conga-sling-plugin/src/main/java/io/wcm/devops/conga/plugins/sling/util/ConfigurationHandler_ConfigAdmin184.java @@ -0,0 +1,728 @@ +/* + * #%L + * wcm.io + * %% + * Copyright (C) 2019 wcm.io + * %% + * Licensed 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. + * #L% + */ +package io.wcm.devops.conga.plugins.sling.util; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.io.PushbackReader; +import java.io.Writer; +import java.lang.reflect.Array; +import java.util.ArrayList; +import java.util.BitSet; +import java.util.Collection; +import java.util.Dictionary; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Hashtable; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.apache.felix.cm.file.FilePersistenceManager; + +/* + * This file is COPIED from the sources of org.apache.felix.configadmin 1.8.4 + * to write the configuration using the old (single line) array style, which is required to support + * deploying configurations to old AEM version like AEM 6.1 and lower. + */ +/** + * The ConfigurationHandler class implements configuration reading + * form a java.io.InputStream and writing to a + * java.io.OutputStream on behalf of the + * {@link FilePersistenceManager} class. + * + *
+ * cfg = prop "=" value .
+ *  prop = symbolic-name . // 1.4.2 of OSGi Core Specification
+ *  symbolic-name = token { "." token } .
+ *  token = { [ 0..9 ] | [ a..z ] | [ A..Z ] | '_' | '-' } .
+ *  value = [ type ] ( "[" values "]" | "(" values ")" | simple ) .
+ *  values = simple { "," simple } .
+ *  simple = """ stringsimple """ .
+ *  type = // 1-char type code .
+ *  stringsimple = // quoted string representation of the value .
+ * 
+ */ +//CHECKSTYLE:OFF +@SuppressWarnings({ "unchecked", "unused", "javadoc" }) +class ConfigurationHandler_ConfigAdmin184 { + + protected static final String ENCODING = "UTF-8"; + + protected static final int TOKEN_NAME = 'N'; + protected static final int TOKEN_EQ = '='; + protected static final int TOKEN_ARR_OPEN = '['; + protected static final int TOKEN_ARR_CLOS = ']'; + protected static final int TOKEN_VEC_OPEN = '('; + protected static final int TOKEN_VEC_CLOS = ')'; + protected static final int TOKEN_COMMA = ','; + protected static final int TOKEN_VAL_OPEN = '"'; // '{'; + protected static final int TOKEN_VAL_CLOS = '"'; // '}'; + + // simple types (string & primitive wrappers) + protected static final int TOKEN_SIMPLE_STRING = 'T'; + protected static final int TOKEN_SIMPLE_INTEGER = 'I'; + protected static final int TOKEN_SIMPLE_LONG = 'L'; + protected static final int TOKEN_SIMPLE_FLOAT = 'F'; + protected static final int TOKEN_SIMPLE_DOUBLE = 'D'; + protected static final int TOKEN_SIMPLE_BYTE = 'X'; + protected static final int TOKEN_SIMPLE_SHORT = 'S'; + protected static final int TOKEN_SIMPLE_CHARACTER = 'C'; + protected static final int TOKEN_SIMPLE_BOOLEAN = 'B'; + + // primitives + protected static final int TOKEN_PRIMITIVE_INT = 'i'; + protected static final int TOKEN_PRIMITIVE_LONG = 'l'; + protected static final int TOKEN_PRIMITIVE_FLOAT = 'f'; + protected static final int TOKEN_PRIMITIVE_DOUBLE = 'd'; + protected static final int TOKEN_PRIMITIVE_BYTE = 'x'; + protected static final int TOKEN_PRIMITIVE_SHORT = 's'; + protected static final int TOKEN_PRIMITIVE_CHAR = 'c'; + protected static final int TOKEN_PRIMITIVE_BOOLEAN = 'b'; + + protected static final String CRLF = "\r\n"; + + protected static final Map code2Type; + protected static final Map type2Code; + + // set of valid characters for "symblic-name" + private static final BitSet NAME_CHARS; + private static final BitSet TOKEN_CHARS; + + static { + type2Code = new HashMap(); + + // simple (exclusive String whose type code is not written) + type2Code.put(Integer.class, new Integer(TOKEN_SIMPLE_INTEGER)); + type2Code.put(Long.class, new Integer(TOKEN_SIMPLE_LONG)); + type2Code.put(Float.class, new Integer(TOKEN_SIMPLE_FLOAT)); + type2Code.put(Double.class, new Integer(TOKEN_SIMPLE_DOUBLE)); + type2Code.put(Byte.class, new Integer(TOKEN_SIMPLE_BYTE)); + type2Code.put(Short.class, new Integer(TOKEN_SIMPLE_SHORT)); + type2Code.put(Character.class, new Integer(TOKEN_SIMPLE_CHARACTER)); + type2Code.put(Boolean.class, new Integer(TOKEN_SIMPLE_BOOLEAN)); + + // primitives + type2Code.put(Integer.TYPE, new Integer(TOKEN_PRIMITIVE_INT)); + type2Code.put(Long.TYPE, new Integer(TOKEN_PRIMITIVE_LONG)); + type2Code.put(Float.TYPE, new Integer(TOKEN_PRIMITIVE_FLOAT)); + type2Code.put(Double.TYPE, new Integer(TOKEN_PRIMITIVE_DOUBLE)); + type2Code.put(Byte.TYPE, new Integer(TOKEN_PRIMITIVE_BYTE)); + type2Code.put(Short.TYPE, new Integer(TOKEN_PRIMITIVE_SHORT)); + type2Code.put(Character.TYPE, new Integer(TOKEN_PRIMITIVE_CHAR)); + type2Code.put(Boolean.TYPE, new Integer(TOKEN_PRIMITIVE_BOOLEAN)); + + // reverse map to map type codes to classes, string class mapping + // to be added manually, as the string type code is not written and + // hence not included in the type2Code map + code2Type = new HashMap(); + for (Iterator ti = type2Code.entrySet().iterator(); ti.hasNext();) { + Map.Entry entry = (Map.Entry)ti.next(); + code2Type.put(entry.getValue(), entry.getKey()); + } + code2Type.put(new Integer(TOKEN_SIMPLE_STRING), String.class); + + NAME_CHARS = new BitSet(); + for (int i = '0'; i <= '9'; i++) { + NAME_CHARS.set(i); + } + for (int i = 'a'; i <= 'z'; i++) { + NAME_CHARS.set(i); + } + for (int i = 'A'; i <= 'Z'; i++) { + NAME_CHARS.set(i); + } + NAME_CHARS.set('_'); + NAME_CHARS.set('-'); + NAME_CHARS.set('.'); + NAME_CHARS.set('\\'); + + TOKEN_CHARS = new BitSet(); + TOKEN_CHARS.set(TOKEN_EQ); + TOKEN_CHARS.set(TOKEN_ARR_OPEN); + TOKEN_CHARS.set(TOKEN_ARR_CLOS); + TOKEN_CHARS.set(TOKEN_VEC_OPEN); + TOKEN_CHARS.set(TOKEN_VEC_CLOS); + TOKEN_CHARS.set(TOKEN_COMMA); + TOKEN_CHARS.set(TOKEN_VAL_OPEN); + TOKEN_CHARS.set(TOKEN_VAL_CLOS); + TOKEN_CHARS.set(TOKEN_SIMPLE_STRING); + TOKEN_CHARS.set(TOKEN_SIMPLE_INTEGER); + TOKEN_CHARS.set(TOKEN_SIMPLE_LONG); + TOKEN_CHARS.set(TOKEN_SIMPLE_FLOAT); + TOKEN_CHARS.set(TOKEN_SIMPLE_DOUBLE); + TOKEN_CHARS.set(TOKEN_SIMPLE_BYTE); + TOKEN_CHARS.set(TOKEN_SIMPLE_SHORT); + TOKEN_CHARS.set(TOKEN_SIMPLE_CHARACTER); + TOKEN_CHARS.set(TOKEN_SIMPLE_BOOLEAN); + + // primitives + TOKEN_CHARS.set(TOKEN_PRIMITIVE_INT); + TOKEN_CHARS.set(TOKEN_PRIMITIVE_LONG); + TOKEN_CHARS.set(TOKEN_PRIMITIVE_FLOAT); + TOKEN_CHARS.set(TOKEN_PRIMITIVE_DOUBLE); + TOKEN_CHARS.set(TOKEN_PRIMITIVE_BYTE); + TOKEN_CHARS.set(TOKEN_PRIMITIVE_SHORT); + TOKEN_CHARS.set(TOKEN_PRIMITIVE_CHAR); + TOKEN_CHARS.set(TOKEN_PRIMITIVE_BOOLEAN); + } + + + /** + * Writes the configuration data from the Dictionary to the + * given OutputStream. + *

+ * This method writes at the current location in the stream and does not + * close the outputstream. + * @param out + * The OutputStream to write the configurtion data + * to. + * @param properties + * The Dictionary to write. + * @throws IOException + * If an error occurrs writing to the output stream. + */ + public static void write(OutputStream out, Dictionary properties) throws IOException { + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(out, ENCODING)); + + for (Enumeration ce = properties.keys(); ce.hasMoreElements();) { + String key = (String)ce.nextElement(); + + // cfg = prop "=" value "." . + writeQuoted(bw, key); + bw.write(TOKEN_EQ); + writeValue(bw, properties.get(key)); + bw.write(CRLF); + } + + bw.flush(); + } + + + /** + * Reads configuration data from the given InputStream and + * returns a new Dictionary object containing the data. + *

+ * This method reads from the current location in the stream upto the end of + * the stream but does not close the stream at the end. + * @param ins + * The InputStream from which to read the + * configuration data. + * @return A Dictionary object containing the configuration + * data. This object may be empty if the stream contains no + * configuration data. + * @throws IOException + * If an error occurrs reading from the stream. This exception + * is also thrown if a syntax error is encountered. + */ + public static Dictionary read(InputStream ins) throws IOException { + return new ConfigurationHandler_ConfigAdmin184().readInternal(ins); + } + + + // private constructor, this class is not to be instantiated from the + // outside + private ConfigurationHandler_ConfigAdmin184() {} + + // ---------- Configuration Input Implementation --------------------------- + + private int token; + private String tokenValue; + private int line; + private int pos; + + + private Dictionary readInternal(InputStream ins) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(ins, ENCODING)); + PushbackReader pr = new PushbackReader(br, 1); + + token = 0; + tokenValue = null; + line = 0; + pos = 0; + + Hashtable configuration = new Hashtable(); + token = 0; + while (nextToken(pr) == TOKEN_NAME) { + String key = tokenValue; + + // expect equal sign + if (nextToken(pr) != TOKEN_EQ) { + throw readFailure(token, TOKEN_EQ); + } + + // expect the token value + Object value = readValue(pr); + if (value != null) { + configuration.put(key, value); + } + } + + return configuration; + } + + + /** + * value = type ( "[" values "]" | "(" values ")" | simple ) . values = + * value { "," value } . simple = "{" stringsimple "}" . type = // 1-char + * type code . stringsimple = // quoted string representation of the value . + * @param pr + * @return + * @throws IOException + */ + private Object readValue(PushbackReader pr) throws IOException { + // read (optional) type code + int type = read(pr); + + // read value kind code if type code is not a value kinde code + int code; + if (code2Type.containsKey(new Integer(type))) { + code = read(pr); + } + else { + code = type; + type = TOKEN_SIMPLE_STRING; + } + + switch (code) { + case TOKEN_ARR_OPEN: + return readArray(type, pr); + + case TOKEN_VEC_OPEN: + return readCollection(type, pr); + + case TOKEN_VAL_OPEN: + Object value = readSimple(type, pr); + ensureNext(pr, TOKEN_VAL_CLOS); + return value; + + default: + return null; + } + } + + + private Object readArray(int typeCode, PushbackReader pr) throws IOException { + List list = new ArrayList(); + for (;;) { + int c = read(pr); + if (c == TOKEN_VAL_OPEN) { + Object value = readSimple(typeCode, pr); + if (value == null) { + // abort due to error + return null; + } + + ensureNext(pr, TOKEN_VAL_CLOS); + + list.add(value); + + c = read(pr); + } + + if (c == TOKEN_ARR_CLOS) { + Class type = (Class)code2Type.get(new Integer(typeCode)); + Object array = Array.newInstance(type, list.size()); + for (int i = 0; i < list.size(); i++) { + Array.set(array, i, list.get(i)); + } + return array; + } + else if (c < 0) { + return null; + } + else if (c != TOKEN_COMMA) { + return null; + } + } + } + + + private Collection readCollection(int typeCode, PushbackReader pr) throws IOException { + Collection collection = new ArrayList(); + for (;;) { + int c = read(pr); + if (c == TOKEN_VAL_OPEN) { + Object value = readSimple(typeCode, pr); + if (value == null) { + // abort due to error + return null; + } + + ensureNext(pr, TOKEN_VAL_CLOS); + + collection.add(value); + + c = read(pr); + } + + if (c == TOKEN_VEC_CLOS) { + return collection; + } + else if (c < 0) { + return null; + } + else if (c != TOKEN_COMMA) { + return null; + } + } + } + + + private Object readSimple(int code, PushbackReader pr) throws IOException { + switch (code) { + case -1: + return null; + + case TOKEN_SIMPLE_STRING: + return readQuoted(pr); + + // Simple/Primitive, only use wrapper classes + case TOKEN_SIMPLE_INTEGER: + case TOKEN_PRIMITIVE_INT: + return Integer.valueOf(readQuoted(pr)); + + case TOKEN_SIMPLE_LONG: + case TOKEN_PRIMITIVE_LONG: + return Long.valueOf(readQuoted(pr)); + + case TOKEN_SIMPLE_FLOAT: + case TOKEN_PRIMITIVE_FLOAT: + int fBits = Integer.parseInt(readQuoted(pr)); + return new Float(Float.intBitsToFloat(fBits)); + + case TOKEN_SIMPLE_DOUBLE: + case TOKEN_PRIMITIVE_DOUBLE: + long dBits = Long.parseLong(readQuoted(pr)); + return new Double(Double.longBitsToDouble(dBits)); + + case TOKEN_SIMPLE_BYTE: + case TOKEN_PRIMITIVE_BYTE: + return Byte.valueOf(readQuoted(pr)); + + case TOKEN_SIMPLE_SHORT: + case TOKEN_PRIMITIVE_SHORT: + return Short.valueOf(readQuoted(pr)); + + case TOKEN_SIMPLE_CHARACTER: + case TOKEN_PRIMITIVE_CHAR: + String cString = readQuoted(pr); + if (cString != null && cString.length() > 0) { + return new Character(cString.charAt(0)); + } + return null; + + case TOKEN_SIMPLE_BOOLEAN: + case TOKEN_PRIMITIVE_BOOLEAN: + return Boolean.valueOf(readQuoted(pr)); + + // unknown type code + default: + return null; + } + } + + + private void ensureNext(PushbackReader pr, int expected) throws IOException { + int next = read(pr); + if (next != expected) { + readFailure(next, expected); + } + } + + + private boolean checkNext(PushbackReader pr, int expected) throws IOException { + int next = read(pr); + if (next < 0) { + return false; + } + + if (next == expected) { + return true; + } + + return false; + } + + + private String readQuoted(PushbackReader pr) throws IOException { + StringBuffer buf = new StringBuffer(); + for (;;) { + int c = read(pr); + switch (c) { + // escaped character + case '\\': + c = read(pr); + switch (c) { + // well known escapes + case 'b': + buf.append('\b'); + break; + case 't': + buf.append('\t'); + break; + case 'n': + buf.append('\n'); + break; + case 'f': + buf.append('\f'); + break; + case 'r': + buf.append('\r'); + break; + case 'u':// need 4 characters ! + char[] cbuf = new char[4]; + if (read(pr, cbuf) == 4) { + c = Integer.parseInt(new String(cbuf), 16); + buf.append((char)c); + } + break; + + // just an escaped character, unescape + default: + buf.append((char)c); + } + break; + + // eof + case -1: // fall through + + // separator token + case TOKEN_EQ: + case TOKEN_VAL_CLOS: + pr.unread(c); + return buf.toString(); + + // no escaping + default: + buf.append((char)c); + } + } + } + + + private int nextToken(PushbackReader pr) throws IOException { + int c = ignorableWhiteSpace(pr); + + // immediately return EOF + if (c < 0) { + return (token = c); + } + + // check whether there is a name + if (NAME_CHARS.get(c) || !TOKEN_CHARS.get(c)) { + // read the property name + pr.unread(c); + tokenValue = readQuoted(pr); + return (token = TOKEN_NAME); + } + + // check another token + if (TOKEN_CHARS.get(c)) { + return (token = c); + } + + // unexpected character -> so what ?? + return (token = -1); + } + + + private int ignorableWhiteSpace(PushbackReader pr) throws IOException { + int c = read(pr); + while (c >= 0 && Character.isWhitespace((char)c)) { + c = read(pr); + } + return c; + } + + + private int read(PushbackReader pr) throws IOException { + int c = pr.read(); + if (c == '\r') { + int c1 = pr.read(); + if (c1 != '\n') { + pr.unread(c1); + } + c = '\n'; + } + + if (c == '\n') { + line++; + pos = 0; + } + else { + pos++; + } + + return c; + } + + + private int read(PushbackReader pr, char[] buf) throws IOException { + for (int i = 0; i < buf.length; i++) { + int c = read(pr); + if (c >= 0) { + buf[i] = (char)c; + } + else { + return i; + } + } + + return buf.length; + } + + + private IOException readFailure(int current, int expected) { + return new IOException("Unexpected token " + current + "; expected: " + expected + " (line=" + line + ", pos=" + + pos + ")"); + } + + + // ---------- Configuration Output Implementation -------------------------- + + private static void writeValue(Writer out, Object value) throws IOException { + Class clazz = value.getClass(); + if (clazz.isArray()) { + writeArray(out, value); + } + else if (value instanceof Collection) { + writeCollection(out, (Collection)value); + } + else { + writeType(out, clazz); + writeSimple(out, value); + } + } + + + private static void writeArray(Writer out, Object arrayValue) throws IOException { + int size = Array.getLength(arrayValue); + writeType(out, arrayValue.getClass().getComponentType()); + out.write(TOKEN_ARR_OPEN); + for (int i = 0; i < size; i++) { + if (i > 0) { + out.write(TOKEN_COMMA); + } + writeSimple(out, Array.get(arrayValue, i)); + } + out.write(TOKEN_ARR_CLOS); + } + + + private static void writeCollection(Writer out, Collection collection) throws IOException { + if (collection.isEmpty()) { + out.write(TOKEN_VEC_OPEN); + out.write(TOKEN_VEC_CLOS); + } + else { + Iterator ci = collection.iterator(); + Object firstElement = ci.next(); + + writeType(out, firstElement.getClass()); + out.write(TOKEN_VEC_OPEN); + writeSimple(out, firstElement); + + while (ci.hasNext()) { + out.write(TOKEN_COMMA); + writeSimple(out, ci.next()); + } + out.write(TOKEN_VEC_CLOS); + } + } + + + private static void writeType(Writer out, Class valueType) throws IOException { + Integer code = (Integer)type2Code.get(valueType); + if (code != null) { + out.write((char)code.intValue()); + } + } + + + private static void writeSimple(Writer out, Object value) throws IOException { + if (value instanceof Double) { + double dVal = ((Double)value).doubleValue(); + value = new Long(Double.doubleToRawLongBits(dVal)); + } + else if (value instanceof Float) { + float fVal = ((Float)value).floatValue(); + value = new Integer(Float.floatToRawIntBits(fVal)); + } + + out.write(TOKEN_VAL_OPEN); + writeQuoted(out, String.valueOf(value)); + out.write(TOKEN_VAL_CLOS); + } + + + private static void writeQuoted(Writer out, String simple) throws IOException { + if (simple == null || simple.length() == 0) { + return; + } + + char c = 0; + int len = simple.length(); + for (int i = 0; i < len; i++) { + c = simple.charAt(i); + switch (c) { + case '\\': + case TOKEN_VAL_CLOS: + case ' ': + case TOKEN_EQ: + out.write('\\'); + out.write(c); + break; + + // well known escapes + case '\b': + out.write("\\b"); + break; + case '\t': + out.write("\\t"); + break; + case '\n': + out.write("\\n"); + break; + case '\f': + out.write("\\f"); + break; + case '\r': + out.write("\\r"); + break; + + // other escaping + default: + if (c < ' ') { + String t = "000" + Integer.toHexString(c); + out.write("\\u" + t.substring(t.length() - 4)); + } + else { + out.write(c); + } + } + } + } +} diff --git a/conga-sling-plugin/src/main/java/io/wcm/devops/conga/plugins/sling/util/OsgiConfigUtil.java b/conga-sling-plugin/src/main/java/io/wcm/devops/conga/plugins/sling/util/OsgiConfigUtil.java new file mode 100644 index 0000000..e7d42e8 --- /dev/null +++ b/conga-sling-plugin/src/main/java/io/wcm/devops/conga/plugins/sling/util/OsgiConfigUtil.java @@ -0,0 +1,49 @@ +/* + * #%L + * wcm.io + * %% + * Copyright (C) 2019 wcm.io + * %% + * Licensed 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. + * #L% + */ +package io.wcm.devops.conga.plugins.sling.util; + +import java.io.IOException; +import java.io.OutputStream; +import java.util.Dictionary; + +/** + * Helper class for writing OSGi configurations in Felix ConfigAdmin format. + * This writes the "old" ConfigAdmin format of Felix ConfigAdmin 1.8.4 to be compatible with AEM 6.1 and below. + */ +public final class OsgiConfigUtil { + + private OsgiConfigUtil() { + // static methods only + } + + /** + * Writes the configuration data from the Dictionary to the given OutputStream. + *

+ * This method writes at the current location in the stream and does not close the outputstream. + *

+ * @param out The OutputStream to write the configuration data to. + * @param properties The Dictionary to write. + * @throws IOException If an error occurs writing to the output stream. + */ + public static void write(OutputStream out, Dictionary properties) throws IOException { + ConfigurationHandler_ConfigAdmin184.write(out, properties); + } + +} From 91eb430f9467fc9bc47b6eaad8fb1f21df3b4310 Mon Sep 17 00:00:00 2001 From: sseifert Date: Wed, 8 May 2019 11:36:17 +0200 Subject: [PATCH 13/15] prepare release --- changes.xml | 2 +- conga-sling-plugin/pom.xml | 2 +- pom.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/changes.xml b/changes.xml index babdc75..9d9c49a 100644 --- a/changes.xml +++ b/changes.xml @@ -23,7 +23,7 @@ xsi:schemaLocation="http://maven.apache.org/changes/1.0.0 http://maven.apache.org/plugins/maven-changes-plugin/xsd/changes-1.0.0.xsd"> - + Read Felix ConfigAdmin configuration files with latest version (1.9.14), but write it using the old file format form ConfigAdmin 1.8.4 to support AEM 6.1 and below. diff --git a/conga-sling-plugin/pom.xml b/conga-sling-plugin/pom.xml index c9b0481..d2186a8 100644 --- a/conga-sling-plugin/pom.xml +++ b/conga-sling-plugin/pom.xml @@ -25,7 +25,7 @@ io.wcm.devops io.wcm.devops.parent_toplevel - 1.1.2 + 1.1.4 diff --git a/pom.xml b/pom.xml index 02c5577..2e6e086 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ io.wcm.devops io.wcm.devops.parent_toplevel - 1.1.2 + 1.1.4 From 777d9c16ed31d0c5a608a7b02403fe3442d87289 Mon Sep 17 00:00:00 2001 From: sseifert Date: Wed, 8 May 2019 11:38:29 +0200 Subject: [PATCH 14/15] =?UTF-8?q?[jgitflow-maven-plugin]=C2=A0updating=20p?= =?UTF-8?q?oms=20for=201.2.6=20branch=20with=20snapshot=20versions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- conga-sling-plugin/pom.xml | 2 +- pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/conga-sling-plugin/pom.xml b/conga-sling-plugin/pom.xml index d2186a8..6fb477a 100644 --- a/conga-sling-plugin/pom.xml +++ b/conga-sling-plugin/pom.xml @@ -31,7 +31,7 @@ io.wcm.devops.conga.plugins io.wcm.devops.conga.plugins.sling - 1.2.5-SNAPSHOT + 1.2.6-SNAPSHOT jar CONGA Sling Plugin diff --git a/pom.xml b/pom.xml index 2e6e086..be47671 100644 --- a/pom.xml +++ b/pom.xml @@ -29,7 +29,7 @@ io.wcm.devops.conga.plugins io.wcm.devops.conga.plugins.sling.root - 1.2.5-SNAPSHOT + 1.2.6-SNAPSHOT pom CONGA Sling Plugin From 6889c7dfdb232317adc6ceb97c94c6687e03d58d Mon Sep 17 00:00:00 2001 From: sseifert Date: Wed, 8 May 2019 11:38:30 +0200 Subject: [PATCH 15/15] =?UTF-8?q?[jgitflow-maven-plugin]=C2=A0updating=20p?= =?UTF-8?q?oms=20for=20branch'release/1.2.6'=20with=20non-snapshot=20versi?= =?UTF-8?q?ons?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- conga-sling-plugin/pom.xml | 2 +- pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/conga-sling-plugin/pom.xml b/conga-sling-plugin/pom.xml index 6fb477a..0833d97 100644 --- a/conga-sling-plugin/pom.xml +++ b/conga-sling-plugin/pom.xml @@ -31,7 +31,7 @@ io.wcm.devops.conga.plugins io.wcm.devops.conga.plugins.sling - 1.2.6-SNAPSHOT + 1.2.6 jar CONGA Sling Plugin diff --git a/pom.xml b/pom.xml index be47671..b5c70d3 100644 --- a/pom.xml +++ b/pom.xml @@ -29,7 +29,7 @@ io.wcm.devops.conga.plugins io.wcm.devops.conga.plugins.sling.root - 1.2.6-SNAPSHOT + 1.2.6 pom CONGA Sling Plugin