@PUT @Path("/edit/{id}") @Consumes(MediaType.APPLICATION_JSON) public void editNote(String inputData, @PathParam("id") int id) { JSONObject inputJSON = new JSONObject(inputData); if ((inputJSON.has("sessionID")) && UsersController.checkLogin(inputJSON.getString("sessionID"))) { Note newNote = resolveNoteData(inputJSON); if (inputJSON.has("noteID")) inputJSON.remove("noteID"); // na wszelki wypadek - ID podano hibernate.controllers.NotesController notesController = new hibernate.controllers.NotesController(); if (newNote != null) notesController.updateNote(newNote, id); } }
@POST @Path("/create") @Consumes(MediaType.APPLICATION_JSON) public void createNote(String inputData) { JSONObject inputJSON = new JSONObject(inputData); if ((inputJSON.has("sessionID")) && UsersController.checkLogin(inputJSON.getString("sessionID"))) { if (inputJSON.has("noteID")) inputJSON.remove("noteID"); // na wszelki wypadek - chcemy generowaƦ ID automatycznie Note newNote = resolveNoteData(inputJSON); hibernate.controllers.NotesController notesController = new hibernate.controllers.NotesController(); if (newNote != null) notesController.addNote(newNote); } }