Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

How to fetch role of a logged in user

 Hi,
From my server side rtc extension plugin I need to fetch the role of a logged in user. Please let me know how to do it...


0 votes


Accepted answer

Permanent link
I use this method to GET the users roles in a project area.
it is deprecated, and I haven't found what the replacement is yet.

com.ibm.team.process.internal.common.RolePersistence.getPersistentRoleData(IProkectArea.getTeamData(), IContrinutorHandle srcuser)

note that a user might have multiple roles.
Chandan M B selected this answer as the correct answer

0 votes

Comments

Hi Sam,
Thank you.
One more question, how to fetch details of Approval tab.
Do you have any sample snippet?

Regards,
Chandan

IApprovals =  IWorkItem.getApprovals()

see the javadoc that is provided as part of the product downloads

Thanks for the Approval code.
But i feel role of a logged in user, i am not able to fetch from the server extensions plugin.
How to do it... ?

I used the code from my server participant plugin, built on Ralph's

I showed you the types, not the exact code..

I am not aware of any role restriction that would prevent you from reading the approvals from a workitem.

the newstate is a workitem, so, once you cast, then you should be able to use the getApprovals() method.

here are the two exact statements

            // Get the full state of the parent work item so we can edit it
            IWorkItem workingCopy = (IWorkItem) fWorkItemServer.getAuditableCommon().resolveAuditable(workItem, IWorkItem.FULL_PROFILE, monitor).getWorkingCopy();
   
            IApprovals approvals = workingCopy.getApprovals();

I am able to fetch approval details.

I need to fetch the roles of logged-in alm user. I am not able to achieve it.
I need a snippet to fetch user role for a project Area.

the AbstractService your plugin extends, provides a method,
getAuthenticatedContributor(), which returns the current Contributor (aka  user ) handle

which you can then use on the prior RolePersistance method

Consider reading some of the links provided below. They show the API that you can use to get the roles of a user. The API is common and can be used on client as well as server. Especially read https://rsjazz.wordpress.com/2015/06/19/a-custom-condition-to-make-attributes-required-or-read-only-by-role/

showing 5 of 7 show 2 more comments

One other answer

Permanent link
 Also see https://rsjazz.wordpress.com/2015/06/19/a-custom-condition-to-make-attributes-required-or-read-only-by-role/ for how to do that.

0 votes

Comments

also see https://rsjazz.wordpress.com/2012/10/01/adding-approvals-to-work-items-using-the-plain-java-client-libraries/ and https://rsjazz.wordpress.com/2012/11/30/a-create-approval-work-item-save-participant/ for how to use the approval API.

Your answer

Register or log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,952
× 411

Question asked: Jun 20 '15, 12:24 p.m.

Question was seen: 5,182 times

Last updated: Jun 22 '15, 9:09 a.m.

Confirmation Cancel Confirm