NodeData parent = getParent();
NodeDefinitionData nodeNt =
nodeTypeDataManager.getChildNodeDefinition(nodeName, parent.getPrimaryTypeName(), parent
.getMixinTypeNames());
NodeTypeData nodeType;
if (nodeNt.getName().equals(Constants.JCR_ANY_NAME) && nodeNt.getDefaultPrimaryType() != null)
{
nodeType = nodeTypeDataManager.getNodeType(nodeNt.getDefaultPrimaryType());
}
else
{
nodeType = nodeTypeDataManager.getNodeType(nodeNt.getName());
}
if (nodeType == null)
throw new ConstraintViolationException("Can not define node-type for node " + nodeName.getAsString()
+ ", parent node type " + parent.getPrimaryTypeName().getAsString());
nodeTypes.add(nodeType);
props.put(Constants.JCR_PRIMARYTYPE, locationFactory.createJCRName(nodeType.getName()).getAsString());
}
if (atts != null)
{
for (String key : atts.keySet())
{
String attValue = atts.get(key);
String propName = ISO9075.decode(key);
if (log.isDebugEnabled())
{
log.debug(propName + ":" + attValue);
}
InternalQName propInternalQName = locationFactory.parseJCRName(propName).getInternalName();
if (Constants.JCR_PRIMARYTYPE.equals(propInternalQName))
{
String primaryNodeType = StringConverter.denormalizeString(attValue);
InternalQName ntName = locationFactory.parseJCRName(primaryNodeType).getInternalName();
NodeTypeData nodeType = nodeTypeDataManager.getNodeType(ntName);
if (nodeType == null)
throw new ConstraintViolationException("Can not find node type " + primaryNodeType);
nodeTypes.add(nodeType);
props.put(propInternalQName, primaryNodeType);
}
else if (Constants.JCR_MIXINTYPES.equals(propInternalQName))
{
String[] amTypes = attValue.split(" ");
for (int mi = 0; mi < amTypes.length; mi++)
{
amTypes[mi] = StringConverter.denormalizeString(amTypes[mi]);
InternalQName name = locationFactory.parseJCRName(amTypes[mi]).getInternalName();
mixinNodeTypes.add(name);
NodeTypeData nodeType = nodeTypeDataManager.getNodeType(name);
if (nodeType == null)
throw new ConstraintViolationException("Can not find node type " + amTypes[mi]);
nodeTypes.add(nodeType);
}