Repository: zeppelin Updated Branches: refs/heads/master d4375977d -> f1e9c5208
[Zeppelin-53] Broken newly created Notebook if there is no permissions to mkdir on disk ### What is this PR for? Error message should be shown to the user when there is permission issue with the 'notebook' storage folder. ### What type of PR is it? Bug Fix ### Todos NA ### What is the Jira issue? https://issues.apache.org/jira/browse/ZEPPELIN-53 ### How should this be tested? - Create the notebook storage folder (i.e zeppelin/notebook) with only read and execute permission - Try to create a notebook from UI - The below error message as in the screenshot should be rendered ### Screenshots (if appropriate)  ### Questions: - Does the licenses files need update? No - Is there breaking changes for older versions? No - Does this needs documentation? No Author: Kavin <[email protected]> Closes #1535 from kavinkumarks/zeppelin-53-create-notebook-mkdir-issue and squashes the following commits: de7c937 [Kavin] Show error message to the user when there is permission issue on creating notebook. Project: http://git-wip-us.apache.org/repos/asf/zeppelin/repo Commit: http://git-wip-us.apache.org/repos/asf/zeppelin/commit/f1e9c520 Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/f1e9c520 Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/f1e9c520 Branch: refs/heads/master Commit: f1e9c520873ca3ee61f59b9425633340366b35f1 Parents: d437597 Author: Kavin <[email protected]> Authored: Tue Oct 18 12:22:15 2016 +0530 Committer: Lee moon soo <[email protected]> Committed: Thu Nov 3 09:44:55 2016 -0700 ---------------------------------------------------------------------- .../apache/zeppelin/socket/NotebookServer.java | 56 ++++++++++++-------- 1 file changed, 33 insertions(+), 23 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/zeppelin/blob/f1e9c520/zeppelin-server/src/main/java/org/apache/zeppelin/socket/NotebookServer.java ---------------------------------------------------------------------- diff --git a/zeppelin-server/src/main/java/org/apache/zeppelin/socket/NotebookServer.java b/zeppelin-server/src/main/java/org/apache/zeppelin/socket/NotebookServer.java index 4934265..3e137b8 100644 --- a/zeppelin-server/src/main/java/org/apache/zeppelin/socket/NotebookServer.java +++ b/zeppelin-server/src/main/java/org/apache/zeppelin/socket/NotebookServer.java @@ -712,39 +712,49 @@ public class NotebookServer extends WebSocketServlet implements return cronUpdated; } + private void createNote(NotebookSocket conn, HashSet<String> userAndRoles, Notebook notebook, Message message) throws IOException { AuthenticationInfo subject = new AuthenticationInfo(message.principal); - Note note = null; - String defaultInterpreterId = (String) message.get("defaultInterpreterId"); - if (!StringUtils.isEmpty(defaultInterpreterId)) { - List<String> interpreterSettingIds = new LinkedList<>(); - interpreterSettingIds.add(defaultInterpreterId); - for (String interpreterSettingId : notebook.getInterpreterFactory(). - getDefaultInterpreterSettingList()) { - if (!interpreterSettingId.equals(defaultInterpreterId)) { - interpreterSettingIds.add(interpreterSettingId); + try { + Note note = null; + + String defaultInterpreterId = (String) message.get("defaultInterpreterId"); + if (!StringUtils.isEmpty(defaultInterpreterId)) { + List<String> interpreterSettingIds = new LinkedList<>(); + interpreterSettingIds.add(defaultInterpreterId); + for (String interpreterSettingId : notebook.getInterpreterFactory(). + getDefaultInterpreterSettingList()) { + if (!interpreterSettingId.equals(defaultInterpreterId)) { + interpreterSettingIds.add(interpreterSettingId); + } } + note = notebook.createNote(interpreterSettingIds, subject); + } else { + note = notebook.createNote(subject); } - note = notebook.createNote(interpreterSettingIds, subject); - } else { - note = notebook.createNote(subject); - } - note.addParagraph(); // it's an empty note. so add one paragraph - if (message != null) { - String noteName = (String) message.get("name"); - if (StringUtils.isEmpty(noteName)){ - noteName = "Note " + note.getId(); + note.addParagraph(); // it's an empty note. so add one paragraph + if (message != null) { + String noteName = (String) message.get("name"); + if (StringUtils.isEmpty(noteName)) { + noteName = "Note " + note.getId(); + } + note.setName(noteName); } - note.setName(noteName); - } - note.persist(subject); - addConnectionToNote(note.getId(), (NotebookSocket) conn); - conn.send(serializeMessage(new Message(OP.NEW_NOTE).put("note", note))); + note.persist(subject); + addConnectionToNote(note.getId(), (NotebookSocket) conn); + conn.send(serializeMessage(new Message(OP.NEW_NOTE).put("note", note))); + } catch (FileSystemException e) { + LOG.error("Exception from createNote", e); + conn.send(serializeMessage(new Message(OP.ERROR_INFO).put("info", + "Oops! There is something wrong with the notebook file system. " + + "Please check the logs for more details."))); + return; + } broadcastNoteList(subject, userAndRoles); }
