Obtain with java api the current repository (iTeamRepository) and the current user (iContributor)
Hello,
I use RTC 4.0.3 and I try to create a java plugin on the server side.
On this program, I try to obtain the current user.
I think that this 2 codes should be correct but I don't know how obtain iTeamRepository.
I have found code this code but it doesn't work on server-side, only on client-side when you create manually a new session.
Thanks a lot.
Regards
Mathieu
I use RTC 4.0.3 and I try to create a java plugin on the server side.
On this program, I try to obtain the current user.
I think that this 2 codes should be correct but I don't know how obtain iTeamRepository.
IContributor iContributor = iTeamRepository.loggedInContributor() ;or
IContributorHandle iContributorHandle = auditableCommon.getUser();
IContributor iContributor = (IContributor) iTeamRepository.itemManager().fetchCompleteItem(iContributorHandle, IItemManager.DEFAULT, monitor) ;In this 2 examples, the problem is that iTeamRepository is null ...
I have found code this code but it doesn't work on server-side, only on client-side when you create manually a new session.
ITeamRepository iTeamRepository = TeamPlatform.getTeamRepositoryService().getTeamRepository(auditableCommon.getRepositoryURI()) ;Can you help me ?
Thanks a lot.
Regards
Mathieu
2 answers
Hello Ralph,
Thanks for all this information mainly the last comment.
In fact, examining your code example, I have found how obtain the current user with this code :
Otherwise, you are right when you said that ITeamRepository is not necessary because this object is a client-side object and not a server-side.
Finally, with your example, I have discovered that your main class extends "AbstractService". Is it important ? In fact, in my code, I don't use this extended class and I have no problem ... Why ??? I don't know.
Thanks for your help Ralph !
Thanks for all this information mainly the last comment.
In fact, examining your code example, I have found how obtain the current user with this code :
IContributorHandle iContributorHandle = auditableCommon.getUser();
IContributor iContributor = (IContributor) auditableCommon.resolveAuditable(iContributorHandle,ItemProfile.createFullProfile(IContributor.ITEM_TYPE), monitor);My problem was that I didn't know the method ItemProfile.createFullProfile.
Otherwise, you are right when you said that ITeamRepository is not necessary because this object is a client-side object and not a server-side.
Finally, with your example, I have discovered that your main class extends "AbstractService". Is it important ? In fact, in my code, I don't use this extended class and I have no problem ... Why ??? I don't know.
Thanks for your help Ralph !
Comments
1 vote
There are several examples on http://rsjazz.wordpress.com/
Start here: http://rsjazz.wordpress.com/2013/02/28/setting-up-rational-team-concert-for-api-development/
continue with http://rsjazz.wordpress.com/2013/03/20/understanding-and-using-the-rtc-java-client-api/
and search the blog.
http://rsjazz.wordpress.com/2012/12/09/analyzing-a-aroject-areas-members-and-roles-using-the-plain-java-client-libraries/ shows details. There is more in the blog.
Start here: http://rsjazz.wordpress.com/2013/02/28/setting-up-rational-team-concert-for-api-development/
continue with http://rsjazz.wordpress.com/2013/03/20/understanding-and-using-the-rtc-java-client-api/
and search the blog.
http://rsjazz.wordpress.com/2012/12/09/analyzing-a-aroject-areas-members-and-roles-using-the-plain-java-client-libraries/ shows details. There is more in the blog.