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 2018/09/14 07:14:21 UTC
[sling-org-apache-sling-feature-launcher] branch master updated:
Extensions should only have one type and repoinit is defined as TEXT (see
FeatureConstants)
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-launcher.git
The following commit(s) were added to refs/heads/master by this push:
new 0521ce3 Extensions should only have one type and repoinit is defined as TEXT (see FeatureConstants)
0521ce3 is described below
commit 0521ce31f36629c6d7ae79ba17794d817e57695e
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Fri Sep 14 09:14:12 2018 +0200
Extensions should only have one type and repoinit is defined as TEXT (see FeatureConstants)
---
.../impl/extensions/handlers/RepoInitHandler.java | 28 +++-------------------
1 file changed, 3 insertions(+), 25 deletions(-)
diff --git a/src/main/java/org/apache/sling/feature/launcher/impl/extensions/handlers/RepoInitHandler.java b/src/main/java/org/apache/sling/feature/launcher/impl/extensions/handlers/RepoInitHandler.java
index 6347067..b439200 100644
--- a/src/main/java/org/apache/sling/feature/launcher/impl/extensions/handlers/RepoInitHandler.java
+++ b/src/main/java/org/apache/sling/feature/launcher/impl/extensions/handlers/RepoInitHandler.java
@@ -16,11 +16,7 @@
*/
package org.apache.sling.feature.launcher.impl.extensions.handlers;
-import java.io.StringReader;
import java.util.concurrent.atomic.AtomicInteger;
-import javax.json.Json;
-import javax.json.JsonArray;
-import javax.json.JsonReader;
import org.apache.sling.feature.Configuration;
import org.apache.sling.feature.Extension;
@@ -38,29 +34,11 @@ public class RepoInitHandler implements ExtensionHandler
public boolean handle(Extension extension, LauncherPrepareContext prepareContext, ExtensionInstallationContext installationContext) throws Exception
{
if ( extension.getName().equals(FeatureConstants.EXTENSION_NAME_REPOINIT) ) {
- String text;
- if ( extension.getType() == ExtensionType.TEXT ) {
- text = extension.getText();
- }
- else if (extension.getType() == ExtensionType.JSON) {
- try (JsonReader reader = Json.createReader(new StringReader(extension.getJSON()))){
- JsonArray array = reader.readArray();
- if (array.size() > 0) {
- text = array.getString(0);
- for (int i = 1; i < array.size(); i++) {
- text += "\n" + array.getString(i);
- }
- }
- else {
- text = "";
- }
- }
- }
- else {
- throw new Exception(FeatureConstants.EXTENSION_NAME_REPOINIT + " extension must be of type text or json");
+ if ( extension.getType() != ExtensionType.TEXT ) {
+ throw new Exception(FeatureConstants.EXTENSION_NAME_REPOINIT + " extension must be of type text");
}
final Configuration cfg = new Configuration("org.apache.sling.jcr.repoinit.RepositoryInitializer", "repoinit" + String.valueOf(index.getAndIncrement()));
- cfg.getProperties().put("scripts", text);
+ cfg.getProperties().put("scripts", extension.getText());
installationContext.addConfiguration(cfg.getName(), cfg.getFactoryPid(), cfg.getProperties());
return true;
}