in src/main/java/org/apache/sling/jcr/contentloader/internal/DefaultContentCreator.java [249:313]
public void createNode(String name, String primaryNodeType, String[] mixinNodeTypes) throws RepositoryException {
final Node parentNode = this.parentNodeStack.peek();
boolean isParentImport = (name == null && isParentNodeImport);
if (name == null) {
if (this.parentNodeStack.size() > 1) {
throw new RepositoryException("Node needs to have a name.");
}
name = this.defaultName;
}
// if we are in parent node import mode, we don't create the root top level
// node!
if (!isParentImport || this.parentNodeStack.size() > 1) {
// if node already exists but should be overwritten, delete it
if (!this.ignoreOverwriteFlag && this.configuration.isOverwrite() && parentNode.hasNode(name)) {
checkoutIfNecessary(parentNode);
parentNode.getNode(name).remove();
}
// ensure repository node
Node node;
if (parentNode.hasNode(name)) {
// use existing node
node = parentNode.getNode(name);
} else if (primaryNodeType == null) {
// no explicit node type, use repository default
checkoutIfNecessary(parentNode);
node = parentNode.addNode(name);
addNodeToCreatedList(node);
if (this.importListener != null) {
this.importListener.onCreate(node.getPath());
}
} else {
// explicit primary node type
checkoutIfNecessary(parentNode);
node = parentNode.addNode(name, primaryNodeType);
addNodeToCreatedList(node);
if (this.importListener != null) {
this.importListener.onCreate(node.getPath());
}
}
// amend mixin node types
if (mixinNodeTypes != null) {
for (final String mixin : mixinNodeTypes) {
if (!node.isNodeType(mixin)) {
node.addMixin(mixin);
}
}
}
importedNodes.add(node.getPath());
// check if node is versionable
final boolean addToVersionables = this.configuration.isCheckin() && node.isNodeType("mix:versionable");
if (addToVersionables) {
this.versionables.add(node);
}
this.parentNodeStack.push(node);
if (this.createdRootNode == null) {
this.createdRootNode = node;
}
}
}