mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merge branch 'REPO-1259' into 'master'
Repo 1259 Part of fix for Repo1259. * remove commented out code * fix code formatting (CMISAbstractDictionaryService) * fix up how the CMIS dictionary is refreshed after a dictionary refresh: dictionaryListener.afterDictionaryInit() is called _after_ the dictionary is made live (including changes to CompiledModelsCache to achieve this). See merge request !3
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -145,7 +145,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.alfresco</groupId>
|
<groupId>org.alfresco</groupId>
|
||||||
<artifactId>alfresco-core</artifactId>
|
<artifactId>alfresco-core</artifactId>
|
||||||
<version>6.5</version>
|
<version>6.8</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!--
|
<!--
|
||||||
| provided dependencies (are not transitive and not included in webapps)
|
| provided dependencies (are not transitive and not included in webapps)
|
||||||
|
@@ -73,20 +73,21 @@ public abstract class CMISAbstractDictionaryService extends AbstractLifecycleBea
|
|||||||
private final ReentrantReadWriteLock registryLock = new ReentrantReadWriteLock();
|
private final ReentrantReadWriteLock registryLock = new ReentrantReadWriteLock();
|
||||||
private final WriteLock registryWriteLock = registryLock.writeLock();
|
private final WriteLock registryWriteLock = registryLock.writeLock();
|
||||||
private final ReadLock registryReadLock = registryLock.readLock();
|
private final ReadLock registryReadLock = registryLock.readLock();
|
||||||
|
|
||||||
// note: cache is tenant-aware (if using TransctionalCache impl)
|
// note: cache is tenant-aware (if using TransctionalCache impl)
|
||||||
private SimpleCache<String, CMISDictionaryRegistry> singletonCache; // eg. for openCmisDictionaryRegistry
|
private SimpleCache<String, CMISDictionaryRegistry> cmisRegistryCache;
|
||||||
private final String KEY_OPENCMIS_DICTIONARY_REGISTRY = "key.openCmisDictionaryRegistry";
|
private final String KEY_OPENCMIS_DICTIONARY_REGISTRY = "key.openCmisDictionaryRegistry";
|
||||||
|
|
||||||
public void setTenantService(TenantService tenantService)
|
public void setTenantService(TenantService tenantService)
|
||||||
{
|
{
|
||||||
this.tenantService = tenantService;
|
this.tenantService = tenantService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the mapping service
|
* Set the mapping service
|
||||||
*
|
*
|
||||||
* @param cmisMapping CMISMapping
|
* @param cmisMapping
|
||||||
|
* CMISMapping
|
||||||
*/
|
*/
|
||||||
public void setCmisMapping(CMISMapping cmisMapping)
|
public void setCmisMapping(CMISMapping cmisMapping)
|
||||||
{
|
{
|
||||||
@@ -96,7 +97,8 @@ public abstract class CMISAbstractDictionaryService extends AbstractLifecycleBea
|
|||||||
/**
|
/**
|
||||||
* Set the property accessor mapping service
|
* Set the property accessor mapping service
|
||||||
*
|
*
|
||||||
* @param accessorMapping mapping
|
* @param accessorMapping
|
||||||
|
* mapping
|
||||||
*/
|
*/
|
||||||
public void setPropertyAccessorMapping(PropertyAccessorMapping accessorMapping)
|
public void setPropertyAccessorMapping(PropertyAccessorMapping accessorMapping)
|
||||||
{
|
{
|
||||||
@@ -106,7 +108,8 @@ public abstract class CMISAbstractDictionaryService extends AbstractLifecycleBea
|
|||||||
/**
|
/**
|
||||||
* Set the property lucene mapping service
|
* Set the property lucene mapping service
|
||||||
*
|
*
|
||||||
* @param luceneBuilderMapping mapping
|
* @param luceneBuilderMapping
|
||||||
|
* mapping
|
||||||
*/
|
*/
|
||||||
public void setPropertyLuceneBuilderMapping(PropertyLuceneBuilderMapping luceneBuilderMapping)
|
public void setPropertyLuceneBuilderMapping(PropertyLuceneBuilderMapping luceneBuilderMapping)
|
||||||
{
|
{
|
||||||
@@ -116,7 +119,8 @@ public abstract class CMISAbstractDictionaryService extends AbstractLifecycleBea
|
|||||||
/**
|
/**
|
||||||
* Set the dictionary Service
|
* Set the dictionary Service
|
||||||
*
|
*
|
||||||
* @param dictionaryService DictionaryService
|
* @param dictionaryService
|
||||||
|
* DictionaryService
|
||||||
*/
|
*/
|
||||||
public void setDictionaryService(DictionaryService dictionaryService)
|
public void setDictionaryService(DictionaryService dictionaryService)
|
||||||
{
|
{
|
||||||
@@ -126,7 +130,8 @@ public abstract class CMISAbstractDictionaryService extends AbstractLifecycleBea
|
|||||||
/**
|
/**
|
||||||
* Set the dictionary DAO
|
* Set the dictionary DAO
|
||||||
*
|
*
|
||||||
* @param dictionaryDAO DictionaryDAO
|
* @param dictionaryDAO
|
||||||
|
* DictionaryDAO
|
||||||
*/
|
*/
|
||||||
public void setDictionaryDAO(DictionaryDAO dictionaryDAO)
|
public void setDictionaryDAO(DictionaryDAO dictionaryDAO)
|
||||||
{
|
{
|
||||||
@@ -135,63 +140,57 @@ public abstract class CMISAbstractDictionaryService extends AbstractLifecycleBea
|
|||||||
|
|
||||||
public void setSingletonCache(SimpleCache<String, CMISDictionaryRegistry> singletonCache)
|
public void setSingletonCache(SimpleCache<String, CMISDictionaryRegistry> singletonCache)
|
||||||
{
|
{
|
||||||
this.singletonCache = singletonCache;
|
this.cmisRegistryCache = singletonCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected interface DictionaryInitializer
|
protected interface DictionaryInitializer
|
||||||
{
|
{
|
||||||
Collection<AbstractTypeDefinitionWrapper> createDefinitions(CMISDictionaryRegistry cmisRegistry);
|
Collection<AbstractTypeDefinitionWrapper> createDefinitions(CMISDictionaryRegistry cmisRegistry);
|
||||||
Collection<AbstractTypeDefinitionWrapper> createDefinitions(CMISDictionaryRegistry cmisRegistry, CompiledModel model);
|
|
||||||
|
Collection<AbstractTypeDefinitionWrapper> createDefinitions(CMISDictionaryRegistry cmisRegistry,
|
||||||
|
CompiledModel model);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract DictionaryInitializer getCoreDictionaryInitializer();
|
protected abstract DictionaryInitializer getCoreDictionaryInitializer();
|
||||||
|
|
||||||
protected abstract DictionaryInitializer getTenantDictionaryInitializer();
|
protected abstract DictionaryInitializer getTenantDictionaryInitializer();
|
||||||
|
|
||||||
protected CMISDictionaryRegistry getRegistry()
|
protected CMISDictionaryRegistry getRegistry()
|
||||||
{
|
{
|
||||||
String tenant = TenantUtil.getCurrentDomain();
|
String tenant = TenantUtil.getCurrentDomain();
|
||||||
return getRegistry(tenant);
|
return getRegistry(tenant);
|
||||||
}
|
}
|
||||||
|
|
||||||
CMISDictionaryRegistry getRegistry(String tenant)
|
CMISDictionaryRegistry getRegistry(String tenant)
|
||||||
{
|
{
|
||||||
CMISDictionaryRegistry cmisRegistry = null;
|
CMISDictionaryRegistry cmisRegistry = null;
|
||||||
boolean readLockReleased = false;
|
|
||||||
//Make sure that DictionaryRegistry exist
|
|
||||||
dictionaryDAO.getDictionaryRegistry(tenant);
|
|
||||||
|
|
||||||
registryReadLock.lock();
|
String cacheKey = getCacheKey(tenant);
|
||||||
try
|
|
||||||
{
|
|
||||||
String cacheKey = getCacheKey(tenant);
|
|
||||||
cmisRegistry = singletonCache.get(cacheKey);
|
|
||||||
if(cmisRegistry == null)
|
|
||||||
{
|
|
||||||
registryReadLock.unlock();
|
|
||||||
readLockReleased = true;
|
|
||||||
|
|
||||||
registryWriteLock.lock();
|
registryReadLock.lock();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
cmisRegistry = singletonCache.get(cacheKey);
|
cmisRegistry = cmisRegistryCache.get(cacheKey);
|
||||||
if(cmisRegistry == null)
|
}
|
||||||
{
|
finally
|
||||||
cmisRegistry = createDictionaryRegistry(tenant);
|
{
|
||||||
}
|
registryReadLock.unlock();
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
if (cmisRegistry == null)
|
||||||
registryWriteLock.unlock();
|
{
|
||||||
}
|
cmisRegistry = createDictionaryRegistry(tenant);
|
||||||
}
|
|
||||||
}
|
registryWriteLock.lock();
|
||||||
finally
|
try
|
||||||
{
|
{
|
||||||
if(!readLockReleased)
|
cmisRegistryCache.put(cacheKey, cmisRegistry);
|
||||||
{
|
}
|
||||||
registryReadLock.unlock();
|
finally
|
||||||
}
|
{
|
||||||
}
|
registryWriteLock.unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return cmisRegistry;
|
return cmisRegistry;
|
||||||
}
|
}
|
||||||
@@ -199,9 +198,8 @@ public abstract class CMISAbstractDictionaryService extends AbstractLifecycleBea
|
|||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
* @see
|
* @see org.springframework.extensions.surf.util.AbstractLifecycleBean#
|
||||||
* org.springframework.extensions.surf.util.AbstractLifecycleBean#onBootstrap
|
* onBootstrap (org.springframework.context.ApplicationEvent)
|
||||||
* (org.springframework.context.ApplicationEvent)
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void onBootstrap(ApplicationEvent event)
|
protected void onBootstrap(ApplicationEvent event)
|
||||||
@@ -233,42 +231,45 @@ public abstract class CMISAbstractDictionaryService extends AbstractLifecycleBea
|
|||||||
|
|
||||||
private String getCacheKey()
|
private String getCacheKey()
|
||||||
{
|
{
|
||||||
String tenant = tenantService.getCurrentUserDomain();
|
String tenant = tenantService.getCurrentUserDomain();
|
||||||
return getCacheKey(tenant);
|
return getCacheKey(tenant);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getCacheKey(String tenant)
|
private String getCacheKey(String tenant)
|
||||||
{
|
{
|
||||||
String cacheKey = KEY_OPENCMIS_DICTIONARY_REGISTRY + "." + tenant + "." + cmisMapping.getCmisVersion().toString();
|
String cacheKey = KEY_OPENCMIS_DICTIONARY_REGISTRY + "." + tenant + "."
|
||||||
return cacheKey;
|
+ cmisMapping.getCmisVersion().toString();
|
||||||
|
return cacheKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected CMISDictionaryRegistry createCoreDictionaryRegistry()
|
protected CMISDictionaryRegistry createCoreDictionaryRegistry()
|
||||||
{
|
{
|
||||||
CMISDictionaryRegistryImpl cmisRegistry = new CMISDictionaryRegistryImpl(this, cmisMapping, dictionaryService,
|
CMISDictionaryRegistryImpl cmisRegistry = new CMISDictionaryRegistryImpl(this, cmisMapping, dictionaryService,
|
||||||
getCoreDictionaryInitializer());
|
getCoreDictionaryInitializer());
|
||||||
cmisRegistry.init();
|
cmisRegistry.init();
|
||||||
return cmisRegistry;
|
return cmisRegistry;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected CMISDictionaryRegistry createTenantDictionaryRegistry(String tenant)
|
protected CMISDictionaryRegistry createTenantDictionaryRegistry(String tenant)
|
||||||
{
|
{
|
||||||
CMISDictionaryRegistryImpl cmisRegistry = new CMISDictionaryRegistryImpl(this, tenant, "",
|
CMISDictionaryRegistryImpl cmisRegistry = new CMISDictionaryRegistryImpl(this, tenant, "", cmisMapping,
|
||||||
cmisMapping, dictionaryService, getTenantDictionaryInitializer());
|
dictionaryService, getTenantDictionaryInitializer());
|
||||||
cmisRegistry.init();
|
cmisRegistry.init();
|
||||||
return cmisRegistry;
|
return cmisRegistry;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected CMISDictionaryRegistry createDictionaryRegistryWithWriteLock()
|
protected CMISDictionaryRegistry createDictionaryRegistryWithWriteLock()
|
||||||
{
|
{
|
||||||
CMISDictionaryRegistry cmisRegistry = null;
|
String tenant = TenantUtil.getCurrentDomain();
|
||||||
|
CMISDictionaryRegistry cmisRegistry = createDictionaryRegistry(tenant);
|
||||||
String tenant = TenantUtil.getCurrentDomain();
|
String cacheKey = getCacheKey(tenant);
|
||||||
|
|
||||||
registryWriteLock.lock();
|
registryWriteLock.lock();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
cmisRegistry = createDictionaryRegistry(tenant);
|
// publish new registry
|
||||||
|
cmisRegistryCache.put(cacheKey, cmisRegistry);
|
||||||
|
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@@ -280,20 +281,16 @@ public abstract class CMISAbstractDictionaryService extends AbstractLifecycleBea
|
|||||||
|
|
||||||
protected CMISDictionaryRegistry createDictionaryRegistry(String tenant)
|
protected CMISDictionaryRegistry createDictionaryRegistry(String tenant)
|
||||||
{
|
{
|
||||||
CMISDictionaryRegistry cmisRegistry = null;
|
CMISDictionaryRegistry cmisRegistry = null;
|
||||||
String cacheKey = getCacheKey(tenant);
|
|
||||||
|
|
||||||
if(tenant.equals(TenantService.DEFAULT_DOMAIN))
|
if (tenant.equals(TenantService.DEFAULT_DOMAIN))
|
||||||
{
|
{
|
||||||
cmisRegistry = createCoreDictionaryRegistry();
|
cmisRegistry = createCoreDictionaryRegistry();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cmisRegistry = createTenantDictionaryRegistry(tenant);
|
cmisRegistry = createTenantDictionaryRegistry(tenant);
|
||||||
}
|
}
|
||||||
|
|
||||||
// publish new registry
|
|
||||||
singletonCache.put(cacheKey, cmisRegistry);
|
|
||||||
|
|
||||||
return cmisRegistry;
|
return cmisRegistry;
|
||||||
}
|
}
|
||||||
@@ -373,7 +370,7 @@ public abstract class CMISAbstractDictionaryService extends AbstractLifecycleBea
|
|||||||
{
|
{
|
||||||
return getRegistry().getAssocDefByQName(cmisMapping.getCmisType(clazz));
|
return getRegistry().getAssocDefByQName(cmisMapping.getCmisType(clazz));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TypeDefinitionWrapper findTypeByQueryName(String queryName)
|
public TypeDefinitionWrapper findTypeByQueryName(String queryName)
|
||||||
{
|
{
|
||||||
@@ -418,15 +415,16 @@ public abstract class CMISAbstractDictionaryService extends AbstractLifecycleBea
|
|||||||
@Override
|
@Override
|
||||||
public List<TypeDefinitionWrapper> getAllTypes()
|
public List<TypeDefinitionWrapper> getAllTypes()
|
||||||
{
|
{
|
||||||
// TODO is there a way of not having to reconstruct this every time?
|
// TODO is there a way of not having to reconstruct this every time?
|
||||||
return Collections.unmodifiableList(new ArrayList<TypeDefinitionWrapper>(getRegistry().getTypeDefs()));
|
return Collections.unmodifiableList(new ArrayList<TypeDefinitionWrapper>(getRegistry().getTypeDefs()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<TypeDefinitionWrapper> getAllTypes(boolean includeParent)
|
public List<TypeDefinitionWrapper> getAllTypes(boolean includeParent)
|
||||||
{
|
{
|
||||||
// TODO is there a way of not having to reconstruct this every time?
|
// TODO is there a way of not having to reconstruct this every time?
|
||||||
return Collections.unmodifiableList(new ArrayList<TypeDefinitionWrapper>(getRegistry().getTypeDefs(includeParent)));
|
return Collections
|
||||||
|
.unmodifiableList(new ArrayList<TypeDefinitionWrapper>(getRegistry().getTypeDefs(includeParent)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -454,7 +452,7 @@ public abstract class CMISAbstractDictionaryService extends AbstractLifecycleBea
|
|||||||
@Override
|
@Override
|
||||||
public void modelAdded(CompiledModel model, String tenantDomain)
|
public void modelAdded(CompiledModel model, String tenantDomain)
|
||||||
{
|
{
|
||||||
getRegistry(tenantDomain).addModel(model);
|
getRegistry(tenantDomain).addModel(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -465,7 +463,7 @@ public abstract class CMISAbstractDictionaryService extends AbstractLifecycleBea
|
|||||||
@Override
|
@Override
|
||||||
public void afterDictionaryInit()
|
public void afterDictionaryInit()
|
||||||
{
|
{
|
||||||
createDictionaryRegistryWithWriteLock();
|
createDictionaryRegistryWithWriteLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -480,8 +478,8 @@ public abstract class CMISAbstractDictionaryService extends AbstractLifecycleBea
|
|||||||
registryWriteLock.lock();
|
registryWriteLock.lock();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
String cacheKey = getCacheKey();
|
String cacheKey = getCacheKey();
|
||||||
singletonCache.remove(cacheKey);
|
cmisRegistryCache.remove(cacheKey);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@@ -493,7 +491,7 @@ public abstract class CMISAbstractDictionaryService extends AbstractLifecycleBea
|
|||||||
public List<TypeDefinitionWrapper> getChildren(String typeId)
|
public List<TypeDefinitionWrapper> getChildren(String typeId)
|
||||||
{
|
{
|
||||||
List<TypeDefinitionWrapper> children = getRegistry().getChildren(typeId);
|
List<TypeDefinitionWrapper> children = getRegistry().getChildren(typeId);
|
||||||
|
|
||||||
for (TypeDefinitionWrapper child : children)
|
for (TypeDefinitionWrapper child : children)
|
||||||
{
|
{
|
||||||
if (child != null && child.getTypeDefinition(false).getDisplayName() == null)
|
if (child != null && child.getTypeDefinition(false).getDisplayName() == null)
|
||||||
@@ -501,7 +499,7 @@ public abstract class CMISAbstractDictionaryService extends AbstractLifecycleBea
|
|||||||
child.updateDefinition(dictionaryService);
|
child.updateDefinition(dictionaryService);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return children;
|
return children;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -33,7 +33,6 @@ import java.util.LinkedList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
|
||||||
import org.alfresco.opencmis.dictionary.CMISAbstractDictionaryService.DictionaryInitializer;
|
import org.alfresco.opencmis.dictionary.CMISAbstractDictionaryService.DictionaryInitializer;
|
||||||
import org.alfresco.opencmis.mapping.CMISMapping;
|
import org.alfresco.opencmis.mapping.CMISMapping;
|
||||||
import org.alfresco.repo.dictionary.CompiledModel;
|
import org.alfresco.repo.dictionary.CompiledModel;
|
||||||
|
@@ -1,77 +0,0 @@
|
|||||||
/*
|
|
||||||
* #%L
|
|
||||||
* Alfresco Data model classes
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
|
||||||
* %%
|
|
||||||
* This file is part of the Alfresco software.
|
|
||||||
* If the software was purchased under a paid Alfresco license, the terms of
|
|
||||||
* the paid license agreement will prevail. Otherwise, the software is
|
|
||||||
* provided under the following open source license terms:
|
|
||||||
*
|
|
||||||
* Alfresco is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Alfresco is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
* #L%
|
|
||||||
*/
|
|
||||||
package org.alfresco.opencmis.dictionary;
|
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
import org.springframework.context.ApplicationEvent;
|
|
||||||
import org.springframework.extensions.surf.util.AbstractLifecycleBean;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Temporary workaround for:
|
|
||||||
* <ul>
|
|
||||||
* <li>ACE-5041: CLONE - google docs content cannot be accessed via cmis</li>
|
|
||||||
* </ul>
|
|
||||||
*
|
|
||||||
* TODO: Remove this bean when rework for MNT-14819 is complete.
|
|
||||||
*
|
|
||||||
* @author Matt Ward
|
|
||||||
*/
|
|
||||||
public final class CMISDictionaryReload extends AbstractLifecycleBean
|
|
||||||
{
|
|
||||||
private static final Log log = LogFactory.getLog(CMISDictionaryReload.class);
|
|
||||||
private final CMISAbstractDictionaryService cmisDictService;
|
|
||||||
private final boolean enabled;
|
|
||||||
|
|
||||||
public CMISDictionaryReload(CMISAbstractDictionaryService cmisDictService, boolean enabled)
|
|
||||||
{
|
|
||||||
this.cmisDictService = cmisDictService;
|
|
||||||
this.enabled = enabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void reload()
|
|
||||||
{
|
|
||||||
if (enabled)
|
|
||||||
{
|
|
||||||
// Avoid deadlock by making sure we already have a registry present.
|
|
||||||
cmisDictService.getRegistry();
|
|
||||||
log.debug("Reloading CMIS dictionary.");
|
|
||||||
cmisDictService.afterDictionaryInit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onBootstrap(ApplicationEvent event)
|
|
||||||
{
|
|
||||||
reload();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onShutdown(ApplicationEvent event)
|
|
||||||
{
|
|
||||||
// Do nothing.
|
|
||||||
}
|
|
||||||
}
|
|
@@ -29,6 +29,9 @@ import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
|||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||||
import org.alfresco.repo.tenant.TenantService;
|
import org.alfresco.repo.tenant.TenantService;
|
||||||
import org.alfresco.util.cache.AbstractAsynchronouslyRefreshedCache;
|
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.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
@@ -103,4 +106,49 @@ public class CompiledModelsCache extends AbstractAsynchronouslyRefreshedCache<Di
|
|||||||
{
|
{
|
||||||
this.tenantService = tenantService;
|
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();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -59,12 +59,6 @@ public class CoreDictionaryRegistryImpl extends AbstractDictionaryRegistry
|
|||||||
dictionaryDeployer.onDictionaryInit();
|
dictionaryDeployer.onDictionaryInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
// notify registered listeners that dictionary has been initialised (population is complete)
|
|
||||||
for (DictionaryListener dictionaryListener : dictionaryDAO.getDictionaryListeners())
|
|
||||||
{
|
|
||||||
dictionaryListener.afterDictionaryInit();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Done
|
// Done
|
||||||
if (logger.isInfoEnabled())
|
if (logger.isInfoEnabled())
|
||||||
{
|
{
|
||||||
@@ -87,33 +81,7 @@ public class CoreDictionaryRegistryImpl extends AbstractDictionaryRegistry
|
|||||||
protected QName putModelImpl(CompiledModel model)
|
protected QName putModelImpl(CompiledModel model)
|
||||||
{
|
{
|
||||||
// TODO disallow model overrides for the core dictionary
|
// TODO disallow model overrides for the core dictionary
|
||||||
|
|
||||||
// if(compiledModels.get(model.getModelDefinition().getName()) != null)
|
|
||||||
// {
|
|
||||||
// throw new AlfrescoRuntimeException("Cannot override existing model " + model.getModelDefinition().getName());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// for(M2Namespace namespace : model.getM2Model().getNamespaces())
|
|
||||||
// {
|
|
||||||
// if(uriToModels.get(namespace.getUri()) != null)
|
|
||||||
// {
|
|
||||||
// throw new AlfrescoRuntimeException("Cannot override existing namespace " + namespace.getUri());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
QName qname = super.putModelImpl(model);
|
QName qname = super.putModelImpl(model);
|
||||||
|
|
||||||
// if(dictionaryDAO.isContextRefreshed())
|
|
||||||
// {
|
|
||||||
// for(DictionaryListener listener : dictionaryDAO.getDictionaryListeners())
|
|
||||||
// {
|
|
||||||
// if(listener instanceof ExtendedDictionaryListener)
|
|
||||||
// {
|
|
||||||
// ((ExtendedDictionaryListener)listener).coreModelAdded(model);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
return qname;
|
return qname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -186,9 +186,6 @@ public class DictionaryDAOImpl implements DictionaryDAO, NamespaceDAO,
|
|||||||
{
|
{
|
||||||
DictionaryRegistry dictionaryRegistry = new CoreDictionaryRegistryImpl(
|
DictionaryRegistry dictionaryRegistry = new CoreDictionaryRegistryImpl(
|
||||||
this);
|
this);
|
||||||
getThreadLocal().put("", dictionaryRegistry);
|
|
||||||
dictionaryRegistry.init();
|
|
||||||
getThreadLocal().remove("");
|
|
||||||
return dictionaryRegistry;
|
return dictionaryRegistry;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,9 +199,6 @@ public class DictionaryDAOImpl implements DictionaryDAO, NamespaceDAO,
|
|||||||
{
|
{
|
||||||
DictionaryRegistry dictionaryRegistry = new TenantDictionaryRegistryImpl(
|
DictionaryRegistry dictionaryRegistry = new TenantDictionaryRegistryImpl(
|
||||||
DictionaryDAOImpl.this, tenant);
|
DictionaryDAOImpl.this, tenant);
|
||||||
getThreadLocal().put(tenant, dictionaryRegistry);
|
|
||||||
dictionaryRegistry.init();
|
|
||||||
getThreadLocal().remove(tenant);
|
|
||||||
return dictionaryRegistry;
|
return dictionaryRegistry;
|
||||||
}
|
}
|
||||||
}, tenantService.getDomainUser(
|
}, tenantService.getDomainUser(
|
||||||
@@ -233,7 +227,6 @@ public class DictionaryDAOImpl implements DictionaryDAO, NamespaceDAO,
|
|||||||
|
|
||||||
// TODO Should be reworked when ACE-2001 will be implemented
|
// TODO Should be reworked when ACE-2001 will be implemented
|
||||||
dictionaryRegistryCache.remove(tenant);
|
dictionaryRegistryCache.remove(tenant);
|
||||||
dictionaryRegistryCache.refresh(tenant);
|
|
||||||
|
|
||||||
if (logger.isDebugEnabled())
|
if (logger.isDebugEnabled())
|
||||||
{
|
{
|
||||||
|
@@ -221,12 +221,6 @@ public class TenantDictionaryRegistryImpl extends AbstractDictionaryRegistry
|
|||||||
dictionaryDeployer.onDictionaryInit();
|
dictionaryDeployer.onDictionaryInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
// notify registered listeners that dictionary has been initialised (population is complete)
|
|
||||||
for (DictionaryListener dictionaryListener : dictionaryDAO.getDictionaryListeners())
|
|
||||||
{
|
|
||||||
dictionaryListener.afterDictionaryInit();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Done
|
// Done
|
||||||
if (logger.isInfoEnabled())
|
if (logger.isInfoEnabled())
|
||||||
{
|
{
|
||||||
|
@@ -33,9 +33,6 @@ import org.alfresco.service.NotAuditable;
|
|||||||
import org.alfresco.service.cmr.i18n.MessageLookup;
|
import org.alfresco.service.cmr.i18n.MessageLookup;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
|
|
||||||
import com.sun.tools.xjc.outline.Aspect;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This interface represents the Repository Data Dictionary. The
|
* This interface represents the Repository Data Dictionary. The
|
||||||
|
Reference in New Issue
Block a user