Search in sources :

Example 1 with WsSubject

use of edu.internet2.middleware.grouperClient.ws.beans.WsSubject in project uPortal by Jasig.

the class GrouperEntityGroupStore method searchForEntities.

/** @see IEntitySearcher#searchForEntities(java.lang.String, int, java.lang.Class) */
@SuppressWarnings("unchecked")
public EntityIdentifier[] searchForEntities(String query, int method, Class type) throws GroupsException {
    // only search for groups
    if (type != IPerson.class) {
        return new EntityIdentifier[] {};
    }
    List<EntityIdentifier> entityIdentifiers = new ArrayList<EntityIdentifier>();
    try {
        GcGetSubjects subjects = new GcGetSubjects();
        subjects.assignIncludeSubjectDetail(true);
        WsGetSubjectsResults results = subjects.assignSearchString(query).execute();
        if (results != null && results.getWsSubjects() != null) {
            for (WsSubject wsSubject : results.getWsSubjects()) {
                entityIdentifiers.add(new EntityIdentifier(wsSubject.getName(), ICompositeGroupService.LEAF_ENTITY_TYPE));
            }
        }
        return entityIdentifiers.toArray(new EntityIdentifier[entityIdentifiers.size()]);
    } catch (Exception e) {
        LOGGER.warn("Exception while attempting to retrieve " + "search results for query " + query + " and entity type " + type.getCanonicalName() + " : " + e.getMessage());
        return new EntityIdentifier[] {};
    }
}
Also used : WsGetSubjectsResults(edu.internet2.middleware.grouperClient.ws.beans.WsGetSubjectsResults) ArrayList(java.util.ArrayList) EntityIdentifier(org.apereo.portal.EntityIdentifier) WsSubject(edu.internet2.middleware.grouperClient.ws.beans.WsSubject) GcGetSubjects(edu.internet2.middleware.grouperClient.api.GcGetSubjects) GroupsException(org.apereo.portal.groups.GroupsException)

Example 2 with WsSubject

use of edu.internet2.middleware.grouperClient.ws.beans.WsSubject in project uPortal by Jasig.

the class GrouperEntityGroupStore method searchForEntities.

/**
 * @see IEntitySearcher#searchForEntities(java.lang.String,
 *     org.apereo.portal.groups.IGroupConstants.SearchMethod, java.lang.Class)
 */
@Override
@SuppressWarnings("unchecked")
public EntityIdentifier[] searchForEntities(String query, SearchMethod method, Class type) throws GroupsException {
    // only search for groups
    if (type != IPerson.class) {
        return new EntityIdentifier[] {};
    }
    List<EntityIdentifier> entityIdentifiers = new ArrayList<EntityIdentifier>();
    try {
        GcGetSubjects subjects = new GcGetSubjects();
        subjects.assignIncludeSubjectDetail(true);
        WsGetSubjectsResults results = subjects.assignSearchString(query).execute();
        if (results != null && results.getWsSubjects() != null) {
            for (WsSubject wsSubject : results.getWsSubjects()) {
                entityIdentifiers.add(new EntityIdentifier(wsSubject.getName(), ICompositeGroupService.LEAF_ENTITY_TYPE));
            }
        }
        return entityIdentifiers.toArray(new EntityIdentifier[entityIdentifiers.size()]);
    } catch (Exception e) {
        LOGGER.warn("Exception while attempting to retrieve " + "search results for query " + query + " and entity type " + type.getCanonicalName() + " : " + e.getMessage());
        return new EntityIdentifier[] {};
    }
}
Also used : WsGetSubjectsResults(edu.internet2.middleware.grouperClient.ws.beans.WsGetSubjectsResults) ArrayList(java.util.ArrayList) EntityIdentifier(org.apereo.portal.EntityIdentifier) WsSubject(edu.internet2.middleware.grouperClient.ws.beans.WsSubject) GcGetSubjects(edu.internet2.middleware.grouperClient.api.GcGetSubjects) GroupsException(org.apereo.portal.groups.GroupsException)

Example 3 with WsSubject

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

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

the class GroupingAssignmentServiceTest method makePerson.

@Test
public void makePerson() {
    String name = "name";
    String id = "uuid";
    String identifier = "username";
    String[] attributeNames = new String[] { UID_KEY, UUID_KEY, LAST_NAME_KEY, COMPOSITE_NAME_KEY, FIRST_NAME_KEY };
    String[] attributeValues = new String[] { identifier, id, null, name, null };
    WsSubject subject = new WsSubject();
    subject.setName(name);
    subject.setId(id);
    subject.setAttributeValues(attributeValues);
    Person person = groupingAssignmentService.makePerson(subject, attributeNames);
    assertTrue(person.getName().equals(name));
    assertTrue(person.getUuid().equals(id));
    assertTrue(person.getUsername().equals(identifier));
    assertNotNull(groupingAssignmentService.makePerson(new WsSubject(), new String[] {}));
}
Also used : WsSubject(edu.internet2.middleware.grouperClient.ws.beans.WsSubject) Person(edu.hawaii.its.api.type.Person) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 5 with WsSubject

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

Aggregations

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