use of org.apache.zeppelin.service.ServiceContext in project zeppelin by apache.
the class NotebookServer method moveParagraph.
private void moveParagraph(NotebookSocket conn, ServiceContext context, Message fromMessage) throws IOException {
final String paragraphId = (String) fromMessage.get("id");
final int newIndex = (int) Double.parseDouble(fromMessage.get("index").toString());
String noteId = connectionManager.getAssociatedNoteId(conn);
getNotebookService().moveParagraph(noteId, paragraphId, newIndex, context, new WebSocketServiceCallback<Paragraph>(conn) {
@Override
public void onSuccess(Paragraph result, ServiceContext context) throws IOException {
super.onSuccess(result, context);
connectionManager.broadcast(result.getNote().getId(), new Message(OP.PARAGRAPH_MOVED).put("id", paragraphId).put("index", newIndex));
}
});
}
use of org.apache.zeppelin.service.ServiceContext in project zeppelin by apache.
the class NotebookServer method insertParagraph.
private String insertParagraph(NotebookSocket conn, ServiceContext context, Message fromMessage) throws IOException {
final int index = (int) Double.parseDouble(fromMessage.get("index").toString());
String noteId = connectionManager.getAssociatedNoteId(conn);
Map<String, Object> config;
if (fromMessage.get("config") != null) {
config = (Map<String, Object>) fromMessage.get("config");
} else {
config = new HashMap<>();
}
Paragraph newPara = getNotebookService().insertParagraph(noteId, index, config, context, new WebSocketServiceCallback<Paragraph>(conn) {
@Override
public void onSuccess(Paragraph p, ServiceContext context) throws IOException {
super.onSuccess(p, context);
broadcastNewParagraph(p.getNote(), p);
}
});
return newPara.getId();
}
use of org.apache.zeppelin.service.ServiceContext in project zeppelin by apache.
the class NotebookServer method broadcastUpdateNoteJobInfo.
public void broadcastUpdateNoteJobInfo(Note note, long lastUpdateUnixTime) throws IOException {
ServiceContext context = new ServiceContext(new AuthenticationInfo(), authorizationService.getOwners(note.getId()));
getJobManagerService().getNoteJobInfoByUnixTime(lastUpdateUnixTime, context, new WebSocketServiceCallback<List<JobManagerService.NoteJobInfo>>(null) {
@Override
public void onSuccess(List<JobManagerService.NoteJobInfo> notesJobInfo, ServiceContext context) throws IOException {
super.onSuccess(notesJobInfo, context);
Map<String, Object> response = new HashMap<>();
response.put("lastResponseUnixTime", System.currentTimeMillis());
response.put("jobs", notesJobInfo);
connectionManager.broadcast(JobManagerServiceType.JOB_MANAGER_PAGE.getKey(), new Message(OP.LIST_UPDATE_NOTE_JOBS).put("noteRunningJobs", response));
}
@Override
public void onFailure(Exception ex, ServiceContext context) throws IOException {
LOG.warn(ex.getMessage());
}
});
}
use of org.apache.zeppelin.service.ServiceContext in project zeppelin by apache.
the class NotebookServer method broadcastSpellExecution.
private void broadcastSpellExecution(NotebookSocket conn, ServiceContext context, Message fromMessage) throws IOException {
String noteId = connectionManager.getAssociatedNoteId(conn);
getNotebookService().spell(noteId, fromMessage, context, new WebSocketServiceCallback<Paragraph>(conn) {
@Override
public void onSuccess(Paragraph p, ServiceContext context) throws IOException {
super.onSuccess(p, context);
// broadcast to other clients only
connectionManager.broadcastExcept(p.getNote().getId(), new Message(OP.RUN_PARAGRAPH_USING_SPELL).put("paragraph", p), conn);
}
});
}
use of org.apache.zeppelin.service.ServiceContext in project zeppelin by apache.
the class NotebookServer method updateNote.
private void updateNote(NotebookSocket conn, ServiceContext context, Message fromMessage) throws IOException {
String noteId = (String) fromMessage.get("id");
String name = (String) fromMessage.get("name");
Map<String, Object> config = (Map<String, Object>) fromMessage.get("config");
if (noteId == null) {
return;
}
if (config == null) {
return;
}
getNotebookService().updateNote(noteId, name, config, context, new WebSocketServiceCallback<Note>(conn) {
@Override
public void onSuccess(Note note, ServiceContext context) throws IOException {
connectionManager.broadcast(note.getId(), new Message(OP.NOTE_UPDATED).put("name", name).put("config", config).put("info", note.getInfo()));
broadcastNoteList(context.getAutheInfo(), context.getUserAndRoles());
}
});
}
Aggregations