we can retrieve contributor handle by email?
Hi ,
Accepted answer
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];
}
}
Comments
Hi Pascal,
private IContributor[] getContributors() { IContributorRestService.ParmsGetContributors parameter =
new IContributorRestService.ParmsGetContributors();
try {
return contributorRestService.getContributors(parameter);
} catch (TeamRepositoryException e) {
return new IContributor[0];
}
}
One other answer
You can use Query models as explained here to find items by other values than the key.
Query Models or how to find stuff with the RTC Java API
sectionGet 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()Comments
Hi Ralph,
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.