if (nodeDefinition == null)
{
NodeTypeDataManager nodeTypesHolder = session.getWorkspace().getNodeTypesHolder();
ExtendedNodeTypeManager nodeTypeManager =
(ExtendedNodeTypeManager) session.getWorkspace().getNodeTypeManager();
if (this.isRoot())
{ // root - no parent
if (nodeDefinition == null)
{
NodeType required =
nodeTypeManager.getNodeType(locationFactory.createJCRName(Constants.NT_BASE).getAsString());
this.nodeDefinition = new NodeDefinitionImpl(null, null, new NodeType[]
{required}, null, true, true, OnParentVersionAction.ABORT, false, false);
}
}
else
{
NodeData parent = (NodeData) dataManager.getItemData(getParentIdentifier());
this.definition =
nodeTypesHolder.findChildNodeDefinition(getInternalName(), parent.getPrimaryTypeName(), parent
.getMixinTypeNames());
if (definition == null)
throw new ConstraintViolationException("Node definition not found for " + getPath());
// TODO same functionality in NodeTypeImpl
InternalQName[] rnames = definition.getRequiredPrimaryTypes();
NodeType[] rnts = new NodeType[rnames.length];
for (int j = 0; j < rnames.length; j++)
{
rnts[j] = nodeTypeManager.findNodeType(rnames[j]);
}
String name =
locationFactory.createJCRName(
definition.getName() != null ? definition.getName() : Constants.JCR_ANY_NAME)
.getAsString();
NodeType defType =
definition.getDefaultPrimaryType() != null ? nodeTypeManager.findNodeType(definition
.getDefaultPrimaryType()) : null;
NodeType declaringNodeType = nodeTypeManager.findNodeType(definition.getDeclaringNodeType());
nodeDefinition =
new NodeDefinitionImpl(name, declaringNodeType, rnts, defType, definition.isAutoCreated(),
definition.isMandatory(), definition.getOnParentVersion(), definition.isProtected(),
definition.isAllowsSameNameSiblings());
}