User Cache is per Scope and not per ckan installation. Fixed this issue

This commit is contained in:
Luca Frosini 2019-09-18 12:58:03 +02:00
parent 3f542a763b
commit d12ed67446
1 changed files with 5 additions and 5 deletions

View File

@ -22,7 +22,7 @@ public abstract class CKANUserCache {
private static final MutableConfiguration<String,CKANUser> userCacheConfiguration; private static final MutableConfiguration<String,CKANUser> userCacheConfiguration;
private static final Map<String,Cache<String,CKANUser>> userCachePerCkanInstance; private static final Map<String,Cache<String,CKANUser>> userCachePerContext;
static { static {
CachingProvider provider = Caching.getCachingProvider(); CachingProvider provider = Caching.getCachingProvider();
@ -32,18 +32,18 @@ public abstract class CKANUserCache {
.setStoreByValue(false) .setStoreByValue(false)
.setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(new Duration(TimeUnit.MINUTES, 15))); .setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(new Duration(TimeUnit.MINUTES, 15)));
userCachePerCkanInstance = new HashMap<String,Cache<String,CKANUser>>(); userCachePerContext = new HashMap<String,Cache<String,CKANUser>>();
} }
private CKANUserCache() { private CKANUserCache() {
} }
public static CKANUser getCurrrentCKANUser() { public static CKANUser getCurrrentCKANUser() {
String ckanURL = CKANInstance.getInstance().getCKANURL(); String context = ContextUtility.getCurrentContext();
Cache<String,CKANUser> userCache = userCachePerCkanInstance.get(ckanURL); Cache<String,CKANUser> userCache = userCachePerContext.get(context);
if(userCache == null) { if(userCache == null) {
userCache = cacheManager.createCache(USERS_CACHE, userCacheConfiguration); userCache = cacheManager.createCache(USERS_CACHE, userCacheConfiguration);
userCachePerCkanInstance.put(ckanURL, userCache); userCachePerContext.put(context, userCache);
} }
String gcubeUsername = ContextUtility.getUsername(); String gcubeUsername = ContextUtility.getUsername();