Search in sources :

Example 1 with WsGetMembersResults

use of edu.internet2.middleware.grouperClient.ws.beans.WsGetMembersResults in project uhgroupings by uhawaii-system-its-ti-iam.

the class GroupingAssignmentServiceTest method makeGroupTest.

@Test
public void makeGroupTest() {
    WsGetMembersResults getMembersResults = new WsGetMembersResults();
    WsGetMembersResult[] getMembersResult = new WsGetMembersResult[1];
    WsGetMembersResult getMembersResult1 = new WsGetMembersResult();
    WsSubject[] list = new WsSubject[3];
    for (int i = 0; i < 3; i++) {
        list[i] = new WsSubject();
        list[i].setName("testSubject_" + i);
        list[i].setId("testSubject_uuid_" + i);
        list[i].setAttributeValues(new String[] { "testSubject_username_" + i });
    }
    getMembersResult1.setWsSubjects(list);
    getMembersResult[0] = getMembersResult1;
    getMembersResults.setResults(getMembersResult);
    Group group = groupingAssignmentService.makeGroup(getMembersResults);
    for (int i = 0; i < group.getMembers().size(); i++) {
        assertTrue(group.getMembers().get(i).getName().equals("testSubject_" + i));
        assertTrue(group.getNames().contains("testSubject_" + i));
        assertTrue(group.getMembers().get(i).getUuid().equals("testSubject_uuid_" + i));
        assertTrue(group.getUuids().contains("testSubject_uuid_" + i));
        assertTrue(group.getMembers().get(i).getUsername().equals("testSubject_username_" + i));
        assertTrue(group.getUsernames().contains("testSubject_username_" + i));
    }
}
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) WsSubject(edu.internet2.middleware.grouperClient.ws.beans.WsSubject) WsGetMembersResults(edu.internet2.middleware.grouperClient.ws.beans.WsGetMembersResults) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with WsGetMembersResults

use of edu.internet2.middleware.grouperClient.ws.beans.WsGetMembersResults in project uhgroupings by uhawaii-system-its-ti-iam.

the class GroupingAssignmentServiceTest method makeGroup.

@Test
public void makeGroup() {
    WsGetMembersResults getMembersResults = new WsGetMembersResults();
    WsGetMembersResult[] getMembersResult = new WsGetMembersResult[1];
    WsGetMembersResult getMembersResult1 = new WsGetMembersResult();
    WsSubject[] subjects = new WsSubject[0];
    getMembersResult1.setWsSubjects(subjects);
    getMembersResult[0] = getMembersResult1;
    getMembersResults.setResults(getMembersResult);
    assertNotNull(groupingAssignmentService.makeGroup(getMembersResults));
    subjects = new WsSubject[1];
    getMembersResults.getResults()[0].setWsSubjects(subjects);
    assertNotNull(groupingAssignmentService.makeGroup(getMembersResults));
    subjects[0] = new WsSubject();
    getMembersResults.getResults()[0].setWsSubjects(subjects);
    assertNotNull(groupingAssignmentService.makeGroup(getMembersResults));
}
Also used : WsGetMembersResult(edu.internet2.middleware.grouperClient.ws.beans.WsGetMembersResult) WsSubject(edu.internet2.middleware.grouperClient.ws.beans.WsSubject) WsGetMembersResults(edu.internet2.middleware.grouperClient.ws.beans.WsGetMembersResults) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 3 with WsGetMembersResults

use of edu.internet2.middleware.grouperClient.ws.beans.WsGetMembersResults 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 4 with WsGetMembersResults

use of edu.internet2.middleware.grouperClient.ws.beans.WsGetMembersResults 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 5 with WsGetMembersResults

use of edu.internet2.middleware.grouperClient.ws.beans.WsGetMembersResults 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)

Aggregations

WsGetMembersResults (edu.internet2.middleware.grouperClient.ws.beans.WsGetMembersResults)6 WsSubject (edu.internet2.middleware.grouperClient.ws.beans.WsSubject)6 WsGroup (edu.internet2.middleware.grouperClient.ws.beans.WsGroup)5 Group (edu.hawaii.its.api.type.Group)4 WsGetMembersResult (edu.internet2.middleware.grouperClient.ws.beans.WsGetMembersResult)3 ArrayList (java.util.ArrayList)3 GcGetMembers (edu.internet2.middleware.grouperClient.api.GcGetMembers)2 GroupsException (org.apereo.portal.groups.GroupsException)2 IGroupMember (org.apereo.portal.groups.IGroupMember)2 Test (org.junit.Test)2 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)2 Person (edu.hawaii.its.api.type.Person)1 WsSubjectLookup (edu.internet2.middleware.grouperClient.ws.beans.WsSubjectLookup)1 EntityImpl (org.apereo.portal.groups.EntityImpl)1 IEntityGroup (org.apereo.portal.groups.IEntityGroup)1