zeppelin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zjf...@apache.org
Subject zeppelin git commit: ZEPPELIN-3309. Import/Clone user not set in Paragraph causes NPE.
Date Sat, 10 Mar 2018 23:18:39 GMT
Repository: zeppelin
Updated Branches:
  refs/heads/master f4a798b62 -> 803116fd0


ZEPPELIN-3309. Import/Clone user not set in Paragraph causes NPE.

What is this PR for?
During Import/Clone Paragraph set "user" to eliminate NPEs thrown in Helium and other functions
leaving unusable notebooks.

What type of PR is it?
[Bug Fix]

Todos

What is the Jira issue?
https://issues.apache.org/jira/browse/ZEPPELIN-3309

How should this be tested?
Manually tested using Import/Clone of Notebooks and attempt to adjust bound interpreters

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: Greg Senia gseniaapache.org

Author: gss2002 <greg@senia.org>

Closes #2855 from gss2002/ZEPPELIN-3309 and squashes the following commits:

b8c35c9 [gss2002] ZEPPELIN-3309. Import/Clone user not set in Paragraph causes NPE.


Project: http://git-wip-us.apache.org/repos/asf/zeppelin/repo
Commit: http://git-wip-us.apache.org/repos/asf/zeppelin/commit/803116fd
Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/803116fd
Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/803116fd

Branch: refs/heads/master
Commit: 803116fd0d4ad5baaf3d85b7c903d75fd04b2030
Parents: f4a798b
Author: gss2002 <greg@senia.org>
Authored: Thu Mar 8 17:06:06 2018 -0500
Committer: Jeff Zhang <zjffdu@apache.org>
Committed: Sun Mar 11 07:18:35 2018 +0800

----------------------------------------------------------------------
 .../java/org/apache/zeppelin/notebook/Note.java |  8 ++++++-
 .../org/apache/zeppelin/notebook/Notebook.java  |  4 ++--
 .../apache/zeppelin/notebook/NotebookTest.java  | 23 +++++++++++++++++++-
 3 files changed, 31 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zeppelin/blob/803116fd/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Note.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Note.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Note.java
index 495f670..fc70c70 100644
--- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Note.java
+++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Note.java
@@ -362,7 +362,7 @@ public class Note implements ParagraphJobListener, JsonSerializable {
    *
    * @param srcParagraph source paragraph
    */
-  void addCloneParagraph(Paragraph srcParagraph) {
+  void addCloneParagraph(Paragraph srcParagraph, AuthenticationInfo subject) {
 
     // Keep paragraph original ID
     final Paragraph newParagraph = new Paragraph(srcParagraph.getId(), this, this, factory);
@@ -371,11 +371,17 @@ public class Note implements ParagraphJobListener, JsonSerializable
{
     Map<String, Object> param = srcParagraph.settings.getParams();
     LinkedHashMap<String, Input> form = srcParagraph.settings.getForms();
 
+    logger.debug("srcParagraph user: " + srcParagraph.getUser());
+    
+    newParagraph.setAuthenticationInfo(subject);
     newParagraph.setConfig(config);
     newParagraph.settings.setParams(param);
     newParagraph.settings.setForms(form);
     newParagraph.setText(srcParagraph.getText());
     newParagraph.setTitle(srcParagraph.getTitle());
+    
+    logger.debug("newParagraph user: " + newParagraph.getUser());
+
 
     try {
       Gson gson = new Gson();

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/803116fd/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Notebook.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Notebook.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Notebook.java
index a9168a3..7467e31 100644
--- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Notebook.java
+++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Notebook.java
@@ -211,7 +211,7 @@ public class Notebook implements NoteEventListener {
       newNote.setCronSupported(getConf());
       List<Paragraph> paragraphs = oldNote.getParagraphs();
       for (Paragraph p : paragraphs) {
-        newNote.addCloneParagraph(p);
+        newNote.addCloneParagraph(p, subject);
       }
 
       notebookAuthorization.setNewNotePermissions(newNote.getId(), subject);
@@ -252,7 +252,7 @@ public class Notebook implements NoteEventListener {
 
     List<Paragraph> paragraphs = sourceNote.getParagraphs();
     for (Paragraph p : paragraphs) {
-      newNote.addCloneParagraph(p);
+      newNote.addCloneParagraph(p, subject);
     }
 
     noteSearchService.addIndexDoc(newNote);

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/803116fd/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NotebookTest.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NotebookTest.java
b/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NotebookTest.java
index ee04291..cfb2e16 100644
--- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NotebookTest.java
+++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NotebookTest.java
@@ -1233,7 +1233,7 @@ public class NotebookTest extends AbstractInterpreterTest implements
JobListener
     Paragraph p1 = note1.addNewParagraph(AuthenticationInfo.ANONYMOUS);
     assertEquals(1, onParagraphCreate.get());
 
-    note1.addCloneParagraph(p1);
+    note1.addCloneParagraph(p1, AuthenticationInfo.ANONYMOUS);
     assertEquals(2, onParagraphCreate.get());
 
     note1.removeParagraph(anonymous.getUser(), p1.getId());
@@ -1401,6 +1401,27 @@ public class NotebookTest extends AbstractInterpreterTest implements
JobListener
     System.setProperty(ConfVars.ZEPPELIN_NOTEBOOK_PUBLIC.getVarName(), "true");
     ZeppelinConfiguration.create();
   }
+  
+  @Test
+  public void testCloneImportCheck() throws IOException {
+    Note sourceNote = notebook.createNote(new AuthenticationInfo("user"));
+    sourceNote.setName("TestNote");
+    
+    assertEquals("TestNote",sourceNote.getName());
+
+    Paragraph sourceParagraph = sourceNote.addNewParagraph(AuthenticationInfo.ANONYMOUS);
+    assertEquals("anonymous", sourceParagraph.getUser());
+
+    Note destNote = notebook.createNote(new AuthenticationInfo("user"));
+    destNote.setName("ClonedNote");
+    assertEquals("ClonedNote",destNote.getName());
+
+    List<Paragraph> paragraphs = sourceNote.getParagraphs();
+    for (Paragraph p : paragraphs) {
+    	  destNote.addCloneParagraph(p, AuthenticationInfo.ANONYMOUS);
+      assertEquals("anonymous", p.getUser());
+    }
+  }
 
   private void delete(File file){
     if(file.isFile()) file.delete();


Mime
View raw message