@GET @Path("{id}") @Produces(MediaType.APPLICATION_JSON) public User get(@PathParam("id") String id) throws ApplicationException { System.out.println("GET get : " + id); return userBean.getUser(id); }
@POST @Path("/update") @Consumes(MediaType.APPLICATION_JSON) public String update(User data) throws ApplicationException { System.out.println("POST update : " + data); userBean.updateUser(data); return "Updated User"; }
@POST @Path("/add") @Consumes(MediaType.APPLICATION_JSON) public String add(User data) throws ApplicationException { System.out.println("POST add : " + data); userBean.addUser(data); return "Added User"; }
@DELETE @Path("{id}") public String delete(@PathParam("id") String id) { try { userBean.deleteUser(id); return "Removed User with id : " + id; } catch (Exception e) { System.err.println("[UserResource] error"); return "Error removing User with id : " + id; } }
@GET @Path("/list") @Produces(MediaType.APPLICATION_JSON) public List<User> getAll() throws ApplicationException { return userBean.getAllUsers(); }