Search in sources :

Example 36 with Group

use of edu.hawaii.its.api.type.Group in project uhgroupings by uhawaii-system-its-ti-iam.

the class GrouperFactoryServiceImplLocal method makeWsGetMembersResults.

@Override
public WsGetMembersResults makeWsGetMembersResults(String subjectAttributeName, WsSubjectLookup lookup, String groupName) {
    WsGetMembersResults wsGetMembersResults = new WsGetMembersResults();
    String[] attributeNames = new String[] { UID_KEY, UUID_KEY, LAST_NAME_KEY, COMPOSITE_NAME_KEY, FIRST_NAME_KEY };
    wsGetMembersResults.setSubjectAttributeNames(attributeNames);
    WsGetMembersResult wsGetMembersResult = new WsGetMembersResult();
    WsSubject[] subjects;
    Group group = groupRepository.findByPath(groupName);
    List<Person> members = group.getMembers();
    List<WsSubject> subjectList = new ArrayList<>();
    for (Person person : members) {
        WsSubject subject = new WsSubject();
        subject.setId(person.getUuid());
        subject.setName(person.getName());
        // has to be the same order as attributeNames array
        subject.setAttributeValues(new String[] { person.getUsername(), person.getUuid(), person.getLastName(), person.getName(), person.getFirstName() });
        subjectList.add(subject);
    }
    subjects = subjectList.toArray(new WsSubject[subjectList.size()]);
    wsGetMembersResult.setWsSubjects(subjects);
    wsGetMembersResults.setResults(new WsGetMembersResult[] { wsGetMembersResult });
    return wsGetMembersResults;
}
Also used : WsGroup(edu.internet2.middleware.grouperClient.ws.beans.WsGroup) Group(edu.hawaii.its.api.type.Group) WsGetMembersResult(edu.internet2.middleware.grouperClient.ws.beans.WsGetMembersResult) ArrayList(java.util.ArrayList) WsSubject(edu.internet2.middleware.grouperClient.ws.beans.WsSubject) WsGetMembersResults(edu.internet2.middleware.grouperClient.ws.beans.WsGetMembersResults) Person(edu.hawaii.its.api.type.Person)

Example 37 with Group

use of edu.hawaii.its.api.type.Group in project uhgroupings by uhawaii-system-its-ti-iam.

the class GroupingAssignmentServiceImpl method getMembers.

// returns a group from grouper or the database
@Override
public Group getMembers(String ownerUsername, String groupPath) {
    logger.info("getMembers; user: " + ownerUsername + "; group: " + groupPath + ";");
    WsSubjectLookup lookup = grouperFS.makeWsSubjectLookup(ownerUsername);
    WsGetMembersResults members = grouperFS.makeWsGetMembersResults(SUBJECT_ATTRIBUTE_NAME_UID, lookup, groupPath);
    // todo should we use EmptyGroup?
    Group groupMembers = new Group();
    if (members.getResults() != null) {
        groupMembers = makeGroup(members);
    }
    return groupMembers;
}
Also used : WsSubjectLookup(edu.internet2.middleware.grouperClient.ws.beans.WsSubjectLookup) WsGroup(edu.internet2.middleware.grouperClient.ws.beans.WsGroup) Group(edu.hawaii.its.api.type.Group) WsGetMembersResults(edu.internet2.middleware.grouperClient.ws.beans.WsGetMembersResults)

Example 38 with Group

use of edu.hawaii.its.api.type.Group in project uhgroupings by uhawaii-system-its-ti-iam.

the class GroupingAssignmentServiceImpl method makeGroup.

// makes a group filled with members from membersResults
@Override
public Group makeGroup(WsGetMembersResults membersResults) {
    Group group = new Group();
    try {
        WsSubject[] subjects = membersResults.getResults()[0].getWsSubjects();
        String[] attributeNames = membersResults.getSubjectAttributeNames();
        if (subjects.length > 0) {
            for (WsSubject subject : subjects) {
                if (subject != null) {
                    group.addMember(makePerson(subject, attributeNames));
                }
            }
        }
    } catch (NullPointerException npe) {
        return new Group();
    }
    return group;
}
Also used : WsGroup(edu.internet2.middleware.grouperClient.ws.beans.WsGroup) Group(edu.hawaii.its.api.type.Group) WsSubject(edu.internet2.middleware.grouperClient.ws.beans.WsSubject)

Example 39 with Group

use of edu.hawaii.its.api.type.Group in project uhgroupings by uhawaii-system-its-ti-iam.

the class GroupingAssignmentServiceImpl method groupingsToOptInto.

// returns the list of groupings that the user is allowed to opt-in to
public List<Grouping> groupingsToOptInto(String optInUsername, List<String> groupPaths) {
    logger.info("groupingsToOptInto; username: " + optInUsername + "; groupPaths : " + groupPaths + ";");
    List<String> trios = new ArrayList<>();
    List<String> opts = new ArrayList<>();
    List<String> excludes = groupPaths.stream().map(group -> group + EXCLUDE).collect(Collectors.toList());
    WsGetAttributeAssignmentsResults assignmentsResults = grouperFS.makeWsGetAttributeAssignmentsResultsTrio(ASSIGN_TYPE_GROUP, TRIO, OPT_IN);
    if (assignmentsResults.getWsAttributeAssigns() != null) {
        for (WsAttributeAssign assign : assignmentsResults.getWsAttributeAssigns()) {
            if (assign.getAttributeDefNameName() != null) {
                if (assign.getAttributeDefNameName().equals(TRIO)) {
                    trios.add(assign.getOwnerGroupName());
                } else if (assign.getAttributeDefNameName().equals(OPT_IN)) {
                    opts.add(assign.getOwnerGroupName());
                }
            }
        }
        // opts intersection trios
        opts.retainAll(trios);
        // excludes intersection opts
        excludes.retainAll(opts);
        // opts - (opts intersection groupPaths)
        opts.removeAll(groupPaths);
        // opts union excludes
        opts.addAll(excludes);
    }
    // get rid of duplicates
    List<String> groups = new ArrayList<>(new HashSet<>(opts));
    return helperService.makeGroupings(groups);
}
Also used : WsGetGroupsResult(edu.internet2.middleware.grouperClient.ws.beans.WsGetGroupsResult) Arrays(java.util.Arrays) GroupingAssignment(edu.hawaii.its.api.type.GroupingAssignment) WsAttributeDefName(edu.internet2.middleware.grouperClient.ws.beans.WsAttributeDefName) Autowired(org.springframework.beans.factory.annotation.Autowired) WsGetAttributeAssignmentsResults(edu.internet2.middleware.grouperClient.ws.beans.WsGetAttributeAssignmentsResults) WsSubjectLookup(edu.internet2.middleware.grouperClient.ws.beans.WsSubjectLookup) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Value(org.springframework.beans.factory.annotation.Value) HashSet(java.util.HashSet) WsSubject(edu.internet2.middleware.grouperClient.ws.beans.WsSubject) Service(org.springframework.stereotype.Service) Map(java.util.Map) WsAttributeAssign(edu.internet2.middleware.grouperClient.ws.beans.WsAttributeAssign) WsGroup(edu.internet2.middleware.grouperClient.ws.beans.WsGroup) Group(edu.hawaii.its.api.type.Group) WsStemLookup(edu.internet2.middleware.grouperClient.ws.beans.WsStemLookup) WsGetMembersResults(edu.internet2.middleware.grouperClient.ws.beans.WsGetMembersResults) Grouping(edu.hawaii.its.api.type.Grouping) AdminListsHolder(edu.hawaii.its.api.type.AdminListsHolder) Person(edu.hawaii.its.api.type.Person) Collectors(java.util.stream.Collectors) List(java.util.List) WsGetGroupsResults(edu.internet2.middleware.grouperClient.ws.beans.WsGetGroupsResults) Log(org.apache.commons.logging.Log) LogFactory(org.apache.commons.logging.LogFactory) StemScope(edu.internet2.middleware.grouperClient.ws.StemScope) ArrayList(java.util.ArrayList) WsGetAttributeAssignmentsResults(edu.internet2.middleware.grouperClient.ws.beans.WsGetAttributeAssignmentsResults) WsAttributeAssign(edu.internet2.middleware.grouperClient.ws.beans.WsAttributeAssign)

Example 40 with Group

use of edu.hawaii.its.api.type.Group in project uhgroupings by uhawaii-system-its-ti-iam.

the class GroupingAssignmentServiceImpl method getGrouping.

// fetch a grouping from Grouper or the database
@Override
public Grouping getGrouping(String groupingPath, String ownerUsername) {
    logger.info("getGrouping; grouping: " + groupingPath + "; username: " + ownerUsername + ";");
    Grouping compositeGrouping = new Grouping();
    if (memberAttributeService.isOwner(groupingPath, ownerUsername) || memberAttributeService.isAdmin(ownerUsername)) {
        compositeGrouping = new Grouping(groupingPath);
        Group include = getMembers(ownerUsername, groupingPath + INCLUDE);
        Group exclude = getMembers(ownerUsername, groupingPath + EXCLUDE);
        Group basis = getMembers(ownerUsername, groupingPath + BASIS);
        Group composite = getMembers(ownerUsername, groupingPath);
        Group owners = getMembers(ownerUsername, groupingPath + OWNERS);
        compositeGrouping = setGroupingAttributes(compositeGrouping);
        compositeGrouping.setBasis(basis);
        compositeGrouping.setExclude(exclude);
        compositeGrouping.setInclude(include);
        compositeGrouping.setComposite(composite);
        compositeGrouping.setOwners(owners);
    }
    return compositeGrouping;
}
Also used : WsGroup(edu.internet2.middleware.grouperClient.ws.beans.WsGroup) Group(edu.hawaii.its.api.type.Group) Grouping(edu.hawaii.its.api.type.Grouping)

Aggregations

Group (edu.hawaii.its.api.type.Group)40 WsGroup (edu.internet2.middleware.grouperClient.ws.beans.WsGroup)23 Person (edu.hawaii.its.api.type.Person)21 Grouping (edu.hawaii.its.api.type.Grouping)13 ArrayList (java.util.ArrayList)10 Test (org.junit.Test)10 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)10 WsSubjectLookup (edu.internet2.middleware.grouperClient.ws.beans.WsSubjectLookup)9 Before (org.junit.Before)8 WsResultMeta (edu.internet2.middleware.grouperClient.ws.beans.WsResultMeta)7 Membership (edu.hawaii.its.api.type.Membership)6 WsGetMembersResults (edu.internet2.middleware.grouperClient.ws.beans.WsGetMembersResults)4 WsSubject (edu.internet2.middleware.grouperClient.ws.beans.WsSubject)4 WsMembership (edu.internet2.middleware.grouperClient.ws.beans.WsMembership)3 AdminListsHolder (edu.hawaii.its.api.type.AdminListsHolder)2 WsGetAttributeAssignmentsResults (edu.internet2.middleware.grouperClient.ws.beans.WsGetAttributeAssignmentsResults)2 WsGetGroupsResult (edu.internet2.middleware.grouperClient.ws.beans.WsGetGroupsResult)2 WsGetGroupsResults (edu.internet2.middleware.grouperClient.ws.beans.WsGetGroupsResults)2 WsGetMembersResult (edu.internet2.middleware.grouperClient.ws.beans.WsGetMembersResult)2 GroupingAssignment (edu.hawaii.its.api.type.GroupingAssignment)1