com.hp.autonomy.hod.caching.HodPerUserCacheResolver Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hod-spring-caching Show documentation
Show all versions of hod-spring-caching Show documentation
Utility classes to assist with caching in applications using Micro Focus Haven OnDemand and the Spring Caching Abstraction
package com.hp.autonomy.hod.caching;
import com.hp.autonomy.hod.client.api.resource.ResourceName;
import com.hp.autonomy.hod.sso.HodAuthenticationPrincipal;
/**
* Cache resolver for methods which should be cached per user (e.g. around API calls using mapped security)
*/
class HodPerUserCacheResolver extends AbstractHodCacheResolver {
private final HodCacheNameResolver hodCacheNameResolver;
HodPerUserCacheResolver(final HodCacheNameResolver hodCacheNameResolver) {
this.hodCacheNameResolver = hodCacheNameResolver;
}
/**
* Resolve the cache for the given name, qualified by the HOD application.
*
* @param cacheName The original cache name
* @param principal HoD authentication principal retrieved from context
* @return The cache name qualified with the application
*/
@Override
protected String resolveName(final String cacheName, final HodAuthenticationPrincipal principal) {
final ResourceName hodApplication = principal.getApplication();
final String userId = principal.getUserUuid().toString();
return hodCacheNameResolver.resolvePerUserCacheName(cacheName, hodApplication, userId);
}
}