Name[] requiredPrimaryTypeNames = childNodeFromAncestor.requiredPrimaryTypeNames();
for (Name requiredPrimaryTypeName : requiredPrimaryTypeNames) {
NodeType requiredPrimaryTypeFromAncestor = findTypeInMapOrList(requiredPrimaryTypeName, pendingTypes);
if (requiredPrimaryTypeFromAncestor == null) {
I18n msg = JcrI18n.couldNotFindDefinitionOfRequiredPrimaryType;
throw new InvalidNodeTypeDefinitionException(msg.text(requiredPrimaryTypeName, childNodeDefinition.getName(),
childNodeDefinition.getDeclaringNodeType()));
}
boolean found = false;
for (Name name : childNodeDefinition.requiredPrimaryTypeNames()) {
JcrNodeType childNodePrimaryType = findTypeInMapOrList(name, pendingTypes);
if (childNodePrimaryType != null
&& childNodePrimaryType.isNodeType(requiredPrimaryTypeFromAncestor.getName())) {
found = true;
break;
}
}
// Allow side-by-side definitions of residual child nodes per JCR 1.0.1 spec 6.7.8
if (!found && !residual) {
I18n msg = JcrI18n.cannotRedefineChildNodeWithIncompatibleDefinition;
throw new InvalidNodeTypeDefinitionException(msg.text(childNodeName,
requiredPrimaryTypeFromAncestor.getName(),
childNodeDefinition.getDeclaringNodeType()));
}
}
}