Пример #1
0
 @POST
 @Consumes("application/json")
 @Produces("application/json")
 public Response saveUser(User user) {
   UserResponse response = new UserResponse();
   response.message = dao.saveUser(user);
   return Response.status(201).entity(response).build();
 }
Пример #2
0
 @GET
 @Path("/{id}")
 @Produces("application/json")
 public Response getUser(@PathParam("id") String id) {
   User user = dao.findUserById(id);
   if (user == null) {
     return Response.status(404).build();
   }
   return Response.ok(user).build();
 }
Пример #3
0
 @DELETE
 @Path("/{id}")
 public Response deleteUser(@PathParam("id") String id) {
   dao.deleteUserById(id);
   return Response.noContent().build();
 }
Пример #4
0
 @PUT
 @Consumes("application/json")
 public Response updateUser(User user) {
   dao.updateUser(user);
   return Response.noContent().build();
 }
Пример #5
0
 @GET
 @Produces("application/json")
 public Set<String> allUserIds() {
   return dao.getAllUserIds();
 }