public Collection<String> getUserGroups() { final com.atlassian.crowd.search.query.membership.MembershipQuery<String> membershipQuery = QueryBuilder.queryFor(String.class, EntityDescriptor.group()) .parentsOf(EntityDescriptor.user()) .withName(name) .returningAtMost(EntityQuery.ALL_RESULTS); return Lists.newArrayList(crowdService.search(membershipQuery)); }
/** * Determines if the use is part of a group that has the permission * * @param entity not used * @param groupName The group. If it is null then it is Anyone * @param user The user to check if they are in the group, must not be null * @param issueCreation not used * @see com.atlassian.jira.security.type.CurrentAssignee#hasPermission * @see com.atlassian.jira.security.type.CurrentReporter#hasPermission * @see ProjectLead#hasPermission * @see SingleUser#hasPermission */ @Override public boolean hasPermission( GenericValue entity, String groupName, com.atlassian.crowd.embedded.api.User user, boolean issueCreation) { if (user == null) { throw new IllegalArgumentException("User passed must not be null"); } // If there is no group then it is Anyone so it is true if (hasPermission(entity, groupName)) { return true; } CrowdService crowdService = ComponentAccessor.getComponentOfType(CrowdService.class); Group group = crowdService.getGroup(groupName); if (group == null) { return false; } return crowdService.isUserMemberOfGroup(user, group); }