public Response getUsers(@SecurityCheck(Role.ADMIN) User user) {
Map<Long, UserModel> users = Maps.newHashMap();
for (UserRole role : userRoleDAO.findAll()) {
User u = role.getUser();
Long key = u.getId();
UserModel userModel = users.get(key);
if (userModel == null) {
userModel = new UserModel();
userModel.setId(u.getId());
userModel.setName(u.getName());
userModel.setEmail(u.getEmail());
userModel.setEnabled(!u.isDisabled());
userModel.setCreated(u.getCreated());
userModel.setLastLogin(u.getLastLogin());
users.put(key, userModel);
}
if (role.getRole() == Role.ADMIN) {
userModel.setAdmin(true);
}
}
return Response.ok(users.values()).build();
}