Search in sources :

Example 1 with RolePermission

use of org.kuali.kfs.kim.impl.role.RolePermission in project cu-kfs by CU-CommunityApps.

the class PermissionServiceImpl method getRoleIdsForPermissionIds.

private List<String> getRoleIdsForPermissionIds(Collection<String> permissionIds) {
    if (CollectionUtils.isEmpty(permissionIds)) {
        return Collections.emptyList();
    }
    String cacheKey = "{getRoleIdsForPermissionIds}permissionIds=" + CacheKeyUtils.key(permissionIds);
    Cache.ValueWrapper cachedValue = cacheManager.getCache(Permission.CACHE_NAME).get(cacheKey);
    if (cachedValue != null && cachedValue.get() instanceof List) {
        return (List<String>) cachedValue.get();
    }
    QueryByCriteria query = QueryByCriteria.Builder.fromPredicates(PredicateFactory.equal("active", "true"), PredicateFactory.in("permissionId", permissionIds.toArray(new String[] {})));
    GenericQueryResults<RolePermission> results = criteriaLookupService.lookup(RolePermission.class, query);
    List<String> roleIds = new ArrayList<>();
    for (RolePermission bo : results.getResults()) {
        roleIds.add(bo.getRoleId());
    }
    roleIds = Collections.unmodifiableList(roleIds);
    cacheManager.getCache(Permission.CACHE_NAME).put(cacheKey, roleIds);
    return roleIds;
}
Also used : QueryByCriteria(org.kuali.kfs.core.api.criteria.QueryByCriteria) ArrayList(java.util.ArrayList) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList) List(java.util.List) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) RolePermission(org.kuali.kfs.kim.impl.role.RolePermission) Cache(org.springframework.cache.Cache)

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1 QueryByCriteria (org.kuali.kfs.core.api.criteria.QueryByCriteria)1 RolePermission (org.kuali.kfs.kim.impl.role.RolePermission)1 Cache (org.springframework.cache.Cache)1