From commits-return-5348-archive-asf-public=cust-asf.ponee.io@zeppelin.apache.org Thu Apr 11 05:22:10 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id 161CD180626 for ; Thu, 11 Apr 2019 07:22:09 +0200 (CEST) Received: (qmail 28579 invoked by uid 500); 11 Apr 2019 05:22:09 -0000 Mailing-List: contact commits-help@zeppelin.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@zeppelin.apache.org Delivered-To: mailing list commits@zeppelin.apache.org Received: (qmail 28570 invoked by uid 99); 11 Apr 2019 05:22:09 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 11 Apr 2019 05:22:09 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 1AD6B80F89; Thu, 11 Apr 2019 05:22:09 +0000 (UTC) Date: Thu, 11 Apr 2019 05:22:08 +0000 To: "commits@zeppelin.apache.org" Subject: [zeppelin] branch master updated: [ZEPPELIN-4043]. Create shell script for moving note permission info from notebook-authorization.json to note file MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Message-ID: <155496012878.29905.14595633860693876595@gitbox.apache.org> From: zjffdu@apache.org X-Git-Host: gitbox.apache.org X-Git-Repo: zeppelin X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 49dfde6c00a2064835176a5f0ce839e7cce0f247 X-Git-Newrev: f63a6196761fa5f4b961c544fbcbe535ed746ba5 X-Git-Rev: f63a6196761fa5f4b961c544fbcbe535ed746ba5 X-Git-NotificationType: ref_changed_plus_diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated 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 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 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 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 getNotebookRepos(AuthenticationInfo subject) { List 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(); } }