Skip to content

Commit 41fbc8e

Browse files
authored
OAK-11415: TypeEditor: constraint exception for node type violations should contain that node's effective type (#2009)
1 parent e1f0a13 commit 41fbc8e

File tree

1 file changed

+8
-2
lines changed
  • oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype

1 file changed

+8
-2
lines changed

oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/TypeEditor.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,23 +458,29 @@ private static boolean mixinsChanged(NodeState before, Iterable<String> after) {
458458
private void checkNodeTypeConstraints(NodeState after) throws CommitFailedException {
459459
EffectiveType effective = getEffective();
460460

461+
// check mandatory properties
462+
461463
Set<String> properties = effective.getMandatoryProperties();
462464
for (PropertyState ps : after.getProperties()) {
463465
properties.remove(ps.getName());
464466
checkPropertyTypeConstraints(ps);
465467
}
466468
// verify the presence of all mandatory items
467469
if (!properties.isEmpty()) {
468-
constraintViolation(21, "Mandatory property '" + properties.iterator().next() + "' not found in a new node");
470+
constraintViolation(21, "Mandatory properties '" + properties + "' not found in a new node of type '" + effective + "'");
469471
}
470472

473+
// check mandatory child nodes
474+
471475
List<String> names = ListUtils.toList(after.getChildNodeNames());
472476
for (String child : effective.getMandatoryChildNodes()) {
473477
if (!names.remove(child)) {
474-
constraintViolation(25, "Mandatory child node '" + child + "' not found in a new node");
478+
constraintViolation(25, "Mandatory child node '" + child + "' not found in a new node of type '" + effective + "'");
475479
}
476480
}
477481

482+
// of the child node names left after above check, verify that these are allowed by the node type
483+
478484
for (String name : names) {
479485
if (!NodeStateUtils.isHidden(name)) {
480486
NodeState child = after.getChildNode(name);

0 commit comments

Comments
 (0)