use of org.apache.zeppelin.rest.exception.BadRequestException in project zeppelin by apache.
the class NotebookService method moveParagraph.
public void moveParagraph(String noteId, String paragraphId, int newIndex, ServiceContext context, ServiceCallback<Paragraph> callback) throws IOException {
if (!checkPermission(noteId, Permission.WRITER, Message.OP.MOVE_PARAGRAPH, context, callback)) {
return;
}
notebook.processNote(noteId, note -> {
if (note == null) {
throw new NoteNotFoundException(noteId);
}
if (note.getParagraph(paragraphId) == null) {
throw new ParagraphNotFoundException(paragraphId);
}
if (newIndex >= note.getParagraphCount()) {
callback.onFailure(new BadRequestException("newIndex " + newIndex + " is out of bounds"), context);
return null;
}
note.moveParagraph(paragraphId, newIndex);
notebook.saveNote(note, context.getAutheInfo());
callback.onSuccess(note.getParagraph(newIndex), context);
return null;
});
}
Aggregations