Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.io.InputStream;
import java.nio.ByteBuffer;


/**
* InputStream from bytebuffer
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ public class AuthenticationInfo {

public AuthenticationInfo() {}

public AuthenticationInfo(String user) {
this.user = user;
}

/***
*
* @param user
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import org.apache.zeppelin.search.SearchService;
import org.apache.zeppelin.server.JsonResponse;
import org.apache.zeppelin.socket.NotebookServer;
import org.apache.zeppelin.user.AuthenticationInfo;
import org.apache.zeppelin.utils.SecurityUtils;
import org.quartz.CronExpression;
import org.slf4j.Logger;
Expand Down Expand Up @@ -158,7 +159,8 @@ public Response putNotePermissions(@PathParam("noteId") String noteId, String re
notebookAuthorization.getOwners(noteId),
notebookAuthorization.getReaders(noteId),
notebookAuthorization.getWriters(noteId));
note.persist();
AuthenticationInfo subject = new AuthenticationInfo(SecurityUtils.getPrincipal());
note.persist(subject);
notebookServer.broadcastNote(note);
return new JsonResponse<>(Status.OK).build();
}
Expand Down Expand Up @@ -224,7 +226,8 @@ public Response bind(@PathParam("noteId") String noteId) {
@Path("/")
@ZeppelinApi
public Response getNotebookList() throws IOException {
List<Map<String, String>> notesInfo = notebookServer.generateNotebooksInfo(false);
AuthenticationInfo subject = new AuthenticationInfo(SecurityUtils.getPrincipal());
List<Map<String, String>> notesInfo = notebookServer.generateNotebooksInfo(false, subject);
return new JsonResponse<>(Status.OK, "", notesInfo ).build();
}

Expand Down Expand Up @@ -266,7 +269,8 @@ public Response exportNoteBook(@PathParam("id") String noteId) throws IOExceptio
@Path("import")
@ZeppelinApi
public Response importNotebook(String req) throws IOException {
Note newNote = notebook.importNote(req, null);
AuthenticationInfo subject = new AuthenticationInfo(SecurityUtils.getPrincipal());
Note newNote = notebook.importNote(req, null, subject);
return new JsonResponse<>(Status.CREATED, "", newNote.getId()).build();
}

Expand All @@ -283,7 +287,8 @@ public Response createNote(String message) throws IOException {
LOG.info("Create new notebook by JSON {}" , message);
NewNotebookRequest request = gson.fromJson(message,
NewNotebookRequest.class);
Note note = notebook.createNote();
AuthenticationInfo subject = new AuthenticationInfo(SecurityUtils.getPrincipal());
Note note = notebook.createNote(subject);
List<NewParagraphRequest> initialParagraphs = request.getParagraphs();
if (initialParagraphs != null) {
for (NewParagraphRequest paragraphRequest : initialParagraphs) {
Expand All @@ -297,10 +302,11 @@ public Response createNote(String message) throws IOException {
if (noteName.isEmpty()) {
noteName = "Note " + note.getId();
}

note.setName(noteName);
note.persist();
note.persist(subject);
notebookServer.broadcastNote(note);
notebookServer.broadcastNoteList();
notebookServer.broadcastNoteList(subject);
return new JsonResponse<>(Status.CREATED, "", note.getId() ).build();
}

Expand All @@ -315,13 +321,15 @@ public Response createNote(String message) throws IOException {
@ZeppelinApi
public Response deleteNote(@PathParam("notebookId") String notebookId) throws IOException {
LOG.info("Delete notebook {} ", notebookId);
AuthenticationInfo subject = new AuthenticationInfo(SecurityUtils.getPrincipal());
if (!(notebookId.isEmpty())) {
Note note = notebook.getNote(notebookId);
if (note != null) {
notebook.removeNote(notebookId);
notebook.removeNote(notebookId, subject);
}
}
notebookServer.broadcastNoteList();

notebookServer.broadcastNoteList(subject);
return new JsonResponse<>(Status.OK, "").build();
}

Expand All @@ -340,9 +348,10 @@ public Response cloneNote(@PathParam("notebookId") String notebookId, String mes
NewNotebookRequest request = gson.fromJson(message,
NewNotebookRequest.class);
String newNoteName = request.getName();
Note newNote = notebook.cloneNote(notebookId, newNoteName);
AuthenticationInfo subject = new AuthenticationInfo(SecurityUtils.getPrincipal());
Note newNote = notebook.cloneNote(notebookId, newNoteName, subject);
notebookServer.broadcastNote(newNote);
notebookServer.broadcastNoteList();
notebookServer.broadcastNoteList(subject);
return new JsonResponse<>(Status.CREATED, "", newNote.getId()).build();
}

Expand Down Expand Up @@ -376,7 +385,8 @@ public Response insertParagraph(@PathParam("notebookId") String notebookId, Stri
p.setTitle(request.getTitle());
p.setText(request.getText());

note.persist();
AuthenticationInfo subject = new AuthenticationInfo(SecurityUtils.getPrincipal());
note.persist(subject);
notebookServer.broadcastNote(note);
return new JsonResponse(Status.CREATED, "", p.getId()).build();
}
Expand Down Expand Up @@ -434,7 +444,8 @@ public Response moveParagraph(@PathParam("notebookId") String notebookId,
try {
note.moveParagraph(paragraphId, Integer.parseInt(newIndex), true);

note.persist();
AuthenticationInfo subject = new AuthenticationInfo(SecurityUtils.getPrincipal());
note.persist(subject);
notebookServer.broadcastNote(note);
return new JsonResponse(Status.OK, "").build();
} catch (IndexOutOfBoundsException e) {
Expand Down Expand Up @@ -466,8 +477,9 @@ public Response deleteParagraph(@PathParam("notebookId") String notebookId,
return new JsonResponse(Status.NOT_FOUND, "paragraph not found.").build();
}

AuthenticationInfo subject = new AuthenticationInfo(SecurityUtils.getPrincipal());
note.removeParagraph(paragraphId);
note.persist();
note.persist(subject);
notebookServer.broadcastNote(note);

return new JsonResponse(Status.OK, "").build();
Expand Down Expand Up @@ -574,7 +586,8 @@ public Response runParagraph(@PathParam("notebookId") String notebookId,
Map<String, Object> paramsForUpdating = request.getParams();
if (paramsForUpdating != null) {
paragraph.settings.getParams().putAll(paramsForUpdating);
note.persist();
AuthenticationInfo subject = new AuthenticationInfo(SecurityUtils.getPrincipal());
note.persist(subject);
}
}

Expand Down Expand Up @@ -700,7 +713,8 @@ public Response getCronJob(@PathParam("notebookId") String notebookId) throws
public Response getJobListforNotebook() throws IOException, IllegalArgumentException {
LOG.info("Get notebook jobs for job manager");

List<Map<String, Object>> notebookJobs = notebook.getJobListforNotebook(false, 0);
AuthenticationInfo subject = new AuthenticationInfo(SecurityUtils.getPrincipal());
List<Map<String, Object>> notebookJobs = notebook.getJobListforNotebook(false, 0, subject);
Map<String, Object> response = new HashMap<>();

response.put("lastResponseUnixTime", System.currentTimeMillis());
Expand All @@ -724,7 +738,8 @@ public Response getUpdatedJobListforNotebook(
LOG.info("Get updated notebook jobs lastUpdateTime {}", lastUpdateUnixTime);

List<Map<String, Object>> notebookJobs;
notebookJobs = notebook.getJobListforNotebook(false, lastUpdateUnixTime);
AuthenticationInfo subject = new AuthenticationInfo(SecurityUtils.getPrincipal());
notebookJobs = notebook.getJobListforNotebook(false, lastUpdateUnixTime, subject);
Map<String, Object> response = new HashMap<>();

response.put("lastResponseUnixTime", System.currentTimeMillis());
Expand Down
Loading