VFSNotebookRepo implements NotebookRepo { @Override public void updateSettings(Map<String, String> settings, AuthenticationInfo subject) { if (settings == null || settings.isEmpty()) { LOGGER.error("Cannot update {} with empty settings", this.getClass().getName()); return; } String newNotebookDirectotyPath = StringUtils.EMPTY; if (settings.containsKey("Notebook Path")) { newNotebookDirectotyPath = settings.get("Notebook Path"); } if (StringUtils.isBlank(newNotebookDirectotyPath)) { LOGGER.error("Notebook path is invalid"); return; } LOGGER.warn("{} will change notebook dir from {} to {}", subject.getUser(), this.rootNotebookFolder, newNotebookDirectotyPath); try { setNotebookDirectory(newNotebookDirectotyPath); } catch (IOException e) { LOGGER.error("Cannot update notebook directory", e); } } VFSNotebookRepo(); @Override void init(ZeppelinConfiguration conf); @Override Map<String, NoteInfo> list(AuthenticationInfo subject); @Override Note get(String noteId, String notePath, AuthenticationInfo subject); @Override synchronized void save(Note note, AuthenticationInfo subject); @Override void move(String noteId,
                   String notePath,
                   String newNotePath,
                   AuthenticationInfo subject); @Override void move(String folderPath, String newFolderPath,
                   AuthenticationInfo subject); @Override void remove(String noteId, String notePath, AuthenticationInfo subject); @Override void remove(String folderPath, AuthenticationInfo subject); @Override void close(); @Override List<NotebookRepoSettingsInfo> getSettings(AuthenticationInfo subject); @Override void updateSettings(Map<String, String> settings, AuthenticationInfo subject);  }
@Test public void testUpdateSettings() throws IOException { List<NotebookRepoSettingsInfo> repoSettings = notebookRepo.getSettings(AuthenticationInfo.ANONYMOUS); assertEquals(1, repoSettings.size()); NotebookRepoSettingsInfo settingInfo = repoSettings.get(0); assertEquals("Notebook Path", settingInfo.name); assertEquals(notebookDir.getAbsolutePath(), settingInfo.selected); createNewNote("{}", "id2", "my_project/name2"); assertEquals(1, notebookRepo.list(AuthenticationInfo.ANONYMOUS).size()); String newNotebookDir = "/tmp/zeppelin/vfs_notebookrepo2"; FileUtils.forceMkdir(new File(newNotebookDir)); Map<String, String> newSettings = ImmutableMap.of("Notebook Path", newNotebookDir); notebookRepo.updateSettings(newSettings, AuthenticationInfo.ANONYMOUS); assertEquals(0, notebookRepo.list(AuthenticationInfo.ANONYMOUS).size()); }