You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by si...@apache.org on 2019/06/19 23:18:49 UTC

[sling-whiteboard] branch master updated: [feature-diff][r2f] simplifying the Feature Diff ArtifactId by letting the diff compute it and avoid to users the task of building it

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 209889a  [feature-diff][r2f] simplifying the Feature Diff ArtifactId by letting the diff compute it and avoid to users the task of building it
209889a is described below

commit 209889ab5950eae16542ebc5bb48bb712686ac0d
Author: Simo Tripodi <st...@adobe.com>
AuthorDate: Thu Jun 20 01:18:41 2019 +0200

    [feature-diff][r2f] simplifying the Feature Diff ArtifactId by letting
    the diff compute it and avoid to users the task of building it
---
 .../java/org/apache/sling/feature/diff/DiffRequest.java | 17 -----------------
 .../java/org/apache/sling/feature/diff/FeatureDiff.java | 10 +++++++---
 .../impl/RuntimeEnvironment2FeatureModelService.java    | 11 +++--------
 3 files changed, 10 insertions(+), 28 deletions(-)

diff --git a/feature-diff/src/main/java/org/apache/sling/feature/diff/DiffRequest.java b/feature-diff/src/main/java/org/apache/sling/feature/diff/DiffRequest.java
index 75cd24e..772b986 100644
--- a/feature-diff/src/main/java/org/apache/sling/feature/diff/DiffRequest.java
+++ b/feature-diff/src/main/java/org/apache/sling/feature/diff/DiffRequest.java
@@ -21,7 +21,6 @@ import static java.util.Objects.requireNonNull;
 import java.util.HashSet;
 import java.util.Set;
 
-import org.apache.sling.feature.ArtifactId;
 import org.apache.sling.feature.Feature;
 
 public final class DiffRequest {
@@ -34,8 +33,6 @@ public final class DiffRequest {
 
     private Feature current;
 
-    private ArtifactId resultId;
-
     public Feature getPrevious() {
         return previous;
     }
@@ -54,20 +51,6 @@ public final class DiffRequest {
         return this;
     }
 
-    public ArtifactId getResultId() {
-        return resultId;
-    }
-
-    public DiffRequest setResultId(String resultId) {
-        resultId = requireNonNull(resultId, "Impossible to create the Feature diff with a null id");
-        return setResultId(ArtifactId.parse(resultId));
-    }
-
-    public DiffRequest setResultId(ArtifactId resultId) {
-        this.resultId = requireNonNull(resultId, "Impossible to create the Feature diff with a null id");
-        return this;
-    }
-
     public DiffRequest addIncludeComparator(String includeComparator) {
         includeComparators.add(requireNonNull(includeComparator, "A null include comparator id is not valid"));
         return this;
diff --git a/feature-diff/src/main/java/org/apache/sling/feature/diff/FeatureDiff.java b/feature-diff/src/main/java/org/apache/sling/feature/diff/FeatureDiff.java
index 705abb5..90aa4a5 100644
--- a/feature-diff/src/main/java/org/apache/sling/feature/diff/FeatureDiff.java
+++ b/feature-diff/src/main/java/org/apache/sling/feature/diff/FeatureDiff.java
@@ -30,7 +30,7 @@ import org.apache.sling.feature.diff.impl.FeatureElementComparator;
 public final class FeatureDiff {
 
     public static Feature compareFeatures(DiffRequest diffRequest) {
-        requireNonNull(diffRequest, "");
+        requireNonNull(diffRequest, "Impossible to compare features without specifying them.");
         Feature previous = requireNonNull(diffRequest.getPrevious(), "Impossible to compare null previous feature.");
         Feature current = requireNonNull(diffRequest.getCurrent(), "Impossible to compare null current feature.");
 
@@ -38,11 +38,15 @@ public final class FeatureDiff {
             throw new IllegalArgumentException("Input Features refer to the the same Feature version.");
         }
 
-        ArtifactId resultId = requireNonNull(diffRequest.getResultId(), "Impossible to create the Feature diff with a null id");
+        ArtifactId resultId = new ArtifactId(current.getId().getGroupId(),
+                                             current.getId().getArtifactId(), 
+                                             current.getId().getVersion(),
+                                             current.getId().getClassifier() + "_updater",
+                                             current.getId().getType());
 
         Feature target = new Feature(resultId);
         target.setTitle(previous.getId() + " to " + current.getId());
-        target.setDescription(previous.getId() + " to " + current.getId() + " Feature upgrade");
+        target.setDescription("Computed " + previous.getId() + " to " + current.getId() + " Feature update");
 
         Prototype prototype = new Prototype(previous.getId());
         target.setPrototype(prototype);
diff --git a/runtime2feature/src/main/java/org/apache/sling/feature/r2f/impl/RuntimeEnvironment2FeatureModelService.java b/runtime2feature/src/main/java/org/apache/sling/feature/r2f/impl/RuntimeEnvironment2FeatureModelService.java
index 8859c67..778a2c8 100644
--- a/runtime2feature/src/main/java/org/apache/sling/feature/r2f/impl/RuntimeEnvironment2FeatureModelService.java
+++ b/runtime2feature/src/main/java/org/apache/sling/feature/r2f/impl/RuntimeEnvironment2FeatureModelService.java
@@ -127,18 +127,13 @@ public class RuntimeEnvironment2FeatureModelService implements RuntimeEnvironmen
     public Feature getLaunch2RuntimeUpgradingFeature() {
         Feature runtimeFeature = getRuntimeFeature();
 
+        // framework-properties can not be scanned in the BundleContext ATM
+        // extensions can not be computed at runtime
         return compareFeatures(new DiffRequest()
                                .setPrevious(launchFeature)
                                .setCurrent(runtimeFeature)
                                .addIncludeComparator("bundles")
-                               .addIncludeComparator("configurations")
-                               // framework-properties can not be scanned in the BundleContext ATM
-                               // extensions can not be computed at runtime
-                               .setResultId(new ArtifactId(runtimeFeature.getId().getGroupId(),
-                                                           runtimeFeature.getId().getArtifactId(), 
-                                                           runtimeFeature.getId().getVersion(),
-                                                           runtimeFeature.getId().getClassifier() + "_updater",
-                                                           runtimeFeature.getId().getType())));
+                               .addIncludeComparator("configurations"));
     }
 
 }