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

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


The following commit(s) were added to refs/heads/SLING-9658 by this push:
     new 2215a3b  Update interface
2215a3b is described below

commit 2215a3bacc96269646259554d6851ec62fdf21e4
Author: David Bosschaert <[email protected]>
AuthorDate: Tue Aug 18 14:22:54 2020 +0100

    Update interface
---
 .../spi/context/ExtensionHandlerContext.java       |  6 ++-
 .../model/impl/InstallFeatureModelTask.java        | 56 +++-------------------
 2 files changed, 10 insertions(+), 52 deletions(-)

diff --git 
a/src/main/java/org/apache/sling/feature/spi/context/ExtensionHandlerContext.java
 
b/src/main/java/org/apache/sling/feature/spi/context/ExtensionHandlerContext.java
index 7aa1786..90c4830 100644
--- 
a/src/main/java/org/apache/sling/feature/spi/context/ExtensionHandlerContext.java
+++ 
b/src/main/java/org/apache/sling/feature/spi/context/ExtensionHandlerContext.java
@@ -23,10 +23,12 @@ import org.apache.sling.feature.builder.ArtifactProvider;
 
 import java.net.URL;
 import java.util.Dictionary;
+import java.util.Map;
 
 public interface ExtensionHandlerContext {
     /**
      * Add a bundle to be installed by the launcher.
+     * @param id The bundle's artifact ID
      * @param startLevel The start level for the bundle.
      * @param file The file with the bundle.
      */
@@ -34,11 +36,11 @@ public interface ExtensionHandlerContext {
 
     /**
      * Add an artifact to be installed by the launcher
-     * @param artifactId The ID of the artifact
+     * @param id The artifact's ID
      * @param url The url to the Artifact resource
      * @param props Additional installation metadata
      */
-    public void addInstallableArtifact(ArtifactId artifactId, final URL url, 
final Dictionary<String,Object> props);
+    public void addInstallableArtifact(ArtifactId id, final URL url, final 
Map<String,Object> props);
 
     /**
      * Add a configuration to be installed by the launcher
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 3b4a60d..f114821 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
@@ -52,6 +52,7 @@ import java.util.ArrayList;
 import java.util.Dictionary;
 import java.util.Hashtable;
 import java.util.List;
+import java.util.Map;
 
 /**
  * This task installs a feature model resources.
@@ -183,43 +184,6 @@ public class InstallFeatureModelTask extends 
AbstractFeatureModelTask {
             }
         }
 
-        /* done by RepoinitExtensionHandler
-        // repoinit
-        final Extension repoInit = 
feature.getExtensions().getByName(Extension.EXTENSION_NAME_REPOINIT);
-        if (repoInit != null && repoInit.getType() == ExtensionType.TEXT) {
-            final String configPid = 
REPOINIT_FACTORY_PID.concat(feature.getId().toMvnName().replace('-', '_'));
-            final Dictionary<String, Object> props = new Hashtable<>();
-            props.put("scripts", repoInit.getText());
-            props.put(Constants.SERVICE_RANKING, 200);
-
-            result.add(new 
InstallableResource("/".concat(configPid).concat(".config"), null,
-                    props, null, InstallableResource.TYPE_CONFIG, null));
-        }
-        */
-
-        /* done by APIRegionsExtensionHandler
-        // api regions
-        final Extension regionExt = 
feature.getExtensions().getByName(ApiRegions.EXTENSION_NAME);
-        if ( regionExt != null ) {
-            try {
-                final ApiRegions regions = 
ApiRegions.parse(regionExt.getJSONStructure().asJsonArray());
-
-                final String configPid = 
REGION_FACTORY_PID.concat(feature.getId().toMvnName().replace('-', '_'));
-                final Dictionary<String, Object> props = new Hashtable<>();
-                props.put(PROP_idbsnver, 
convert(LauncherProperties.getBundleIDtoBSNandVersionMap(feature, 
this.installContext.artifactManager)));
-                props.put(PROP_bundleFeatures, 
convert(LauncherProperties.getBundleIDtoFeaturesMap(feature)));
-                props.put(PROP_featureRegions, 
convert(LauncherProperties.getFeatureIDtoRegionsMap(regions)));
-                props.put(PROP_regionPackage, 
convert(LauncherProperties.getRegionNametoPackagesMap(regions)));
-
-                result.add(new 
InstallableResource("/".concat(configPid).concat(".config"), null,
-                        props, null, InstallableResource.TYPE_CONFIG, null));
-            } catch (final IOException ioe) {
-                logger.warn("Unable to parse region information " + 
feature.getId().toMvnId(), ioe);
-                return null;
-            }
-        }
-        */
-
         // bundles
         for (final Artifact bundle : feature.getBundles()) {
             if (!addArtifact(bundle, result)) {
@@ -227,17 +191,6 @@ public class InstallFeatureModelTask extends 
AbstractFeatureModelTask {
             }
         }
 
-        /*
-        // artifact extensions
-        for(final Extension ext : feature.getExtensions()) {
-            if ( ext.getType() == ExtensionType.ARTIFACTS ) {
-                for (final Artifact artifact : ext.getArtifacts()) {
-                    addArtifact(artifact, result);
-                }
-            }
-        }
-        */
-
         return result;
     }
 
@@ -331,10 +284,13 @@ public class InstallFeatureModelTask extends 
AbstractFeatureModelTask {
         }
 
         @Override
-        public void addInstallableArtifact(ArtifactId id, URL url, 
Dictionary<String,Object> props) {
+        public void addInstallableArtifact(ArtifactId id, URL url, 
Map<String,Object> props) {
             try {
+                Dictionary <String,Object> dict = new Hashtable<>();
+                props.entrySet().stream().forEach(e -> dict.put(e.getKey(), 
e.getValue()));
+
                 InputStream is = url.openStream();
-                results.add(new 
InstallableResource("/".concat(id.toMvnName()), is, props, null /* TODO digest? 
*/,
+                results.add(new 
InstallableResource("/".concat(id.toMvnName()), is, dict, null /* TODO digest? 
*/,
                         InstallableResource.TYPE_FILE, null));
             } catch (IOException e) {
                 logger.warn("Unable to read artifact " + id + " from url " + 
url, e);

Reply via email to