private static final String ROLE_TYPE_VALUE = "role";
public Map<String, Object> getUserById(String userId) throws DotDataException,DotSecurityException {
UserWebAPI uWebAPI = WebAPILocator.getUserWebAPI();
UserProxyAPI uProxyWebAPI = APILocator.getUserProxyAPI();
WebContext ctx = WebContextFactory.get();
HttpServletRequest request = ctx.getHttpServletRequest();
UserAPI uAPI = APILocator.getUserAPI();
User user = null;
try {
// lock down to users with access to Users portlet
User loggedInUser=uWebAPI.getLoggedInUser(request);
if(loggedInUser==null || !APILocator.getPortletAPI().hasUserAdminRights(loggedInUser)) {
SecurityLogger.logInfo(UserAjax.class, "unauthorized attempt to call getUserById by user "+loggedInUser!=null?loggedInUser.getUserId():"[not logged in]");
throw new DotSecurityException("not authorized");
}
user = uAPI.loadUserById(userId,uWebAPI.getSystemUser(), !uWebAPI.isLoggedToBackend(request));
Map<String, Object> aRecord = user.toMap();
aRecord.put("id", user.getUserId());
aRecord.put("type", USER_TYPE_VALUE);
aRecord.put("name", user.getFullName());
aRecord.put("firstName", user.getFirstName());
aRecord.put("lastName", user.getLastName());
aRecord.put("emailaddress", user.getEmailAddress());
UserProxy up = uProxyWebAPI.getUserProxy(user, uWebAPI.getSystemUser(), !uWebAPI.isLoggedToBackend(request));
aRecord.putAll(up.getMap());
return aRecord;
} catch (Exception e) {