Search in sources :

Example 6 with ParagraphNotFoundException

use of org.apache.zeppelin.rest.exception.ParagraphNotFoundException in project zeppelin by apache.

the class NotebookService method removeParagraph.

public void removeParagraph(String noteId, String paragraphId, ServiceContext context, ServiceCallback<Paragraph> callback) throws IOException {
    if (!checkPermission(noteId, Permission.WRITER, Message.OP.PARAGRAPH_REMOVE, context, callback)) {
        return;
    }
    notebook.processNote(noteId, note -> {
        if (note == null) {
            throw new NoteNotFoundException(noteId);
        }
        if (note.getParagraph(paragraphId) == null) {
            throw new ParagraphNotFoundException(paragraphId);
        }
        Paragraph p = note.removeParagraph(context.getAutheInfo().getUser(), paragraphId);
        notebook.saveNote(note, context.getAutheInfo());
        callback.onSuccess(p, context);
        return null;
    });
}
Also used : ParagraphNotFoundException(org.apache.zeppelin.rest.exception.ParagraphNotFoundException) NoteNotFoundException(org.apache.zeppelin.rest.exception.NoteNotFoundException) Paragraph(org.apache.zeppelin.notebook.Paragraph)

Aggregations

NoteNotFoundException (org.apache.zeppelin.rest.exception.NoteNotFoundException)6 ParagraphNotFoundException (org.apache.zeppelin.rest.exception.ParagraphNotFoundException)6 Paragraph (org.apache.zeppelin.notebook.Paragraph)5 BadRequestException (org.apache.zeppelin.rest.exception.BadRequestException)2 IOException (java.io.IOException)1 ParseException (java.text.ParseException)1 InterpreterResult (org.apache.zeppelin.interpreter.InterpreterResult)1 CorruptedNoteException (org.apache.zeppelin.notebook.exception.CorruptedNoteException)1 NotePathAlreadyExistsException (org.apache.zeppelin.notebook.exception.NotePathAlreadyExistsException)1 ForbiddenException (org.apache.zeppelin.rest.exception.ForbiddenException)1