Search in sources :

Example 21 with IEntityGroup

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

the class EntityPersonAttributesGroupStore method convertPagsGroupToEntity.

private IEntityGroup convertPagsGroupToEntity(IPersonAttributesGroupDefinition group) {
    final String cacheKey = group.getName();
    Element element = entityGroupCache.get(cacheKey);
    if (element == null) {
        final IEntityGroup entityGroup = new EntityTestingGroupImpl(group.getName(), IPERSON_CLASS);
        entityGroup.setName(group.getName());
        entityGroup.setDescription(group.getDescription());
        element = new Element(cacheKey, entityGroup);
        entityGroupCache.put(element);
    }
    return (IEntityGroup) element.getObjectValue();
}
Also used : IEntityGroup(org.apereo.portal.groups.IEntityGroup) Element(net.sf.ehcache.Element) EntityTestingGroupImpl(org.apereo.portal.groups.EntityTestingGroupImpl)

Example 22 with IEntityGroup

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

the class EntityPersonAttributesGroupStore method getParentGroups.

private Set<IEntityGroup> getParentGroups(String name, Set<IEntityGroup> groups) throws GroupsException {
    logger.debug("Looking up containing groups for {}", name);
    IPersonAttributesGroupDefinition pagsGroup = getPagsGroupDefByName(name);
    Set<IPersonAttributesGroupDefinition> pagsParentGroups = personAttributesGroupDefinitionDao.getParentPersonAttributesGroupDefinitions(pagsGroup);
    for (IPersonAttributesGroupDefinition pagsParent : pagsParentGroups) {
        IEntityGroup parent = convertPagsGroupToEntity(pagsParent);
        if (!groups.contains(parent)) {
            groups.add(parent);
            getParentGroups(pagsParent.getName(), groups);
        } else {
            throw new RuntimeException("Recursive grouping detected! for " + name + " and parent " + pagsParent.getName());
        }
    }
    return groups;
}
Also used : IEntityGroup(org.apereo.portal.groups.IEntityGroup)

Example 23 with IEntityGroup

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

the class EntityPersonAttributesGroupStore method findParentGroups.

@Override
public Iterator<IEntityGroup> findParentGroups(IGroupMember member) throws GroupsException {
    if (!IPERSON_CLASS.equals(member.getLeafType())) {
        // knowing that PAGS only supports groups of IPerson (we are).
        return Collections.emptyIterator();
    }
    logger.debug("finding containing groups for member key {}", member.getKey());
    final Set<IEntityGroup> set = Collections.emptySet();
    // default
    Iterator<IEntityGroup> rslt = set.iterator();
    if (member.isGroup()) {
        // PAGS groups may only contain other PAGS groups (and people, of course)
        final IEntityGroup ieg = (IEntityGroup) member;
        if (PagsService.SERVICE_NAME_PAGS.equals(ieg.getServiceName().toString())) {
            rslt = findParentGroupsForGroup((IEntityGroup) member);
        }
    } else {
        rslt = findParentGroupsForEntity((IEntity) member);
    }
    return rslt;
}
Also used : IEntityGroup(org.apereo.portal.groups.IEntityGroup) IEntity(org.apereo.portal.groups.IEntity)

Example 24 with IEntityGroup

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

the class EntityPersonAttributesGroupStore method findParentGroupsForEntity.

private Iterator<IEntityGroup> findParentGroupsForEntity(IEntity member) throws GroupsException {
    Set<IPersonAttributesGroupDefinition> pagsGroups = personAttributesGroupDefinitionDao.getPersonAttributesGroupDefinitions();
    List<IEntityGroup> results = new ArrayList<IEntityGroup>();
    for (IPersonAttributesGroupDefinition pagsGroup : pagsGroups) {
        IEntityGroup group = convertPagsGroupToEntity(pagsGroup);
        if (contains(group, member)) {
            results.add(group);
        }
    }
    return results.iterator();
}
Also used : IEntityGroup(org.apereo.portal.groups.IEntityGroup) ArrayList(java.util.ArrayList)

Example 25 with IEntityGroup

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

the class SmartLdapGroupStore method findMemberGroupKeys.

/**
     * Returns a <code>String[]</code> containing the keys of <code>IEntityGroups</code> that are
     * members of this <code>IEntityGroup</code>. In a composite group system, a group may contain a
     * member group from a different service. This is called a foreign membership, and is only
     * possible in an internally-managed service. A group store in such a service can return the key
     * of a foreign member group, but not the group itself, which can only be returned by its local
     * store.
     *
     * @return String[]
     * @param group org.apereo.portal.groups.IEntityGroup
     */
public String[] findMemberGroupKeys(IEntityGroup group) throws GroupsException {
    if (isTreeRefreshRequired()) {
        refreshTree();
    }
    log.debug("Invoking findMemberGroupKeys() for group:  {}", group.getLocalKey());
    List<String> rslt = new LinkedList<>();
    for (Iterator it = findMemberGroups(group); it.hasNext(); ) {
        IEntityGroup g = (IEntityGroup) it.next();
        // Return composite keys here...
        rslt.add(g.getKey());
    }
    return rslt.toArray(new String[rslt.size()]);
}
Also used : IEntityGroup(org.apereo.portal.groups.IEntityGroup) Iterator(java.util.Iterator) LinkedList(java.util.LinkedList)

Aggregations

IEntityGroup (org.apereo.portal.groups.IEntityGroup)74 IGroupMember (org.apereo.portal.groups.IGroupMember)27 ArrayList (java.util.ArrayList)18 IAuthorizationPrincipal (org.apereo.portal.security.IAuthorizationPrincipal)14 EntityIdentifier (org.apereo.portal.EntityIdentifier)12 HashSet (java.util.HashSet)10 EntityEnum (org.apereo.portal.portlets.groupselector.EntityEnum)9 HashMap (java.util.HashMap)8 LinkedList (java.util.LinkedList)8 AggregatedGroupMapping (org.apereo.portal.events.aggr.groups.AggregatedGroupMapping)8 GroupsException (org.apereo.portal.groups.GroupsException)8 JsonEntityBean (org.apereo.portal.layout.dlm.remoting.JsonEntityBean)8 IPermission (org.apereo.portal.security.IPermission)8 CompositeName (javax.naming.CompositeName)7 CallableWithoutResult (org.apereo.portal.concurrency.CallableWithoutResult)7 IPortletDefinition (org.apereo.portal.portlet.om.IPortletDefinition)7 IPerson (org.apereo.portal.security.IPerson)7 BaseAggrEventsJpaDaoTest (org.apereo.portal.test.BaseAggrEventsJpaDaoTest)7 DateTime (org.joda.time.DateTime)7 Test (org.junit.Test)7