Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -445,4 +445,31 @@ public void testEnhancedFileAggregatePackageWithIntermediateSaves() throws IOExc
assertPropertyExists("/testroot/tika/config.xml/jcr:content/jcr:data");
assertProperty("/testroot/tika/config.xml/jcr:content/jcr:mimeType", "text/xml");
}

@Test
public void testSkipFilterChecksOnImport_disabled() throws Exception {
ImportOptions opts = getDefaultOptions();
Importer importer = new Importer(opts);
try (Archive archive = getFileArchive("/test-packages/tmp-content-outside-filters.zip")) {
archive.open(true);
importer.run(archive, admin.getRootNode());
admin.save();
}
assertNodeExists("/tmp/foo");
assertPropertyMissing("/tmp/foo/bar/tobi/excludeddProp");
Copy link
Copy Markdown
Member

@kwin kwin Sep 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add some assertions what happens to nodes/properties below filter roots not contained in the package.

}

@Test
public void testSkipFilterChecksOnImport_enabled() throws Exception {
ImportOptions opts = getDefaultOptions();
opts.setSkipFilterChecksOnImport(true);
Importer importer = new Importer(opts);
try (Archive archive = getFileArchive("/test-packages/tmp-content-outside-filters.zip")) {
archive.open(true);
importer.run(archive, admin.getRootNode());
admin.save();
}
assertNodeExists("/tmp/foo");
assertPropertyExists("/tmp/foo/bar/tobi/excludedProp");
}
}
Comment thread
kwin marked this conversation as resolved.
Outdated
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ public class DefaultWorkspaceFilter implements Dumpable, WorkspaceFilter {
*/
private ImportMode importMode;

/**
* skip filter checks when importing content
*/
private boolean skipFilterChecksOnImport = false;

/**
* Add a #PathFilterSet for nodes items.
* @param set the set of filters to add.
Expand Down Expand Up @@ -232,6 +237,10 @@ public void setImportMode(ImportMode importMode) {
this.importMode = importMode;
}

public void setSkipFilterChecksOnImport(boolean skipFilterChecksOnImport) {
this.skipFilterChecksOnImport = skipFilterChecksOnImport;
}

/**
* {@inheritDoc}
*/
Expand Down Expand Up @@ -264,6 +273,11 @@ public boolean covers(String path) {

@Override
public boolean includesProperty(String propertyPath) {
if (skipFilterChecksOnImport) {
// skip the filter checks if requested; assume that the package only includes content
// which matches the filters.
return true;
Comment thread
joerghoh marked this conversation as resolved.
Outdated
}
if (!covers(propertyPath)) {
// include all properties that are not covered by any filter. this is to ensure that the ancestor paths
// have at least jcr:primary type.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

@Version("2.9.0")
@Version("2.10.0")
package org.apache.jackrabbit.vault.fs.config;

import org.osgi.annotation.versioning.Version;
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ public class ImportOptions {

private Boolean overwritePrimaryTypesOfFolders = null;

private Boolean skipFilterChecksOnImport = false;

/**
* Default constructor.
*/
Expand Down Expand Up @@ -105,6 +107,7 @@ public ImportOptions(ImportOptions base) {
dependencyHandling = base.dependencyHandling;
idConflictPolicy = base.idConflictPolicy;
overwritePrimaryTypesOfFolders = base.overwritePrimaryTypesOfFolders;
skipFilterChecksOnImport = base.skipFilterChecksOnImport;
}
}

Expand Down Expand Up @@ -132,6 +135,7 @@ public ImportOptions copy() {
ret.dependencyHandling = dependencyHandling;
ret.idConflictPolicy = idConflictPolicy;
ret.overwritePrimaryTypesOfFolders = overwritePrimaryTypesOfFolders;
ret.skipFilterChecksOnImport = skipFilterChecksOnImport;
return ret;
}

Expand Down Expand Up @@ -480,6 +484,24 @@ public void setIdConflictPolicy(@NotNull IdConflictPolicy idConflictPolicy) {
this.idConflictPolicy = idConflictPolicy;
}

/**
* Allows to skip filter checks when importing content; you can set this
* to {{code true}} if you are sure that there this package contains no content
Comment thread
joerghoh marked this conversation as resolved.
Outdated
* which would be rejected by filters
* @param skipFilterChecksOnImport if true skip the checks
*/
public void setSkipFilterChecksOnImport (boolean skipFilterChecksOnImport) {
this.skipFilterChecksOnImport = skipFilterChecksOnImport;
}

/**
* get the filter check skip policy
* @return true if the filter check is skipped
*/
public boolean getskipFilterChecksOnImport() {
Comment thread
joerghoh marked this conversation as resolved.
Outdated
return this.skipFilterChecksOnImport;
}

@Override
public int hashCode() {
final int prime = 31;
Expand All @@ -502,6 +524,7 @@ public int hashCode() {
result = prime * result + ((idConflictPolicy == null) ? 0 : idConflictPolicy.hashCode());
result = prime * result + (strict ? 1231 : 1237);
result = prime * result + (overwritePrimaryTypesOfFolders ? 1231 : 1237);
result = prime * result + (skipFilterChecksOnImport ? 1231 : 1237);

return result;
}
Expand Down Expand Up @@ -575,6 +598,8 @@ public boolean equals(Object obj) {
return false;
} else if (!idConflictPolicy.equals(other.idConflictPolicy))
return false;
if (skipFilterChecksOnImport != other.skipFilterChecksOnImport)
return false;
return true;
}

Expand All @@ -592,6 +617,7 @@ public String toString() {
+ (pathMapping != null ? "pathMapping=" + pathMapping + ", " : "")
+ (dependencyHandling != null ? "dependencyHandling=" + dependencyHandling + ", " : "")
+ "overwritePrimaryTypesOfFolders=" + overwritePrimaryTypesOfFolders + ", "
+ "idConflictPolicy=" + (idConflictPolicy != null ? idConflictPolicy : IdConflictPolicy.FAIL) + "]";
+ "idConflictPolicy=" + (idConflictPolicy != null ? idConflictPolicy : IdConflictPolicy.FAIL) + "],"
+ "skipFilterChecksOnImport=" + skipFilterChecksOnImport;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,11 @@ public void run(Archive archive, Session session, String parentPath)
log.warn("Unable to override import mode, incompatible filter: {}", filter.getClass().getName());
}
}
if (filter instanceof DefaultWorkspaceFilter) {
((DefaultWorkspaceFilter) filter).setSkipFilterChecksOnImport(opts.getskipFilterChecksOnImport());
} else {
log.warn("Unable to overwrite 'skipFilterChecksOnImport', incompatible filter: {}", filter.getClass().getName());
}
// build filter tree
for (PathFilterSet set: filter.getFilterSets()) {
filterTree.put(set.getRoot(), set);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

@Version("2.16.0")
@Version("2.17.0")
package org.apache.jackrabbit.vault.fs.io;

import org.osgi.annotation.versioning.Version;
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

@Version("2.16.0")
@Version("2.17.0")
package org.apache.jackrabbit.vault.packaging;

import org.osgi.annotation.versioning.Version;