Search in sources :

Example 6 with WsGroup

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

the class GrouperEntityGroupStore method findMemberGroups.

@SuppressWarnings("unchecked")
public Iterator findMemberGroups(IEntityGroup group) throws GroupsException {
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Searching for group-type members of group with key: " + group.getKey());
    }
    try {
        if (!validKey(group.getLocalKey())) {
            return Collections.<IEntityGroup>emptyList().iterator();
        }
        GcGetMembers gcGetMembers = new GcGetMembers();
        gcGetMembers.addGroupName(group.getLocalKey());
        gcGetMembers.assignIncludeSubjectDetail(true);
        gcGetMembers.addSourceId("g:gsa");
        WsGetMembersResults results = gcGetMembers.execute();
        if (results == null || results.getResults() == null || results.getResults().length == 0 || results.getResults()[0].getWsSubjects() == null) {
            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("No group-type members found for group with key " + group.getKey());
            }
            return Collections.<IEntityGroup>emptyList().iterator();
        }
        final List<IEntityGroup> members = new ArrayList<IEntityGroup>();
        WsSubject[] subjects = results.getResults()[0].getWsSubjects();
        for (WsSubject wsSubject : subjects) {
            if (validKey(wsSubject.getName())) {
                WsGroup wsGroup = findGroupFromKey(wsSubject.getName());
                if (wsGroup != null) {
                    IEntityGroup member = createUportalGroupFromGrouperGroup(wsGroup);
                    members.add(member);
                    if (LOGGER.isTraceEnabled()) {
                        LOGGER.trace("found IEntityGroup member: " + member);
                    }
                }
            }
        }
        return members.iterator();
    } catch (Exception e) {
        LOGGER.warn("Exception while attempting to retrieve " + "member groups of group with key " + group.getKey() + " from Grouper web services: " + e.getMessage());
        return Collections.<IGroupMember>emptyList().iterator();
    }
}
Also used : IEntityGroup(org.apereo.portal.groups.IEntityGroup) IGroupMember(org.apereo.portal.groups.IGroupMember) ArrayList(java.util.ArrayList) WsGroup(edu.internet2.middleware.grouperClient.ws.beans.WsGroup) WsSubject(edu.internet2.middleware.grouperClient.ws.beans.WsSubject) GcGetMembers(edu.internet2.middleware.grouperClient.api.GcGetMembers) WsGetMembersResults(edu.internet2.middleware.grouperClient.ws.beans.WsGetMembersResults) GroupsException(org.apereo.portal.groups.GroupsException)

Aggregations

WsGroup (edu.internet2.middleware.grouperClient.ws.beans.WsGroup)6 GroupsException (org.apereo.portal.groups.GroupsException)4 IEntityGroup (org.apereo.portal.groups.IEntityGroup)4 GcFindGroups (edu.internet2.middleware.grouperClient.api.GcFindGroups)2 WsFindGroupsResults (edu.internet2.middleware.grouperClient.ws.beans.WsFindGroupsResults)2 ArrayList (java.util.ArrayList)2 GcGetGroups (edu.internet2.middleware.grouperClient.api.GcGetGroups)1 GcGetMembers (edu.internet2.middleware.grouperClient.api.GcGetMembers)1 GcGroupSave (edu.internet2.middleware.grouperClient.api.GcGroupSave)1 WsGetGroupsResult (edu.internet2.middleware.grouperClient.ws.beans.WsGetGroupsResult)1 WsGetGroupsResults (edu.internet2.middleware.grouperClient.ws.beans.WsGetGroupsResults)1 WsGetMembersResults (edu.internet2.middleware.grouperClient.ws.beans.WsGetMembersResults)1 WsGroupLookup (edu.internet2.middleware.grouperClient.ws.beans.WsGroupLookup)1 WsGroupToSave (edu.internet2.middleware.grouperClient.ws.beans.WsGroupToSave)1 WsQueryFilter (edu.internet2.middleware.grouperClient.ws.beans.WsQueryFilter)1 WsStemLookup (edu.internet2.middleware.grouperClient.ws.beans.WsStemLookup)1 WsSubject (edu.internet2.middleware.grouperClient.ws.beans.WsSubject)1 WsSubjectLookup (edu.internet2.middleware.grouperClient.ws.beans.WsSubjectLookup)1 LinkedList (java.util.LinkedList)1 EntityIdentifier (org.apereo.portal.EntityIdentifier)1