use of org.apache.zeppelin.notebook.exception.NotePathAlreadyExistsException in project zeppelin by apache.
the class NotebookService method renameNote.
public void renameNote(String noteId, String newNotePath, boolean isRelative, ServiceContext context, ServiceCallback<Note> callback) throws IOException {
if (!checkPermission(noteId, Permission.OWNER, Message.OP.NOTE_RENAME, context, callback)) {
return;
}
notebook.processNote(noteId, readNote -> {
if (readNote == null) {
callback.onFailure(new NoteNotFoundException(noteId), context);
}
readNote.setCronSupported(notebook.getConf());
String newNotePathReal = newNotePath;
if (isRelative && !readNote.getParentPath().equals("/")) {
newNotePathReal = readNote.getParentPath() + "/" + newNotePath;
} else {
if (!newNotePath.startsWith("/")) {
newNotePathReal = "/" + newNotePath;
}
}
try {
notebook.moveNote(noteId, newNotePathReal, context.getAutheInfo());
callback.onSuccess(readNote, context);
} catch (NotePathAlreadyExistsException e) {
callback.onFailure(e, context);
}
return null;
});
}
Aggregations