// Get /rest/users public HttpHeaders index() { if (searchTerm == null) { users = usersService.getAll(); } else { users = usersService.getAllBySearchTerm(searchTerm); } model = users; return httpHeaders.withStatus(200); }
// DELETE /rest/users/{id} public HttpHeaders destroy() { user = new User(); user.setId(Long.parseLong(id)); usersService.delete(user); model = user; return httpHeaders.withStatus(200); }
// GET /rest/users/{id}/friends public HttpHeaders friends() { user = usersService.get(Long.parseLong(id)); friends = friendsService.getAllByUser(user); model = friends; return httpHeaders.withStatus(200); }
// PUT /rest/users/{id} public HttpHeaders update() { user.setId(Long.parseLong(id)); usersService.update(user); model = user; return httpHeaders.withStatus(200); }
// GET /rest/users/{id} public HttpHeaders show() { user = usersService.get(Long.parseLong(id)); user.setPassword(""); model = user; return httpHeaders.withStatus(200); }
// POST /rest/users public HttpHeaders create() throws IOException { usersService.save((User) model); model = user; return httpHeaders.withStatus(200); }