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.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.