+ ": cannot add child node to protected parent node");
}
// make sure there's an applicable definition for new child node
EffectiveNodeType entParent = getEffectiveNodeType(parentState);
entParent.checkAddNodeConstraints(nodeName, nodeTypeName, ntReg);
QNodeDefinition newNodeDef =
findApplicableNodeDefinition(nodeName, nodeTypeName,
parentState);
// check for name collisions
if (parentState.hasChildNodeEntry(nodeName)) {
// there's already a node with that name...
// get definition of existing conflicting node
ChildNodeEntry entry = parentState.getChildNodeEntry(nodeName, 1);
NodeState conflictingState;
NodeId conflictingId = entry.getId();
try {
conflictingState = (NodeState) stateMgr.getItemState(conflictingId);
} catch (ItemStateException ise) {
String msg =
"internal error: failed to retrieve state of "
+ safeGetJCRPath(conflictingId);
log.debug(msg);
throw new RepositoryException(msg, ise);
}
QNodeDefinition conflictingTargetDef = itemMgr.getDefinition(conflictingState).unwrap();
// check same-name sibling setting of both target and existing node
if (!conflictingTargetDef.allowsSameNameSiblings()
|| !newNodeDef.allowsSameNameSiblings()) {
throw new ItemExistsException(
"cannot add child node '" + nodeName.getLocalName()
+ "' to " + safeGetJCRPath(parentState.getNodeId())
+ ": colliding with same-named existing node");