You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by jo...@apache.org on 2026/02/04 11:42:27 UTC
(jackrabbit-filevault) 02/05: JCRVLT-830 fix
This is an automated email from the ASF dual-hosted git repository.
joerghoh pushed a commit to branch JCRVLT-830_2
in repository https://gitbox.apache.org/repos/asf/jackrabbit-filevault.git
commit 888d02ca28abcc5909a1887c5a7d5fc5610fb150
Author: Joerg Hoh <jh...@adobe.com>
AuthorDate: Mon Feb 2 18:56:14 2026 +0100
JCRVLT-830 fix
---
.../vault/fs/impl/io/DocViewImporter.java | 2 +-
.../apache/jackrabbit/vault/fs/io/Importer.java | 111 +++++++++++++++++++++
2 files changed, 112 insertions(+), 1 deletion(-)
diff --git a/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/DocViewImporter.java b/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/DocViewImporter.java
index 983febdb..913c7f7c 100644
--- a/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/DocViewImporter.java
+++ b/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/DocViewImporter.java
@@ -703,7 +703,7 @@ public class DocViewImporter implements DocViewParserHandler {
private boolean isIncluded(Item item, int depth) throws RepositoryException {
String path = importInfo.getRemapped().map(item.getPath());
- return wspFilter.contains(path) && (depth == 0 || filter.contains(item, path, depth));
+ return wspFilter.contains(path) && filter.contains(item, path, depth);
}
public ImportInfoImpl getInfo() {
diff --git a/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/Importer.java b/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/Importer.java
index 2fba58fa..d2c68e94 100644
--- a/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/Importer.java
+++ b/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/Importer.java
@@ -60,6 +60,9 @@ import org.apache.jackrabbit.vault.fs.api.ProgressTrackerListener;
import org.apache.jackrabbit.vault.fs.api.SerializationType;
import org.apache.jackrabbit.vault.fs.api.VaultInputSource;
import org.apache.jackrabbit.vault.fs.api.WorkspaceFilter;
+import org.apache.jackrabbit.vault.fs.api.ItemFilterSet;
+import org.apache.jackrabbit.vault.fs.api.Aggregator;
+import org.apache.jackrabbit.vault.fs.api.VaultFsConfig;
import org.apache.jackrabbit.vault.fs.config.ConfigurationException;
import org.apache.jackrabbit.vault.fs.config.DefaultWorkspaceFilter;
import org.apache.jackrabbit.vault.fs.config.MetaInf;
@@ -1036,8 +1039,116 @@ public class Importer {
}
}
+ /**
+ * Restores the coverage filter on the artifact set from the aggregator configuration.
+ * This is necessary because the coverage filter metadata is lost during the archive→import flow.
+ *
+ * The coverage filter determines which child nodes are "covered" by this aggregate and should
+ * be removed if not present in the package. Aggregators with partial coverage (e.g., folder
+ * aggregates with {@code <exclude isNode="true" />}) should preserve child nodes that are
+ * outside their coverage.
+ *
+ * This method only applies the filter when there are child aggregates (hints), which indicates
+ * that we're dealing with a parent aggregate that has nested content.
+ *
+ * See also JCRVLT-830
+ *
+ * @param session the JCR session
+ * @param info the transaction info for the current import operation
+ * @throws RepositoryException if accessing repository nodes fails
+ */
+ private void restoreCoverageFilterFromConfiguration(Session session, TxInfo info) throws RepositoryException {
+ // Only apply when there are child aggregates (hints), indicating partial
+ // coverage scenario
+ boolean hasChildAggregates = info.children != null && !info.children.isEmpty();
+ if (!hasChildAggregates || info.artifacts == null || info.artifacts.isEmpty() || archive == null
+ || info.path == null || info.path.isEmpty()) {
+ return;
+ }
+
+ try {
+ VaultFsConfig config = archive.getMetaInf().getConfig();
+ if (config == null) {
+ return;
+ }
+
+ // Try to find a matching aggregator
+ // First try with the node itself if it exists, otherwise try parent node
+ Node nodeToMatch = null;
+ if (session.nodeExists(info.path)) {
+ nodeToMatch = session.getNode(info.path);
+ } else if (info.parent != null && info.parent.path != null && !info.parent.path.isEmpty()
+ && session.nodeExists(info.parent.path)) {
+ nodeToMatch = session.getNode(info.parent.path);
+ }
+
+ if (nodeToMatch == null) {
+ return;
+ }
+
+ // Find matching aggregator for this node or its parent
+ // Prefer aggregators with explicit match criteria over those with empty
+ // matchFilters
+ Aggregator matchedDefaultAggregator = null;
+ for (Aggregator aggregator : config.getAggregators()) {
+ if (!aggregator.matches(nodeToMatch, nodeToMatch.getPath())) {
+ continue;
+ }
+
+ // Only GenericAggregator provides coverage filter information
+ if (!(aggregator instanceof org.apache.jackrabbit.vault.fs.impl.aggregator.GenericAggregator)) {
+ log.debug("Matched aggregator {} for {} but it's not a GenericAggregator",
+ aggregator.getClass().getSimpleName(), info.path);
+ break;
+ }
+
+ org.apache.jackrabbit.vault.fs.impl.aggregator.GenericAggregator genAgg = (org.apache.jackrabbit.vault.fs.impl.aggregator.GenericAggregator) aggregator;
+
+ // Skip non-default aggregators with empty matchFilters (they match everything)
+ if (genAgg.getMatchFilter().getEntries().isEmpty() && !genAgg.isDefault()) {
+ log.trace("Skipping aggregator {} with empty matchFilter (not default)", genAgg.getName());
+ continue;
+ }
+
+ // Store default aggregator as fallback, but keep looking for more specific one
+ if (genAgg.isDefault()) {
+ matchedDefaultAggregator = aggregator;
+ continue;
+ }
+
+ // Found a non-default GenericAggregator - use its coverage filter
+ ItemFilterSet contentFilter = genAgg.getContentFilter();
+ if (contentFilter != null) {
+ info.artifacts.setCoverage(contentFilter);
+ log.debug(
+ "Set coverage filter for {} from aggregator {} (matched against {}), has {} child aggregates",
+ info.path, genAgg.getName(), nodeToMatch.getPath(), info.children.size());
+ }
+ break;
+ }
+
+ // If only default aggregator matched, use it as fallback
+ if (matchedDefaultAggregator != null
+ && info.artifacts.getCoverage() == org.apache.jackrabbit.vault.fs.api.ItemFilter.ALL) {
+ org.apache.jackrabbit.vault.fs.impl.aggregator.GenericAggregator defaultAgg = (org.apache.jackrabbit.vault.fs.impl.aggregator.GenericAggregator) matchedDefaultAggregator;
+ ItemFilterSet contentFilter = defaultAgg.getContentFilter();
+ if (contentFilter != null) {
+ info.artifacts.setCoverage(contentFilter);
+ log.debug("Set coverage filter for {} from DEFAULT aggregator {}, has {} child aggregates",
+ info.path, defaultAgg.getName(), info.children.size());
+ }
+ }
+ } catch (Exception e) {
+ log.warn("Failed to set coverage filter for {}: {}", info.path, e.getMessage());
+ }
+ }
+
private ImportInfoImpl commit(Session session, TxInfo info) throws RepositoryException, IOException {
log.trace("committing {}", info.path);
+
+ // Restore coverage filter from aggregator configuration to handle partial coverage correctly
+ restoreCoverageFilterFromConfiguration(session, info);
+
ImportInfoImpl imp = null;
if (info.artifacts == null) {
log.debug("S {}", info.path);