This is an automated email from the ASF dual-hosted git repository.
simonetripodi pushed a commit to branch master
in repository
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-distribution-core.git
The following commit(s) were added to refs/heads/master by this push:
new 3690223 SLING-7730 - Distribution package is lost if there is an
installation error on receiver side
3690223 is described below
commit 36902234b950596342d0f3da4d771fd9101285bc
Author: Simo Tripodi
AuthorDate: Thu Jun 21 11:53:53 2018 +0200
SLING-7730 - Distribution package is lost if there is an installation
error on receiver side
---
.../serialization/impl/vlt/FileVaultContentSerializer.java | 7 +--
.../impl/vlt/VaultDistributionPackageBuilderFactory.java| 13 -
.../sling/distribution/serialization/impl/vlt/VltUtils.java | 4 ++--
.../impl/importer/LocalDistributionPackageImporterTest.java | 3 ++-
.../impl/vlt/FileVaultContentSerializerTest.java| 4 ++--
5 files changed, 23 insertions(+), 8 deletions(-)
diff --git
a/src/main/java/org/apache/sling/distribution/serialization/impl/vlt/FileVaultContentSerializer.java
b/src/main/java/org/apache/sling/distribution/serialization/impl/vlt/FileVaultContentSerializer.java
index c759c36..17fce95 100644
---
a/src/main/java/org/apache/sling/distribution/serialization/impl/vlt/FileVaultContentSerializer.java
+++
b/src/main/java/org/apache/sling/distribution/serialization/impl/vlt/FileVaultContentSerializer.java
@@ -81,10 +81,12 @@ public class FileVaultContentSerializer implements
DistributionContentSerializer
private final boolean useBinaryReferences;
private final String name;
private final Map exportPathMapping;
+private final boolean strict;
public FileVaultContentSerializer(String name, Packaging packaging,
ImportMode importMode, AccessControlHandling aclHandling, String[] packageRoots,
String[] nodeFilters, String[]
propertyFilters, boolean useBinaryReferences, int autosaveThreshold,
- Map exportPathMapping) {
+ Map exportPathMapping,
+ boolean strict) {
this.name = name;
this.packaging = packaging;
this.importMode = importMode;
@@ -95,6 +97,7 @@ public class FileVaultContentSerializer implements
DistributionContentSerializer
this.propertyFilters = VltUtils.parseFilters(propertyFilters);
this.useBinaryReferences = useBinaryReferences;
this.exportPathMapping = exportPathMapping;
+this.strict = strict;
}
@Override
@@ -127,7 +130,7 @@ public class FileVaultContentSerializer implements
DistributionContentSerializer
Archive archive = null;
try {
session = getSession(resourceResolver);
-ImportOptions importOptions =
VltUtils.getImportOptions(aclHandling, importMode, autosaveThreshold);
+ImportOptions importOptions =
VltUtils.getImportOptions(aclHandling, importMode, autosaveThreshold, strict);
Importer importer = new Importer(importOptions);
archive = new ZipStreamArchive(inputStream);
archive.open(false);
diff --git
a/src/main/java/org/apache/sling/distribution/serialization/impl/vlt/VaultDistributionPackageBuilderFactory.java
b/src/main/java/org/apache/sling/distribution/serialization/impl/vlt/VaultDistributionPackageBuilderFactory.java
index 220d987..f832883 100644
---
a/src/main/java/org/apache/sling/distribution/serialization/impl/vlt/VaultDistributionPackageBuilderFactory.java
+++
b/src/main/java/org/apache/sling/distribution/serialization/impl/vlt/VaultDistributionPackageBuilderFactory.java
@@ -208,6 +208,15 @@ public class VaultDistributionPackageBuilderFactory
implements DistributionPacka
"The format is {sourcePattern}={destinationPattern}, e.g.
/etc/(.*)=/var/$1/some or simply /data=/bak")
private static final String PATHS_MAPPING = "pathsMapping";
+private static final boolean DEFAULT_STRICT_IMPORT_SETTINGS = true;
+
+@Property(
+label = "Install a content package in a strict mode",
+description = "Flag to mark an error response will be thrown, if a
content package will incorrectly installed",
+boolValue = DEFAULT_STRICT_IMPORT_SETTINGS
+)
+public static final String STRICT_IMPORT_SETTINGS = "strictImport";
+
@Reference
private Packaging packaging;
@@ -256,8 +265,10 @@ public class VaultDistributionPackageBuilderFactory
implements DistributionPacka
Map pathsMapping =
PropertiesUtil.toMap(config.get(PATHS_MAPPING), new String[0]);
pathsMapping = SettingsUtils.removeEmptyEntries(pathsMapping);
+boolean strictImport =
PropertiesUtil.toBoolean(config.get(STRICT_IMPORT_SETTINGS),
DEFAULT_STRICT_IMPORT_SETTINGS);
+
DistributionContentSerializer contentSe