Exemplo n.º 1
0
  @DELETE
  @Path("users/{id}")
  public void deleteUserById(@PathParam("id") Long id) {
    User user = getUserById(id);

    userDao.deleteUser(user);
  }
Exemplo n.º 2
0
 @POST
 @Path("users")
 public void createUser(
     @FormParam("fname") String fname,
     @FormParam("lname") String lname,
     @FormParam("id") Long id) {
   User user = new User(fname, lname, id);
   userDao.createUser(user);
 }
Exemplo n.º 3
0
 @GET
 @Path("users")
 // JSON: include "application/json" in the @Produces annotation to include json support
 @Produces({"application/json"})
 // @Produces({ "application/xml" })
 public Map<String, List<User>> getUsersMap() {
   Map<String, List<User>> result = new HashMap<String, List<User>>();
   result.put("users", userDao.getAll());
   return result;
 }
Exemplo n.º 4
0
  private User getUser(Long id) {
    for (User user : userDao.getAll()) if (user.getId().equals(id)) return user;

    throw new WebApplicationException(Response.Status.NOT_FOUND);
  }