Hi everyone,
I'm writing a plugin for Jira/Bitbucket/Confluence Server, and for some reasons, I need to get a user by searching its email address, then I try to find an API like this:
User user = userService.getUserByEmail(givenEmail)
I eventually found one such API in Jira:
Iterable<ApplicationUser> users = ComponentAccessor.getUserSearchService().findUsersByEmail(email);
But I wonder if there‘re any APIs like that in Confluence or Bitbucket? Or any other APIs that I can use to search users by email address?
Thanks so much.
I just found such an API in Bitbucket:
ComponentLocator.getComponent(com.atlassian.bitbucket.user.UserService.class).findUserByEmail(email)
(For Confluence) Such as:
/**
* @param email
* @return
* @see DefaultUserAccessor#getUsersByEmail(String)
*/
private SearchResult getUsersByEmail(String email) {
if (!TextUtils.stringSet(email)) {
return new DefaultSearchResult();
} else {
SearchResult<com.atlassian.user.User> results = null;
EmailTermQuery emailQuery = new EmailTermQuery(email);
try {
results = entityQueryParser.findUsers(emailQuery);
results = ComponentLocator.getComponent(EntityQueryParser.class).findUsers(emailQuery);
} catch (EntityException var5) {
log.error(var5.getMessage());
}
return results;
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.