int lastSlash = path.lastIndexOf("/");
if (lastSlash != -1) {
String parentPath = path.substring(0, lastSlash);
String filename = path.substring(lastSlash + 1, path.length());
makeFolders(relativeRoot, parentPath, editor);
Folder newFolder = newFolder(filename);
newFolder.setEditor(editor);
if (editor.getRole().containsType(newFolder.getClass())) {
Nodes.append(
relativeRoot.getChild(Filenames.asId(parentPath)),
newFolder);
} else {
throw new NodeException.IllegalNesting();
}
} else {
Folder newFolder = newFolder(path);
newFolder.setEditor(editor);
if (editor.getRole().containsType(newFolder.getClass())) {
Nodes.append(relativeRoot, newFolder);
} else {
throw new NodeException.IllegalNesting();
}
}