MT - simpify tenant deployer service (subsume tenant service)

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@8244 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Jan Vonka 2008-02-11 11:53:56 +00:00
parent 1f36c62b18
commit 14ef325e93
13 changed files with 101 additions and 80 deletions

View File

@ -69,9 +69,6 @@
<property name="authenticationComponent"> <property name="authenticationComponent">
<ref bean="authenticationComponent" /> <ref bean="authenticationComponent" />
</property> </property>
<property name="tenantService">
<ref bean="tenantService" />
</property>
<property name="tenantDeployerService"> <property name="tenantDeployerService">
<ref bean="tenantAdminService" /> <ref bean="tenantAdminService" />
</property> </property>

View File

@ -62,7 +62,6 @@
<property name="namespaceService" ref="namespaceService"/> <property name="namespaceService" ref="namespaceService"/>
<property name="nodeService" ref="NodeService"/> <property name="nodeService" ref="NodeService"/>
<property name="messageService" ref="messageService"/> <property name="messageService" ref="messageService"/>
<property name="tenantService" ref="tenantService"/>
<property name="tenantDeployerService" ref="tenantAdminService"/> <property name="tenantDeployerService" ref="tenantAdminService"/>
<property name="repositoryModelsLocations"> <property name="repositoryModelsLocations">

View File

@ -252,9 +252,6 @@
<property name="usageService"> <property name="usageService">
<ref bean="usageService"/> <ref bean="usageService"/>
</property> </property>
<property name="tenantService">
<ref bean="tenantService" />
</property>
<property name="tenantDeployerService"> <property name="tenantDeployerService">
<ref bean="tenantAdminService" /> <ref bean="tenantAdminService" />
</property> </property>

View File

@ -36,7 +36,6 @@ 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.Tenant; import org.alfresco.repo.tenant.Tenant;
import org.alfresco.repo.tenant.TenantDeployerService; import org.alfresco.repo.tenant.TenantDeployerService;
import org.alfresco.repo.tenant.TenantService;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.service.cmr.admin.PatchException; import org.alfresco.service.cmr.admin.PatchException;
import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.NodeService;
@ -88,8 +87,6 @@ public abstract class AbstractPatch implements Patch
/** support service */ /** support service */
protected AuthenticationComponent authenticationComponent; protected AuthenticationComponent authenticationComponent;
/** support service */ /** support service */
protected TenantService tenantService;
/** support service */
protected TenantDeployerService tenantDeployerService; protected TenantDeployerService tenantDeployerService;
@ -164,11 +161,6 @@ public abstract class AbstractPatch implements Patch
this.authenticationComponent = authenticationComponent; this.authenticationComponent = authenticationComponent;
} }
public void setTenantService(TenantService tenantService)
{
this.tenantService = tenantService;
}
public void setTenantDeployerService(TenantDeployerService tenantDeployerService) public void setTenantDeployerService(TenantDeployerService tenantDeployerService)
{ {
this.tenantDeployerService = tenantDeployerService; this.tenantDeployerService = tenantDeployerService;
@ -380,8 +372,7 @@ public abstract class AbstractPatch implements Patch
String report = applyInternal(); String report = applyInternal();
if ((tenantService != null) && (tenantDeployerService != null) && if ((tenantDeployerService != null) && tenantDeployerService.isEnabled() && applyToTenants)
tenantService.isEnabled() && applyToTenants)
{ {
List<Tenant> tenants = tenantDeployerService.getAllTenants(); List<Tenant> tenants = tenantDeployerService.getAllTenants();
for (Tenant tenant : tenants) for (Tenant tenant : tenants)
@ -393,7 +384,7 @@ public abstract class AbstractPatch implements Patch
{ {
return applyInternal(); return applyInternal();
} }
}, tenantService.getDomainUser(AuthenticationUtil.getSystemUserName(), tenantDomain)); }, tenantDeployerService.getDomainUser(AuthenticationUtil.getSystemUserName(), tenantDomain));
report = report + "\n" + tenantReport + " (for tenant: " + tenantDomain + ")"; report = report + "\n" + tenantReport + " (for tenant: " + tenantDomain + ")";
} }

View File

@ -46,7 +46,6 @@ 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.TenantDeployer; import org.alfresco.repo.tenant.TenantDeployer;
import org.alfresco.repo.tenant.TenantDeployerService; import org.alfresco.repo.tenant.TenantDeployerService;
import org.alfresco.repo.tenant.TenantService;
import org.alfresco.service.transaction.TransactionService; import org.alfresco.service.transaction.TransactionService;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
@ -71,7 +70,6 @@ public class RepoXMLConfigService extends XMLConfigService implements TenantDepl
private TransactionService transactionService; private TransactionService transactionService;
private AuthenticationComponent authenticationComponent; private AuthenticationComponent authenticationComponent;
private TenantDeployerService tenantDeployerService; private TenantDeployerService tenantDeployerService;
private TenantService tenantService;
// Internal caches that are clusterable // Internal caches that are clusterable
private SimpleCache<String, ConfigImpl> globalConfigCache; private SimpleCache<String, ConfigImpl> globalConfigCache;
@ -96,12 +94,6 @@ public class RepoXMLConfigService extends XMLConfigService implements TenantDepl
this.tenantDeployerService = tenantDeployerService; this.tenantDeployerService = tenantDeployerService;
} }
public void setTenantService(TenantService tenantService)
{
this.tenantService = tenantService;
}
public void setGlobalConfigCache(SimpleCache<String, ConfigImpl> globalConfigCache) public void setGlobalConfigCache(SimpleCache<String, ConfigImpl> globalConfigCache)
{ {
this.globalConfigCache = globalConfigCache; this.globalConfigCache = globalConfigCache;
@ -200,7 +192,7 @@ public class RepoXMLConfigService extends XMLConfigService implements TenantDepl
} }
}, AuthenticationUtil.getSystemUserName()); }, AuthenticationUtil.getSystemUserName());
if (tenantService.isEnabled() && (tenantDeployerService != null)) if ((tenantDeployerService != null) && (tenantDeployerService.isEnabled()))
{ {
tenantDeployerService.deployTenants(this, logger); tenantDeployerService.deployTenants(this, logger);
tenantDeployerService.register(this); tenantDeployerService.register(this);
@ -220,7 +212,7 @@ public class RepoXMLConfigService extends XMLConfigService implements TenantDepl
} }
}, AuthenticationUtil.getSystemUserName()); }, AuthenticationUtil.getSystemUserName());
if (tenantService.isEnabled() && (tenantDeployerService != null)) if ((tenantDeployerService != null) && (tenantDeployerService.isEnabled()))
{ {
tenantDeployerService.undeployTenants(this, logger); tenantDeployerService.undeployTenants(this, logger);
tenantDeployerService.unregister(this); tenantDeployerService.unregister(this);
@ -595,6 +587,6 @@ public class RepoXMLConfigService extends XMLConfigService implements TenantDepl
// 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 tenantService.getCurrentUserDomain(); return tenantDeployerService.getCurrentUserDomain();
} }
} }

View File

@ -37,7 +37,6 @@ 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.TenantDeployer; import org.alfresco.repo.tenant.TenantDeployer;
import org.alfresco.repo.tenant.TenantDeployerService; import org.alfresco.repo.tenant.TenantDeployerService;
import org.alfresco.repo.tenant.TenantService;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.service.cmr.repository.ContentReader; import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.cmr.repository.ContentService; import org.alfresco.service.cmr.repository.ContentService;
@ -81,9 +80,6 @@ public class DictionaryRepositoryBootstrap extends AbstractLifecycleBean impleme
/** The node service */ /** The node service */
private NodeService nodeService; private NodeService nodeService;
/** The tenant service */
private TenantService tenantService;
/** The tenant deployer service */ /** The tenant deployer service */
private TenantDeployerService tenantDeployerService; private TenantDeployerService tenantDeployerService;
@ -136,16 +132,6 @@ public class DictionaryRepositoryBootstrap extends AbstractLifecycleBean impleme
this.nodeService = nodeService; this.nodeService = nodeService;
} }
/**
* Set the tenant service
*
* @param tenantService the tenant service
*/
public void setTenantService(TenantService tenantService)
{
this.tenantService = tenantService;
}
/** /**
* Set the tenant admin service * Set the tenant admin service
* *
@ -415,7 +401,7 @@ public class DictionaryRepositoryBootstrap extends AbstractLifecycleBean impleme
} }
}, AuthenticationUtil.getSystemUserName()); }, AuthenticationUtil.getSystemUserName());
if (tenantService.isEnabled()) if (tenantDeployerService.isEnabled())
{ {
tenantDeployerService.deployTenants(this, logger); tenantDeployerService.deployTenants(this, logger);
} }
@ -438,7 +424,7 @@ public class DictionaryRepositoryBootstrap extends AbstractLifecycleBean impleme
} }
}, AuthenticationUtil.getSystemUserName()); }, AuthenticationUtil.getSystemUserName());
if (tenantService.isEnabled()) if (tenantDeployerService.isEnabled())
{ {
tenantDeployerService.undeployTenants(this, logger); tenantDeployerService.undeployTenants(this, logger);
} }
@ -465,7 +451,7 @@ public class DictionaryRepositoryBootstrap extends AbstractLifecycleBean impleme
// register with Message Service to allow (re-)init // register with Message Service to allow (re-)init
messageService.register(this); messageService.register(this);
if (tenantService.isEnabled()) if (tenantDeployerService.isEnabled())
{ {
// register dictionary repository bootstrap // register dictionary repository bootstrap
tenantDeployerService.register(this); tenantDeployerService.register(this);
@ -480,7 +466,7 @@ public class DictionaryRepositoryBootstrap extends AbstractLifecycleBean impleme
*/ */
protected void unregister() protected void unregister()
{ {
if (tenantService.isEnabled()) if (tenantDeployerService.isEnabled())
{ {
// register dictionary repository bootstrap // register dictionary repository bootstrap
tenantDeployerService.unregister(this); tenantDeployerService.unregister(this);

View File

@ -9,7 +9,6 @@ import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.repo.i18n.MessageService; import org.alfresco.repo.i18n.MessageService;
import org.alfresco.repo.policy.BehaviourFilter; import org.alfresco.repo.policy.BehaviourFilter;
import org.alfresco.repo.tenant.TenantDeployerService; import org.alfresco.repo.tenant.TenantDeployerService;
import org.alfresco.repo.tenant.TenantService;
import org.alfresco.service.cmr.dictionary.DictionaryException; import org.alfresco.service.cmr.dictionary.DictionaryException;
import org.alfresco.service.cmr.dictionary.ModelDefinition; import org.alfresco.service.cmr.dictionary.ModelDefinition;
import org.alfresco.service.cmr.repository.ContentWriter; import org.alfresco.service.cmr.repository.ContentWriter;
@ -70,9 +69,6 @@ public class DictionaryRepositoryBootstrapTest extends BaseAlfrescoSpringTest
/** The transaction service */ /** The transaction service */
private TransactionService transactionService; private TransactionService transactionService;
/** The tenant service */
private TenantService tenantService;
/** The tenant deployer service */ /** The tenant deployer service */
private TenantDeployerService tenantDeployerService; private TenantDeployerService tenantDeployerService;
@ -97,7 +93,6 @@ public class DictionaryRepositoryBootstrapTest extends BaseAlfrescoSpringTest
this.searchService = (SearchService)this.applicationContext.getBean("searchService"); this.searchService = (SearchService)this.applicationContext.getBean("searchService");
this.dictionaryDAO = (DictionaryDAO)this.applicationContext.getBean("dictionaryDAO"); this.dictionaryDAO = (DictionaryDAO)this.applicationContext.getBean("dictionaryDAO");
this.transactionService = (TransactionService)this.applicationContext.getBean("transactionComponent"); this.transactionService = (TransactionService)this.applicationContext.getBean("transactionComponent");
this.tenantService = (TenantService)this.applicationContext.getBean("tenantService");
this.tenantDeployerService = (TenantDeployerService)this.applicationContext.getBean("tenantAdminService"); this.tenantDeployerService = (TenantDeployerService)this.applicationContext.getBean("tenantAdminService");
this.namespaceService = (NamespaceService)this.applicationContext.getBean("namespaceService"); this.namespaceService = (NamespaceService)this.applicationContext.getBean("namespaceService");
this.messageService = (MessageService)this.applicationContext.getBean("messageService"); this.messageService = (MessageService)this.applicationContext.getBean("messageService");
@ -107,7 +102,6 @@ public class DictionaryRepositoryBootstrapTest extends BaseAlfrescoSpringTest
this.bootstrap.setSearchService(this.searchService); this.bootstrap.setSearchService(this.searchService);
this.bootstrap.setDictionaryDAO(this.dictionaryDAO); this.bootstrap.setDictionaryDAO(this.dictionaryDAO);
this.bootstrap.setTransactionService(this.transactionService); this.bootstrap.setTransactionService(this.transactionService);
this.bootstrap.setTenantService(this.tenantService);
this.bootstrap.setTenantDeployerService(this.tenantDeployerService); this.bootstrap.setTenantDeployerService(this.tenantDeployerService);
this.bootstrap.setNodeService(this.nodeService); this.bootstrap.setNodeService(this.nodeService);
this.bootstrap.setNamespaceService(this.namespaceService); this.bootstrap.setNamespaceService(this.namespaceService);

View File

@ -1013,11 +1013,6 @@ public class MultiTAdminServiceImpl extends AbstractLifecycleBean implements Ten
} }
} }
public boolean isEnabled()
{
return tenantService.isEnabled();
}
public void resetCache(String tenantDomain) public void resetCache(String tenantDomain)
{ {
if (existsTenant(tenantDomain)) if (existsTenant(tenantDomain))
@ -1098,6 +1093,28 @@ public class MultiTAdminServiceImpl extends AbstractLifecycleBean implements Ten
} }
} }
// tenant deployer services delegated to tenant service
public boolean isEnabled()
{
return tenantService.isEnabled();
}
public String getCurrentUserDomain()
{
return tenantService.getCurrentUserDomain();
}
public String getDomainUser(String baseUsername, String tenantDomain)
{
return tenantService.getDomainUser(baseUsername, tenantDomain);
}
public String getDomain(String name)
{
return tenantService.getDomain(name);
}
// local helpers // local helpers
private String getSystemUser(String tenantDomain) private String getSystemUser(String tenantDomain)

View File

@ -59,4 +59,24 @@ public class SingleTDeployerServiceImpl implements TenantDeployerService
{ {
return new ArrayList<Tenant>(0); // empty list return new ArrayList<Tenant>(0); // empty list
} }
public String getCurrentUserDomain()
{
return TenantService.DEFAULT_DOMAIN;
}
public String getDomainUser(String baseUsername, String tenantDomain)
{
return baseUsername;
}
public String getDomain(String name)
{
return TenantService.DEFAULT_DOMAIN;
}
public boolean isEnabled()
{
return false;
}
} }

View File

@ -0,0 +1,43 @@
/*
* Copyright (C) 2005-2008 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program 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 General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
package org.alfresco.repo.tenant;
/**
* Tenant Base Service interface.
* <p>
* Common for TenantService and TenantDeployerService
*
*/
public interface TenantBaseService
{
public String getCurrentUserDomain();
public String getDomainUser(String baseUsername, String tenantDomain);
public String getDomain(String name);
public boolean isEnabled();
}

View File

@ -37,7 +37,7 @@ import org.apache.commons.logging.Log;
* *
*/ */
public interface TenantDeployerService public interface TenantDeployerService extends TenantBaseService
{ {
public void deployTenants(final TenantDeployer deployer, Log logger); public void deployTenants(final TenantDeployer deployer, Log logger);

View File

@ -39,7 +39,7 @@ import org.alfresco.service.namespace.QName;
* This interface provides methods to support either ST or MT implementations. * This interface provides methods to support either ST or MT implementations.
* *
*/ */
public interface TenantService public interface TenantService extends TenantBaseService
{ {
public static final String SEPARATOR = "@"; public static final String SEPARATOR = "@";
@ -89,13 +89,5 @@ public interface TenantService
public String getUserDomain(String username); public String getUserDomain(String username);
public String getCurrentUserDomain();
public String getDomain(String name);
public String getDomainUser(String baseUsername, String tenantDomain);
public Tenant getTenant(String tenantDomain); public Tenant getTenant(String tenantDomain);
public boolean isEnabled();
} }

View File

@ -36,7 +36,6 @@ 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.Tenant; import org.alfresco.repo.tenant.Tenant;
import org.alfresco.repo.tenant.TenantDeployerService; import org.alfresco.repo.tenant.TenantDeployerService;
import org.alfresco.repo.tenant.TenantService;
import org.alfresco.repo.transaction.RetryingTransactionHelper; import org.alfresco.repo.transaction.RetryingTransactionHelper;
import org.alfresco.repo.transaction.TransactionServiceImpl; import org.alfresco.repo.transaction.TransactionServiceImpl;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
@ -70,7 +69,6 @@ public class UserUsageTrackingComponent
private NodeService nodeService; private NodeService nodeService;
private UsageService usageService; private UsageService usageService;
private TenantDeployerService tenantDeployerService; private TenantDeployerService tenantDeployerService;
private TenantService tenantService;
private boolean enabled = true; private boolean enabled = true;
@ -110,11 +108,6 @@ public class UserUsageTrackingComponent
this.tenantDeployerService = tenantDeployerService; this.tenantDeployerService = tenantDeployerService;
} }
public void setTenantService(TenantService tenantService)
{
this.tenantService = tenantService;
}
public void setEnabled(boolean enabled) public void setEnabled(boolean enabled)
{ {
this.enabled = enabled; this.enabled = enabled;
@ -147,7 +140,7 @@ public class UserUsageTrackingComponent
// default domain // default domain
bootstrapInternal(); bootstrapInternal();
if (tenantService.isEnabled()) if (tenantDeployerService.isEnabled())
{ {
List<Tenant> tenants = tenantDeployerService.getAllTenants(); List<Tenant> tenants = tenantDeployerService.getAllTenants();
for (Tenant tenant : tenants) for (Tenant tenant : tenants)
@ -159,7 +152,7 @@ public class UserUsageTrackingComponent
bootstrapInternal(); bootstrapInternal();
return null; return null;
} }
}, tenantService.getDomainUser(AuthenticationUtil.getSystemUserName(), tenant.getTenantDomain())); }, tenantDeployerService.getDomainUser(AuthenticationUtil.getSystemUserName(), tenant.getTenantDomain()));
} }
} }
} }
@ -395,7 +388,7 @@ public class UserUsageTrackingComponent
} }
return null; return null;
} }
}, tenantService.getDomainUser(AuthenticationUtil.getSystemUserName(), tenantService.getDomain(usageNodeRef.getStoreRef().getIdentifier()))); }, tenantDeployerService.getDomainUser(AuthenticationUtil.getSystemUserName(), tenantDeployerService.getDomain(usageNodeRef.getStoreRef().getIdentifier())));
} }
return null; return null;
} }