You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zeppelin.apache.org by zj...@apache.org on 2018/12/05 09:16:51 UTC
zeppelin git commit: ZEPPELIN-3876. Unable to rename note
Repository: zeppelin
Updated Branches:
refs/heads/master dda5a1452 -> a02e8e0f9
ZEPPELIN-3876. Unable to rename note
### What is this PR for?
This is trivial PR for fixing the issue of unable to rename note. The root cause is that the notePath may have 2 leading `/` which cause the error.
### What type of PR is it?
[Bug Fix]
### Todos
* [ ] - Task
### What is the Jira issue?
* https://jira.apache.org/jira/browse/ZEPPELIN-3876
### 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 <zj...@apache.org>
Closes #3234 from zjffdu/ZEPPELIN-3876 and squashes the following commits:
8fc3de83d [Jeff Zhang] ZEPPELIN-3876. Unable to rename note
Project: http://git-wip-us.apache.org/repos/asf/zeppelin/repo
Commit: http://git-wip-us.apache.org/repos/asf/zeppelin/commit/a02e8e0f
Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/a02e8e0f
Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/a02e8e0f
Branch: refs/heads/master
Commit: a02e8e0f9fde8372ff0eea0e674f72bb8be15875
Parents: dda5a14
Author: Jeff Zhang <zj...@apache.org>
Authored: Thu Nov 22 07:54:52 2018 +0800
Committer: Jeff Zhang <zj...@apache.org>
Committed: Wed Dec 5 16:42:16 2018 +0800
----------------------------------------------------------------------
.../zeppelin/service/NotebookService.java | 2 +-
.../apache/zeppelin/socket/NotebookServer.java | 7 +++++-
.../zeppelin/service/NotebookServiceTest.java | 12 +++++++---
.../notebook/repo/InMemoryNotebookRepo.java | 24 +++++++++++++++++---
4 files changed, 37 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/a02e8e0f/zeppelin-server/src/main/java/org/apache/zeppelin/service/NotebookService.java
----------------------------------------------------------------------
diff --git a/zeppelin-server/src/main/java/org/apache/zeppelin/service/NotebookService.java b/zeppelin-server/src/main/java/org/apache/zeppelin/service/NotebookService.java
index 14b8e23..d33c237 100644
--- a/zeppelin-server/src/main/java/org/apache/zeppelin/service/NotebookService.java
+++ b/zeppelin-server/src/main/java/org/apache/zeppelin/service/NotebookService.java
@@ -262,7 +262,7 @@ public class NotebookService {
Note note = notebook.getNote(noteId);
if (note != null) {
note.setCronSupported(notebook.getConf());
- if (isRelative) {
+ if (isRelative && !note.getParentPath().equals("/")) {
newNotePath = note.getParentPath() + "/" + newNotePath;
} else {
if (!newNotePath.startsWith("/")) {
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/a02e8e0f/zeppelin-server/src/main/java/org/apache/zeppelin/socket/NotebookServer.java
----------------------------------------------------------------------
diff --git a/zeppelin-server/src/main/java/org/apache/zeppelin/socket/NotebookServer.java b/zeppelin-server/src/main/java/org/apache/zeppelin/socket/NotebookServer.java
index ac167d1..a5c0290 100644
--- a/zeppelin-server/src/main/java/org/apache/zeppelin/socket/NotebookServer.java
+++ b/zeppelin-server/src/main/java/org/apache/zeppelin/socket/NotebookServer.java
@@ -408,6 +408,11 @@ public class NotebookServer extends WebSocketServlet
}
} catch (Exception e) {
LOG.error("Can't handle message: " + msg, e);
+ try {
+ conn.send(serializeMessage(new Message(OP.ERROR_INFO).put("info", e.getMessage())));
+ } catch (IOException iox) {
+ LOG.error("Fail to send error info", iox);
+ }
}
}
@@ -788,7 +793,7 @@ public class NotebookServer extends WebSocketServlet
broadcastNoteList(context.getAutheInfo(), context.getUserAndRoles());
}
});
-
+
}
private void restoreNote(NotebookSocket conn,
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/a02e8e0f/zeppelin-server/src/test/java/org/apache/zeppelin/service/NotebookServiceTest.java
----------------------------------------------------------------------
diff --git a/zeppelin-server/src/test/java/org/apache/zeppelin/service/NotebookServiceTest.java b/zeppelin-server/src/test/java/org/apache/zeppelin/service/NotebookServiceTest.java
index 9d8a735..90f3533 100644
--- a/zeppelin-server/src/test/java/org/apache/zeppelin/service/NotebookServiceTest.java
+++ b/zeppelin-server/src/test/java/org/apache/zeppelin/service/NotebookServiceTest.java
@@ -160,10 +160,16 @@ public class NotebookServiceTest {
assertEquals("/folder_3/new_name", notesInfo.get(0).getPath());
// create another note
- Note note2 = notebookService.createNote("/folder_4/note2", "test", context, callback);
+ Note note2 = notebookService.createNote("/note2", "test", context, callback);
assertEquals("note2", note2.getName());
verify(callback).onSuccess(note2, context);
+ // rename note
+ reset(callback);
+ notebookService.renameNote(note2.getId(), "new_note2", true, context, callback);
+ verify(callback).onSuccess(note2, context);
+ assertEquals("new_note2", note2.getName());
+
// list note
reset(callback);
notesInfo = notebookService.listNotesInfo(false, context, callback);
@@ -172,7 +178,7 @@ public class NotebookServiceTest {
// delete note
reset(callback);
- notebookService.removeNote(note1.getId(), context, callback);
+ notebookService.removeNote(note2.getId(), context, callback);
verify(callback).onSuccess("Delete note successfully", context);
// list note again
@@ -182,7 +188,7 @@ public class NotebookServiceTest {
verify(callback).onSuccess(notesInfo, context);
// delete folder
- notesInfo = notebookService.removeFolder("/folder_4", context, callback);
+ notesInfo = notebookService.removeFolder("/folder_3", context, callback);
verify(callback).onSuccess(notesInfo, context);
// list note again
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/a02e8e0f/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/InMemoryNotebookRepo.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/InMemoryNotebookRepo.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/InMemoryNotebookRepo.java
index 64e1f38..1793f9c 100644
--- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/InMemoryNotebookRepo.java
+++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/InMemoryNotebookRepo.java
@@ -48,6 +48,9 @@ public class InMemoryNotebookRepo implements NotebookRepo {
@Override
public Note get(String noteId, String notePath, AuthenticationInfo subject) throws IOException {
+ if (!notePath.startsWith("/")) {
+ throw new RuntimeException(String.format("notePath '%s' is not started with '/'", notePath));
+ }
return notes.get(noteId);
}
@@ -58,22 +61,37 @@ public class InMemoryNotebookRepo implements NotebookRepo {
@Override
public void move(String noteId, String notePath, String newNotePath, AuthenticationInfo subject) {
-
+ if (!newNotePath.startsWith("/")) {
+ throw new RuntimeException(String.format("newNotePath '%s' is not started with '/'", newNotePath));
+ }
+ if (newNotePath.startsWith("//")) {
+ throw new RuntimeException(String.format("newNotePath '%s' is started with '//'", newNotePath));
+ }
}
@Override
public void move(String folderPath, String newFolderPath, AuthenticationInfo subject) {
-
+ if (!newFolderPath.startsWith("/")) {
+ throw new RuntimeException(String.format("newFolderPath '%s' is not started with '/'", newFolderPath));
+ }
+ if (newFolderPath.startsWith("//")) {
+ throw new RuntimeException(String.format("newFolderPath '%s' is started with '//'", newFolderPath));
+ }
}
@Override
public void remove(String noteId, String notePath, AuthenticationInfo subject) throws IOException {
+ if (!notePath.startsWith("/")) {
+ throw new RuntimeException(String.format("notePath '%s' is not started with '/'", notePath));
+ }
notes.remove(noteId);
}
@Override
public void remove(String folderPath, AuthenticationInfo subject) {
-
+ if (!folderPath.startsWith("/")) {
+ throw new RuntimeException(String.format("folderPath '%s' is not started with '/'", folderPath));
+ }
}
@Override