public static JSONObject getUserJson(String uid, String contextPath) throws JSONException {
JSONObject obj = new JSONObject();
obj.put("login", uid); //$NON-NLS-1$
try {
User user = userAdmin.getUser(UserConstants.KEY_UID, uid);
if (user == null) {
return null;
}
// try to add the login timestamp to the user info
IOrionUserProfileNode generalUserProfile = LdapAuthenticationService.getUserProfileService().getUserProfileNode(uid, IOrionUserProfileConstants.GENERAL_PROFILE_PART);
obj.put(UserConstants.KEY_UID, uid);
obj.put(UserConstants.KEY_LOGIN, user.getLogin());
obj.put("Location", contextPath + user.getLocation());
obj.put("Name", user.getName());
if (generalUserProfile.get(IOrionUserProfileConstants.LAST_LOGIN_TIMESTAMP, null) != null) {
Long lastLogin = Long.parseLong(generalUserProfile.get(IOrionUserProfileConstants.LAST_LOGIN_TIMESTAMP, ""));
obj.put(IOrionUserProfileConstants.LAST_LOGIN_TIMESTAMP, lastLogin);
}