NotebookRestApi extends AbstractRestApi { @PUT @Path("{noteId}/rename") @ZeppelinApi public Response renameNote(@PathParam("noteId") String noteId, String message) throws IOException { LOGGER.info("Rename note by JSON {}", message); RenameNoteRequest request = GSON.fromJson(message, RenameNoteRequest.class); String newName = request.getName(); if (newName.isEmpty()) { LOGGER.warn("Trying to rename notebook {} with empty name parameter", noteId); throw new BadRequestException("name can not be empty"); } notebookService.renameNote(noteId, request.getName(), false, getServiceContext(), new RestServiceCallback<Note>() { @Override public void onSuccess(Note note, ServiceContext context) throws IOException { notebookServer.broadcastNote(note); notebookServer.broadcastNoteList(context.getAutheInfo(), context.getUserAndRoles()); } }); 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 testRenameNote() throws IOException { LOG.info("Running testRenameNote"); Note note = null; try { String oldName = "old_name"; note = TestUtils.getInstance(Notebook.class).createNote(oldName, anonymous); assertEquals(note.getName(), oldName); String noteId = note.getId(); final String newName = "testName"; String jsonRequest = "{\"name\": " + newName + "}"; PutMethod put = httpPut("/notebook/" + noteId + "/rename/", jsonRequest); assertThat("test testRenameNote:", put, isAllowed()); put.releaseConnection(); assertEquals(note.getName(), newName); } finally { if (null != note) { TestUtils.getInstance(Notebook.class).removeNote(note, anonymous); } } }