@Override public void handleGet(ActionParameters params) throws ActionException { log.info("handleGet"); final JSONObject response; long id = getId(params); try { if (id > -1) { log.info("handleGet: has id"); User user = userService.getUser(id); response = user2Json(user); } else { log.info("handleGet: no id"); List<User> users = userService.getUsers(); log.info("found: " + users.size() + "users"); response = new JSONObject(); JSONArray arr = new JSONArray(); response.put("users", arr); List<User> newUsers = userService.getUsersWithRoles(); for (User user : newUsers) { arr.put(user2Json(user)); } } } catch (ServiceException se) { throw new ActionException(se.getMessage(), se); } catch (JSONException je) { throw new ActionException(je.getMessage(), je); } log.info(response); ResponseHelper.writeResponse(params, response); }