desiredKey = new NodeKey(documentStoreKey);
}
}
// We can create the child, so start by building the required properties ...
PropertyFactory propFactory = session.propertyFactory();
Property ptProp = propFactory.create(JcrLexicon.PRIMARY_TYPE, childPrimaryNodeTypeName);
if (JcrNtLexicon.UNSTRUCTURED.equals(childPrimaryNodeTypeName)) {
// This is very common, and we know they don't have auto-created properties or children ...
MutableCachedNode newChild = mutable().createChild(cache, desiredKey, childName, ptProp);
// And get or create the JCR node ...
AbstractJcrNode jcrNode = session.node(newChild.getKey(), null, key());
// Set the child node definition ...
jcrNode.setNodeDefinitionId(childDefn.getId(), nodeTypes.getVersion());
return jcrNode;
}
// Auto-create the properties ...
NodeTypes capabilities = session.repository().nodeTypeManager().getNodeTypes();
LinkedList<Property> props = autoCreatePropertiesFor(childName, childPrimaryNodeTypeName, propFactory, capabilities);
// Then create the node ...
MutableCachedNode newChild = null;
if (props != null) {
props.addFirst(ptProp);
newChild = mutable().createChild(cache, desiredKey, childName, props);
} else {
newChild = mutable().createChild(cache, desiredKey, childName, ptProp);
}
// Check if the child node is referenceable
if (capabilities.getNodeType(childPrimaryNodeTypeName).isNodeType(JcrMixLexicon.REFERENCEABLE)) {
newChild.setProperty(cache, propFactory.create(JcrLexicon.UUID, session.nodeIdentifier(newChild.getKey())));
}
// And get or create the JCR node ...
AbstractJcrNode jcrNode = session.node(newChild.getKey(), null, key());