zeppelin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m...@apache.org
Subject zeppelin git commit: [ZEPPELIN-2722]. Use Note.toJson and fromJson in ZeppelinHubRepo
Date Fri, 07 Jul 2017 04:51:23 GMT
Repository: zeppelin
Updated Branches:
  refs/heads/master 155a55b56 -> c3e908e61


[ZEPPELIN-2722]. Use Note.toJson and fromJson in ZeppelinHubRepo

### What is this PR for?
It's a following up of ZEPPELIN-2397. Otherwise ZeppelinHubRepo can not load/save note properly

### What type of PR is it?
[Bug Fix | Refactoring]

### Todos
* [ ] - Task

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

### How should this be tested?
Outline the steps to test the PR here.

### 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 <zjffdu@apache.org>

Closes #2464 from zjffdu/ZEPPELIN-2722 and squashes the following commits:

f9b2d56 [Jeff Zhang] ZEPPELIN-2722. Use Note.toJson and fromJson in ZeppelinHubRepo


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

Branch: refs/heads/master
Commit: c3e908e613eceeff5f3d7b85466ca734d3a42846
Parents: 155a55b
Author: Jeff Zhang <zjffdu@apache.org>
Authored: Wed Jul 5 17:18:42 2017 +0800
Committer: Lee moon soo <moon@apache.org>
Committed: Fri Jul 7 13:51:18 2017 +0900

----------------------------------------------------------------------
 .../main/java/org/apache/zeppelin/socket/NotebookServer.java   | 3 +++
 .../src/main/java/org/apache/zeppelin/notebook/Note.java       | 1 +
 .../zeppelin/notebook/repo/zeppelinhub/ZeppelinHubRepo.java    | 6 +++---
 3 files changed, 7 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zeppelin/blob/c3e908e6/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 9a4ed7a..c3b18e0 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
@@ -57,6 +57,7 @@ import org.apache.zeppelin.notebook.Note;
 import org.apache.zeppelin.notebook.Notebook;
 import org.apache.zeppelin.notebook.NotebookAuthorization;
 import org.apache.zeppelin.notebook.NotebookEventListener;
+import org.apache.zeppelin.notebook.NotebookImportDeserializer;
 import org.apache.zeppelin.notebook.Paragraph;
 import org.apache.zeppelin.notebook.ParagraphJobListener;
 import org.apache.zeppelin.notebook.ParagraphRuntimeInfo;
@@ -129,6 +130,8 @@ public class NotebookServer extends WebSocketServlet
           }
         }
       }).setDateFormat("yyyy-MM-dd'T'HH:mm:ssZ")
+      .registerTypeAdapter(Date.class, new NotebookImportDeserializer())
+      .setPrettyPrinting()
       .registerTypeAdapterFactory(Input.TypeAdapterFactory).create();
 
   final Map<String, List<NotebookSocket>> noteSocketMap = new HashMap<>();

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/c3e908e6/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 ff915a3..ecbd4da 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
@@ -76,6 +76,7 @@ public class Note implements ParagraphJobListener, JsonSerializable {
         }
       }).setDateFormat("yyyy-MM-dd HH:mm:ss.SSS")
       .registerTypeAdapter(Date.class, new NotebookImportDeserializer())
+      .setPrettyPrinting()
       .registerTypeAdapterFactory(Input.TypeAdapterFactory).create();
 
   // threadpool for delayed persist of note

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/c3e908e6/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/zeppelinhub/ZeppelinHubRepo.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/zeppelinhub/ZeppelinHubRepo.java
b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/zeppelinhub/ZeppelinHubRepo.java
index cd94180..89c1dd1 100644
--- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/zeppelinhub/ZeppelinHubRepo.java
+++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/zeppelinhub/ZeppelinHubRepo.java
@@ -186,7 +186,7 @@ public class ZeppelinHubRepo implements NotebookRepo {
     }
     String token = getUserToken(subject.getUser());
     String response = restApiClient.get(token, noteId);
-    Note note = GSON.fromJson(response, Note.class);
+    Note note = Note.fromJson(response);
     if (note == null) {
       return EMPTY_NOTE;
     }
@@ -199,7 +199,7 @@ public class ZeppelinHubRepo implements NotebookRepo {
     if (note == null || !isSubjectValid(subject)) {
       throw new IOException("Zeppelinhub failed to save note");
     }
-    String jsonNote = GSON.toJson(note);
+    String jsonNote = note.toJson();
     String token = getUserToken(subject.getUser());
     LOG.info("ZeppelinHub REST API saving note {} ", note.getId());
     restApiClient.put(token, jsonNote);
@@ -245,7 +245,7 @@ public class ZeppelinHubRepo implements NotebookRepo {
     String token = getUserToken(subject.getUser());
     String response = restApiClient.get(token, endpoint);
 
-    Note note = GSON.fromJson(response, Note.class);
+    Note note = Note.fromJson(response);
     if (note == null) {
       return EMPTY_NOTE;
     }


Mime
View raw message