use of org.apache.zeppelin.user.AuthenticationInfo in project zeppelin by apache.
the class NotebookServer method listRevisionHistory.
private void listRevisionHistory(NotebookSocket conn, Notebook notebook, Message fromMessage) throws IOException {
String noteId = (String) fromMessage.get("noteId");
AuthenticationInfo subject = new AuthenticationInfo(fromMessage.principal);
List<Revision> revisions = notebook.listRevisionHistory(noteId, subject);
conn.send(serializeMessage(new Message(OP.LIST_REVISION_HISTORY).put("revisionList", revisions)));
}
use of org.apache.zeppelin.user.AuthenticationInfo in project zeppelin by apache.
the class NotebookServer method setNoteRevision.
private void setNoteRevision(NotebookSocket conn, HashSet<String> userAndRoles, Notebook notebook, Message fromMessage) throws IOException {
String noteId = (String) fromMessage.get("noteId");
String revisionId = (String) fromMessage.get("revisionId");
AuthenticationInfo subject = new AuthenticationInfo(fromMessage.principal);
if (!hasParagraphWriterPermission(conn, notebook, noteId, userAndRoles, fromMessage.principal, "update")) {
return;
}
Note headNote = null;
boolean setRevisionStatus;
try {
headNote = notebook.setNoteRevision(noteId, revisionId, subject);
setRevisionStatus = headNote != null;
} catch (Exception e) {
setRevisionStatus = false;
LOG.error("Failed to set given note revision", e);
}
if (setRevisionStatus) {
notebook.loadNoteFromRepo(noteId, subject);
}
conn.send(serializeMessage(new Message(OP.SET_NOTE_REVISION).put("status", setRevisionStatus)));
if (setRevisionStatus) {
Note reloadedNote = notebook.getNote(headNote.getId());
broadcastNote(reloadedNote);
} else {
conn.send(serializeMessage(new Message(OP.ERROR_INFO).put("info", "Couldn't set note to the given revision. " + "Please check the logs for more details.")));
}
}
use of org.apache.zeppelin.user.AuthenticationInfo in project zeppelin by apache.
the class NotebookServer method renameFolder.
private void renameFolder(NotebookSocket conn, HashSet<String> userAndRoles, Notebook notebook, Message fromMessage, String op) throws SchedulerException, IOException {
String oldFolderId = (String) fromMessage.get("id");
String newFolderId = (String) fromMessage.get("name");
if (oldFolderId == null) {
return;
}
for (Note note : notebook.getNotesUnderFolder(oldFolderId)) {
String noteId = note.getId();
if (!hasParagraphOwnerPermission(conn, notebook, noteId, userAndRoles, fromMessage.principal, op + " folder of '" + note.getName() + "'")) {
return;
}
}
Folder oldFolder = notebook.renameFolder(oldFolderId, newFolderId);
if (oldFolder != null) {
AuthenticationInfo subject = new AuthenticationInfo(fromMessage.principal);
List<Note> renamedNotes = oldFolder.getNotesRecursively();
for (Note note : renamedNotes) {
note.persist(subject);
broadcastNote(note);
}
broadcastNoteList(subject, userAndRoles);
}
}
use of org.apache.zeppelin.user.AuthenticationInfo in project zeppelin by apache.
the class NotebookServer method saveInterpreterBindings.
public void saveInterpreterBindings(NotebookSocket conn, Message fromMessage) {
String noteId = (String) fromMessage.data.get("noteId");
try {
List<String> settingIdList = gson.fromJson(String.valueOf(fromMessage.data.get("selectedSettingIds")), new TypeToken<ArrayList<String>>() {
}.getType());
AuthenticationInfo subject = new AuthenticationInfo(fromMessage.principal);
notebook().bindInterpretersToNote(subject.getUser(), noteId, settingIdList);
broadcastInterpreterBindings(noteId, InterpreterBindingUtils.getInterpreterBindings(notebook(), noteId));
} catch (Exception e) {
LOG.error("Error while saving interpreter bindings", e);
}
}
use of org.apache.zeppelin.user.AuthenticationInfo in project zeppelin by apache.
the class NotebookServer method removeNote.
private void removeNote(NotebookSocket conn, HashSet<String> userAndRoles, Notebook notebook, Message fromMessage) throws IOException {
String noteId = (String) fromMessage.get("id");
if (noteId == null) {
return;
}
if (!hasParagraphOwnerPermission(conn, notebook, noteId, userAndRoles, fromMessage.principal, "remove")) {
return;
}
AuthenticationInfo subject = new AuthenticationInfo(fromMessage.principal);
notebook.removeNote(noteId, subject);
removeNote(noteId);
broadcastNoteList(subject, userAndRoles);
}
Aggregations