MNT-16541: "Cache update for custom workflow model fails"

This commit is contained in:
Steven Glover
2016-11-02 12:41:13 +00:00
parent 4b3930e124
commit a7378ac0fc
4 changed files with 48 additions and 13 deletions

View File

@@ -33,7 +33,6 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.opencmis.dictionary.CMISAbstractDictionaryService.DictionaryInitializer;
import org.alfresco.opencmis.mapping.CMISMapping;
import org.alfresco.repo.dictionary.CompiledModel;

View File

@@ -29,6 +29,9 @@ import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
import org.alfresco.repo.tenant.TenantService;
import org.alfresco.util.cache.AbstractAsynchronouslyRefreshedCache;
import org.alfresco.util.cache.RefreshableCacheEvent;
import org.alfresco.util.cache.RefreshableCacheListener;
import org.alfresco.util.cache.RefreshableCacheRefreshedEvent;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -103,4 +106,49 @@ public class CompiledModelsCache extends AbstractAsynchronouslyRefreshedCache<Di
{
this.tenantService = tenantService;
}
@Override
public void afterPropertiesSet() throws Exception
{
super.afterPropertiesSet();
// RefreshableCacheListener as anonymous class since CompileModelsCache already
// implements this interface, but expects to be invoked in different circumstances.
register(new RefreshableCacheListener()
{
@Override
public void onRefreshableCacheEvent(RefreshableCacheEvent event)
{
if (logger.isDebugEnabled())
{
logger.debug("Handling "+event.getClass().getSimpleName()+
", cache="+event.getCacheId()+
", key="+event.getKey());
}
if (event instanceof RefreshableCacheRefreshedEvent &&
event.getCacheId().equals(getCacheId()))
{
// notify registered listeners that dictionary has been initialised (population is complete).
// Note we do that here to ensure that the dictionary registry has been added to the cache,
// so that any dependencies (like the CMIS dictionary) will use the new dictionary.
for (DictionaryListener dictionaryListener : dictionaryDAO.getDictionaryListeners())
{
logger.debug("Calling afterDIctionaryInit ["+event.getClass().getSimpleName()+
", cache="+event.getCacheId()+
", key="+event.getKey()+
"] on "+
dictionaryListener.getClass().getSimpleName());
dictionaryListener.afterDictionaryInit();
}
}
}
@Override
public String getCacheId()
{
return CompiledModelsCache.this.getCacheId();
}
});
}
}

View File

@@ -59,12 +59,6 @@ public class CoreDictionaryRegistryImpl extends AbstractDictionaryRegistry
dictionaryDeployer.onDictionaryInit();
}
// notify registered listeners that dictionary has been initialised (population is complete)
for (DictionaryListener dictionaryListener : dictionaryDAO.getDictionaryListeners())
{
dictionaryListener.afterDictionaryInit();
}
// Done
if (logger.isInfoEnabled())
{

View File

@@ -221,12 +221,6 @@ public class TenantDictionaryRegistryImpl extends AbstractDictionaryRegistry
dictionaryDeployer.onDictionaryInit();
}
// notify registered listeners that dictionary has been initialised (population is complete)
for (DictionaryListener dictionaryListener : dictionaryDAO.getDictionaryListeners())
{
dictionaryListener.afterDictionaryInit();
}
// Done
if (logger.isInfoEnabled())
{