I have an old plugin for Jira 4.0 that I want to upgrade to Jira 5.2. The plugin uses the obsolete "com.opensymphony.user" classes. For example:
List<String> groups = issue.getReporter().getGroups();
I want to migrate the plugin to the new "com.atlassian.crowd.embedded.api" classes but the "getGroups" method is not available there. How can I enumerate the groups a user belongs to in Jira 5.2?
Community moderators have prevented the ability to post new answers.
User reporter = issue.getReporter();
SortedSet<Group> groups = userUtil.getGroupsForUser(reporter.getName());
That's it, thanks. For getting a reference to UserUtil I used something like
private final UserUtil userUtil; // ... userUtil = ComponentAccessor.getUserUtil();
in the class constructor.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
... import com.atlassian.jira.component.ComponentAccessor; import com.atlassian.jira.user.util.UserManager; import com.atlassian.crowd.embedded.api.User; import com.atlassian.crowd.embedded.api.Group; ... UserManager userManager = ComponentAccessor.getUserManager(); Set<Group> groups = userManager.getAllGroups(); for (Group group1 : groups) { Group group = group1; // you logic here }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This would enumerate all available groups, not the groups of a single user.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
ah, you are right
as far as I remember correctly I have been using
com.atlassian.crowd.embedded.api.CrowdService
once
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.