joerghoh commented on code in PR #416:
URL:
https://github.com/apache/jackrabbit-filevault/pull/416#discussion_r3507681721
##########
vault-core/src/main/java/org/apache/jackrabbit/vault/fs/config/DefaultWorkspaceFilter.java:
##########
@@ -278,6 +287,61 @@ public boolean includesProperty(String propertyPath) {
return false;
}
+ /**
+ * Enables or disables extra validation reflected by {@link
#isSubtreeFullyCovered(javax.jcr.Node)} (JCRVLT-830).
+ * @param extraValidationBeforeSubtreeRemoval {@code true} to perform the
subtree check; {@code false} to always
+ * report fully covered (legacy behavior for removal gating)
+ */
+ public void setExtraValidationBeforeSubtreeRemoval(boolean
extraValidationBeforeSubtreeRemoval) {
+ this.extraValidationBeforeSubtreeRemoval =
extraValidationBeforeSubtreeRemoval;
+ }
+
+ @Override
+ public boolean isSubtreeFullyCovered(javax.jcr.Node subTree) throws
RepositoryException {
+ /**
+ * if this validation is explicitly disabled, just assume that the
subtree is fully covered,
+ * which is the default behavior before this check was introduced with
JCRVLT-830
+ */
+ if (!extraValidationBeforeSubtreeRemoval) {
+ return true;
+ }
+ if (subTree == null) {
+ return false;
+ }
+ String path = subTree.getPath();
+ if (isGloballyIgnored(path)) {
+ return false;
+ }
+ if (getCoveringFilterSet(path) == null) {
+ return false;
+ }
+ if (getImportMode(path) != ImportMode.REPLACE) {
+ return false;
+ }
+ return isSubtreeFullyOverwrittenRecursive(subTree);
+ }
+
+ private boolean isSubtreeFullyOverwrittenRecursive(javax.jcr.Node node)
throws RepositoryException {
+ String nodePath = node.getPath();
+ if (!contains(nodePath)) {
+ return false;
+ }
+ PropertyIterator props = node.getProperties();
+ while (props.hasNext()) {
+ Property prop = props.nextProperty();
+ if (!includesProperty(prop.getPath())) {
+ return false;
+ }
+ }
+ NodeIterator children = node.getNodes();
+ while (children.hasNext()) {
+ if (!isSubtreeFullyOverwrittenRecursive(children.nextNode())) {
Review Comment:
I think that there is no way to avoid iterating all children. But that's a
good point, I need to re-evaluate again under which circumstances this code is
executed at all.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]