if (nodeType == null)
throw new NoSuchNodeTypeException("Nodetype not found "
+ sysLocFactory.createJCRName(primaryTypeName).getAsString());
if (nodeType.isMixin())
throw new ConstraintViolationException("Add Node failed, "
+ sysLocFactory.createJCRName(primaryTypeName).getAsString() + " is MIXIN type!");
// Check if new node's node type is allowed by its parent definition
if (!nodeTypeDataManager.isChildNodePrimaryTypeAllowed(primaryTypeName, nodeData().getPrimaryTypeName(),
nodeData().getMixinTypeNames()))
{
throw new ConstraintViolationException("Can't add node " + sysLocFactory.createJCRName(name).getAsString()
+ " to " + getPath() + " node type " + sysLocFactory.createJCRName(primaryTypeName).getAsString()
+ " is not allowed as child's node type for parent node type ");
}
// Check if node is not protected
NodeDefinitionData childNodeDefinition =
session
.getWorkspace()
.getNodeTypesHolder()
.getChildNodeDefinition(name, primaryTypeName, nodeData().getPrimaryTypeName(),
nodeData().getMixinTypeNames());
if (childNodeDefinition == null)
throw new ConstraintViolationException("Can't find child node definition for "
+ sysLocFactory.createJCRName(name).getAsString() + " in " + getPath());
if (childNodeDefinition.isProtected())
throw new ConstraintViolationException("Can't add protected node "
+ sysLocFactory.createJCRName(name).getAsString() + " to " + getPath());
// Check if versionable ancestor is not checked-in
if (!checkedOut())
throw new VersionException("Node " + getPath() + " or its nearest ancestor is checked-in");