Search in sources :

Example 31 with EntityIdentifier

use of org.apereo.portal.EntityIdentifier in project uPortal by Jasig.

the class EntityGroupImpl method getChildren.

/**
 * Returns an <code>Iterator</code> over the <code>GroupMembers</code> in our member <code>
 * Collection</code>. Reflects pending changes.
 *
 * @return Iterator
 */
@Override
public Set<IGroupMember> getChildren() throws GroupsException {
    final EntityIdentifier cacheKey = getUnderlyingEntityIdentifier();
    Element element = childrenCache.get(cacheKey);
    if (element == null) {
        final Set<IGroupMember> children = buildChildrenSet();
        element = new Element(cacheKey, children);
        childrenCache.put(element);
    }
    @SuppressWarnings("unchecked") final Set<IGroupMember> rslt = (Set<IGroupMember>) element.getObjectValue();
    return rslt;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) Element(net.sf.ehcache.Element) EntityIdentifier(org.apereo.portal.EntityIdentifier)

Example 32 with EntityIdentifier

use of org.apereo.portal.EntityIdentifier in project uPortal by Jasig.

the class GroupMemberImpl method getParentGroups.

/**
 * Returns an <code>Iterator</code> over this <code>IGroupMember's</code> parent groups.
 * Synchronize the collection of keys with adds and removes.
 *
 * @return Iterator
 */
@Override
public Set<IEntityGroup> getParentGroups() throws GroupsException {
    final EntityIdentifier cacheKey = getUnderlyingEntityIdentifier();
    Element element = parentGroupsCache.get(cacheKey);
    if (element == null) {
        final Set<IEntityGroup> groups = buildParentGroupsSet();
        element = new Element(cacheKey, groups);
        parentGroupsCache.put(element);
    }
    @SuppressWarnings("unchecked") final Set<IEntityGroup> rslt = (Set<IEntityGroup>) element.getObjectValue();
    return rslt;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) Element(net.sf.ehcache.Element) EntityIdentifier(org.apereo.portal.EntityIdentifier)

Example 33 with EntityIdentifier

use of org.apereo.portal.EntityIdentifier in project uPortal by Jasig.

the class RDBMEntityGroupStore method searchForGroups.

@Override
public EntityIdentifier[] searchForGroups(String query, SearchMethod method, Class leaftype) throws GroupsException {
    EntityIdentifier[] r = new EntityIdentifier[0];
    ArrayList ar = new ArrayList();
    Connection conn = null;
    PreparedStatement ps = null;
    int type = EntityTypesLocator.getEntityTypes().getEntityIDFromType(leaftype).intValue();
    try {
        conn = RDBMServices.getConnection();
        switch(method) {
            case DISCRETE:
                ps = conn.prepareStatement(RDBMEntityGroupStore.SEARCH_GROUPS);
                break;
            case DISCRETE_CI:
                ps = conn.prepareStatement(RDBMEntityGroupStore.SEARCH_GROUPS_CASE_INSENSITIVE);
                break;
            case STARTS_WITH:
                query = query + "%";
                ps = conn.prepareStatement(RDBMEntityGroupStore.SEARCH_GROUPS_PARTIAL);
                break;
            case STARTS_WITH_CI:
                query = query + "%";
                ps = conn.prepareStatement(RDBMEntityGroupStore.SEARCH_GROUPS_PARTIAL_CASE_INSENSITIVE);
                break;
            case ENDS_WITH:
                query = "%" + query;
                ps = conn.prepareStatement(RDBMEntityGroupStore.SEARCH_GROUPS_PARTIAL);
                break;
            case ENDS_WITH_CI:
                query = "%" + query;
                ps = conn.prepareStatement(RDBMEntityGroupStore.SEARCH_GROUPS_PARTIAL_CASE_INSENSITIVE);
                break;
            case CONTAINS:
                query = "%" + query + "%";
                ps = conn.prepareStatement(RDBMEntityGroupStore.SEARCH_GROUPS_PARTIAL);
                break;
            case CONTAINS_CI:
                query = "%" + query + "%";
                ps = conn.prepareStatement(RDBMEntityGroupStore.SEARCH_GROUPS_PARTIAL_CASE_INSENSITIVE);
                break;
            default:
                throw new GroupsException("Unknown search type");
        }
        try {
            ps.clearParameters();
            ps.setInt(1, type);
            ps.setString(2, query);
            ResultSet rs = ps.executeQuery();
            try {
                // System.out.println(ps.toString());
                while (rs.next()) {
                    // System.out.println("result");
                    ar.add(new EntityIdentifier(rs.getString(1), ICompositeGroupService.GROUP_ENTITY_TYPE));
                }
            } finally {
                close(rs);
            }
        } finally {
            close(ps);
        }
    } catch (Exception e) {
        LOG.error("RDBMChannelDefSearcher.searchForEntities(): " + ps, e);
    } finally {
        RDBMServices.releaseConnection(conn);
    }
    return (EntityIdentifier[]) ar.toArray(r);
}
Also used : ArrayList(java.util.ArrayList) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) EntityIdentifier(org.apereo.portal.EntityIdentifier) SQLException(java.sql.SQLException)

Example 34 with EntityIdentifier

use of org.apereo.portal.EntityIdentifier in project uPortal by Jasig.

the class ReferenceCompositeGroupService method searchForEntities.

/**
 * Find EntityIdentifiers for entities whose name matches the query string according to the
 * specified method and is of the specified type
 */
@Override
public EntityIdentifier[] searchForEntities(String query, IGroupConstants.SearchMethod method, Class type) throws GroupsException {
    Set allIds = new HashSet();
    for (Iterator services = getComponentServices().values().iterator(); services.hasNext(); ) {
        IIndividualGroupService service = (IIndividualGroupService) services.next();
        EntityIdentifier[] ids = service.searchForEntities(query, method, type);
        for (int i = 0; i < ids.length; i++) {
            allIds.add(ids[i]);
        }
    }
    return (EntityIdentifier[]) allIds.toArray(new EntityIdentifier[allIds.size()]);
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) Iterator(java.util.Iterator) EntityIdentifier(org.apereo.portal.EntityIdentifier) HashSet(java.util.HashSet)

Example 35 with EntityIdentifier

use of org.apereo.portal.EntityIdentifier in project uPortal by Jasig.

the class ReferenceCompositeGroupService method searchForGroups.

/**
 * Find EntityIdentifiers for groups whose name matches the query string according to the
 * specified method and matches the provided leaf type
 */
@Override
public EntityIdentifier[] searchForGroups(String query, IGroupConstants.SearchMethod method, Class leaftype) throws GroupsException {
    Set allIds = new HashSet();
    for (Iterator services = getComponentServices().values().iterator(); services.hasNext(); ) {
        IIndividualGroupService service = (IIndividualGroupService) services.next();
        EntityIdentifier[] ids = service.searchForGroups(query, method, leaftype);
        for (int i = 0; i < ids.length; i++) {
            try {
                CompositeEntityIdentifier cei = new CompositeEntityIdentifier(ids[i].getKey(), ids[i].getType());
                cei.setServiceName(service.getServiceName());
                allIds.add(cei);
            } catch (javax.naming.InvalidNameException ine) {
            }
        }
    }
    return (EntityIdentifier[]) allIds.toArray(new EntityIdentifier[allIds.size()]);
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) InvalidNameException(javax.naming.InvalidNameException) Iterator(java.util.Iterator) EntityIdentifier(org.apereo.portal.EntityIdentifier) HashSet(java.util.HashSet)

Aggregations

EntityIdentifier (org.apereo.portal.EntityIdentifier)93 IAuthorizationPrincipal (org.apereo.portal.security.IAuthorizationPrincipal)31 HashSet (java.util.HashSet)25 ArrayList (java.util.ArrayList)24 IPerson (org.apereo.portal.security.IPerson)17 GroupsException (org.apereo.portal.groups.GroupsException)16 IEntityGroup (org.apereo.portal.groups.IEntityGroup)16 Set (java.util.Set)14 IPortletDefinition (org.apereo.portal.portlet.om.IPortletDefinition)13 Iterator (java.util.Iterator)12 IGroupMember (org.apereo.portal.groups.IGroupMember)12 List (java.util.List)6 Element (net.sf.ehcache.Element)6 PortletCategory (org.apereo.portal.portlet.om.PortletCategory)6 HashMap (java.util.HashMap)5 InvalidNameException (javax.naming.InvalidNameException)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 LinkedList (java.util.LinkedList)3 Map (java.util.Map)3 GcFindGroups (edu.internet2.middleware.grouperClient.api.GcFindGroups)2