Search in sources :

Example 1 with CachingException

use of org.apereo.portal.concurrency.CachingException in project uPortal by Jasig.

the class MapBackedEntityCache method add.

/* (non-Javadoc)
     * @see org.apereo.portal.concurrency.IEntityCache#add(org.apereo.portal.IBasicEntity)
     */
public void add(IBasicEntity entity) throws CachingException {
    final EntityIdentifier entityIdentifier = entity.getEntityIdentifier();
    final Class<? extends IBasicEntity> addType = entityIdentifier.getType();
    if (!this.entityType.isAssignableFrom(addType)) {
        throw new CachingException("Problem adding " + entity + ": entity type '" + addType + "' is incompatible with cache type '" + this.entityType + "'.");
    }
    this.cache.put(entityIdentifier.getKey(), entity);
}
Also used : CachingException(org.apereo.portal.concurrency.CachingException) EntityIdentifier(org.apereo.portal.EntityIdentifier)

Example 2 with CachingException

use of org.apereo.portal.concurrency.CachingException in project uPortal by Jasig.

the class ReferenceIndividualGroupService method findParentGroups.

/**
     * Returns and caches the containing groups for the <code>IGroupMember</code>
     *
     * @param gm IGroupMember
     */
@Override
public Iterator findParentGroups(IGroupMember gm) throws GroupsException {
    log.debug("Finding containing groups for member {}", gm.getKey());
    Collection groups = new ArrayList(10);
    IEntityGroup group = null;
    for (Iterator it = getGroupStore().findParentGroups(gm); it.hasNext(); ) {
        group = (IEntityGroup) it.next();
        group.setLocalGroupService(this);
        groups.add(group);
        if (cacheInUse()) {
            try {
                if (getGroupFromCache(group.getEntityIdentifier().getKey()) == null) {
                    cacheAdd(group);
                }
            } catch (CachingException ce) {
                throw new GroupsException("Problem finding containing groups", ce);
            }
        }
    }
    return groups.iterator();
}
Also used : CachingException(org.apereo.portal.concurrency.CachingException) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) Collection(java.util.Collection)

Example 3 with CachingException

use of org.apereo.portal.concurrency.CachingException in project uPortal by Jasig.

the class ReferenceIndividualGroupService method findLocalMemberGroups.

/**
     * Returns and caches the member groups for the <code>IEntityGroup</code>
     *
     * @param eg IEntityGroup
     */
protected Iterator findLocalMemberGroups(IEntityGroup eg) throws GroupsException {
    Collection groups = new ArrayList(10);
    IEntityGroup group = null;
    for (Iterator it = getGroupStore().findMemberGroups(eg); it.hasNext(); ) {
        group = (IEntityGroup) it.next();
        if (group == null) {
            log.warn("A null IEntityGroup object was part of a list groupStore.findMemberGroups");
            continue;
        }
        group.setLocalGroupService(this);
        groups.add(group);
        if (cacheInUse()) {
            try {
                if (getGroupFromCache(group.getEntityIdentifier().getKey()) == null) {
                    cacheAdd(group);
                }
            } catch (CachingException ce) {
                throw new GroupsException("Problem finding member groups", ce);
            }
        }
    }
    return groups.iterator();
}
Also used : CachingException(org.apereo.portal.concurrency.CachingException) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) Collection(java.util.Collection)

Example 4 with CachingException

use of org.apereo.portal.concurrency.CachingException in project uPortal by Jasig.

the class GroupService method ifinishedSession.

/**
     * Receives notice that the UserInstance has been unbound from the HttpSession. In response, we
     * remove the corresponding group member from the cache. We use the roundabout route of creating
     * a group member and then getting its EntityIdentifier because we need the EntityIdentifier for
     * the group member, which is cached, not the EntityIdentifier for the IPerson, which is not.
     *
     * @param person org.apereo.portal.security.IPerson
     */
private void ifinishedSession(IPerson person) throws GroupsException {
    IGroupMember gm = getGroupMember(person.getEntityIdentifier());
    try {
        final EntityIdentifier entityIdentifier = gm.getEntityIdentifier();
        EntityCachingService.getEntityCachingService().remove(entityIdentifier.getType(), entityIdentifier.getKey());
    } catch (CachingException ce) {
        throw new GroupsException("Problem removing group member " + gm.getKey() + " from cache", ce);
    }
}
Also used : CachingException(org.apereo.portal.concurrency.CachingException) IGroupMember(org.apereo.portal.groups.IGroupMember) GroupsException(org.apereo.portal.groups.GroupsException) EntityIdentifier(org.apereo.portal.EntityIdentifier)

Aggregations

CachingException (org.apereo.portal.concurrency.CachingException)4 ArrayList (java.util.ArrayList)2 Collection (java.util.Collection)2 Iterator (java.util.Iterator)2 EntityIdentifier (org.apereo.portal.EntityIdentifier)2 GroupsException (org.apereo.portal.groups.GroupsException)1 IGroupMember (org.apereo.portal.groups.IGroupMember)1