@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; }
private User getUser(Long id) { for (User user : userDao.getAll()) if (user.getId().equals(id)) return user; throw new WebApplicationException(Response.Status.NOT_FOUND); }