Example #1
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;
 }
Example #2
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);
  }