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 2021/03/15 05:12:20 UTC
[zeppelin] branch master updated: [ZEPPELIN-5227] User can choose
whether add empty paragraph when calling create note http api
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 304c3a9 [ZEPPELIN-5227] User can choose whether add empty paragraph when calling create note http api
304c3a9 is described below
commit 304c3a9e09ccdb09405570b518acf039ffc4a47b
Author: Bowen0729 <bo...@qq.com>
AuthorDate: Thu Mar 11 18:43:31 2021 +0800
[ZEPPELIN-5227] User can choose whether add empty paragraph when calling create note http api
### What is this PR for?
When I call create note http api on zeppelin-0.9.0, a empty note without any paragraph was created, but I can't add paragraph on the note with zeppelin ui(https://issues.apache.org/jira/browse/ZEPPELIN-5227), so I put the "addingEmptyParagraph" parameter to the api message, user can add a empty paragraph when call create note http api, and won't add a empty paragraph for default.
### What type of PR is it?
Improvement
### Todos
* [ ] - Task
### What is the Jira issue?
https://issues.apache.org/jira/browse/ZEPPELIN-5227
### How should this be tested?
CI
Unit Test
### 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: Bowen0729 <bo...@qq.com>
Closes #4066 from Bowen0729/ZEPPELIN-5227 and squashes the following commits:
6221bbf96 [Bowen0729] [ZEPPELIN-5227] User can choose whether add empty paragraph when calling create note http api
---
.../org/apache/zeppelin/rest/NotebookRestApi.java | 2 +-
.../zeppelin/rest/message/NewNoteRequest.java | 5 ++++
.../apache/zeppelin/rest/NotebookRestApiTest.java | 32 ++++++++++++++++++++++
3 files changed, 38 insertions(+), 1 deletion(-)
diff --git a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/NotebookRestApi.java b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/NotebookRestApi.java
index c5a3db4..caddc20 100644
--- a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/NotebookRestApi.java
+++ b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/NotebookRestApi.java
@@ -392,7 +392,7 @@ public class NotebookRestApi extends AbstractRestApi {
Note note = notebookService.createNote(
request.getName(),
defaultInterpreterGroup,
- false,
+ request.getAddingEmptyParagraph(),
getServiceContext(),
new RestServiceCallback<>());
AuthenticationInfo subject = new AuthenticationInfo(authenticationService.getPrincipal());
diff --git a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/NewNoteRequest.java b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/NewNoteRequest.java
index 7d6a3a6..85744dc 100644
--- a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/NewNoteRequest.java
+++ b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/NewNoteRequest.java
@@ -31,11 +31,16 @@ public class NewNoteRequest implements JsonSerializable {
//TODO(zjffdu) rename it to be notePath instead of name
private String name;
private String defaultInterpreterGroup;
+ private boolean addingEmptyParagraph = false;
private List<NewParagraphRequest> paragraphs;
public NewNoteRequest (){
}
+ public boolean getAddingEmptyParagraph() {
+ return addingEmptyParagraph;
+ }
+
public String getName() {
return name;
}
diff --git a/zeppelin-server/src/test/java/org/apache/zeppelin/rest/NotebookRestApiTest.java b/zeppelin-server/src/test/java/org/apache/zeppelin/rest/NotebookRestApiTest.java
index 214ba7b..60f8643 100644
--- a/zeppelin-server/src/test/java/org/apache/zeppelin/rest/NotebookRestApiTest.java
+++ b/zeppelin-server/src/test/java/org/apache/zeppelin/rest/NotebookRestApiTest.java
@@ -202,6 +202,38 @@ public class NotebookRestApiTest extends AbstractTestRestApi {
}
@Test
+ public void testCreateNote() throws Exception {
+ LOG.info("Running testCreateNote");
+ String message1 = "{\n\t\"name\" : \"test1\",\n\t\"addingEmptyParagraph\" : true\n}";
+ CloseableHttpResponse post1 = httpPost("/notebook/", message1);
+ assertThat(post1, isAllowed());
+
+ Map<String, Object> resp1 = gson.fromJson(EntityUtils.toString(post1.getEntity(), StandardCharsets.UTF_8),
+ new TypeToken<Map<String, Object>>() {}.getType());
+ assertEquals("OK", resp1.get("status"));
+
+ String noteId1 = (String) resp1.get("body");
+ Note note1 = TestUtils.getInstance(Notebook.class).getNote(noteId1);
+ assertEquals("test1", note1.getName());
+ assertEquals(1, note1.getParagraphCount());
+ assertNull(note1.getParagraph(0).getText());
+ assertNull(note1.getParagraph(0).getTitle());
+
+ String message2 = "{\n\t\"name\" : \"test2\"\n}";
+ CloseableHttpResponse post2 = httpPost("/notebook/", message2);
+ assertThat(post2, isAllowed());
+
+ Map<String, Object> resp2 = gson.fromJson(EntityUtils.toString(post2.getEntity(), StandardCharsets.UTF_8),
+ new TypeToken<Map<String, Object>>() {}.getType());
+ assertEquals("OK", resp2.get("status"));
+
+ String noteId2 = (String) resp2.get("body");
+ Note note2 = TestUtils.getInstance(Notebook.class).getNote(noteId2);
+ assertEquals("test2", note2.getName());
+ assertEquals(0, note2.getParagraphCount());
+ }
+
+ @Test
public void testRunNoteBlocking() throws IOException {
LOG.info("Running testRunNoteBlocking");
Note note1 = null;