Search in sources :

Example 1 with AssignedUserGroupView

use of com.synopsys.integration.blackduck.api.manual.temporary.response.AssignedUserGroupView in project blackduck-common by blackducksoftware.

the class ProjectUsersService method getAllActiveUsersForProject.

/**
 * 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.
 */
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()) {
            HttpUrl groupUrl = new HttpUrl(assignedUserGroupView.getGroup());
            UserGroupView userGroupView = blackDuckApiClient.getResponse(groupUrl, UserGroupView.class);
            if (userGroupView.getActive()) {
                List<UserView> groupUsers = blackDuckApiClient.getAllResponses(userGroupView.metaUsersLink());
                users.addAll(groupUsers);
            }
        }
    }
    List<AssignedUserView> assignedUsers = getAssignedUsersToProject(projectView);
    for (AssignedUserView assignedUser : assignedUsers) {
        HttpUrl userUrl = new HttpUrl(assignedUser.getUser());
        UserView userView = blackDuckApiClient.getResponse(userUrl, UserView.class);
        users.add(userView);
    }
    return users.stream().filter(UserView::getActive).collect(Collectors.toSet());
}
Also used : UserGroupView(com.synopsys.integration.blackduck.api.generated.view.UserGroupView) AssignedUserGroupView(com.synopsys.integration.blackduck.api.manual.temporary.response.AssignedUserGroupView) AssignedUserGroupView(com.synopsys.integration.blackduck.api.manual.temporary.response.AssignedUserGroupView) AssignedUserView(com.synopsys.integration.blackduck.api.manual.temporary.view.AssignedUserView) UserView(com.synopsys.integration.blackduck.api.generated.view.UserView) AssignedUserView(com.synopsys.integration.blackduck.api.manual.temporary.view.AssignedUserView) HttpUrl(com.synopsys.integration.rest.HttpUrl) HashSet(java.util.HashSet)

Example 2 with AssignedUserGroupView

use of com.synopsys.integration.blackduck.api.manual.temporary.response.AssignedUserGroupView in project blackduck-common by blackducksoftware.

the class ProjectUsersService method getGroupsForProject.

public List<UserGroupView> getGroupsForProject(ProjectView project) throws IntegrationException {
    logger.debug("Attempting to get the assigned users for Project: " + project.getName());
    List<AssignedUserGroupView> assignedGroups = getAssignedGroupsToProject(project);
    List<UserGroupView> resolvedGroupViews = new ArrayList<>();
    for (AssignedUserGroupView assigned : assignedGroups) {
        HttpUrl groupUrl = new HttpUrl(assigned.getGroup());
        UserGroupView groupView = blackDuckApiClient.getResponse(groupUrl, UserGroupView.class);
        if (groupView != null) {
            resolvedGroupViews.add(groupView);
        }
    }
    return resolvedGroupViews;
}
Also used : UserGroupView(com.synopsys.integration.blackduck.api.generated.view.UserGroupView) AssignedUserGroupView(com.synopsys.integration.blackduck.api.manual.temporary.response.AssignedUserGroupView) AssignedUserGroupView(com.synopsys.integration.blackduck.api.manual.temporary.response.AssignedUserGroupView) ArrayList(java.util.ArrayList) HttpUrl(com.synopsys.integration.rest.HttpUrl)

Aggregations

UserGroupView (com.synopsys.integration.blackduck.api.generated.view.UserGroupView)2 AssignedUserGroupView (com.synopsys.integration.blackduck.api.manual.temporary.response.AssignedUserGroupView)2 HttpUrl (com.synopsys.integration.rest.HttpUrl)2 UserView (com.synopsys.integration.blackduck.api.generated.view.UserView)1 AssignedUserView (com.synopsys.integration.blackduck.api.manual.temporary.view.AssignedUserView)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1