Search in sources :

Example 1 with NotePathAlreadyExistsException

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;
    });
}
Also used : NotePathAlreadyExistsException(org.apache.zeppelin.notebook.exception.NotePathAlreadyExistsException) NoteNotFoundException(org.apache.zeppelin.rest.exception.NoteNotFoundException)

Aggregations

NotePathAlreadyExistsException (org.apache.zeppelin.notebook.exception.NotePathAlreadyExistsException)1 NoteNotFoundException (org.apache.zeppelin.rest.exception.NoteNotFoundException)1