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.
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
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
Accepted answer
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.
3 other answers
Hi,
I think your code is for Client side. I want to implement this as Server side plugin code.
Thanks
There is IContributorManager.fetchContributorByUserId(String userId, IProgressMonitor monitor). You can get the contributor manager from the repository with ITeamRepository.contributorManager()
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()
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 !!!
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 !!!
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