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());
}
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;
}
Aggregations