You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by kw...@apache.org on 2020/08/19 15:17:53 UTC
[jackrabbit-filevault] branch
feature/nodetype-validator-improvements created (now fdc2628)
This is an automated email from the ASF dual-hosted git repository.
kwin pushed a change to branch feature/nodetype-validator-improvements
in repository https://gitbox.apache.org/repos/asf/jackrabbit-filevault.git.
at fdc2628 JCRVLT-462 no validation error for uncontained root node
This branch includes the following new commits:
new fdc2628 JCRVLT-462 no validation error for uncontained root node
The 1 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.
[jackrabbit-filevault] 01/01: JCRVLT-462 no validation error for
uncontained root node
Posted by kw...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
kwin pushed a commit to branch feature/nodetype-validator-improvements
in repository https://gitbox.apache.org/repos/asf/jackrabbit-filevault.git
commit fdc2628d4528f3bc7be436ce450731a3b2917e40
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Wed Aug 19 17:17:39 2020 +0200
JCRVLT-462 no validation error for uncontained root node
---
.../validation/spi/impl/nodetype/NodeTypeValidator.java | 10 +++++++---
.../spi/impl/nodetype/NodeTypeValidatorTest.java | 17 +++++++++++++++++
2 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/vault-validation/src/main/java/org/apache/jackrabbit/vault/validation/spi/impl/nodetype/NodeTypeValidator.java b/vault-validation/src/main/java/org/apache/jackrabbit/vault/validation/spi/impl/nodetype/NodeTypeValidator.java
index f3af76c..dffa19b 100644
--- a/vault-validation/src/main/java/org/apache/jackrabbit/vault/validation/spi/impl/nodetype/NodeTypeValidator.java
+++ b/vault-validation/src/main/java/org/apache/jackrabbit/vault/validation/spi/impl/nodetype/NodeTypeValidator.java
@@ -164,7 +164,11 @@ public class NodeTypeValidator implements DocumentViewXmlValidator, JcrPathValid
final EffectiveNodeType parentNodeType;
final boolean useDefaultNodeType;
- if (parentNodeNameAndType == null || !filter.contains(parentNodePath)) {
+ // is this the root node?
+ if (parentNodeNameAndType == null && nodeContext.getNodePath().equals("/")) {
+ parentNodeType = null;
+ useDefaultNodeType = false;
+ } else if (parentNodeNameAndType == null || !filter.contains(parentNodePath)) {
parentNodeType = defaultType;
useDefaultNodeType = true;
} else if (!parentNodeNameAndType.isUnknown()) {
@@ -254,9 +258,9 @@ public class NodeTypeValidator implements DocumentViewXmlValidator, JcrPathValid
protectedNodeContext = null;
}
- // validate mandatory child nodes
+ // validate mandatory child nodes (only in case this is a covered path)
NodeNameAndType currentNodeNameAndType = nodeTypePerPath.get(nodeContext.getNodePath());
- if (currentNodeNameAndType != null && !currentNodeNameAndType.isUnknown()) {
+ if (currentNodeNameAndType != null && !currentNodeNameAndType.isUnknown() && filter.contains(nodeContext.getNodePath())) {
Collection<ValidationMessage> messages = new LinkedList<>();
for (QNodeDefinition mandatoryNodeType : currentNodeNameAndType.getEffectiveNodeType().getMandatoryQNodeDefinitions()) {
NodeNameAndType childNodeType;
diff --git a/vault-validation/src/test/java/org/apache/jackrabbit/vault/validation/spi/impl/nodetype/NodeTypeValidatorTest.java b/vault-validation/src/test/java/org/apache/jackrabbit/vault/validation/spi/impl/nodetype/NodeTypeValidatorTest.java
index fb5af86..164a041 100644
--- a/vault-validation/src/test/java/org/apache/jackrabbit/vault/validation/spi/impl/nodetype/NodeTypeValidatorTest.java
+++ b/vault-validation/src/test/java/org/apache/jackrabbit/vault/validation/spi/impl/nodetype/NodeTypeValidatorTest.java
@@ -96,6 +96,23 @@ public class NodeTypeValidatorTest {
}
@Test
+ public void testUncontainedRootNode() {
+ NodeContext nodeContext = new NodeContextImpl("/", Paths.get("jcr_root"), Paths.get(""));
+
+ Map<String, DocViewProperty> props = new HashMap<>();
+ props.put(NameConstants.JCR_PRIMARYTYPE.toString(),
+ new DocViewProperty(NameConstants.JCR_PRIMARYTYPE.toString(),
+ new String[] { "rep:root" }, false, PropertyType.STRING));
+ props.put(NameConstants.JCR_MIXINTYPES.toString(),
+ new DocViewProperty(NameConstants.JCR_MIXINTYPES.toString(),
+ new String[] { "rep:AccessControllable", "rep:RepoAccessControllable" }, true, PropertyType.STRING));
+ DocViewNode node = new DocViewNode("jcr:root", "jcr:root", null, props, null, "rep:root");
+
+ Assert.assertThat(validator.validate(node, nodeContext, true), AnyValidationMessageMatcher.noValidationInCollection());
+ Assert.assertThat(validator.validateEnd(node, nodeContext, true), AnyValidationMessageMatcher.noValidationInCollection());
+ }
+
+ @Test
public void testInvalidChildNodeTypeBelowDefault() {
NodeContext nodeContext = new NodeContextImpl("/apps/test/node4", Paths.get("node4"), Paths.get(""));