You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/07 09:58:47 UTC

[sling-org-apache-sling-provisioning-model] annotated tag org.apache.sling.provisioning.model-1.6.0 created (now a598afd)

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

rombert pushed a change to annotated tag org.apache.sling.provisioning.model-1.6.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-provisioning-model.git.


      at a598afd  (tag)
 tagging 66e803d5e507766271cd1c9fd2b2c559967e7b66 (commit)
      by Carsten Ziegeler
      on Sat Nov 5 10:01:40 2016 +0000

- Log -----------------------------------------------------------------
org.apache.sling.provisioning.model-1.6.0
-----------------------------------------------------------------------

This annotated tag includes the following new commits:

     new 11a204a  Add slingstart model
     new 03f094c  Add slingstart model
     new a86fcd4  Update javadocs and rename subsystem to deliverable and run mode to feature
     new 58cc5a6  Add simple txt parser
     new 43a5c06  Add simple txt parser
     new fdc1ccf  Fully support Apach Felix config file format. Move from properties to getter and setter methods
     new 470e4bc  Fully support Apach Felix config file format. Move from properties to getter and setter methods
     new 9857e6c  Fully support Apach Felix config file format. Move from properties to getter and setter methods
     new 75a411c  Simplify model, move completely to getter/setter methods
     new 1a36bd0  Implement txt format for reading and writing
     new 7bee16a  Add merger utility and variable replacement
     new ca9289e  Finish configuration support
     new 245be2d  Add resolver to resolve variables from environment, system properties etc.
     new ffb35f8  Don't output jar extension if not necessary
     new 252bf2d  Remove support for xml
     new 456ebb1  Implement provisioning model
     new 380d68e  Rename some constants
     new c58f1ab  Cleanup methods and constants
     new d3b6bc4  Update to Sling Parent POM 22 with baselining enabled
     new 5154296  Correct method name
     new 55e51ed  Remove old slingstart model
     new 4b98c32  Refactor model and add basic read/write test
     new 98736d5  Consistent method naming and javadocs
     new 2341da7  Rename to provisoning model
     new 4d55db0  Rename to provisioning model
     new dc48bc1  Keep ${sling.home} in settings
     new fb3de37  Remove artifact on merge regardless of the start level
     new 43e7bcf  Fix writing out raw configs
     new 54361e3  Fix writing out raw configs
     new d71c810  Fix reading configs
     new bbe9bcd  Allow comments in configurations
     new bccda6c  Add some tests to verify the parsed and effective models
     new c47da2f  [maven-release-plugin] prepare release org.apache.sling.provisioning.model-1.0.0
     new e93aff8  [maven-release-plugin] prepare for next development iteration
     new 7aee9d5  Fix comments
     new ee05f2c  Update to latest launchpad base release
     new 523138f  SLING-4473 : Provide a way to remove settings, artifacts and features through a model SLING-4475 : Artifact is twice in feature after merge
     new 94c918f  [maven-release-plugin] prepare release org.apache.sling.provisioning.model-1.1.0
     new 15d9a12  [maven-release-plugin] prepare for next development iteration
     new 89e8cf9  Add test case for run modes
     new 97ac28f  Update test case
     new 52ee32c  Fix javadocs
     new 7a21cc8  Add missing licence headers
     new ceeb1f7  SLING-4698 - Set parent.relativePath to empty for all modules
     new 43429c2  SLING-4768 : Sort entries alphabetical in written model
     new fba2533  SLING-4768 : Sort entries alphabetical in written model
     new ee04adc  SLING-4768 : Sort entries alphabetical in written model
     new 9c0eaaa  SLING-4766 Provisioning Model does not support adding variables to Sling Settings - allow escaping with \${var}
     new 9dcb074  SLING-4768 : Sort entries alphabetical in written model
     new 1f2cf68  SLING-4782 : Update to latest format from Apache Felix config admin
     new f66c21e  SLING-4786 : Attributes and configuration format are wronlgy written out
     new 2192bda  SLING-4126 : Provide a mechanism to merge configurations
     new 5f9f27c  SLING-4126 : Provide a mechanism to merge configurations
     new bd96e54  SLING-4124 : Bootstrap command file can't be appended
     new c2b343f  SLING-4790 : Removal of artifacts from inherited model is not possible
     new 9c0fcd5  [maven-release-plugin] prepare release org.apache.sling.provisioning.model-1.2.0
     new 690eb71  [maven-release-plugin] prepare for next development iteration
     new 0972528  SLING-4807 : Variables in configurations are not replaced
     new 312ade9  Update to Sling Parent 23
     new 1d0ef5f  Remove superflous sling.java.version=6 as it's the default now
     new 58dbd4a  set parent version to 24 and add empty relativePath where missing
     new 3509c1f  SLING-4645 Update Tika to 1.9
     new bbf7873  SLING-4880 Allow to get artifact versions from POM
     new 6a392fa  SLING-4879 refactor model processing logic from ModelUtility#getEffectiveModel into separate class to make it reusable
     new 82e4d3f  SLING-4879 move resolver/replace logic to separate class ModelResolverUtility
     new 7d6e31f  SLING-4807 make sure variable replacement is applied whether custom resolver exists or not
     new 5eea7de  SLING-4879 add ModelUtility.applyVariables method that allows to inject further variables from a custom variable resolver
     new ce9607f  SLING-4880 apply resolved dependencies to raw model instead of attaching effective model add new optional parameter "allowUnresolvedPomDependencies" (default: false)
     new 84e3f39  fix some javadoc errors java 8 complains about
     new 9a36bf7  SLING-4807 introduce explicit boolean flag to make sure variable replacement does not take place when merging models
     new e3b7720  [maven-release-plugin] prepare release org.apache.sling.provisioning.model-1.3.0
     new b0181cd  [maven-release-plugin] prepare for next development iteration
     new 9a80232  Update the main reactor to parent 25
     new b36cc99  SLING-5148 : Support OSGi Subsystems in the Sling Provisioning model. Apply patch from David Bosschaert
     new d0779ce  SLING-5172 : Provide support for custom sections in the provisioning model
     new 7fa8736  SLING-5148 : Support OSGi Subsystems in the Sling Provisioning model.
     new 94bc251  SLING-5174 : Refactor merging of models into separate utility class and add merge options
     new 4a90126  git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/tooling/support/provisioning-model@1709754 13f79535-47bb-0310-9956-ffa450edef68
     new b0f38e7  SLING-5172 : Provide support for custom sections in the provisioning model
     new 42a911c  SLING-5174 : Refactor merging of models into separate utility class and add merge options
     new b05b9ce  [maven-release-plugin] prepare release org.apache.sling.provisioning.model-1.4.0
     new d7059e2  [maven-release-plugin] prepare for next development iteration
     new 6bb2a5e  SLING-5185 : Version comparision is wrong in case of qualifiers
     new 2c05c45  SLING-5189 : Improve start level handling when merging models
     new 967d25a  SLING-5318 : Sling provisioning model does not propagate Artifact metadata during processing. Apply patch from David Bosschaert
     new a4b997d  [maven-release-plugin] prepare release org.apache.sling.provisioning.model-1.4.2
     new 7da6bc0  [maven-release-plugin] prepare for next development iteration
     new 90c365d  SLING-5355 - test multiline strings in configs
     new 5ba03f6  Switch to parent pom 26
     new f1b113a  SLING-5765 : No way to remove an artifact from a special runmode
     new 609d205  [maven-release-plugin] prepare release org.apache.sling.provisioning.model-1.4.4
     new 3bd7409  [maven-release-plugin] prepare for next development iteration
     new 636f387  SLING-5914 - add tests that demonstrate the current behavior
     new af9d553  SLING-6181 : Support adding version info to Feature
     new 62c933d  [maven-release-plugin] prepare release org.apache.sling.provisioning.model-1.5.0
     new 3502210  [maven-release-plugin] prepare for next development iteration
     new 52c62df  SLING-6215 : Catch IllegalArgumentException when comparing versions
     new 8cc4eef  SLING-6214 : Validate feature version to be a valid version
     new f12e1de  SLING-6216 : Merge versioned features by using highest version
     new d6876f6  SLING-6218 : Make usage of MergeOptions easier
     new 57a433e  [maven-release-plugin] prepare release org.apache.sling.provisioning.model-1.6.0
     new 66e803d  [maven-release-plugin] copy for tag org.apache.sling.provisioning.model-1.6.0

The 102 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


-- 
To stop receiving notification emails like this one, please contact
['"commits@sling.apache.org" <co...@sling.apache.org>'].

[sling-org-apache-sling-provisioning-model] 06/07: [maven-release-plugin] prepare release org.apache.sling.provisioning.model-1.6.0

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.provisioning.model-1.6.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-provisioning-model.git

commit 57a433eed3639eadb1449aeaffd73efd2ba6415f
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Sat Nov 5 10:01:27 2016 +0000

    [maven-release-plugin] prepare release org.apache.sling.provisioning.model-1.6.0
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/tooling/support/provisioning-model@1768176 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index e4607fb..db40ad0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -22,7 +22,7 @@
     </parent>
 
     <artifactId>org.apache.sling.provisioning.model</artifactId>
-    <version>1.5.1-SNAPSHOT</version>
+    <version>1.6.0</version>
     <packaging>bundle</packaging>
 
     <name>Apache Sling Provisioning Model</name>
@@ -31,9 +31,9 @@
     </description>
 
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/tooling/support/provisioning-model</connection>
-        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/tooling/support/provisioning-model</developerConnection>
-        <url>http://svn.apache.org/viewvc/sling/trunk/tooling/support/provisioning-model</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.provisioning.model-1.6.0</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.provisioning.model-1.6.0</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.provisioning.model-1.6.0</url>
     </scm>
 
     <build>

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-provisioning-model] 07/07: [maven-release-plugin] copy for tag org.apache.sling.provisioning.model-1.6.0

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.provisioning.model-1.6.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-provisioning-model.git

commit 66e803d5e507766271cd1c9fd2b2c559967e7b66
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Sat Nov 5 10:01:40 2016 +0000

    [maven-release-plugin] copy for tag org.apache.sling.provisioning.model-1.6.0
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.provisioning.model-1.6.0@1768177 13f79535-47bb-0310-9956-ffa450edef68

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-provisioning-model] 01/07: [maven-release-plugin] prepare for next development iteration

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.provisioning.model-1.6.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-provisioning-model.git

commit 35022106bdb036e75275cffd6732e91681f9e3f1
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Fri Oct 28 05:15:03 2016 +0000

    [maven-release-plugin] prepare for next development iteration
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/tooling/support/provisioning-model@1766924 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index f789de8..e4607fb 100644
--- a/pom.xml
+++ b/pom.xml
@@ -22,7 +22,7 @@
     </parent>
 
     <artifactId>org.apache.sling.provisioning.model</artifactId>
-    <version>1.5.0</version>
+    <version>1.5.1-SNAPSHOT</version>
     <packaging>bundle</packaging>
 
     <name>Apache Sling Provisioning Model</name>
@@ -31,9 +31,9 @@
     </description>
 
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.provisioning.model-1.5.0</connection>
-        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.provisioning.model-1.5.0</developerConnection>
-        <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.provisioning.model-1.5.0</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/tooling/support/provisioning-model</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/tooling/support/provisioning-model</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/trunk/tooling/support/provisioning-model</url>
     </scm>
 
     <build>

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-provisioning-model] 04/07: SLING-6216 : Merge versioned features by using highest version

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.provisioning.model-1.6.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-provisioning-model.git

commit f12e1de3fc910e00aef32cd03b922fc82c88b2c9
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Sun Oct 30 11:00:33 2016 +0000

    SLING-6216 : Merge versioned features by using highest version
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/tooling/support/provisioning-model@1767141 13f79535-47bb-0310-9956-ffa450edef68
---
 .../sling/provisioning/model/KeyValueMap.java      |  8 ++
 .../sling/provisioning/model/MergeUtility.java     | 30 ++++++++
 .../sling/provisioning/model/ModelUtility.java     |  3 +-
 .../sling/provisioning/model/io/package-info.java  |  3 +-
 .../sling/provisioning/model/package-info.java     |  3 +-
 .../sling/provisioning/model/MergeUtilityTest.java | 86 ++++++++++++++++++++++
 6 files changed, 128 insertions(+), 5 deletions(-)

diff --git a/src/main/java/org/apache/sling/provisioning/model/KeyValueMap.java b/src/main/java/org/apache/sling/provisioning/model/KeyValueMap.java
index 4d08db1..6646ab6 100644
--- a/src/main/java/org/apache/sling/provisioning/model/KeyValueMap.java
+++ b/src/main/java/org/apache/sling/provisioning/model/KeyValueMap.java
@@ -93,4 +93,12 @@ public class KeyValueMap<T>
     public int size() {
         return this.properties.size();
     }
+
+    /**
+     * Clear the map
+     * @since 1.7
+     */
+    public void clear() {
+        this.properties.clear();
+    }
 }
diff --git a/src/main/java/org/apache/sling/provisioning/model/MergeUtility.java b/src/main/java/org/apache/sling/provisioning/model/MergeUtility.java
index 86f3203..265643f 100644
--- a/src/main/java/org/apache/sling/provisioning/model/MergeUtility.java
+++ b/src/main/java/org/apache/sling/provisioning/model/MergeUtility.java
@@ -92,6 +92,9 @@ public abstract class MergeUtility {
      * <p>
      * For each feature, the following actions are performed:
      * <ul>
+     *   <li>If either the base feature or the additional feature has a version, then
+     *    the one with the higher version is used, the other one is skipped. A missing
+     *    version is considered the lowest possible version.</li>
      *   <li>The feature type of the base feature is set to the type of the additional feature.</li>
      *   <li>All additional sections of the additional feature are added to the base feature.</li>
      *   <li>All variables from the additional feature are set on the base feature, overriding
@@ -107,6 +110,33 @@ public abstract class MergeUtility {
         // features
         for(final Feature feature : additional.getFeatures()) {
             final Feature baseFeature = base.getOrCreateFeature(feature.getName());
+
+            // version check first
+            boolean overwrite = false;
+            if ( baseFeature.getVersion() != null ) {
+                if ( feature.getVersion() == null ) {
+                    continue;
+                }
+                final Version baseVersion = new Version(baseFeature.getVersion());
+                final Version addVersion = new Version(feature.getVersion());
+                if ( baseVersion.compareTo(addVersion) >= 0 ) {
+                    continue;
+                }
+                overwrite = true;
+            } else {
+                if ( feature.getVersion() != null ) {
+                    overwrite = true;
+                }
+            }
+            if ( overwrite ) {
+                // set version
+                baseFeature.setVersion(feature.getVersion());
+                // remove everything from base feature
+                baseFeature.getRunModes().clear();
+                baseFeature.getAdditionalSections().clear();
+                baseFeature.getVariables().clear();
+            }
+
             baseFeature.setType(feature.getType());
 
             // additional sections
diff --git a/src/main/java/org/apache/sling/provisioning/model/ModelUtility.java b/src/main/java/org/apache/sling/provisioning/model/ModelUtility.java
index e4b1479..71b8a15 100644
--- a/src/main/java/org/apache/sling/provisioning/model/ModelUtility.java
+++ b/src/main/java/org/apache/sling/provisioning/model/ModelUtility.java
@@ -157,8 +157,9 @@ public abstract class ModelUtility {
 
     /**
      * Validates the model.
+     *
      * @param model The model to validate
-     * @return A map with errors or {@code null}.
+     * @return A map with errors or {@code null} if valid.
      */
     public static Map<Traceable, String> validate(final Model model) {
         final Map<Traceable, String> errors = new HashMap<Traceable, String>();
diff --git a/src/main/java/org/apache/sling/provisioning/model/io/package-info.java b/src/main/java/org/apache/sling/provisioning/model/io/package-info.java
index 175208e..a100458 100644
--- a/src/main/java/org/apache/sling/provisioning/model/io/package-info.java
+++ b/src/main/java/org/apache/sling/provisioning/model/io/package-info.java
@@ -17,8 +17,7 @@
  * under the License.
  */
 
-@Version("1.2")
+@org.osgi.annotation.versioning.Version("1.2")
 package org.apache.sling.provisioning.model.io;
 
-import aQute.bnd.annotation.Version;
 
diff --git a/src/main/java/org/apache/sling/provisioning/model/package-info.java b/src/main/java/org/apache/sling/provisioning/model/package-info.java
index 9821b30..1a04095 100644
--- a/src/main/java/org/apache/sling/provisioning/model/package-info.java
+++ b/src/main/java/org/apache/sling/provisioning/model/package-info.java
@@ -17,8 +17,7 @@
  * under the License.
  */
 
-@Version("1.6.0")
+@org.osgi.annotation.versioning.Version("1.7.0")
 package org.apache.sling.provisioning.model;
 
-import aQute.bnd.annotation.Version;
 
diff --git a/src/test/java/org/apache/sling/provisioning/model/MergeUtilityTest.java b/src/test/java/org/apache/sling/provisioning/model/MergeUtilityTest.java
index afff784..37f3bb7 100644
--- a/src/test/java/org/apache/sling/provisioning/model/MergeUtilityTest.java
+++ b/src/test/java/org/apache/sling/provisioning/model/MergeUtilityTest.java
@@ -291,4 +291,90 @@ public class MergeUtilityTest {
         final List<Artifact> list = U.assertArtifactsInGroup(model.getFeature("f").getRunMode().getArtifactGroup(0), 1);
         U.assertArtifact(list.get(0), "g", "c", "1.6.0", "jar", null);
     }
+
+    @Test public void mergeBaseNoVersionWithVersionedFeature() {
+        final Model base = new Model();
+        final Feature f1 = base.getOrCreateFeature("f1");
+        f1.getOrCreateRunMode(null).getOrCreateArtifactGroup(0).add(new Artifact("g", "a", "0.1.0", null, null));
+        f1.getVariables().put("a", "1");
+        f1.getAdditionalSections().add(new Section("foo"));
+
+        final Model add = new Model();
+        final Feature f1Add = add.getOrCreateFeature("f1");
+        f1Add.setVersion("1.0");
+        f1Add.getOrCreateRunMode(null).getOrCreateArtifactGroup(0).add(new Artifact("g", "b", "1.0.0", null, null));
+
+        MergeUtility.merge(base, add);
+        final List<Artifact> list = U.assertArtifactsInGroup(base.getFeature("f1").getRunMode().getArtifactGroup(0), 1);
+        U.assertArtifact(list.get(0), "g", "b", "1.0.0", "jar", null);
+        assertTrue(f1.getVariables().isEmpty());
+        assertTrue(f1.getAdditionalSections().isEmpty());
+    }
+
+    @Test public void mergeBaseVersionedFeatureWithHigherVersionedFeature() {
+        final Model base = new Model();
+        final Feature f1 = base.getOrCreateFeature("f1");
+        f1.setVersion("0.1.0");
+        f1.getOrCreateRunMode(null).getOrCreateArtifactGroup(0).add(new Artifact("g", "a", "0.1.0", null, null));
+        f1.getVariables().put("a", "1");
+        f1.getAdditionalSections().add(new Section("foo"));
+
+        final Model add = new Model();
+        final Feature f1Add = add.getOrCreateFeature("f1");
+        f1Add.setVersion("1.0");
+        f1Add.getOrCreateRunMode(null).getOrCreateArtifactGroup(0).add(new Artifact("g", "b", "1.0.0", null, null));
+
+        MergeUtility.merge(base, add);
+        final List<Artifact> list = U.assertArtifactsInGroup(base.getFeature("f1").getRunMode().getArtifactGroup(0), 1);
+        U.assertArtifact(list.get(0), "g", "b", "1.0.0", "jar", null);
+        assertTrue(f1.getVariables().isEmpty());
+        assertTrue(f1.getAdditionalSections().isEmpty());
+    }
+
+    @Test public void mergeBaseVersionedFeatureWithNoVersion() {
+        final Model base = new Model();
+        final Feature f1 = base.getOrCreateFeature("f1");
+        f1.setVersion("1.0");
+        f1.getOrCreateRunMode(null).getOrCreateArtifactGroup(0).add(new Artifact("g", "a", "0.1.0", null, null));
+        f1.getVariables().put("a", "1");
+        f1.getAdditionalSections().add(new Section("foo"));
+
+        final Model add = new Model();
+        final Feature f1Add = add.getOrCreateFeature("f1");
+        f1Add.getOrCreateRunMode(null).getOrCreateArtifactGroup(0).add(new Artifact("g", "b", "1.0.0", null, null));
+        f1Add.getVariables().put("b", "1");
+        f1Add.getAdditionalSections().add(new Section("foo2"));
+
+        MergeUtility.merge(base, add);
+        final List<Artifact> list = U.assertArtifactsInGroup(base.getFeature("f1").getRunMode().getArtifactGroup(0), 1);
+        U.assertArtifact(list.get(0), "g", "a", "0.1.0", "jar", null);
+        assertEquals(1, f1.getVariables().size());
+        assertNotNull(f1.getVariables().get("a"));
+        assertEquals(1, f1.getAdditionalSections().size());
+        assertEquals(1, f1.getAdditionalSections("foo").size());
+    }
+
+    @Test public void mergeBaseVersionedFeatureWithLowerVersionedFeature() {
+        final Model base = new Model();
+        final Feature f1 = base.getOrCreateFeature("f1");
+        f1.setVersion("1.0");
+        f1.getOrCreateRunMode(null).getOrCreateArtifactGroup(0).add(new Artifact("g", "a", "0.1.0", null, null));
+        f1.getVariables().put("a", "1");
+        f1.getAdditionalSections().add(new Section("foo"));
+
+        final Model add = new Model();
+        final Feature f1Add = add.getOrCreateFeature("f1");
+        f1Add.setVersion("0.1.0");
+        f1Add.getOrCreateRunMode(null).getOrCreateArtifactGroup(0).add(new Artifact("g", "b", "1.0.0", null, null));
+        f1Add.getVariables().put("b", "1");
+        f1Add.getAdditionalSections().add(new Section("foo2"));
+
+        MergeUtility.merge(base, add);
+        final List<Artifact> list = U.assertArtifactsInGroup(base.getFeature("f1").getRunMode().getArtifactGroup(0), 1);
+        U.assertArtifact(list.get(0), "g", "a", "0.1.0", "jar", null);
+        assertEquals(1, f1.getVariables().size());
+        assertNotNull(f1.getVariables().get("a"));
+        assertEquals(1, f1.getAdditionalSections().size());
+        assertEquals(1, f1.getAdditionalSections("foo").size());
+    }
 }

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-provisioning-model] 03/07: SLING-6214 : Validate feature version to be a valid version

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.provisioning.model-1.6.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-provisioning-model.git

commit 8cc4eefae45c9131e1f6e69e99dea0ec6f4bd957
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Sun Oct 30 10:31:38 2016 +0000

    SLING-6214 : Validate feature version to be a valid version
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/tooling/support/provisioning-model@1767140 13f79535-47bb-0310-9956-ffa450edef68
---
 .../apache/sling/provisioning/model/ModelUtility.java    |  8 ++++++++
 .../sling/provisioning/model/ModelUtilityTest.java       | 16 ++++++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/src/main/java/org/apache/sling/provisioning/model/ModelUtility.java b/src/main/java/org/apache/sling/provisioning/model/ModelUtility.java
index a5b6d1c..e4b1479 100644
--- a/src/main/java/org/apache/sling/provisioning/model/ModelUtility.java
+++ b/src/main/java/org/apache/sling/provisioning/model/ModelUtility.java
@@ -168,6 +168,14 @@ public abstract class ModelUtility {
             if ( feature.getName() == null || feature.getName().isEmpty() ) {
                 errors.put(feature, "Name is required for a feature.");
             }
+            // version should be a valid version
+            if ( feature.getVersion() != null ) {
+                try {
+                    new Version(feature.getVersion());
+                } catch ( final IllegalArgumentException iae) {
+                    errors.put(feature, "Version is not a valid version");
+                }
+            }
             for(final RunMode runMode : feature.getRunModes()) {
                 final String[] rm = runMode.getNames();
                 if ( rm != null ) {
diff --git a/src/test/java/org/apache/sling/provisioning/model/ModelUtilityTest.java b/src/test/java/org/apache/sling/provisioning/model/ModelUtilityTest.java
index d8c3463..8cd2feb 100644
--- a/src/test/java/org/apache/sling/provisioning/model/ModelUtilityTest.java
+++ b/src/test/java/org/apache/sling/provisioning/model/ModelUtilityTest.java
@@ -252,4 +252,20 @@ public class ModelUtilityTest {
         assertNotNull(ModelUtility.validate(m));
         f.getRunModes().remove(rmC);
     }
+
+    @Test public void testValidateFeatureVersion() {
+        final Model m = new Model();
+        final Feature f = m.getOrCreateFeature("f");
+
+        // no version -> no error
+        assertNull(ModelUtility.validate(m));
+
+        f.setVersion("1.0");
+        // valid version -> no error
+        assertNull(ModelUtility.validate(m));
+
+        f.setVersion("foo");
+        // invalid version -> error
+        assertNotNull(ModelUtility.validate(m));
+    }
 }

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-provisioning-model] 02/07: SLING-6215 : Catch IllegalArgumentException when comparing versions

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.provisioning.model-1.6.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-provisioning-model.git

commit 52c62dff5075a101a25dd4cabd8eb5b95de32298
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Sun Oct 30 10:26:48 2016 +0000

    SLING-6215 : Catch IllegalArgumentException when comparing versions
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/tooling/support/provisioning-model@1767139 13f79535-47bb-0310-9956-ffa450edef68
---
 .../sling/provisioning/model/MergeUtility.java     | 24 +++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/src/main/java/org/apache/sling/provisioning/model/MergeUtility.java b/src/main/java/org/apache/sling/provisioning/model/MergeUtility.java
index 0d18a05..86f3203 100644
--- a/src/main/java/org/apache/sling/provisioning/model/MergeUtility.java
+++ b/src/main/java/org/apache/sling/provisioning/model/MergeUtility.java
@@ -141,13 +141,23 @@ public abstract class MergeUtility {
                                     searchGroup.remove(found);
                                     foundStartLevel = searchGroup.getStartLevel();
                                 } else {
-                                    final Version baseVersion = new Version(found.getVersion());
-                                    final Version mergeVersion = new Version(artifact.getVersion());
-                                    if ( baseVersion.compareTo(mergeVersion) <= 0 ) {
-                                        searchGroup.remove(found);
-                                        foundStartLevel = searchGroup.getStartLevel();
-                                    } else {
-                                        addArtifact = false;
+                                    try {
+                                        final Version baseVersion = new Version(found.getVersion());
+                                        final Version mergeVersion = new Version(artifact.getVersion());
+                                        if ( baseVersion.compareTo(mergeVersion) <= 0 ) {
+                                            searchGroup.remove(found);
+                                            foundStartLevel = searchGroup.getStartLevel();
+                                        } else {
+                                            addArtifact = false;
+                                        }
+                                    } catch ( final IllegalArgumentException iae) {
+                                        // if at least one version is not a valid maven version
+                                        if ( found.getVersion().compareTo(artifact.getVersion()) <= 0 ) {
+                                            searchGroup.remove(found);
+                                            foundStartLevel = searchGroup.getStartLevel();
+                                        } else {
+                                            addArtifact = false;
+                                        }
                                     }
                                 }
                             }

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-provisioning-model] 05/07: SLING-6218 : Make usage of MergeOptions easier

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.provisioning.model-1.6.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-provisioning-model.git

commit d6876f66260312e7cc39b1c93aab6fd833f54817
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Sun Oct 30 12:47:48 2016 +0000

    SLING-6218 : Make usage of MergeOptions easier
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/tooling/support/provisioning-model@1767152 13f79535-47bb-0310-9956-ffa450edef68
---
 .../org/apache/sling/provisioning/model/MergeUtility.java   | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/main/java/org/apache/sling/provisioning/model/MergeUtility.java b/src/main/java/org/apache/sling/provisioning/model/MergeUtility.java
index 265643f..9cfdc3e 100644
--- a/src/main/java/org/apache/sling/provisioning/model/MergeUtility.java
+++ b/src/main/java/org/apache/sling/provisioning/model/MergeUtility.java
@@ -24,7 +24,7 @@ import java.util.Map;
 import java.util.Set;
 
 /**
- * Utility for merging two model.
+ * Utility for merging two models.
  *
  * @since 1.4
  */
@@ -49,10 +49,12 @@ public abstract class MergeUtility {
 
         /**
          * Set to {@code true} if the remove run mode should be respected.
-         * @param handleRemoveRunMode
+         * @param handleRemoveRunMode Whether the remove run mode should be respected.
+         * @return This instance.
          */
-        public void setHandleRemoveRunMode(boolean handleRemoveRunMode) {
+        public MergeOptions setHandleRemoveRunMode(boolean handleRemoveRunMode) {
             this.handleRemoveRunMode = handleRemoveRunMode;
+            return this;
         }
 
         /**
@@ -67,9 +69,12 @@ public abstract class MergeUtility {
         /**
          * Set to {@code true} if the latest artifact should win on a merge.
          * Set to {@code false} if the artifact with the highest version should win
+         * @param latestArtifactWins Whether the latest artifact should win
+         * @return This instance.
          */
-        public void setLatestArtifactWins(boolean latestArtifactWins) {
+        public MergeOptions setLatestArtifactWins(boolean latestArtifactWins) {
             this.latestArtifactWins = latestArtifactWins;
+            return this;
         }
     }
 

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.