use of org.apache.zeppelin.notebook.socket.Message in project zeppelin by apache.
the class NotebookServer method broadcastSpellExecution.
private void broadcastSpellExecution(NotebookSocket conn, HashSet<String> userAndRoles, Notebook notebook, Message fromMessage) throws IOException {
final String paragraphId = (String) fromMessage.get("id");
if (paragraphId == null) {
return;
}
String noteId = getOpenNoteId(conn);
if (!hasParagraphWriterPermission(conn, notebook, noteId, userAndRoles, fromMessage.principal, "write")) {
return;
}
String text = (String) fromMessage.get("paragraph");
String title = (String) fromMessage.get("title");
Status status = Status.valueOf((String) fromMessage.get("status"));
Map<String, Object> params = (Map<String, Object>) fromMessage.get("params");
Map<String, Object> config = (Map<String, Object>) fromMessage.get("config");
final Note note = notebook.getNote(noteId);
Paragraph p = setParagraphUsingMessage(note, fromMessage, paragraphId, text, title, params, config);
p.setResult(fromMessage.get("results"));
p.setErrorMessage((String) fromMessage.get("errorMessage"));
p.setStatusWithoutNotification(status);
addNewParagraphIfLastParagraphIsExecuted(note, p);
if (!persistNoteWithAuthInfo(conn, note, p)) {
return;
}
// broadcast to other clients only
broadcastExcept(note.getId(), new Message(OP.RUN_PARAGRAPH_USING_SPELL).put("paragraph", p), conn);
}
use of org.apache.zeppelin.notebook.socket.Message in project zeppelin by apache.
the class NotebookServer method checkpointNote.
private void checkpointNote(NotebookSocket conn, Notebook notebook, Message fromMessage) throws IOException {
String noteId = (String) fromMessage.get("noteId");
String commitMessage = (String) fromMessage.get("commitMessage");
AuthenticationInfo subject = new AuthenticationInfo(fromMessage.principal);
Revision revision = notebook.checkpointNote(noteId, commitMessage, subject);
if (!Revision.isEmpty(revision)) {
List<Revision> revisions = notebook.listRevisionHistory(noteId, subject);
conn.send(serializeMessage(new Message(OP.LIST_REVISION_HISTORY).put("revisionList", revisions)));
} else {
conn.send(serializeMessage(new Message(OP.ERROR_INFO).put("info", "Couldn't checkpoint note revision: possibly storage doesn't support versioning. " + "Please check the logs for more details.")));
}
}
use of org.apache.zeppelin.notebook.socket.Message 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.notebook.socket.Message in project zeppelin by apache.
the class NotebookServer method removeAngularFromRemoteRegistry.
private void removeAngularFromRemoteRegistry(String noteId, String paragraphId, String varName, RemoteAngularObjectRegistry remoteRegistry, String interpreterGroupId, NotebookSocket conn) {
final AngularObject ao = remoteRegistry.removeAndNotifyRemoteProcess(varName, noteId, paragraphId);
this.broadcastExcept(noteId, new Message(OP.ANGULAR_OBJECT_REMOVE).put("angularObject", ao).put("interpreterGroupId", interpreterGroupId).put("noteId", noteId).put("paragraphId", paragraphId), conn);
}
use of org.apache.zeppelin.notebook.socket.Message 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.")));
}
}
Aggregations