/** * Returns the RoleActors in a {@link ProjectRole} that have the given type * e.g. {@link com.atlassian.jira.security.roles.actor.UserRoleActorFactory.UserRoleActor#} * or {@link com.atlassian.jira.security.roles.actor.GroupRoleActorFactory.GroupRoleActor#}. * @param projectRole * @param type designation to specify which kind of RoleActor to get. * @param length * @return the Collection of {@link com.atlassian.jira.security.roles.RoleActor}s. */ public Collection getRoleActorTypes(ProjectRole projectRole, String type, int length) { ProjectRoleActors projectRoleActors = projectRoleService.getProjectRoleActors(projectRole, getProject(), this); // This should only ever be null if the user does not have permission to get to this point, the UI should have // stopped the user from getting here if (projectRoleActors == null) { return Collections.EMPTY_LIST; } Set<RoleActor> roleActorsByType = projectRoleActors.getRoleActorsByType(type); if (length == -1 || roleActorsByType.size() <= length) { return projectRoleActors.getRoleActorsByType(type); } else { // Sublist the return set via an ArrayList (Sorry!) return new ArrayList<RoleActor>(projectRoleActors.getRoleActorsByType(type)).subList(0,length); } }
public Collection getCurrentGroups() { final Collection<Group> groups = new ArrayList<Group>(); Collection<RoleActor> roleActorsByType = null; if (getProject() != null) { ProjectRoleActors projectRoleActors = projectRoleService.getProjectRoleActors(getProjectRole(), getProject(), this); if (projectRoleActors != null) { roleActorsByType = projectRoleActors.getRoleActorsByType(ProjectRoleActor.GROUP_ROLE_ACTOR_TYPE); } } else { DefaultRoleActors defaultRoleActors = projectRoleService.getDefaultRoleActors(getProjectRole(), this); if (defaultRoleActors != null) { roleActorsByType = defaultRoleActors.getRoleActorsByType(ProjectRoleActor.GROUP_ROLE_ACTOR_TYPE); } } if (roleActorsByType != null) { for (final RoleActor aRoleActorsByType : roleActorsByType) { GroupRoleActorFactory.GroupRoleActor groupRoleActor = (GroupRoleActorFactory.GroupRoleActor) aRoleActorsByType; groups.add(groupRoleActor.getGroup()); } } return groups; }