Search in sources :

Example 1 with EntityImpl

use of org.apereo.portal.groups.EntityImpl in project uPortal by Jasig.

the class LDAPGroupStore method findEntitiesForGroup.

public Iterator findEntitiesForGroup(IEntityGroup group) throws GroupsException {
    GroupShadow shadow = getShadow(group);
    ArrayList al = new ArrayList();
    String[] keys = getPersonKeys(shadow.key);
    for (int i = 0; i < keys.length; i++) {
        al.add(new EntityImpl(keys[i], iperson));
    }
    return al.iterator();
}
Also used : EntityImpl(org.apereo.portal.groups.EntityImpl) ArrayList(java.util.ArrayList)

Example 2 with EntityImpl

use of org.apereo.portal.groups.EntityImpl in project uPortal by Jasig.

the class GrouperEntityGroupStore method findEntitiesForGroup.

/* (non-Javadoc)
     * @see org.apereo.portal.groups.IEntityGroupStore#findEntitiesForGroup(org.apereo.portal.groups.IEntityGroup)
     */
@SuppressWarnings("unchecked")
public Iterator findEntitiesForGroup(IEntityGroup group) throws GroupsException {
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Searching Grouper for members of the group with key: " + group.getKey());
    }
    try {
        // execute a search for members of the specified group
        GcGetMembers getGroupsMembers = new GcGetMembers();
        getGroupsMembers.addGroupName(group.getLocalKey());
        getGroupsMembers.assignIncludeSubjectDetail(true);
        WsGetMembersResults results = getGroupsMembers.execute();
        if (results == null || results.getResults() == null || results.getResults().length == 0 || results.getResults()[0].getWsSubjects() == null) {
            LOGGER.debug("No members found for Grouper group with key " + group.getLocalKey());
            return Collections.<IGroupMember>emptyList().iterator();
        }
        WsSubject[] gInfos = results.getResults()[0].getWsSubjects();
        final List<IGroupMember> members = new ArrayList<IGroupMember>(gInfos.length);
        // add each result to the member list
        for (WsSubject gInfo : gInfos) {
            // if the member is not a group (aka person)
            if (!StringUtils.equals(gInfo.getSourceId(), "g:gsa")) {
                if (LOGGER.isDebugEnabled()) {
                    LOGGER.debug("creating leaf member:" + gInfo.getId() + " and name: " + gInfo.getName() + " from group: " + group.getLocalKey());
                }
                //use the name instead of id as it shows better in the display
                IGroupMember member = new EntityImpl(gInfo.getName(), IPerson.class);
                members.add(member);
            }
        }
        // return an iterator for the assembled group
        return members.iterator();
    } catch (Exception e) {
        LOGGER.warn("Exception while attempting to retrieve " + "member entities of group with key " + group.getKey() + " from Grouper web services: " + e.getMessage());
        return Collections.<IGroupMember>emptyList().iterator();
    }
}
Also used : IGroupMember(org.apereo.portal.groups.IGroupMember) EntityImpl(org.apereo.portal.groups.EntityImpl) ArrayList(java.util.ArrayList) 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

ArrayList (java.util.ArrayList)2 EntityImpl (org.apereo.portal.groups.EntityImpl)2 GcGetMembers (edu.internet2.middleware.grouperClient.api.GcGetMembers)1 WsGetMembersResults (edu.internet2.middleware.grouperClient.ws.beans.WsGetMembersResults)1 WsSubject (edu.internet2.middleware.grouperClient.ws.beans.WsSubject)1 GroupsException (org.apereo.portal.groups.GroupsException)1 IGroupMember (org.apereo.portal.groups.IGroupMember)1