You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2020/04/29 10:44:24 UTC

[sling-org-apache-sling-installer-factory-feature] 05/08: Fix url scheme

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

cziegeler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-installer-factory-feature.git

commit 7549fb2734c692db07eccf783d06a2d87e164519
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Wed Apr 15 15:50:50 2020 +0200

    Fix url scheme
---
 pom.xml                                                             | 6 +++---
 .../installer/factory/model/impl/AbstractFeatureModelTask.java      | 5 +++++
 .../sling/installer/factory/model/impl/InstallFeatureModelTask.java | 2 +-
 .../installer/factory/model/impl/UninstallFeatureModelTask.java     | 3 +--
 .../factory/model/impl/FeatureModelInstallerPluginTest.java         | 2 +-
 5 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/pom.xml b/pom.xml
index 2bcd34a..fe8398e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -113,13 +113,13 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.feature</artifactId>
-            <version>1.1.2</version>
+            <version>1.1.8</version>
             <scope>provided</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.feature.io</artifactId>
-            <version>1.3.0-SNAPSHOT</version>
+            <version>1.3.0</version>
             <scope>provided</scope>
         </dependency>
    <!-- Testing -->
@@ -130,7 +130,7 @@
         <dependency>
             <groupId>org.mockito</groupId>
             <artifactId>mockito-core</artifactId>
-            <version>2.15.0</version>
+            <version>3.3.0</version>
             <scope>test</scope>
         </dependency>
     </dependencies>
diff --git a/src/main/java/org/apache/sling/installer/factory/model/impl/AbstractFeatureModelTask.java b/src/main/java/org/apache/sling/installer/factory/model/impl/AbstractFeatureModelTask.java
index 2f6f459..d58ec51 100644
--- a/src/main/java/org/apache/sling/installer/factory/model/impl/AbstractFeatureModelTask.java
+++ b/src/main/java/org/apache/sling/installer/factory/model/impl/AbstractFeatureModelTask.java
@@ -23,6 +23,7 @@ import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.sling.installer.api.tasks.InstallTask;
+import org.apache.sling.installer.api.tasks.TaskResource;
 import org.apache.sling.installer.api.tasks.TaskResourceGroup;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
@@ -54,6 +55,10 @@ public abstract class AbstractFeatureModelTask extends InstallTask {
         this.services.clear();
     }
 
+    protected String getScheme(final TaskResource resource) {
+        return "model-".concat(resource.getAttribute(FeatureModelInstallerPlugin.ATTR_ID).toString().replace(':', '_'));
+    }
+
     @SuppressWarnings("unchecked")
     protected <T> T getService(final Class<T> type) {
         T service = null;
diff --git a/src/main/java/org/apache/sling/installer/factory/model/impl/InstallFeatureModelTask.java b/src/main/java/org/apache/sling/installer/factory/model/impl/InstallFeatureModelTask.java
index 34572c4..5e97d54 100644
--- a/src/main/java/org/apache/sling/installer/factory/model/impl/InstallFeatureModelTask.java
+++ b/src/main/java/org/apache/sling/installer/factory/model/impl/InstallFeatureModelTask.java
@@ -120,7 +120,7 @@ public class InstallFeatureModelTask extends AbstractFeatureModelTask {
                         final OsgiInstaller installer = this.getService(OsgiInstaller.class);
                         if (installer != null) {
                             installer.registerResources(
-                                    "model-" + resource.getAttribute(FeatureModelInstallerPlugin.ATTR_ID),
+                                    getScheme(resource),
                                     result.resources.toArray(new InstallableResource[result.resources.size()]));
                         } else {
                             ctx.log("Unable to install feature model resource {} : unable to get OSGi installer",
diff --git a/src/main/java/org/apache/sling/installer/factory/model/impl/UninstallFeatureModelTask.java b/src/main/java/org/apache/sling/installer/factory/model/impl/UninstallFeatureModelTask.java
index d734e4a..4370438 100644
--- a/src/main/java/org/apache/sling/installer/factory/model/impl/UninstallFeatureModelTask.java
+++ b/src/main/java/org/apache/sling/installer/factory/model/impl/UninstallFeatureModelTask.java
@@ -44,8 +44,7 @@ public class UninstallFeatureModelTask extends AbstractFeatureModelTask {
             } else {
                 final TaskResource resource = this.getResource();
                 ctx.log("Uninstalling {}", resource.getEntityId());
-                installer.registerResources("model-" + resource.getAttribute(FeatureModelInstallerPlugin.ATTR_ID),
-                        null);
+                installer.registerResources(getScheme(resource), null);
                 this.getResourceGroup().setFinishState(ResourceState.UNINSTALLED);
                 ctx.log("Uninstalled {}", resource.getEntityId());
             }
diff --git a/src/test/java/org/apache/sling/installer/factory/model/impl/FeatureModelInstallerPluginTest.java b/src/test/java/org/apache/sling/installer/factory/model/impl/FeatureModelInstallerPluginTest.java
index 04c7eda..e640a5a 100644
--- a/src/test/java/org/apache/sling/installer/factory/model/impl/FeatureModelInstallerPluginTest.java
+++ b/src/test/java/org/apache/sling/installer/factory/model/impl/FeatureModelInstallerPluginTest.java
@@ -50,7 +50,7 @@ public class FeatureModelInstallerPluginTest {
     }
 
     @Test
-    public void tesClassifierPatterns() throws Exception {
+    public void testClassifierPatterns() throws Exception {
         final FeatureModelInstallerPlugin.Config config = Mockito.mock(FeatureModelInstallerPlugin.Config.class);
         Mockito.when(config.classifierPatterns()).thenReturn(new String[] { ":", "*devfar", "*prodfar", "*special*" });