@Override public JsonElement view(User user, JsonBuilder ctx) { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("id", user.getExternalId()); jsonObject.addProperty("username", user.getUsername()); jsonObject.addProperty("name", user.getPresentationName()); jsonObject.addProperty("active", !user.isLoginExpired()); LocalDate expiration = user.getExpiration(); if (expiration != null) { jsonObject.addProperty("expiration", ISODateTimeFormat.date().print(expiration)); } UserProfile profile = user.getProfile(); //FIXME: remove on the next major when profile is mandatory if (profile != null) { JsonUtils.put(jsonObject, "givenNames", profile.getGivenNames()); JsonUtils.put(jsonObject, "familyNames", profile.getFamilyNames()); JsonUtils.put(jsonObject, "displayName", profile.getDisplayName()); JsonUtils.put(jsonObject, "avatar", profile.getAvatarUrl()); } JsonUtils.put(jsonObject, "email", user.getEmail()); JsonUtils.put(jsonObject, "preferredLocale", ctx.view(user.getPreferredLocale())); return jsonObject; }