use of org.apache.zeppelin.rest.exception.NoteNotFoundException in project zeppelin by apache.
the class NotebookService method updatePersonalizedMode.
public void updatePersonalizedMode(String noteId, boolean isPersonalized, 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.WRITER, Message.OP.UPDATE_PERSONALIZED_MODE, context, callback)) {
return null;
}
note.setPersonalizedMode(isPersonalized);
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 clearAllParagraphOutput.
public void clearAllParagraphOutput(String noteId, ServiceContext context, ServiceCallback<Note> callback) throws IOException {
if (!checkPermission(noteId, Permission.WRITER, Message.OP.PARAGRAPH_CLEAR_ALL_OUTPUT, context, callback)) {
return;
}
notebook.processNote(noteId, note -> {
if (note == null) {
callback.onFailure(new NoteNotFoundException(noteId), context);
return null;
}
note.clearAllParagraphOutput();
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 getNotebyRevision.
public void getNotebyRevision(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, context, callback)) {
return null;
}
Note 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 setNoteRevision.
public void setNoteRevision(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.WRITER, Message.OP.SET_NOTE_REVISION, context, callback)) {
return null;
}
try {
Note resultNote = notebook.setNoteRevision(noteId, note.getPath(), revisionId, context.getAutheInfo());
callback.onSuccess(resultNote, context);
} catch (Exception e) {
callback.onFailure(new IOException("Fail to set given note revision", e), context);
}
return null;
});
}
use of org.apache.zeppelin.rest.exception.NoteNotFoundException in project zeppelin by apache.
the class NotebookService method moveNoteToTrash.
public void moveNoteToTrash(String noteId, ServiceContext context, ServiceCallback<Note> callback) throws IOException {
if (!checkPermission(noteId, Permission.OWNER, Message.OP.MOVE_NOTE_TO_TRASH, context, callback)) {
return;
}
String destNotePath = "/" + NoteManager.TRASH_FOLDER + notebook.getNoteManager().getNotesInfo().get(noteId);
if (notebook.containsNote(destNotePath)) {
destNotePath = destNotePath + " " + TRASH_CONFLICT_TIMESTAMP_FORMATTER.format(Instant.now());
}
final String finalDestNotePath = destNotePath;
try {
notebook.processNote(noteId, note -> {
if (note == null) {
callback.onFailure(new NoteNotFoundException(noteId), context);
return null;
}
notebook.moveNote(noteId, finalDestNotePath, context.getAutheInfo());
callback.onSuccess(note, context);
return null;
});
} catch (CorruptedNoteException e) {
LOGGER.info("Move corrupted note to trash");
notebook.moveNote(noteId, destNotePath, context.getAutheInfo());
}
}
Aggregations