mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Formatting (line-endings) only
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@13697 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2005-2009 Alfresco Software Limited.
|
* Copyright (C) 2005-2009 Alfresco Software Limited.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
@@ -71,13 +71,13 @@ public class RepoXMLConfigService extends XMLConfigService implements TenantDepl
|
|||||||
private AuthenticationComponent authenticationComponent;
|
private AuthenticationComponent authenticationComponent;
|
||||||
private TenantAdminService tenantAdminService;
|
private TenantAdminService tenantAdminService;
|
||||||
|
|
||||||
// Internal cache (clusterable)
|
// Internal cache (clusterable)
|
||||||
private SimpleCache<String, ConfigData> configDataCache;
|
private SimpleCache<String, ConfigData> configDataCache;
|
||||||
|
|
||||||
// used to reset the cache
|
// used to reset the cache
|
||||||
private ThreadLocal<String> tenantDomainThreadLocal = new ThreadLocal<String>();
|
private ThreadLocal<String> tenantDomainThreadLocal = new ThreadLocal<String>();
|
||||||
private ThreadLocal<ConfigData> configDataThreadLocal = new ThreadLocal<ConfigData>();
|
private ThreadLocal<ConfigData> configDataThreadLocal = new ThreadLocal<ConfigData>();
|
||||||
|
|
||||||
public void setTransactionService(TransactionService transactionService)
|
public void setTransactionService(TransactionService transactionService)
|
||||||
{
|
{
|
||||||
this.transactionService = transactionService;
|
this.transactionService = transactionService;
|
||||||
@@ -93,11 +93,11 @@ public class RepoXMLConfigService extends XMLConfigService implements TenantDepl
|
|||||||
this.tenantAdminService = tenantAdminService;
|
this.tenantAdminService = tenantAdminService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setConfigDataCache(SimpleCache<String, ConfigData> configDataCache)
|
public void setConfigDataCache(SimpleCache<String, ConfigData> configDataCache)
|
||||||
{
|
{
|
||||||
this.configDataCache = configDataCache;
|
this.configDataCache = configDataCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs an XMLConfigService using the given config source
|
* Constructs an XMLConfigService using the given config source
|
||||||
@@ -112,12 +112,12 @@ public class RepoXMLConfigService extends XMLConfigService implements TenantDepl
|
|||||||
|
|
||||||
public List<ConfigDeployment> initConfig()
|
public List<ConfigDeployment> initConfig()
|
||||||
{
|
{
|
||||||
return resetRepoConfig().getConfigDeployments();
|
return resetRepoConfig().getConfigDeployments();
|
||||||
}
|
}
|
||||||
|
|
||||||
private ConfigData initRepoConfig(String tenantDomain)
|
private ConfigData initRepoConfig(String tenantDomain)
|
||||||
{
|
{
|
||||||
ConfigData configData = null;
|
ConfigData configData = null;
|
||||||
|
|
||||||
// can be null e.g. initial login, after fresh bootstrap
|
// can be null e.g. initial login, after fresh bootstrap
|
||||||
String currentUser = authenticationComponent.getCurrentUserName();
|
String currentUser = authenticationComponent.getCurrentUserName();
|
||||||
@@ -132,15 +132,15 @@ public class RepoXMLConfigService extends XMLConfigService implements TenantDepl
|
|||||||
{
|
{
|
||||||
userTransaction.begin();
|
userTransaction.begin();
|
||||||
|
|
||||||
// parse config
|
// parse config
|
||||||
List<ConfigDeployment> configDeployments = super.initConfig();
|
List<ConfigDeployment> configDeployments = super.initConfig();
|
||||||
|
|
||||||
configData = getConfigDataLocal(tenantDomain);
|
configData = getConfigDataLocal(tenantDomain);
|
||||||
if (configData != null)
|
if (configData != null)
|
||||||
{
|
{
|
||||||
configData.setConfigDeployments(configDeployments);
|
configData.setConfigDeployments(configDeployments);
|
||||||
}
|
}
|
||||||
|
|
||||||
userTransaction.commit();
|
userTransaction.commit();
|
||||||
|
|
||||||
logger.info("Config initialised");
|
logger.info("Config initialised");
|
||||||
@@ -158,7 +158,7 @@ public class RepoXMLConfigService extends XMLConfigService implements TenantDepl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return configData;
|
return configData;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void destroy()
|
public void destroy()
|
||||||
@@ -167,76 +167,76 @@ public class RepoXMLConfigService extends XMLConfigService implements TenantDepl
|
|||||||
|
|
||||||
logger.info("Config destroyed");
|
logger.info("Config destroyed");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resets the config service
|
* Resets the config service
|
||||||
*/
|
*/
|
||||||
public void reset()
|
public void reset()
|
||||||
{
|
{
|
||||||
resetRepoConfig();
|
resetRepoConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resets the config service
|
* Resets the config service
|
||||||
*/
|
*/
|
||||||
private ConfigData resetRepoConfig()
|
private ConfigData resetRepoConfig()
|
||||||
{
|
{
|
||||||
if (logger.isDebugEnabled())
|
if (logger.isDebugEnabled())
|
||||||
{
|
{
|
||||||
logger.debug("Resetting repo config service");
|
logger.debug("Resetting repo config service");
|
||||||
}
|
}
|
||||||
|
|
||||||
String tenantDomain = getTenantDomain();
|
String tenantDomain = getTenantDomain();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
destroy();
|
destroy();
|
||||||
|
|
||||||
// create threadlocal, if needed
|
// create threadlocal, if needed
|
||||||
ConfigData configData = getConfigDataLocal(tenantDomain);
|
ConfigData configData = getConfigDataLocal(tenantDomain);
|
||||||
if (configData == null)
|
if (configData == null)
|
||||||
{
|
{
|
||||||
configData = new ConfigData();
|
configData = new ConfigData();
|
||||||
this.tenantDomainThreadLocal.set(tenantDomain);
|
this.tenantDomainThreadLocal.set(tenantDomain);
|
||||||
this.configDataThreadLocal.set(configData);
|
this.configDataThreadLocal.set(configData);
|
||||||
}
|
}
|
||||||
|
|
||||||
configData = initRepoConfig(tenantDomain);
|
configData = initRepoConfig(tenantDomain);
|
||||||
|
|
||||||
if (configData == null)
|
if (configData == null)
|
||||||
{
|
{
|
||||||
// unexpected
|
// unexpected
|
||||||
throw new AlfrescoRuntimeException("Failed to reset configData " + tenantDomain);
|
throw new AlfrescoRuntimeException("Failed to reset configData " + tenantDomain);
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
writeLock.lock();
|
writeLock.lock();
|
||||||
configDataCache.put(tenantDomain, configData);
|
configDataCache.put(tenantDomain, configData);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
writeLock.unlock();
|
writeLock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return configData;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
readLock.lock();
|
||||||
|
if (configDataCache.get(tenantDomain) != null)
|
||||||
|
{
|
||||||
|
this.configDataThreadLocal.set(null); // it's in the cache, clear the threadlocal
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
readLock.unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return configData;
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
readLock.lock();
|
|
||||||
if (configDataCache.get(tenantDomain) != null)
|
|
||||||
{
|
|
||||||
this.configDataThreadLocal.set(null); // it's in the cache, clear the threadlocal
|
|
||||||
}
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
readLock.unlock();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onBootstrap(ApplicationEvent event)
|
protected void onBootstrap(ApplicationEvent event)
|
||||||
@@ -274,230 +274,230 @@ public class RepoXMLConfigService extends XMLConfigService implements TenantDepl
|
|||||||
destroy(); // will be called in context of tenant
|
destroy(); // will be called in context of tenant
|
||||||
}
|
}
|
||||||
|
|
||||||
// re-entrant (eg. via reset)
|
// re-entrant (eg. via reset)
|
||||||
private ConfigData getConfigData()
|
private ConfigData getConfigData()
|
||||||
{
|
{
|
||||||
String tenantDomain = getTenantDomain();
|
String tenantDomain = getTenantDomain();
|
||||||
|
|
||||||
// check threadlocal first - return if set
|
// check threadlocal first - return if set
|
||||||
ConfigData configData = getConfigDataLocal(tenantDomain);
|
ConfigData configData = getConfigDataLocal(tenantDomain);
|
||||||
if (configData != null)
|
if (configData != null)
|
||||||
{
|
{
|
||||||
return configData; // return local config
|
return configData; // return local config
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// check cache second - return if set
|
// check cache second - return if set
|
||||||
readLock.lock();
|
readLock.lock();
|
||||||
configData = configDataCache.get(tenantDomain);
|
configData = configDataCache.get(tenantDomain);
|
||||||
|
|
||||||
if (configData != null)
|
if (configData != null)
|
||||||
{
|
{
|
||||||
return configData; // return cached config
|
return configData; // return cached config
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
readLock.unlock();
|
readLock.unlock();
|
||||||
}
|
|
||||||
|
|
||||||
// reset caches - may have been invalidated (e.g. in a cluster)
|
|
||||||
configData = resetRepoConfig();
|
|
||||||
|
|
||||||
if (configData == null)
|
|
||||||
{
|
|
||||||
// unexpected
|
|
||||||
throw new AlfrescoRuntimeException("Failed to get configData " + tenantDomain);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return configData;
|
// reset caches - may have been invalidated (e.g. in a cluster)
|
||||||
}
|
configData = resetRepoConfig();
|
||||||
|
|
||||||
|
if (configData == null)
|
||||||
|
{
|
||||||
|
// unexpected
|
||||||
|
throw new AlfrescoRuntimeException("Failed to get configData " + tenantDomain);
|
||||||
|
}
|
||||||
|
|
||||||
|
return configData;
|
||||||
|
}
|
||||||
|
|
||||||
// get threadlocal
|
// get threadlocal
|
||||||
private ConfigData getConfigDataLocal(String tenantDomain)
|
private ConfigData getConfigDataLocal(String tenantDomain)
|
||||||
|
{
|
||||||
|
ConfigData configData = this.configDataThreadLocal.get();
|
||||||
|
|
||||||
|
// check to see if domain switched (eg. during login)
|
||||||
|
if ((configData != null) && (tenantDomain.equals(tenantDomainThreadLocal.get())))
|
||||||
|
{
|
||||||
|
return configData; // return threadlocal, if set
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void removeConfigData()
|
||||||
{
|
{
|
||||||
ConfigData configData = this.configDataThreadLocal.get();
|
|
||||||
|
|
||||||
// check to see if domain switched (eg. during login)
|
|
||||||
if ((configData != null) && (tenantDomain.equals(tenantDomainThreadLocal.get())))
|
|
||||||
{
|
|
||||||
return configData; // return threadlocal, if set
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void removeConfigData()
|
|
||||||
{
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
writeLock.lock();
|
writeLock.lock();
|
||||||
String tenantDomain = getTenantDomain();
|
String tenantDomain = getTenantDomain();
|
||||||
if (configDataCache.get(tenantDomain) != null)
|
if (configDataCache.get(tenantDomain) != null)
|
||||||
{
|
{
|
||||||
configDataCache.remove(tenantDomain);
|
configDataCache.remove(tenantDomain);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
writeLock.unlock();
|
writeLock.unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ConfigImpl getGlobalConfigImpl()
|
||||||
|
{
|
||||||
|
return getConfigData().getGlobalConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void putGlobalConfig(ConfigImpl globalConfig)
|
||||||
|
{
|
||||||
|
getConfigData().setGlobalConfig(globalConfig);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ConfigImpl getGlobalConfigImpl()
|
|
||||||
{
|
|
||||||
return getConfigData().getGlobalConfig();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void putGlobalConfig(ConfigImpl globalConfig)
|
|
||||||
{
|
|
||||||
getConfigData().setGlobalConfig(globalConfig);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void removeGlobalConfig()
|
protected void removeGlobalConfig()
|
||||||
{
|
{
|
||||||
removeConfigData();
|
removeConfigData();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Map<String, Evaluator> getEvaluators()
|
protected Map<String, Evaluator> getEvaluators()
|
||||||
{
|
{
|
||||||
return getConfigData().getEvaluators();
|
return getConfigData().getEvaluators();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void putEvaluators(Map<String, Evaluator> evaluators)
|
protected void putEvaluators(Map<String, Evaluator> evaluators)
|
||||||
{
|
{
|
||||||
getConfigData().setEvaluators(evaluators);
|
getConfigData().setEvaluators(evaluators);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void removeEvaluators()
|
protected void removeEvaluators()
|
||||||
{
|
{
|
||||||
removeConfigData();
|
removeConfigData();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Map<String, List<ConfigSection>> getSectionsByArea()
|
protected Map<String, List<ConfigSection>> getSectionsByArea()
|
||||||
{
|
{
|
||||||
return getConfigData().getSectionsByArea();
|
return getConfigData().getSectionsByArea();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void putSectionsByArea(Map<String, List<ConfigSection>> sectionsByArea)
|
protected void putSectionsByArea(Map<String, List<ConfigSection>> sectionsByArea)
|
||||||
{
|
{
|
||||||
getConfigData().setSectionsByArea(sectionsByArea);
|
getConfigData().setSectionsByArea(sectionsByArea);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void removeSectionsByArea()
|
protected void removeSectionsByArea()
|
||||||
{
|
{
|
||||||
removeConfigData();
|
removeConfigData();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<ConfigSection> getSections()
|
protected List<ConfigSection> getSections()
|
||||||
{
|
{
|
||||||
return getConfigData().getSections();
|
return getConfigData().getSections();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void putSections(List<ConfigSection> sections)
|
protected void putSections(List<ConfigSection> sections)
|
||||||
{
|
{
|
||||||
getConfigData().setSections(sections);
|
getConfigData().setSections(sections);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void removeSections()
|
protected void removeSections()
|
||||||
{
|
{
|
||||||
removeConfigData();
|
removeConfigData();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Map<String, ConfigElementReader> getElementReaders()
|
protected Map<String, ConfigElementReader> getElementReaders()
|
||||||
{
|
{
|
||||||
return getConfigData().getElementReaders();
|
return getConfigData().getElementReaders();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void putElementReaders(Map<String, ConfigElementReader> elementReaders)
|
protected void putElementReaders(Map<String, ConfigElementReader> elementReaders)
|
||||||
{
|
{
|
||||||
getConfigData().setElementReaders(elementReaders);
|
getConfigData().setElementReaders(elementReaders);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void removeElementReaders()
|
protected void removeElementReaders()
|
||||||
{
|
{
|
||||||
removeConfigData();
|
removeConfigData();
|
||||||
}
|
}
|
||||||
|
|
||||||
// local helper - returns tenant domain (or empty string if default non-tenant)
|
// local helper - returns tenant domain (or empty string if default non-tenant)
|
||||||
private String getTenantDomain()
|
private String getTenantDomain()
|
||||||
{
|
{
|
||||||
return tenantAdminService.getCurrentUserDomain();
|
return tenantAdminService.getCurrentUserDomain();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ConfigData
|
private class ConfigData
|
||||||
{
|
{
|
||||||
private ConfigImpl globalConfig;
|
private ConfigImpl globalConfig;
|
||||||
private Map<String, Evaluator> evaluators;
|
private Map<String, Evaluator> evaluators;
|
||||||
private Map<String, List<ConfigSection>> sectionsByArea;
|
private Map<String, List<ConfigSection>> sectionsByArea;
|
||||||
private List<ConfigSection> sections;
|
private List<ConfigSection> sections;
|
||||||
private Map<String, ConfigElementReader> elementReaders;
|
private Map<String, ConfigElementReader> elementReaders;
|
||||||
|
|
||||||
private List<ConfigDeployment> configDeployments;
|
private List<ConfigDeployment> configDeployments;
|
||||||
|
|
||||||
public ConfigImpl getGlobalConfig()
|
public ConfigImpl getGlobalConfig()
|
||||||
{
|
{
|
||||||
return globalConfig;
|
return globalConfig;
|
||||||
}
|
}
|
||||||
public void setGlobalConfig(ConfigImpl globalConfig)
|
public void setGlobalConfig(ConfigImpl globalConfig)
|
||||||
{
|
{
|
||||||
this.globalConfig = globalConfig;
|
this.globalConfig = globalConfig;
|
||||||
}
|
}
|
||||||
public Map<String, Evaluator> getEvaluators()
|
public Map<String, Evaluator> getEvaluators()
|
||||||
{
|
{
|
||||||
return evaluators;
|
return evaluators;
|
||||||
}
|
}
|
||||||
public void setEvaluators(Map<String, Evaluator> evaluators)
|
public void setEvaluators(Map<String, Evaluator> evaluators)
|
||||||
{
|
{
|
||||||
this.evaluators = evaluators;
|
this.evaluators = evaluators;
|
||||||
}
|
}
|
||||||
public Map<String, List<ConfigSection>> getSectionsByArea()
|
public Map<String, List<ConfigSection>> getSectionsByArea()
|
||||||
{
|
{
|
||||||
return sectionsByArea;
|
return sectionsByArea;
|
||||||
}
|
}
|
||||||
public void setSectionsByArea(Map<String, List<ConfigSection>> sectionsByArea)
|
public void setSectionsByArea(Map<String, List<ConfigSection>> sectionsByArea)
|
||||||
{
|
{
|
||||||
this.sectionsByArea = sectionsByArea;
|
this.sectionsByArea = sectionsByArea;
|
||||||
}
|
}
|
||||||
public List<ConfigSection> getSections()
|
public List<ConfigSection> getSections()
|
||||||
{
|
{
|
||||||
return sections;
|
return sections;
|
||||||
}
|
}
|
||||||
public void setSections(List<ConfigSection> sections)
|
public void setSections(List<ConfigSection> sections)
|
||||||
{
|
{
|
||||||
this.sections = sections;
|
this.sections = sections;
|
||||||
}
|
}
|
||||||
public Map<String, ConfigElementReader> getElementReaders()
|
public Map<String, ConfigElementReader> getElementReaders()
|
||||||
{
|
{
|
||||||
return elementReaders;
|
return elementReaders;
|
||||||
}
|
}
|
||||||
public void setElementReaders(Map<String, ConfigElementReader> elementReaders)
|
public void setElementReaders(Map<String, ConfigElementReader> elementReaders)
|
||||||
{
|
{
|
||||||
this.elementReaders = elementReaders;
|
this.elementReaders = elementReaders;
|
||||||
}
|
}
|
||||||
public List<ConfigDeployment> getConfigDeployments()
|
public List<ConfigDeployment> getConfigDeployments()
|
||||||
{
|
{
|
||||||
return configDeployments;
|
return configDeployments;
|
||||||
}
|
}
|
||||||
public void setConfigDeployments(List<ConfigDeployment> configDeployments)
|
public void setConfigDeployments(List<ConfigDeployment> configDeployments)
|
||||||
{
|
{
|
||||||
this.configDeployments = configDeployments;
|
this.configDeployments = configDeployments;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user