This is an automated email from the ASF dual-hosted git repository. zjffdu pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/zeppelin.git
The following commit(s) were added to refs/heads/master by this push: new f63a619 [ZEPPELIN-4043]. Create shell script for moving note permission info from notebook-authorization.json to note file f63a619 is described below commit f63a6196761fa5f4b961c544fbcbe535ed746ba5 Author: Jeff Zhang <zjf...@apache.org> AuthorDate: Mon Apr 1 10:27:46 2019 +0800 [ZEPPELIN-4043]. Create shell script for moving note permission info from notebook-authorization.json to note file ### What is this PR for? This PR is followup of ZEPPELIN-3985. It will help user to do the note upgrade (moving permission info from notebook-authorization.json to note file) ### What type of PR is it? [ Improvement ] ### Todos * [ ] - Task ### What is the Jira issue? * https://jira.apache.org/jira/browse/ZEPPELIN-4043 ### How should this be tested? * CI pass ### 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: Jeff Zhang <zjf...@apache.org> Closes #3345 from zjffdu/ZEPPELIN-4043 and squashes the following commits: 98b363455 [Jeff Zhang] [ZEPPELIN-4043]. Create shell script for moving note permission info from notebook-authorization.json to note file --- docs/setup/operation/upgrading.md | 2 +- .../zeppelin/notebook/repo/NotebookRepoSync.java | 19 +++++++++++++++++++ .../zeppelin/notebook/repo/UpgradeNoteFileTool.java | 1 + 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/docs/setup/operation/upgrading.md b/docs/setup/operation/upgrading.md index a3941c3..99b239b 100644 --- a/docs/setup/operation/upgrading.md +++ b/docs/setup/operation/upgrading.md @@ -37,7 +37,7 @@ So, copying `notebook` and `conf` directory should be enough. ### Upgrading from Zeppelin 0.8 to 0.9 - - From 0.9, we change the notes file name structure ([ZEPPELIN-2619](https://issues.apache.org/jira/browse/ZEPPELIN-2619)). So when you upgrading zeppelin to 0.9, you need to upgrade note file. Here's steps you need to follow: + - From 0.9, we change the notes file name structure ([ZEPPELIN-2619](https://issues.apache.org/jira/browse/ZEPPELIN-2619)) and move permissions info from `notebook-authorization.json` into note file itself [ZEPPELIN-3985](https://issues.apache.org/jira/browse/ZEPPELIN-3985). So when you upgrading zeppelin to 0.9, you need to upgrade note file. Here's steps you need to follow: 1. Backup your notes file in case the upgrade fails 2. Call `bin/upgrade-note.sh -d` to upgrade note, `-d` option means to delete the old note file, missing this option will keep the old file. diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/NotebookRepoSync.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/NotebookRepoSync.java index dd43d20..9a5e829 100644 --- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/NotebookRepoSync.java +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/NotebookRepoSync.java @@ -23,8 +23,10 @@ import org.apache.zeppelin.conf.ZeppelinConfiguration; import org.apache.zeppelin.conf.ZeppelinConfiguration.ConfVars; import org.apache.zeppelin.notebook.Note; import org.apache.zeppelin.notebook.NoteInfo; +import org.apache.zeppelin.notebook.NotebookAuthorization; import org.apache.zeppelin.notebook.OldNoteInfo; import org.apache.zeppelin.notebook.Paragraph; +import org.apache.zeppelin.notebook.repo.zeppelinhub.security.Authentication; import org.apache.zeppelin.plugin.PluginManager; import org.apache.zeppelin.user.AuthenticationInfo; import org.apache.zeppelin.util.Util; @@ -142,6 +144,23 @@ public class NotebookRepoSync implements NotebookRepoWithVersionControl { } } + public void mergeAuthorizationInfo() throws IOException { + LOGGER.info("Merge AuthorizationInfo into note file"); + NotebookAuthorization notebookAuthorization = NotebookAuthorization.getInstance(); + for (int i = 0; i < repos.size(); ++i) { + NotebookRepo notebookRepo = repos.get(i); + Map<String, NoteInfo> notesInfo = notebookRepo.list(AuthenticationInfo.ANONYMOUS); + for (NoteInfo noteInfo : notesInfo.values()) { + Note note = notebookRepo.get(noteInfo.getId(), noteInfo.getPath(), AuthenticationInfo.ANONYMOUS); + note.setOwners(notebookAuthorization.getOwners(noteInfo.getId())); + note.setRunners(notebookAuthorization.getRunners(noteInfo.getId())); + note.setReaders(notebookAuthorization.getReaders(noteInfo.getId())); + note.setWriters(notebookAuthorization.getWriters(noteInfo.getId())); + notebookRepo.save(note, AuthenticationInfo.ANONYMOUS); + } + } + } + public List<NotebookRepoWithSettings> getNotebookRepos(AuthenticationInfo subject) { List<NotebookRepoWithSettings> reposSetting = Lists.newArrayList(); diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/UpgradeNoteFileTool.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/UpgradeNoteFileTool.java index c39b116..6429e74 100644 --- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/UpgradeNoteFileTool.java +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/UpgradeNoteFileTool.java @@ -40,5 +40,6 @@ public class UpgradeNoteFileTool { ZeppelinConfiguration conf = ZeppelinConfiguration.create(); NotebookRepoSync notebookRepoSync = new NotebookRepoSync(conf); notebookRepoSync.convertNoteFiles(conf, cmd.hasOption("d")); + notebookRepoSync.mergeAuthorizationInfo(); } }