user profile info
I am trying to fetch user info in my portlet (JSR 286 portlet deployed in JBoss GateIn) like
Map userInfo = (Map) request.getAttribute(PortletRequest.USER_INFO);
but I get nothing back. My portlet.xml has following params:
<user-attribute>
<description>User Name</description>
<name>user.name</name>
</user-attribute>
<user-attribute>
<description>User Id</description>
开发者_Go百科 <name>user.id</name>
</user-attribute>
GateIn provides PortalRequestContext which gives getRemoteUser() method to get logged in user's id. This id can then be used by OrganizationService to get User but thats all GateIn specific and not as per JSR286 standard. JSR 286 states that user related attributes can be fetched from PortletRequest.USER_INFO as mentioned above. Please guide.
Thanks in advance!
Ps: Similar post on JBoss community http://community.jboss.org/message/425683#425683
your name ids are different, according to the spec it is something like,
<user-attribute>
<description>User Given Name</description>
<name>user.name.given</name>
</user-attribute>
<user-attribute>
<description>User Last Name</description>
<name>user.name.family</name>
</user-attribute>
<user-attribute>
<description>User eMail</description>
<name>user.business-info.online.email</name>
</user-attribute>
below are more(just part of it)..you can get the full list from jsr286 spec
user.gender
user.employer
user.department
user.jobtitle
user.name.prefix
user.name.given
user.name.family
user.name.middle
user.name.suffix
user.name.nickName
user.login.id
user.home-info.postal.name
user.home-info.postal.street
user.home-info.postal.city
user.home-info.postal.stateprov
user.home-info.postal.postalcode
user.home-info.postal.country
user.home-info.postal.organization
user.home-info.telecom.telephone.intcode
user.home-info.telecom.telephone.loccode
user.home-info.telecom.telephone.number
user.home-info.telecom.telephone.ext
user.home-info.telecom.telephone.comment
user.home-info.telecom.fax.intcode
user.home-info.telecom.fax.loccode
user.home-info.telecom.fax.number
SPList userInformationList = web.SiteUserInfoList;
SPUser user = web.EnsureUser(web.CurrentUser.Name);
// The actual User Information is within this SPListItem
SPListItem userItem = userInformationList.Items.GetItemById(user.ID);
if (userItem["EMail"] != null)
email = userItem["EMail"].ToString();
精彩评论