NotebookRestApi extends AbstractRestApi { @PUT @Path("{noteId}/clear") @ZeppelinApi public Response clearAllParagraphOutput(@PathParam("noteId") String noteId) throws IOException { LOGGER.info("Clear all paragraph output of note {}", noteId); notebookService.clearAllParagraphOutput(noteId, getServiceContext(), new RestServiceCallback<>()); return new JsonResponse(Status.OK, "").build(); } @Inject  NotebookRestApi(
      Notebook notebook,
      NotebookServer notebookServer,
      NotebookService notebookService,
      SearchService search,
      AuthorizationService authorizationService,
      ZeppelinConfiguration zConf,
      AuthenticationService authenticationService,
      JobManagerService jobManagerService,
      SchedulerService schedulerService); @GET @Path("{noteId}/permissions") @ZeppelinApi Response getNotePermissions(@PathParam("noteId") String noteId); @PUT @Path("{noteId}/permissions") @ZeppelinApi Response putNotePermissions(@PathParam("noteId") String noteId, String req); @GET @ZeppelinApi Response getNoteList(); @GET @Path("{noteId}") @ZeppelinApi Response getNote(@PathParam("noteId") String noteId); @GET @Path("export/{noteId}") @ZeppelinApi Response exportNote(@PathParam("noteId") String noteId); @POST @Path("import") @ZeppelinApi Response importNote(@QueryParam("notePath") String notePath, String noteJson); @POST @ZeppelinApi Response createNote(String message); @DELETE @Path("{noteId}") @ZeppelinApi Response deleteNote(@PathParam("noteId") String noteId); @POST @Path("{noteId}") @ZeppelinApi Response cloneNote(@PathParam("noteId") String noteId, String message); @PUT @Path("{noteId}/rename") @ZeppelinApi Response renameNote(@PathParam("noteId") String noteId,
                             String message); @POST @Path("{noteId}/paragraph") @ZeppelinApi Response insertParagraph(@PathParam("noteId") String noteId, String message); @GET @Path("{noteId}/paragraph/{paragraphId}") @ZeppelinApi Response getParagraph(@PathParam("noteId") String noteId,
                               @PathParam("paragraphId") String paragraphId); @PUT @Path("{noteId}/paragraph/{paragraphId}") @ZeppelinApi Response updateParagraph(@PathParam("noteId") String noteId,
                                  @PathParam("paragraphId") String paragraphId,
                                  String message); @PUT @Path("{noteId}/paragraph/{paragraphId}/config") @ZeppelinApi Response updateParagraphConfig(@PathParam("noteId") String noteId,
                                        @PathParam("paragraphId") String paragraphId,
                                        String message); @POST @Path("{noteId}/paragraph/{paragraphId}/move/{newIndex}") @ZeppelinApi Response moveParagraph(@PathParam("noteId") String noteId,
                                @PathParam("paragraphId") String paragraphId,
                                @PathParam("newIndex") String newIndex); @DELETE @Path("{noteId}/paragraph/{paragraphId}") @ZeppelinApi Response deleteParagraph(@PathParam("noteId") String noteId,
                                  @PathParam("paragraphId") String paragraphId); @POST @Path("{noteId}/paragraph/next") Response nextSessionParagraph(@PathParam("noteId") String noteId,
                                       @QueryParam("maxParagraph") int maxParagraph); @PUT @Path("{noteId}/clear") @ZeppelinApi Response clearAllParagraphOutput(@PathParam("noteId") String noteId); @POST @Path("job/{noteId}") @ZeppelinApi Response runNoteJobs(@PathParam("noteId") String noteId,
                              @QueryParam("blocking") Boolean blocking,
                              @QueryParam("isolated") Boolean isolated,
                              String message); @DELETE @Path("job/{noteId}") @ZeppelinApi Response stopNoteJobs(@PathParam("noteId") String noteId); @GET @Path("job/{noteId}") @ZeppelinApi Response getNoteJobStatus(@PathParam("noteId") String noteId); @GET @Path("job/{noteId}/{paragraphId}") @ZeppelinApi Response getNoteParagraphJobStatus(@PathParam("noteId") String noteId,
                                            @PathParam("paragraphId") String paragraphId); @POST @Path("job/{noteId}/{paragraphId}") @ZeppelinApi Response runParagraph(@PathParam("noteId") String noteId,
                               @PathParam("paragraphId") String paragraphId,
                               @QueryParam("sessionId") String sessionId,
                               String message); @POST @Path("run/{noteId}/{paragraphId}") @ZeppelinApi Response runParagraphSynchronously(@PathParam("noteId") String noteId,
                                            @PathParam("paragraphId") String paragraphId,
                                            @QueryParam("sessionId") String sessionId,
                                            String message); @DELETE @Path("job/{noteId}/{paragraphId}") @ZeppelinApi Response cancelParagraph(@PathParam("noteId") String noteId,
                                  @PathParam("paragraphId") String paragraphId); @POST @Path("cron/{noteId}") @ZeppelinApi Response registerCronJob(@PathParam("noteId") String noteId, String message); @DELETE @Path("cron/{noteId}") @ZeppelinApi Response removeCronJob(@PathParam("noteId") String noteId); @GET @Path("cron/{noteId}") @ZeppelinApi Response getCronJob(@PathParam("noteId") String noteId); @GET @Path("jobmanager/") @ZeppelinApi Response getJobListforNote(); @GET @Path("jobmanager/{lastUpdateUnixtime}/") @ZeppelinApi Response getUpdatedJobListforNote(@PathParam("lastUpdateUnixtime") long lastUpdateUnixTime); @GET @Path("search") @ZeppelinApi Response search(@QueryParam("q") String queryTerm);  }
@Test public void testClearAllParagraphOutput() throws IOException { LOG.info("Running testClearAllParagraphOutput"); Note note = null; try { note = TestUtils.getInstance(Notebook.class).createNote("note1", anonymous); Paragraph p1 = note.addNewParagraph(AuthenticationInfo.ANONYMOUS); InterpreterResult result = new InterpreterResult(InterpreterResult.Code.SUCCESS, InterpreterResult.Type.TEXT, "result"); p1.setResult(result); Paragraph p2 = note.addNewParagraph(AuthenticationInfo.ANONYMOUS); p2.setReturn(result, new Throwable()); PutMethod put = httpPut("/notebook/" + note.getId() + "/clear", ""); LOG.info("test clear paragraph output response\n" + put.getResponseBodyAsString()); assertThat(put, isAllowed()); put.releaseConnection(); GetMethod get = httpGet("/notebook/" + note.getId() + "/paragraph/" + p1.getId()); assertThat(get, isAllowed()); Map<String, Object> resp1 = gson.fromJson(get.getResponseBodyAsString(), new TypeToken<Map<String, Object>>() {}.getType()); Map<String, Object> resp1Body = (Map<String, Object>) resp1.get("body"); assertNull(resp1Body.get("result")); get = httpGet("/notebook/" + note.getId() + "/paragraph/" + p2.getId()); assertThat(get, isAllowed()); Map<String, Object> resp2 = gson.fromJson(get.getResponseBodyAsString(), new TypeToken<Map<String, Object>>() {}.getType()); Map<String, Object> resp2Body = (Map<String, Object>) resp2.get("body"); assertNull(resp2Body.get("result")); get.releaseConnection(); } finally { if (null != note) { TestUtils.getInstance(Notebook.class).removeNote(note, anonymous); } } }