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

Add Subscriber to a Work item from JAVA API.

Hi All,

I am trying to add a Subscriber through java API. I am succeeded partially. My code snippet is as follows.


IContributorHandle user = SourceWI.getCreator();
System.out.println(user.toString());
SourceWI.getSubscriptions().add(user);


But My requirement is that how to pass User Id of my own..
Ofcoourse, i will pass the User ID which is existing in the repository.

Thanks

0 votes


Accepted answer

Permanent link
Hi All,

I am trying to add a Subscriber through java API. I am succeeded partially. My code snippet is as follows.
IContributorHandle user = SourceWI.getCreator();
System.out.println(user.toString());
SourceWI.getSubscriptions().add(user);


But My requirement is that how to pass User Id of my own..
Of course, i will pass the User ID which is existing in the repository.

Thanks


On the client side, there is IContributorManager.fetchContributorByUserId(String userId, IProgressMonitor monitor). You can get the contributor manager from the repository with ITeamRepository.contributorManager().

On the server side, there is IContributorService.fetchContributorByUserId(String userId) which returns an IContributorHandle.  If your code is in a service, you can add a dependency on IContributorService and use IAbstractScmService#getService to get it.  Otherwise you might be able to use OsgiServicesManager.INSTANCE.getService.
Muthukumar C selected this answer as the correct answer

0 votes


3 other answers

Permanent link
Hi,

I think your code is for Client side. I want to implement this as Server side plugin code.

Thanks

Hi All,

I am trying to add a Subscriber through java API. I am succeeded partially. My code snippet is as follows.


IContributorHandle user = SourceWI.getCreator();
System.out.println(user.toString());
SourceWI.getSubscriptions().add(user);


But My requirement is that how to pass User Id of my own..
Ofcoourse, i will pass the User ID which is existing in the repository.

Thanks


There is IContributorManager.fetchContributorByUserId(String userId, IProgressMonitor monitor). You can get the contributor manager from the repository with ITeamRepository.contributorManager()

0 votes

Comments

I edited my post above to add server side information (IContributorService)


Permanent link
Hi All.

Here is the working code to add a Given user id as subscriber [Server Side]

IContributorService IConService = getService(IContributorService.class);
IContributorHandle user = IConService.fetchContributorByUserId("myuserid");
WorkItem.getSubscriptions().add(user);

NOTE :  Its assumed that we are passing the exiting user id. else, a condition to be added to throw User does not exists error message.

Thanks to all !!!

0 votes


Permanent link
Hi

I am getting an error when I use the line:

IContributorService IConService = getService(IContributorService.class); 

the exception says: the service cant be found,Do you know why this can be happenning ?

I am using this line in a class that extends from AbstractService and implements IOperationParticipant

0 votes

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,938

Question asked: May 29 '12, 9:40 a.m.

Question was seen: 6,274 times

Last updated: Jul 26 '12, 6:18 p.m.

Confirmation Cancel Confirm