User cache is removed on configuration update/create

This commit is contained in:
Luca Frosini 2022-04-21 17:18:02 +02:00
parent c227d5069d
commit 7acdc6a718
2 changed files with 12 additions and 0 deletions

View File

@ -4,6 +4,7 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.gcube.common.authorization.utils.manager.SecretManagerProvider; import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
import org.gcube.gcat.persistence.ckan.CKANUserCache;
/** /**
* @author Luca Frosini (ISTI - CNR) * @author Luca Frosini (ISTI - CNR)
@ -52,6 +53,11 @@ public class CatalogueConfigurationFactory {
GCoreISConfigurationProxy gCoreISConfigurationProxy = new GCoreISConfigurationProxy(context, catalogueConfiguration); GCoreISConfigurationProxy gCoreISConfigurationProxy = new GCoreISConfigurationProxy(context, catalogueConfiguration);
catalogueConfiguration = gCoreISConfigurationProxy.createOrUpdateOnIS(); catalogueConfiguration = gCoreISConfigurationProxy.createOrUpdateOnIS();
catalogueConfigurations.put(context, catalogueConfiguration); catalogueConfigurations.put(context, catalogueConfiguration);
// The supported organizations could be changed we need to empty the user cache for the context
// to avoid to miss to add an user in an organization which has been added.
CKANUserCache.emptyUserCache();
return catalogueConfiguration; return catalogueConfiguration;
} }

View File

@ -69,6 +69,12 @@ public abstract class CKANUserCache {
} }
} }
public synchronized static void emptyUserCache() {
SecretManager secretManager = SecretManagerProvider.instance.get();
String context = secretManager.getContext();
userCachePerContext.remove(context);
}
@Override @Override
protected void finalize() throws Throwable { protected void finalize() throws Throwable {
super.finalize(); super.finalize();