use of joynr.infrastructure.DacTypes.Role in project joynr by bmwcarit.
the class DomainAccessControlStoreEhCache method getDomainRole.
@Override
public DomainRoleEntry getDomainRole(String uid, Role role) {
Cache cache = getCache(CacheId.DOMAIN_ROLES);
Attribute<String> uidAttribute = cache.getSearchAttribute(UserRoleKey.USER_ID);
Attribute<Role> roleAttribute = cache.getSearchAttribute(UserRoleKey.ROLE);
// query is the fastest if you search for keys and if you need value then call Cache.get(key)
Query queryRequestedUid = cache.createQuery().addCriteria(uidAttribute.eq(uid)).addCriteria(roleAttribute.eq(role)).includeKeys().end();
Results results = queryRequestedUid.execute();
DomainRoleEntry domainRole = null;
if (!results.all().isEmpty()) {
// results is either empty or contains exactly one entry
assert (results.all().size() == 1);
domainRole = (DomainAccessControlStoreEhCache.<DomainRoleEntry>getElementValue(cache.get(results.all().get(0).getKey())));
}
return domainRole;
}
Aggregations