in src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProvider.java [457:489]
public Resource create(final @NotNull ResolveContext<JcrProviderState> ctx, @Nullable final String path,
@Nullable final Map<String, Object> properties) throws PersistenceException {
if (path == null) {
throw new PersistenceException("Unable to create node with [path=null]");
}
try {
Node node;
final int lastPos = path.lastIndexOf('/');
final Node parent;
if (lastPos == 0) {
parent = getSession(ctx).getRootNode();
} else {
parent = (Node) getSession(ctx).getItem(path.substring(0, lastPos));
}
final String name = path.substring(lastPos + 1);
// extract the nodetype
final String nodeType = getNodeType(properties, ctx);
if (nodeType != null) {
node = parent.addNode(name, nodeType);
} else {
node = parent.addNode(name);
}
if (properties != null) {
populateProperties(node, properties, ctx, path);
}
return new JcrNodeResource(ctx.getResourceResolver(), path, null, node, getHelperData(ctx));
} catch (final RepositoryException e) {
throw new PersistenceException("Unable to create node at " + path, e, path, null);
}
}