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

we can retrieve contributor handle by email?

 Hi ,


Is it possible to retrieve the contributor handle by email.
we tried as follows :

IContributorHandle fromContributor =
(IContributorHandle)rtcRepository.contributorManager().fetchContributorByUserId("email", nullProgressMonitor);

but it didn't works. Please suggest me how to proceed.

Thanks in advance!

0 votes


Accepted answer

Permanent link

Fetching contributors like that will only work if your user ids are actually emails. If you have other user ids but have access to their emails, you have to use a different approach.

This is sort-of pseudo code, but mostly translates to working code. Also, this assumes you're using the server sdk. I've split the functions up to make their intent clear. The first function gets all contributors and iterates over them to find the one matching the email in question. The second function uses framework capabilities to try and retrieve all available contributors. The empty parameters filter nothing, which should return everyone.

public IContributor getByEmail(String email) {
    IContributor[] contributors = getContributors();

for (IContributor contributor : contributors) {
if (contributor.getEmailAddress().equalsIgnoreCase(email)) {
return contributor;
}
}
return null;
}

private IContributor[] getContributors() {
    IContributorRestService.ParmsGetContributors parameter = 
new IContributorRestService.ParmsGetContributors();

try {
return contributorRestService.getContributors(parameter);
} catch (TeamRepositoryException e) {
return new IContributor[0];
}
}

lakshmi jyothsna selected this answer as the correct answer

0 votes

Comments

 Hi Pascal,


Thanks for your reply. I will try the suggestion . 

 

HI Pascal ,

I followed your suggestion , but in the second function :
private IContributor[] getContributors() {
    IContributorRestService.ParmsGetContributors parameter = 
new IContributorRestService.ParmsGetContributors();

try {
return contributorRestService.getContributors(parameter);
} catch (TeamRepositoryException e) {
return new IContributor[0];
}
}

 how can i initialize the  contributorRestService.getContributors(parameter); ?

If i  did initialization as :  
   IContributorRestService contributorRestService = (IContributorRestService)rtcRepository.getClientLibrary(getClass());
it returns " null " value. So i am unable to find the contributors list in repository  . please suggest me how can i  proceed.? 
Thanks in advance. !!



One other answer

Permanent link

 You can use Query models as explained here to find items by other values than the key.

See the blog post 

Query Models or how to find stuff with the RTC Java API

 section 

Get contributor by user name

 you would use com.ibm.team.repository.common.model.query.BaseContributorQueryModel.emailAddress() instead of com.ibm.team.repository.common.model.query.BaseContributorQueryModel.name()

0 votes

Comments

 Hi  Ralph,


Thanks for reply ! I followed your suggestion but i end up in infinite loop. Please suggest any other possibility.

Thanks in advance.

 If you can't get that example working and if you can't provide precise information about what blocks you, I can not help you. There is no other option I am aware of either.´Good luck.

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

Question asked: Jun 20 '17, 11:26 a.m.

Question was seen: 1,344 times

Last updated: Nov 16 '17, 9:20 a.m.

Confirmation Cancel Confirm