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/11/25 12:40:45 UTC
[sling-org-apache-sling-feature-cpconverter] branch master updated:
SLING-9936 : Converter should fail with reference based repoinit
configurations
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 677e4de SLING-9936 : Converter should fail with reference based repoinit configurations
677e4de is described below
commit 677e4de8e058cb1bd8718c163fa1f5e9f467af9a
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Wed Nov 25 13:40:21 2020 +0100
SLING-9936 : Converter should fail with reference based repoinit configurations
---
.../AbstractConfigurationEntryHandler.java | 23 ++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)
diff --git a/src/main/java/org/apache/sling/feature/cpconverter/handlers/AbstractConfigurationEntryHandler.java b/src/main/java/org/apache/sling/feature/cpconverter/handlers/AbstractConfigurationEntryHandler.java
index 5cb874c..1b71d29 100644
--- a/src/main/java/org/apache/sling/feature/cpconverter/handlers/AbstractConfigurationEntryHandler.java
+++ b/src/main/java/org/apache/sling/feature/cpconverter/handlers/AbstractConfigurationEntryHandler.java
@@ -23,10 +23,13 @@ import java.util.regex.Matcher;
import org.apache.jackrabbit.vault.fs.io.Archive;
import org.apache.jackrabbit.vault.fs.io.Archive.Entry;
import org.apache.sling.feature.cpconverter.ContentPackage2FeatureModelConverter;
+import org.osgi.util.converter.Converters;
abstract class AbstractConfigurationEntryHandler extends AbstractRegexEntryHandler {
- private static final String REPOINIT_PID = "org.apache.sling.jcr.repoinit.RepositoryInitializer";
+ private static final String REPOINIT_FACTORY_PID = "org.apache.sling.jcr.repoinit.RepositoryInitializer";
+
+ private static final String REPOINIT_PID = "org.apache.sling.jcr.repoinit.impl.RepositoryInitializer ";
public AbstractConfigurationEntryHandler(String extension) {
super("/jcr_root/(?:apps|libs)/.+/config(\\.(?<runmode>[^/]+))?/(?<pid>.*)\\." + extension);
@@ -71,14 +74,22 @@ abstract class AbstractConfigurationEntryHandler extends AbstractRegexEntryHandl
// there is a specified RunMode
runMode = matcher.group("runmode");
- if (REPOINIT_PID.equals(factoryPid)) {
- String[] scripts = (String[]) configurationProperties.get("scripts");
- if (scripts != null) {
+ if (REPOINIT_FACTORY_PID.equals(factoryPid)) {
+ final String[] scripts = Converters.standardConverter().convert(configurationProperties.get("scripts")).to(String[].class);
+ if (scripts != null && scripts.length > 0 ) {
String text = String.join("\n", scripts);
converter.getFeaturesManager().addOrAppendRepoInitExtension(text, runMode);
- } else {
- // any repoinit configuration with empty scripts may be igored - filereferences are not supported at that point
}
+ final String[] references = Converters.standardConverter().convert(configurationProperties.get("references")).to(String[].class);
+ if ( references != null && references.length > 0 ) {
+ throw new IllegalArgumentException("References are not supported for repoinit (factory configuration " + pid + ")");
+ }
+ } else if ( REPOINIT_PID.equals(pid) ) {
+ final String[] references = Converters.standardConverter().convert(configurationProperties.get("references")).to(String[].class);
+ if ( references != null && references.length > 0 ) {
+ throw new IllegalArgumentException("References are not supported for repoinit (configuration " + pid + ")");
+ }
+
} else {
converter.getFeaturesManager().addConfiguration(runMode, id, configurationProperties);
}