@Managed("{path: .*}")
@ManagedRole("administrators")
@ManagedOperation(name = OperationNames.ADD_RESOURCE, description = "Adds the navigation node")
public ModelObject addNode(@MappedPath("path") String path, @ManagedContext PathAddress address) {
NodePath nodePath = NodePath.fromString(path);
Node parent = getNode(nodePath.parent(), true, Nodes.visitChildren());
String name = nodePath.getLastSegment();
if (parent.hasChild(name)) {
throw alreadyExists("Cannot add node", navigation.getSiteId(), nodePath);
}
// Add child and save
Node child = parent.addChild(name);
navigation.saveNode(parent);
// Populate model
ModelObject model = modelProvider.newModel(ModelObject.class);
populateNode(child, 0, model, address);