JBoss.orgCommunity Documentation
The SocailContactProvider class gets users' profiles by userId via the IdentityManager class.
public CommonContact getCommonContact(String userId) {
CommonContact contact = new CommonContact();
try {
IdentityManager identityM = (IdentityManager) PortalContainer.getInstance().getComponentInstanceOfType(IdentityManager.class);
Identity userIdentity = identityM.getIdentity(OrganizationIdentityProvider.NAME, userId, true);
Profile profile = userIdentity.getProfile();
if (profile.contains(Profile.EMAIL)) {
contact.setEmailAddress(profile.getProperty(Profile.EMAIL).toString());
}
if (profile.contains(Profile.FIRST_NAME)) {
contact.setFirstName(profile.getProperty(Profile.FIRST_NAME).toString());
}
if (profile.contains(Profile.LAST_NAME)) {
contact.setLastName(profile.getProperty(Profile.LAST_NAME).toString());
}
contact.setAvatarUrl(profile.getAvatarImageSource());
if (profile.contains(Profile.GENDER)) {
contact.setGender(profile.getProperty(Profile.GENDER).toString());
}
if (profile.contains(Profile.CONTACT_PHONES)) {
contact.setPhone(profile.getProperty(Profile.CONTACT_PHONES).toString());
}
if (profile.contains(Profile.URL)) {
contact.setWebSite(profile.getProperty(Profile.URL).toString());
}
} catch (Exception e) {
if (LOG.isErrorEnabled()) LOG.error(String.format("can not load contact from eXo Social Profile with user [%s]", userId), e);
}
return contact;
}