Search in sources :

Example 1 with TargetType

use of org.apereo.portal.permission.target.IPermissionTarget.TargetType in project uPortal by Jasig.

the class EntityTargetProviderImpl method searchTargets.

/*
     * (non-Javadoc)
     * @see org.apereo.portal.permission.target.IPermissionTargetProvider#searchTargets(java.lang.String)
     */
public Collection<IPermissionTarget> searchTargets(String term) {
    // Initialize a new collection of matching targets.  We use a HashSet
    // implementation here to prevent duplicate target entries.
    Collection<IPermissionTarget> matching = new HashSet<IPermissionTarget>();
    /*
         * Attempt to find matching entities for each allowed entity type.
         * Any matching entities will be added to our collection.
         */
    for (TargetType targetType : allowedTargetTypes) {
        Set<JsonEntityBean> entities = groupListHelper.search(targetType.toString(), term);
        for (JsonEntityBean entity : entities) {
            IPermissionTarget target = new PermissionTargetImpl(entity.getId(), entity.getName(), targetType);
            matching.add(target);
        }
    }
    if (IPermission.ALL_CATEGORIES_TARGET.contains(term)) {
        matching.add(ALL_CATEGORIES_TARGET);
    } else if (IPermission.ALL_PORTLETS_TARGET.contains(term)) {
        matching.add(ALL_PORTLETS_TARGET);
    } else if (IPermission.ALL_GROUPS_TARGET.contains(term)) {
        matching.add(ALL_GROUPS_TARGET);
    }
    // return the list of matching targets
    return matching;
}
Also used : JsonEntityBean(org.apereo.portal.layout.dlm.remoting.JsonEntityBean) TargetType(org.apereo.portal.permission.target.IPermissionTarget.TargetType) HashSet(java.util.HashSet)

Aggregations

HashSet (java.util.HashSet)1 JsonEntityBean (org.apereo.portal.layout.dlm.remoting.JsonEntityBean)1 TargetType (org.apereo.portal.permission.target.IPermissionTarget.TargetType)1