You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2023/09/20 15:02:37 UTC
[sling-org-apache-sling-feature-extension-content] branch master updated (9c4d4f0 -> 71798cc)
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-feature-extension-content.git
from 9c4d4f0 Update to the latest version of the parent POM
new 3a60dcf SLING-12029 - Make strictMode configurable
new 71798cc trivial: code cleanups
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
README.md | 2 ++
.../sling/feature/extension/content/ContentHandler.java | 15 +++++++++------
.../feature/extension/content/ContentHandlerTest.java | 6 +++---
3 files changed, 14 insertions(+), 9 deletions(-)
[sling-org-apache-sling-feature-extension-content] 01/02: SLING-12029 - Make strictMode configurable
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-feature-extension-content.git
commit 3a60dcf6443d8c0e50fb462e21c2ed0ffa6226df
Author: Robert Munteanu <ro...@apache.org>
AuthorDate: Wed Sep 20 11:04:43 2023 +0200
SLING-12029 - Make strictMode configurable
Make strictMode configurable and document the way to configure it.
---
README.md | 2 ++
.../apache/sling/feature/extension/content/ContentHandler.java | 9 ++++++---
.../sling/feature/extension/content/ContentHandlerTest.java | 6 +++---
3 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/README.md b/README.md
index 749b28b..8fea7fc 100644
--- a/README.md
+++ b/README.md
@@ -19,3 +19,5 @@ To influence the package installation order the following format must be used
The default start order is the maximum integer value (i.e. the package is processed after all packages with an explicit start-order).
All content-packages from the model are registered (externally) in a [`FSPackageRegistry`](https://jackrabbit.apache.org/filevault/apidocs/org/apache/jackrabbit/vault/packaging/registry/impl/FSPackageRegistry.html) and scheduled for installation with execution plans (given via OSGi configuration) which automatically get executed during repository start by [ExecutionPlanRepoInitializer](https://github.com/apache/sling-org-apache-sling-jcr-packageinit/blob/master/src/main/java/org/apache/s [...]
+
+Strict package mode installation can be enabled for all packages by setting the `org.apache.sling.feature.extension.content.useStrictMode` system property to true.
\ No newline at end of file
diff --git a/src/main/java/org/apache/sling/feature/extension/content/ContentHandler.java b/src/main/java/org/apache/sling/feature/extension/content/ContentHandler.java
index 87c952d..eaaffbd 100644
--- a/src/main/java/org/apache/sling/feature/extension/content/ContentHandler.java
+++ b/src/main/java/org/apache/sling/feature/extension/content/ContentHandler.java
@@ -54,7 +54,7 @@ public class ContentHandler implements ExtensionHandler {
private static final String REGISTRY_FOLDER = "packageregistry";
- private static ExecutionPlanBuilder buildExecutionPlan(Collection<Artifact> artifacts, Set<PackageId> satisfiedPackages, LauncherPrepareContext prepareContext, File registryHome) throws Exception {
+ private static ExecutionPlanBuilder buildExecutionPlan(Collection<Artifact> artifacts, Set<PackageId> satisfiedPackages, LauncherPrepareContext prepareContext, File registryHome, boolean useStrictMode) throws Exception {
List<File> packageReferences = new ArrayList<>();
@@ -79,7 +79,7 @@ public class ContentHandler implements ExtensionHandler {
try {
PackageId pid = registry.registerExternal(pkgFile, false);
ImportOptions importOptions = new ImportOptions();
- importOptions.setStrict(true);
+ importOptions.setStrict(useStrictMode);
PackageTaskOptions options = new ImportOptionsPackageTaskOption(importOptions);
builder.addTask().with(pid).withOptions(options).with(Type.EXTRACT);
} catch (PackageExistsException ex) {
@@ -97,6 +97,9 @@ public class ContentHandler implements ExtensionHandler {
File registryHome = getRegistryHomeDir(context);
if (extension.getType() == ExtensionType.ARTIFACTS
&& extension.getName().equals(Extension.EXTENSION_NAME_CONTENT_PACKAGES)) {
+
+ boolean useStrictMode = Boolean.getBoolean(getClass().getPackageName()+ ".useStrictMode");
+
Map<Integer, Collection<Artifact>> orderedArtifacts = new TreeMap<>();
for (final Artifact a : extension.getArtifacts()) {
int order;
@@ -112,7 +115,7 @@ public class ContentHandler implements ExtensionHandler {
Set<PackageId> satisfiedPackages = new HashSet<>();
for (Object key : orderedArtifacts.keySet()) {
Collection<Artifact> artifacts = orderedArtifacts.get(key);
- ExecutionPlanBuilder builder = buildExecutionPlan(artifacts, satisfiedPackages, context, registryHome);
+ ExecutionPlanBuilder builder = buildExecutionPlan(artifacts, satisfiedPackages, context, registryHome, useStrictMode);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
builder.save(baos);
executionPlans.add(baos.toString("UTF-8"));
diff --git a/src/test/java/org/apache/sling/feature/extension/content/ContentHandlerTest.java b/src/test/java/org/apache/sling/feature/extension/content/ContentHandlerTest.java
index 64ae766..589f90d 100644
--- a/src/test/java/org/apache/sling/feature/extension/content/ContentHandlerTest.java
+++ b/src/test/java/org/apache/sling/feature/extension/content/ContentHandlerTest.java
@@ -115,7 +115,7 @@ public class ContentHandlerTest {
"<executionPlan version=\"1.0\">\n" +
" <task cmd=\"extract\" packageId=\"my_packages:test_c:1.0\">\n" +
" <options type=\"ImportOptions\">\n" +
- " <isStrict>true</isStrict>\n" +
+ " <isStrict>false</isStrict>\n" +
" <autoSaveThreshold>-1</autoSaveThreshold>\n" +
" <nonRecursive>false</nonRecursive>\n" +
" <dryRun>false</dryRun>\n" +
@@ -123,7 +123,7 @@ public class ContentHandlerTest {
" </task>\n" +
" <task cmd=\"extract\" packageId=\"my_packages:test_b:1.0\">\n" +
" <options type=\"ImportOptions\">\n" +
- " <isStrict>true</isStrict>\n" +
+ " <isStrict>false</isStrict>\n" +
" <autoSaveThreshold>-1</autoSaveThreshold>\n" +
" <nonRecursive>false</nonRecursive>\n" +
" <dryRun>false</dryRun>\n" +
@@ -137,7 +137,7 @@ public class ContentHandlerTest {
"<executionPlan version=\"1.0\">\n" +
" <task cmd=\"extract\" packageId=\"my_packages:test_a:1.0\">\n" +
" <options type=\"ImportOptions\">\n" +
- " <isStrict>true</isStrict>\n" +
+ " <isStrict>false</isStrict>\n" +
" <autoSaveThreshold>-1</autoSaveThreshold>\n" +
" <nonRecursive>false</nonRecursive>\n" +
" <dryRun>false</dryRun>\n" +
[sling-org-apache-sling-feature-extension-content] 02/02: trivial: code cleanups
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-feature-extension-content.git
commit 71798cc5a8f3921557ab817bd7861413b60fbb3b
Author: Robert Munteanu <ro...@apache.org>
AuthorDate: Wed Sep 20 11:09:13 2023 +0200
trivial: code cleanups
---
.../org/apache/sling/feature/extension/content/ContentHandler.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/main/java/org/apache/sling/feature/extension/content/ContentHandler.java b/src/main/java/org/apache/sling/feature/extension/content/ContentHandler.java
index eaaffbd..c5dc8eb 100644
--- a/src/main/java/org/apache/sling/feature/extension/content/ContentHandler.java
+++ b/src/main/java/org/apache/sling/feature/extension/content/ContentHandler.java
@@ -19,6 +19,7 @@ package org.apache.sling.feature.extension.content;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.net.URL;
+import java.nio.charset.StandardCharsets;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collection;
@@ -113,12 +114,11 @@ public class ContentHandler implements ExtensionHandler {
}
List<String> executionPlans = new ArrayList<>();
Set<PackageId> satisfiedPackages = new HashSet<>();
- for (Object key : orderedArtifacts.keySet()) {
- Collection<Artifact> artifacts = orderedArtifacts.get(key);
+ for (Collection<Artifact> artifacts : orderedArtifacts.values()) {
ExecutionPlanBuilder builder = buildExecutionPlan(artifacts, satisfiedPackages, context, registryHome, useStrictMode);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
builder.save(baos);
- executionPlans.add(baos.toString("UTF-8"));
+ executionPlans.add(baos.toString(StandardCharsets.UTF_8));
}
// Workaround for too bold relocation mechanism - corresponding details at https://issues.apache.org/jira/browse/MSHADE-156
final Configuration initcfg = new Configuration("org.apache.sling.jcr.packageinit.impl.ExecutionPlanRepoInitializer");