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[] {};
}
}
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[] {};
}
}
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));
}
}
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[] {}));
}
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));
}
Aggregations