You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by da...@apache.org on 2018/04/04 12:50:17 UTC

[sling-whiteboard] branch master updated: Handle run modes in feature properties similar to configuration

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

davidb 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 6464dc7  Handle run modes in feature properties similar to configuration
6464dc7 is described below

commit 6464dc754716da7731e1cc5172d662e40c4a43d2
Author: David Bosschaert <da...@gmail.com>
AuthorDate: Wed Apr 4 13:49:17 2018 +0100

    Handle run modes in feature properties similar to configuration
---
 .../sling/feature/modelconverter/impl/FeatureToProvisioning.java | 9 +++++----
 .../sling/feature/modelconverter/impl/ProvisioningToFeature.java | 4 ++--
 featuremodel/feature-modelconverter/src/test/resources/boot.json | 4 ++--
 3 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/featuremodel/feature-modelconverter/src/main/java/org/apache/sling/feature/modelconverter/impl/FeatureToProvisioning.java b/featuremodel/feature-modelconverter/src/main/java/org/apache/sling/feature/modelconverter/impl/FeatureToProvisioning.java
index 9327df6..3c526c2 100644
--- a/featuremodel/feature-modelconverter/src/main/java/org/apache/sling/feature/modelconverter/impl/FeatureToProvisioning.java
+++ b/featuremodel/feature-modelconverter/src/main/java/org/apache/sling/feature/modelconverter/impl/FeatureToProvisioning.java
@@ -183,11 +183,12 @@ public class FeatureToProvisioning {
         // framework properties
         for(final Map.Entry<String, String> prop : frameworkProps) {
             String key = prop.getKey();
-            if (key.startsWith(".runmodes:")) {
-                int lastIdx = key.lastIndexOf(':');
-                String rm = key.substring(".runmodes:".length(), lastIdx);
+            int idx = key.indexOf(".runmodes:");
+
+            if (idx > 0) {
+                String rm = key.substring(idx + ".runmodes:".length());
                 String[] runmodes = rm.split(",");
-                key = key.substring(lastIdx + 1);
+                key = key.substring(0, idx);
                 f.getOrCreateRunMode(runmodes).getSettings().put(key, prop.getValue());
             } else {
                 f.getOrCreateRunMode(null).getSettings().put(key, prop.getValue());
diff --git a/featuremodel/feature-modelconverter/src/main/java/org/apache/sling/feature/modelconverter/impl/ProvisioningToFeature.java b/featuremodel/feature-modelconverter/src/main/java/org/apache/sling/feature/modelconverter/impl/ProvisioningToFeature.java
index 4693ba8..70a6d76 100644
--- a/featuremodel/feature-modelconverter/src/main/java/org/apache/sling/feature/modelconverter/impl/ProvisioningToFeature.java
+++ b/featuremodel/feature-modelconverter/src/main/java/org/apache/sling/feature/modelconverter/impl/ProvisioningToFeature.java
@@ -398,8 +398,8 @@ public class ProvisioningToFeature {
                 if (runModeNames == null) {
                     properties.put(prop.getKey(), prop.getValue());
                 } else {
-                    properties.put(".runmodes:" + String.join(",", runModeNames) + ":" +
-                            prop.getKey(), prop.getValue());
+                    properties.put(prop.getKey() + ".runmodes:" + String.join(",", runModeNames),
+                            prop.getValue());
                 }
             }
         }
diff --git a/featuremodel/feature-modelconverter/src/test/resources/boot.json b/featuremodel/feature-modelconverter/src/test/resources/boot.json
index 4cc7d40..e535f7b 100644
--- a/featuremodel/feature-modelconverter/src/test/resources/boot.json
+++ b/featuremodel/feature-modelconverter/src/test/resources/boot.json
@@ -92,8 +92,8 @@
         "localIndexDir": "${sling.home}/repository/index",
         
         "# we need runmodes here too...": "",
-        ".runmodes:a:something": "else",
-        ".runmodes::b:special": "true", 
+        "something.runmodes:a": "else",
+        "special.runmodes::b": "true", 
         
         "#": "${sling.home} needs to be provided at launch time"
     }

-- 
To stop receiving notification emails like this one, please contact
davidb@apache.org.