use of org.apache.zeppelin.rest.exception.NoteNotFoundException in project zeppelin by apache.
the class NotebookService method clearParagraphOutput.
public void clearParagraphOutput(String noteId, String paragraphId, ServiceContext context, ServiceCallback<Paragraph> callback) throws IOException {
if (!checkPermission(noteId, Permission.WRITER, Message.OP.PARAGRAPH_CLEAR_OUTPUT, context, callback)) {
return;
}
notebook.processNote(noteId, note -> {
if (note == null) {
callback.onFailure(new NoteNotFoundException(noteId), context);
return null;
}
Paragraph p = note.getParagraph(paragraphId);
if (p == null) {
callback.onFailure(new ParagraphNotFoundException(paragraphId), context);
return null;
}
Paragraph returnedParagraph;
if (note.isPersonalizedMode()) {
returnedParagraph = note.clearPersonalizedParagraphOutput(paragraphId, context.getAutheInfo().getUser());
} else {
note.clearParagraphOutput(paragraphId);
returnedParagraph = note.getParagraph(paragraphId);
}
callback.onSuccess(returnedParagraph, context);
return null;
});
}
use of org.apache.zeppelin.rest.exception.NoteNotFoundException in project zeppelin by apache.
the class NotebookService method saveNoteForms.
public void saveNoteForms(String noteId, Map<String, Object> noteParams, ServiceContext context, ServiceCallback<Note> callback) throws IOException {
if (!checkPermission(noteId, Permission.WRITER, Message.OP.SAVE_NOTE_FORMS, context, callback)) {
return;
}
// use write lock because noteParams are overwritten
notebook.processNote(noteId, note -> {
if (note == null) {
callback.onFailure(new NoteNotFoundException(noteId), context);
return null;
}
note.setNoteParams(noteParams);
notebook.saveNote(note, context.getAutheInfo());
callback.onSuccess(note, context);
return null;
});
}
use of org.apache.zeppelin.rest.exception.NoteNotFoundException in project zeppelin by apache.
the class NotebookService method getNote.
public <T> T getNote(String noteId, boolean reload, ServiceContext context, ServiceCallback<Note> callback, NoteProcessor<T> noteProcessor) throws IOException {
return notebook.processNote(noteId, reload, note -> {
if (note == null) {
callback.onFailure(new NoteNotFoundException(noteId), context);
return null;
}
if (!checkPermission(noteId, Permission.READER, Message.OP.GET_NOTE, context, callback)) {
return null;
}
Note newNote = note;
if (note.isPersonalizedMode()) {
newNote = note.getUserNote(context.getAutheInfo().getUser());
}
callback.onSuccess(newNote, context);
if (noteProcessor == null) {
return null;
}
return noteProcessor.process(newNote);
});
}
use of org.apache.zeppelin.rest.exception.NoteNotFoundException in project zeppelin by apache.
the class NotebookService method getNoteByRevisionForCompare.
public void getNoteByRevisionForCompare(String noteId, String revisionId, ServiceContext context, ServiceCallback<Note> callback) throws IOException {
notebook.processNote(noteId, note -> {
if (note == null) {
callback.onFailure(new NoteNotFoundException(noteId), context);
return null;
}
if (!checkPermission(noteId, Permission.READER, Message.OP.NOTE_REVISION_FOR_COMPARE, context, callback)) {
return null;
}
Note revisionNote;
if (revisionId.equals("Head")) {
revisionNote = note;
} else {
revisionNote = notebook.getNoteByRevision(noteId, note.getPath(), revisionId, context.getAutheInfo());
}
callback.onSuccess(revisionNote, context);
return null;
});
}
use of org.apache.zeppelin.rest.exception.NoteNotFoundException in project zeppelin by apache.
the class NotebookService method completion.
public List<InterpreterCompletion> completion(String noteId, String paragraphId, String buffer, int cursor, ServiceContext context, ServiceCallback<List<InterpreterCompletion>> callback) throws IOException {
return notebook.processNote(noteId, note -> {
if (note == null) {
callback.onFailure(new NoteNotFoundException(noteId), context);
return null;
}
if (!checkPermission(noteId, Permission.WRITER, Message.OP.COMPLETION, context, callback)) {
return null;
}
try {
List<InterpreterCompletion> completions = note.completion(paragraphId, buffer, cursor, context.getAutheInfo());
callback.onSuccess(completions, context);
return completions;
} catch (RuntimeException e) {
callback.onFailure(new IOException("Fail to get completion", e), context);
return null;
}
});
}
Aggregations