Search in sources :

Example 16 with Group

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

the class GrouperFactoryServiceImplLocal method makeWsDeleteMemberResults.

@Override
public WsDeleteMemberResults makeWsDeleteMemberResults(String group, WsSubjectLookup lookup, Person personToDelete) {
    WsDeleteMemberResults wsDeleteMemberResults = new WsDeleteMemberResults();
    WsResultMeta wsResultMeta = new WsResultMeta();
    wsResultMeta.setResultCode(SUCCESS);
    wsDeleteMemberResults.setResultMetadata(wsResultMeta);
    Grouping grouping = groupingRepository.findByIncludePathOrExcludePathOrCompositePathOrOwnersPath(group, group, group, group);
    if (personToDelete.getUsername() != null) {
        personToDelete = personRepository.findByUsername(personToDelete.getUsername());
    } else if (personToDelete.getUuid() != null) {
        personToDelete = personRepository.findByUuid(personToDelete.getUuid());
    }
    if (grouping == null) {
        Group groupToDeleteFrom = groupRepository.findByPath(group);
        deleteMember(groupToDeleteFrom, personToDelete);
    } else {
        if (group.endsWith(OWNERS)) {
            deleteMember(grouping.getOwners(), personToDelete);
        } else if (group.endsWith(EXCLUDE)) {
            deleteMember(grouping.getExclude(), personToDelete);
        } else if (group.endsWith(INCLUDE)) {
            deleteMember(grouping.getInclude(), personToDelete);
        }
        grouping = groupingRepository.findByPath(grouping.getPath());
        grouping = groupingRepository.findByPath(grouping.getPath());
        Group composite = buildComposite(grouping.getInclude(), grouping.getExclude(), grouping.getBasis(), grouping.getPath());
        groupRepository.save(composite);
    }
    return wsDeleteMemberResults;
}
Also used : WsGroup(edu.internet2.middleware.grouperClient.ws.beans.WsGroup) Group(edu.hawaii.its.api.type.Group) WsResultMeta(edu.internet2.middleware.grouperClient.ws.beans.WsResultMeta) Grouping(edu.hawaii.its.api.type.Grouping) WsDeleteMemberResults(edu.internet2.middleware.grouperClient.ws.beans.WsDeleteMemberResults)

Example 17 with Group

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

the class GrouperFactoryServiceImplLocal method makeWsHasMemberResults.

@Override
public WsHasMemberResults makeWsHasMemberResults(String group, Person person) {
    WsHasMemberResults wsHasMemberResults = new WsHasMemberResults();
    WsHasMemberResult wsHasMemberResult = new WsHasMemberResult();
    WsResultMeta wsResultMeta = new WsResultMeta();
    wsHasMemberResult.setResultMetadata(wsResultMeta);
    wsHasMemberResults.setResults(new WsHasMemberResult[] { wsHasMemberResult });
    wsResultMeta.setResultCode("not member");
    Group groupToCheck = groupRepository.findByPath(group);
    // first try username
    if (person.getUsername() != null) {
        person = personRepository.findByUsername(person.getUsername());
        if (groupToCheck.isMember(person)) {
            wsResultMeta.setResultCode(IS_MEMBER);
        }
    // if username is null, try uuid
    } else if (person.getUuid() != null) {
        Person person0 = personRepository.findByUuid(person.getUuid());
        if (groupToCheck.isMember(person0)) {
            wsResultMeta.setResultCode(IS_MEMBER);
        }
    }
    return wsHasMemberResults;
}
Also used : WsGroup(edu.internet2.middleware.grouperClient.ws.beans.WsGroup) Group(edu.hawaii.its.api.type.Group) WsHasMemberResult(edu.internet2.middleware.grouperClient.ws.beans.WsHasMemberResult) WsHasMemberResults(edu.internet2.middleware.grouperClient.ws.beans.WsHasMemberResults) WsResultMeta(edu.internet2.middleware.grouperClient.ws.beans.WsResultMeta) Person(edu.hawaii.its.api.type.Person)

Example 18 with Group

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

the class GroupingsRestControllerTest method grouping.

// Test data.
private Grouping grouping() {
    Grouping grouping = new Grouping("test:ing:me:bob");
    Group basisGroup = new Group();
    basisGroup.addMember(new Person("b0-name", "b0-uuid", "b0-username"));
    basisGroup.addMember(new Person("b1-name", "b1-uuid", "b1-username"));
    basisGroup.addMember(new Person("b2-name", "b2-uuid", "b2-username"));
    grouping.setBasis(basisGroup);
    Group exclude = new Group();
    exclude.addMember(new Person("e0-name", "e0-uuid", "e0-username"));
    grouping.setExclude(exclude);
    Group include = new Group();
    include.addMember(new Person("i0-name", "i0-uuid", "i0-username"));
    include.addMember(new Person("i1-name", "i1-uuid", "i1-username"));
    grouping.setInclude(include);
    Group owners = new Group();
    owners.addMember(new Person("o0-name", "o0-uuid", "o0-username"));
    owners.addMember(new Person("o1-name", "o1-uuid", "o1-username"));
    owners.addMember(new Person("o2-name", "o2-uuid", "o2-username"));
    owners.addMember(new Person("o3-name", "o3-uuid", "o3-username"));
    grouping.setOwners(owners);
    grouping.setListservOn(true);
    return grouping;
}
Also used : Group(edu.hawaii.its.api.type.Group) Grouping(edu.hawaii.its.api.type.Grouping) Person(edu.hawaii.its.api.type.Person)

Example 19 with Group

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

the class GroupRepositoryTest method setup.

@Before
public void setup() {
    for (int i = 0; i < 10; i++) {
        persons[i] = new Person("name" + i, "uuid" + i, "username" + i);
        personRepository.save(persons[i]);
    }
    for (int i = 0; i < 5; i++) {
        memberLists.add(new ArrayList<>());
    }
    memberLists.get(1).add(persons[0]);
    memberLists.get(1).add(persons[1]);
    memberLists.get(2).add(persons[2]);
    memberLists.get(2).add(persons[3]);
    memberLists.get(2).add(persons[4]);
    memberLists.get(3).add(persons[5]);
    memberLists.get(3).add(persons[6]);
    memberLists.get(3).add(persons[7]);
    memberLists.get(3).add(persons[8]);
    memberLists.get(4).add(persons[0]);
    memberLists.get(4).add(persons[1]);
    memberLists.get(4).add(persons[2]);
    memberLists.get(4).add(persons[3]);
    memberLists.get(4).add(persons[4]);
    memberLists.get(4).add(persons[5]);
    memberLists.get(4).add(persons[6]);
    memberLists.get(4).add(persons[7]);
    memberLists.get(4).add(persons[8]);
    memberLists.get(4).add(persons[9]);
    for (int i = 0; i < 5; i++) {
        groups[i] = new Group("path:to:group" + i, memberLists.get(i));
        groupRepository.save(groups[i]);
    }
}
Also used : Group(edu.hawaii.its.api.type.Group) Person(edu.hawaii.its.api.type.Person) Before(org.junit.Before)

Example 20 with Group

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

the class DatabaseSetup method buildComposite.

// /////////////////////////////////////////////////////////
// helper methods
// /////////////////////////////////////////////////////////
private Group buildComposite(Group include, Group exclude, Group basis, String path) {
    Group basisPlusInclude = addIncludedMembers(include, basis);
    Group compositeGroup = removeExcludedMembers(basisPlusInclude, exclude);
    compositeGroup.setPath(path);
    return compositeGroup;
}
Also used : Group(edu.hawaii.its.api.type.Group)

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