in src/main/java/org/apache/sling/jcr/contentloader/internal/BundleContentLoader.java [663:699]
private Node getTargetNode(Session session, String path, boolean overwrite) throws RepositoryException {
// not specified path directive
if (path == null) {
return session.getRootNode();
}
if (!path.startsWith("/")) {
// make relative path absolute
path = "/" + path; // NOSONAR
}
if (!session.itemExists(path)) {
Node currentNode = session.getRootNode();
final StringTokenizer st = new StringTokenizer(path.substring(1), "/");
while (st.hasMoreTokens()) {
final String name = st.nextToken();
if (!currentNode.hasNode(name)) {
currentNode.addNode(name, "sling:Folder");
}
currentNode = currentNode.getNode(name);
}
return currentNode;
} else {
Item item = session.getItem(path);
if (!item.isNode()) {
log.warn("Cannot use item as target path {} as this is an existing property", path);
return null;
}
Node targetNode = session.getNode(path);
// overwrite target node itself?
if (overwrite) {
targetNode = createFolder(targetNode.getParent(), targetNode.getName(), true);
}
return targetNode;
}
}