Source:
public Response createNote(String message) throws IOException { String user = SecurityUtils.getPrincipal(); LOG.info("Create new note by JSON {}", message); NewNoteRequest request = NewNoteRequest.fromJson(message); AuthenticationInfo subject = new AuthenticationInfo(user); Note note; if (request != null && request.getInterpreter() != null) { String interpreter = request.getInterpreter(); InterpreterSettingManager manager = notebook.getInterpreterSettingManager(); List<String> interpreterIDs = manager.getDefaultInterpreterSettingList(); String defaultId = null; for (String id : interpreterIDs) { if (manager.get(id).getName().equals(interpreter)) { defaultId = id; break; } } if (defaultId != null) { interpreterIDs.remove(defaultId); interpreterIDs.add(0, defaultId); note = notebook.createNote(interpreterIDs, subject); } else { String errorMsg = String.format("interpreter %s doesn't exist", interpreter); return new JsonResponse<>(Status.BAD_REQUEST, errorMsg).build(); } } else { note = notebook.createNote(subject); } if (request != null) { List<NewParagraphRequest> initialParagraphs = request.getParagraphs(); if (initialParagraphs != null) { for (NewParagraphRequest paragraphRequest : initialParagraphs) { Paragraph p = note.addNewParagraph(subject); initParagraph(p, paragraphRequest, user); } } } note.addNewParagraph(subject); String noteName = "Note " + note.getId(); if (request != null && request.getName() != null) { if (!request.getName().isEmpty()) { noteName = request.getName(); } } note.setName(noteName); note.persist(subject); notebookServer.broadcastNote(note); notebookServer.broadcastNoteList(subject, SecurityUtils.getRoles()); return new JsonResponse<>(Status.CREATED, "", note.getId()).build(); }

Target:
public Response createNote(String message) throws IOException { String user = SecurityUtils.getPrincipal(); LOG.info("Create new note by JSON {}", message); NewNoteRequest request = NewNoteRequest.fromJson(message); AuthenticationInfo subject = new AuthenticationInfo(user); Note note; if (request != null && request.getDefaultInterpreter() != null) { String interpreter = request.getDefaultInterpreter(); InterpreterSettingManager manager = notebook.getInterpreterSettingManager(); List<String> interpreterIDs = manager.getDefaultInterpreterSettingList(); String defaultId = null; for (String id : interpreterIDs) { if (manager.get(id).getName().equals(interpreter)) { defaultId = id; break; } } if (defaultId != null) { interpreterIDs.remove(defaultId); interpreterIDs.add(0, defaultId); note = notebook.createNote(interpreterIDs, subject); } else { String errorMsg = String.format("interpreter %s not found", interpreter); return new JsonResponse<>(Status.NOT_FOUND, errorMsg).build(); } } else { note = notebook.createNote(subject); } if (request != null) { List<NewParagraphRequest> initialParagraphs = request.getParagraphs(); if (initialParagraphs != null) { for (NewParagraphRequest paragraphRequest : initialParagraphs) { Paragraph p = note.addNewParagraph(subject); initParagraph(p, paragraphRequest, user); } } } note.addNewParagraph(subject); String noteName = "Note " + note.getId(); if (request != null && request.getName() != null) { if (!request.getName().isEmpty()) { noteName = request.getName(); } } note.setName(noteName); note.persist(subject); notebookServer.broadcastNote(note); notebookServer.broadcastNoteList(subject, SecurityUtils.getRoles()); return new JsonResponse<>(Status.OK, "", note.getId()).build(); }