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;
}
Aggregations