Repository: zeppelin Updated Branches: refs/heads/branch-0.7 bb83bfc65 -> e2def13cc
[MINOR] Supported old note format in case of not having name of note ### What is this PR for? Supporting old format of note which doesn't have name inside. Long time ago, when creating note without specific name, name field become empty string. but it become error while remove note for current master. It will fix this error ### What type of PR is it? [Bug Fix] ### Todos * [ ] - Enable getName returns getId if it has empty value ### What is the Jira issue? N/A ### How should this be tested? See the test added ### Screenshots (if appropriate) N/A ### Questions: * Does the licenses files need update? No * Is there breaking changes for older versions? No * Does this needs documentation? No Author: Jongyoul Lee <[email protected]> Closes #2028 from jongyoul/hotfix/remove-note-without-name and squashes the following commits: e671040 [Jongyoul Lee] Set note's name if it's empty cc6b6ca [Jongyoul Lee] Supported old note format in case of not having name of note (cherry picked from commit 5144050f990988e99ad0901ba4513467dc4bf119) Signed-off-by: Jongyoul Lee <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/zeppelin/repo Commit: http://git-wip-us.apache.org/repos/asf/zeppelin/commit/e2def13c Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/e2def13c Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/e2def13c Branch: refs/heads/branch-0.7 Commit: e2def13cc32e30b3c6c3218e0b12a3337804fea3 Parents: bb83bfc Author: Jongyoul Lee <[email protected]> Authored: Tue Feb 21 13:03:07 2017 +0900 Committer: Jongyoul Lee <[email protected]> Committed: Wed Feb 22 18:17:00 2017 +0900 ---------------------------------------------------------------------- .../src/main/java/org/apache/zeppelin/notebook/Note.java | 5 ++++- .../src/test/java/org/apache/zeppelin/notebook/NoteTest.java | 7 +++++++ 2 files changed, 11 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/zeppelin/blob/e2def13c/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 26f4e1a..7a63879 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 @@ -141,6 +141,9 @@ public class Note implements Serializable, ParagraphJobListener { } public String getName() { + if (isNameEmpty()) { + name = getId(); + } return name; } @@ -178,7 +181,7 @@ public class Note implements Serializable, ParagraphJobListener { } public boolean isNameEmpty() { - return getName().trim().isEmpty(); + return this.name.trim().isEmpty(); } private String normalizeNoteName(String name) { http://git-wip-us.apache.org/repos/asf/zeppelin/blob/e2def13c/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NoteTest.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NoteTest.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NoteTest.java index ad6031e..35b6462 100644 --- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NoteTest.java +++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NoteTest.java @@ -199,4 +199,11 @@ public class NoteTest { note.setName(Folder.TRASH_FOLDER_ID + "/a/b/c"); assertTrue(note.isTrash()); } + + @Test + public void getNameWithoutNameItself() { + Note note = new Note(repo, interpreterFactory, interpreterSettingManager, jobListenerFactory, index, credentials, noteEventListener); + + assertEquals("getName should return same as getId when name is empty", note.getId(), note.getName()); + } }
