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 2022/05/13 11:25:29 UTC

[sling-org-apache-sling-feature-cpconverter] branch master updated: SLING-11318 : Inform deployer about a potential runmode

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-feature-cpconverter.git


The following commit(s) were added to refs/heads/master by this push:
     new a621424  SLING-11318 : Inform deployer about a potential runmode
a621424 is described below

commit a621424457d9244603d63abcd5afaf03c320d98b
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Fri May 13 13:25:23 2022 +0200

    SLING-11318 : Inform deployer about a potential runmode
---
 .../feature/cpconverter/ContentPackage2FeatureModelConverter.java     | 4 ++--
 .../apache/sling/feature/cpconverter/artifacts/ArtifactsDeployer.java | 4 +++-
 .../cpconverter/artifacts/LocalMavenRepositoryArtifactsDeployer.java  | 3 ++-
 .../apache/sling/feature/cpconverter/handlers/BundleEntryHandler.java | 4 ++--
 .../feature/cpconverter/artifacts/DefaultBundlesDeployerTest.java     | 4 ++--
 .../feature/cpconverter/artifacts/SimpleFolderArtifactsDeployer.java  | 3 ++-
 6 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/src/main/java/org/apache/sling/feature/cpconverter/ContentPackage2FeatureModelConverter.java b/src/main/java/org/apache/sling/feature/cpconverter/ContentPackage2FeatureModelConverter.java
index 3b8d49e..30a60ac 100644
--- a/src/main/java/org/apache/sling/feature/cpconverter/ContentPackage2FeatureModelConverter.java
+++ b/src/main/java/org/apache/sling/feature/cpconverter/ContentPackage2FeatureModelConverter.java
@@ -452,7 +452,7 @@ public class ContentPackage2FeatureModelConverter extends BaseVaultPackageScanne
                     if (unreferencedArtifactsDeployer == null) {
                         throw new IllegalStateException("ContentTypePackagePolicy PUT_IN_DEDICATED_FOLDER requires a valid deployer ");
                     }
-                    final String location = unreferencedArtifactsDeployer.deploy(new FileArtifactWriter(contentPackageArchive), mvnPackageId);
+                    final String location = unreferencedArtifactsDeployer.deploy(new FileArtifactWriter(contentPackageArchive), runMode, mvnPackageId);
                     logger.info("Put converted package of PackageType.CONTENT {} (content-package id: {}) at {} (not referenced in feature model)",
                             mvnPackageId.getArtifactId(), vaultPackage.getId(), location);
                     break;
@@ -488,7 +488,7 @@ public class ContentPackage2FeatureModelConverter extends BaseVaultPackageScanne
             try {
                 File finalContentPackageArchive = assembler.createPackage();
                 // deploy the new content-package to the local mvn bundles dir
-                deployer.deploy(new FileArtifactWriter(finalContentPackageArchive), mvnPackageId);
+                deployer.deploy(new FileArtifactWriter(finalContentPackageArchive), runMode, mvnPackageId);
             } catch (Exception ex) {
                 throw new RuntimeException(ex);
             }
diff --git a/src/main/java/org/apache/sling/feature/cpconverter/artifacts/ArtifactsDeployer.java b/src/main/java/org/apache/sling/feature/cpconverter/artifacts/ArtifactsDeployer.java
index 83ac52f..ea5a3ce 100644
--- a/src/main/java/org/apache/sling/feature/cpconverter/artifacts/ArtifactsDeployer.java
+++ b/src/main/java/org/apache/sling/feature/cpconverter/artifacts/ArtifactsDeployer.java
@@ -20,6 +20,7 @@ import java.io.IOException;
 
 import org.apache.sling.feature.ArtifactId;
 import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
 
 /**
  * SPI to deploy artifacts
@@ -29,10 +30,11 @@ public interface ArtifactsDeployer {
     /**
      * Deploy the artifact and return information about its location
      * @param artifactWriter The artifact writer to use
+     * @param runmode Optional runmode
      * @param id The artifact id
      * @return Information about the location, this is deployer specific
      * @throws IOException If deploying fails
      */
-    @NotNull String deploy(@NotNull ArtifactWriter artifactWriter, @NotNull ArtifactId id) throws IOException;
+    @NotNull String deploy(@NotNull ArtifactWriter artifactWriter, @Nullable String runmode, @NotNull ArtifactId id) throws IOException;
 
 }
diff --git a/src/main/java/org/apache/sling/feature/cpconverter/artifacts/LocalMavenRepositoryArtifactsDeployer.java b/src/main/java/org/apache/sling/feature/cpconverter/artifacts/LocalMavenRepositoryArtifactsDeployer.java
index 7849734..ccc2725 100644
--- a/src/main/java/org/apache/sling/feature/cpconverter/artifacts/LocalMavenRepositoryArtifactsDeployer.java
+++ b/src/main/java/org/apache/sling/feature/cpconverter/artifacts/LocalMavenRepositoryArtifactsDeployer.java
@@ -26,6 +26,7 @@ import java.util.StringTokenizer;
 
 import org.apache.sling.feature.ArtifactId;
 import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -50,7 +51,7 @@ public final class LocalMavenRepositoryArtifactsDeployer implements ArtifactsDep
     }
 
     @Override
-    public @NotNull String deploy(@NotNull ArtifactWriter artifactWriter, @NotNull ArtifactId id) throws IOException {
+    public @NotNull String deploy(@NotNull ArtifactWriter artifactWriter, @Nullable String runmode, @NotNull ArtifactId id) throws IOException {
         requireNonNull(artifactWriter, "Null ArtifactWriter can not install an artifact to a Maven repository.");
         requireNonNull(id, "Bundle can not be installed to a Maven repository without specifying a valid id.");
 
diff --git a/src/main/java/org/apache/sling/feature/cpconverter/handlers/BundleEntryHandler.java b/src/main/java/org/apache/sling/feature/cpconverter/handlers/BundleEntryHandler.java
index 87f2ca8..c379a1c 100644
--- a/src/main/java/org/apache/sling/feature/cpconverter/handlers/BundleEntryHandler.java
+++ b/src/main/java/org/apache/sling/feature/cpconverter/handlers/BundleEntryHandler.java
@@ -155,10 +155,10 @@ public class BundleEntryHandler extends AbstractRegexEntryHandler {
             try (InputStream strippedBundleInput = bundleSlingInitialContentExtractor.extract(context)) {
                 if (strippedBundleInput != null && slingInitialContentPolicy == ContentPackage2FeatureModelConverter.SlingInitialContentPolicy.EXTRACT_AND_REMOVE) {
                     id = id.changeVersion(id.getVersion() + "-" + ContentPackage2FeatureModelConverter.PACKAGE_CLASSIFIER);
-                    Objects.requireNonNull(converter.getArtifactsDeployer()).deploy(new InputStreamArtifactWriter(strippedBundleInput), id);
+                    Objects.requireNonNull(converter.getArtifactsDeployer()).deploy(new InputStreamArtifactWriter(strippedBundleInput), runMode, id);
                 } else {
                     try (InputStream originalBundleInput = Files.newInputStream(originalBundleFile)) {
-                        Objects.requireNonNull(converter.getArtifactsDeployer()).deploy(new InputStreamArtifactWriter(originalBundleInput), id);
+                        Objects.requireNonNull(converter.getArtifactsDeployer()).deploy(new InputStreamArtifactWriter(originalBundleInput), runMode, id);
                     }
                 }
             }
diff --git a/src/test/java/org/apache/sling/feature/cpconverter/artifacts/DefaultBundlesDeployerTest.java b/src/test/java/org/apache/sling/feature/cpconverter/artifacts/DefaultBundlesDeployerTest.java
index 22cbbef..1f29b4a 100644
--- a/src/test/java/org/apache/sling/feature/cpconverter/artifacts/DefaultBundlesDeployerTest.java
+++ b/src/test/java/org/apache/sling/feature/cpconverter/artifacts/DefaultBundlesDeployerTest.java
@@ -65,12 +65,12 @@ public class DefaultBundlesDeployerTest {
 
     @Test(expected = NullPointerException.class)
     public void deployLocallyAndAttachRequiresNonNullInput() throws Exception {
-        artifactDeployer.deploy(null, null);
+        artifactDeployer.deploy(null, null, null);
     }
 
     @Test(expected = NullPointerException.class)
     public void deployLocallyAndAttachRequiresNonNullArtifactId() throws Exception {
-        artifactDeployer.deploy(mock(ArtifactWriter.class), null);
+        artifactDeployer.deploy(mock(ArtifactWriter.class), null, null);
     }
 
 }
diff --git a/src/test/java/org/apache/sling/feature/cpconverter/artifacts/SimpleFolderArtifactsDeployer.java b/src/test/java/org/apache/sling/feature/cpconverter/artifacts/SimpleFolderArtifactsDeployer.java
index 5a1bb37..6263ce7 100644
--- a/src/test/java/org/apache/sling/feature/cpconverter/artifacts/SimpleFolderArtifactsDeployer.java
+++ b/src/test/java/org/apache/sling/feature/cpconverter/artifacts/SimpleFolderArtifactsDeployer.java
@@ -22,6 +22,7 @@ import java.io.IOException;
 
 import org.apache.sling.feature.ArtifactId;
 import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -46,7 +47,7 @@ public class SimpleFolderArtifactsDeployer implements ArtifactsDeployer {
     }
 
     @Override
-    public @NotNull String deploy(@NotNull ArtifactWriter artifactWriter, @NotNull ArtifactId id) throws IOException {
+    public @NotNull String deploy(@NotNull ArtifactWriter artifactWriter, @Nullable String runmode, @NotNull ArtifactId id) throws IOException {
         File targetFile = new File(artifactsDirectory, id.toMvnName());
         logger.info("Writing data to {}...", targetFile);