public Set < UserView > getAllActiveUsersForProject ( ProjectView projectView ) throws IntegrationException { Set < UserView > users = new HashSet <> ( ) ; List < AssignedUserGroupView > assignedGroups = getAssignedGroupsToProject ( projectView ) ; for ( AssignedUserGroupView assignedUserGroupView : assignedGroups ) { if ( assignedUserGroupView . getActive ( ) ) { UserGroupView userGroupView = blackDuckService . getResponse ( assignedUserGroupView . getGroup ( ) , UserGroupView . class ) ; if ( userGroupView . getActive ( ) ) { List < UserView > groupUsers = blackDuckService . getAllResponses ( userGroupView , UserGroupView . USERS_LINK_RESPONSE ) ; users . addAll ( groupUsers ) ; } } } List < AssignedUserView > assignedUsers = getAssignedUsersToProject ( projectView ) ; for ( AssignedUserView assignedUser : assignedUsers ) { UserView userView = blackDuckService . getResponse ( assignedUser . getUser ( ) , UserView . class ) ; users . add ( userView ) ; } return users . stream ( ) . filter ( userView -> userView . getActive ( ) ) . collect ( Collectors . toSet ( ) ) ; }
This will get all explicitly assigned users for a project as well as all users who are assigned to groups that are explicitly assigned to a project .