kwin commented on code in PR #165:
URL:
https://github.com/apache/sling-org-apache-sling-feature-cpconverter/pull/165#discussion_r1176314895
##########
src/main/java/org/apache/sling/feature/cpconverter/ContentPackage2FeatureModelConverter.java:
##########
@@ -242,7 +260,16 @@ public boolean hasMainPackageAssembler() {
this.removeInstallHooks = removeInstallHook;
return this;
}
+
+ public @NotNull ContentPackage2FeatureModelConverter
setRunmodePolicy(@NotNull RunModePolicy runmodePolicy) {
+ this.runmodePolicy = runmodePolicy;
Review Comment:
runModePolicy
##########
src/main/java/org/apache/sling/feature/cpconverter/ContentPackage2FeatureModelConverter.java:
##########
@@ -158,10 +171,15 @@ public ContentPackage2FeatureModelConverter(boolean
strictValidation, @NotNull S
}
public ContentPackage2FeatureModelConverter(boolean strictValidation,
@NotNull SlingInitialContentPolicy slingInitialContentPolicy, boolean
disablePackageTypeRecalculation) throws IOException {
+ this(strictValidation, slingInitialContentPolicy,
disablePackageTypeRecalculation, RunModePolicy.DIRECT_ONLY);
+ }
+
+ public ContentPackage2FeatureModelConverter(boolean strictValidation,
@NotNull SlingInitialContentPolicy slingInitialContentPolicy, boolean
disablePackageTypeRecalculation, @NotNull RunModePolicy runmodePolicy) throws
IOException {
super(strictValidation);
this.disablePackageTypeRecalculation = disablePackageTypeRecalculation;
this.recollectorVaultPackageScanner = new
RecollectorVaultPackageScanner(this, this.packageManager, strictValidation,
subContentPackages, slingInitialContentPolicy);
this.tmpDirectory =
Files.createTempDirectory("cp2fm-converter").toFile();
+ this.runmodePolicy = runmodePolicy;
Review Comment:
runModePolicy
##########
src/main/java/org/apache/sling/feature/cpconverter/handlers/AbstractRegexEntryHandler.java:
##########
@@ -45,4 +54,40 @@ public final boolean matches(@NotNull String path) {
return pattern;
}
+ protected String extractTargetRunmode(String path,
ContentPackage2FeatureModelConverter converter,
Review Comment:
extractTargetRunMode
##########
src/main/java/org/apache/sling/feature/cpconverter/handlers/AbstractConfigurationEntryHandler.java:
##########
@@ -74,12 +74,14 @@ public final void handle(@NotNull String path, @NotNull
Archive archive, @NotNul
throw new ConverterException("OSGi configuration are only
considered if placed below a folder called 'config', but the configuration at
'"+ path + "' is placed outside!");
}
- // there is a specified RunMode
- runMode = matcher.group("runmode");
-
+ // determine runmodestring for current path
+ String runModeMatch = matcher.group("runmode");
+ targetRunmode = extractTargetRunmode(path, converter, runMode,
Review Comment:
targetRunMode
##########
src/test/java/org/apache/sling/feature/cpconverter/ContentPackage2FeatureModelConverterTest.java:
##########
@@ -569,6 +571,125 @@ public void verifyContainerDependencyHandling() throws
Exception {
deleteDirTree(outputDirectory);
}
}
+
+
+ @Test
+ public void verifyRunModesInheritedWithInheritanceOn() throws Exception {
+ URL packageUrl = getClass().getResource("runmodenesting-0.0.1.zip");
+ File packageFile = FileUtils.toFile(packageUrl);
+
+ File outputDirectory = new File(System.getProperty("java.io.tmpdir"),
getClass().getName() + '_' + System.currentTimeMillis());
+
+ try {
+ converter.setFeaturesManager(new DefaultFeaturesManager(true, 5,
outputDirectory, null, null, new HashMap<>(), new DefaultAclManager()))
+ .setBundlesDeployer(new
LocalMavenRepositoryArtifactsDeployer(outputDirectory))
+
.setEmitter(DefaultPackagesEventsEmitter.open(outputDirectory))
+ .setRunmodePolicy(RunModePolicy.PREPEND_INHERITED)
+ .convert(packageFile);
+
+ File runmodeMapperFile = new File(outputDirectory,
"runmode.mapping");
Review Comment:
runModeMapperFile
##########
src/main/java/org/apache/sling/feature/cpconverter/handlers/BundleEntryHandler.java:
##########
@@ -105,12 +106,11 @@ public void handle(@NotNull String path,
throw new ConverterException("OSGi bundles are only considered if
placed below a folder called 'install', but the bundle at '"+ path + "' is
placed outside!");
}
-
- runMode = matcher.group("runmode");
- if (runMode != null) {
- // there is a specified RunMode
- logger.debug("Runmode {} was extracted from path {}", runMode,
path);
- }
+ // determine runmodestring for current path
+ String runModeMatch = matcher.group("runmode");
+
+ String targetRunmode = extractTargetRunmode(path, converter, runMode,
Review Comment:
targetRunMode
##########
src/main/java/org/apache/sling/feature/cpconverter/ContentPackage2FeatureModelConverter.java:
##########
@@ -242,7 +260,16 @@ public boolean hasMainPackageAssembler() {
this.removeInstallHooks = removeInstallHook;
return this;
}
+
+ public @NotNull ContentPackage2FeatureModelConverter
setRunmodePolicy(@NotNull RunModePolicy runmodePolicy) {
+ this.runmodePolicy = runmodePolicy;
+ return this;
+ }
+ public RunModePolicy getRunmodePolicy() {
Review Comment:
getRunModePolicy()
##########
src/main/java/org/apache/sling/feature/cpconverter/handlers/AbstractContentPackageHandler.java:
##########
@@ -84,15 +83,16 @@ public final void handle(@NotNull String path, @NotNull
Archive archive, @NotNul
+ "' but it does not, currently");
}
- runMode = matcher.group(1);
- if (runMode != null) {
- // there is a specified RunMode
- logger.debug("Runmode {} was extracted from path {}", runMode,
path);
- }
+ String targetRunmode;
Review Comment:
targetRunMode
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]