diff --git a/config/alfresco/patch/patch-services-context.xml b/config/alfresco/patch/patch-services-context.xml index 3e4baf2d79..61cdfbdf43 100644 --- a/config/alfresco/patch/patch-services-context.xml +++ b/config/alfresco/patch/patch-services-context.xml @@ -69,9 +69,6 @@ - - - diff --git a/config/alfresco/repo-admin-context.xml b/config/alfresco/repo-admin-context.xml index 04e13c3d74..a290160ad5 100755 --- a/config/alfresco/repo-admin-context.xml +++ b/config/alfresco/repo-admin-context.xml @@ -62,7 +62,6 @@ - diff --git a/config/alfresco/scheduled-jobs-context.xml b/config/alfresco/scheduled-jobs-context.xml index f6157c444b..e87685609f 100644 --- a/config/alfresco/scheduled-jobs-context.xml +++ b/config/alfresco/scheduled-jobs-context.xml @@ -252,9 +252,6 @@ - - - diff --git a/source/java/org/alfresco/repo/admin/patch/AbstractPatch.java b/source/java/org/alfresco/repo/admin/patch/AbstractPatch.java index 617be5caae..ffc4e270e6 100644 --- a/source/java/org/alfresco/repo/admin/patch/AbstractPatch.java +++ b/source/java/org/alfresco/repo/admin/patch/AbstractPatch.java @@ -36,7 +36,6 @@ import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; import org.alfresco.repo.tenant.Tenant; import org.alfresco.repo.tenant.TenantDeployerService; -import org.alfresco.repo.tenant.TenantService; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; import org.alfresco.service.cmr.admin.PatchException; import org.alfresco.service.cmr.repository.NodeService; @@ -88,8 +87,6 @@ public abstract class AbstractPatch implements Patch /** support service */ protected AuthenticationComponent authenticationComponent; /** support service */ - protected TenantService tenantService; - /** support service */ protected TenantDeployerService tenantDeployerService; @@ -164,11 +161,6 @@ public abstract class AbstractPatch implements Patch this.authenticationComponent = authenticationComponent; } - public void setTenantService(TenantService tenantService) - { - this.tenantService = tenantService; - } - public void setTenantDeployerService(TenantDeployerService tenantDeployerService) { this.tenantDeployerService = tenantDeployerService; @@ -380,8 +372,7 @@ public abstract class AbstractPatch implements Patch String report = applyInternal(); - if ((tenantService != null) && (tenantDeployerService != null) && - tenantService.isEnabled() && applyToTenants) + if ((tenantDeployerService != null) && tenantDeployerService.isEnabled() && applyToTenants) { List tenants = tenantDeployerService.getAllTenants(); for (Tenant tenant : tenants) @@ -393,7 +384,7 @@ public abstract class AbstractPatch implements Patch { return applyInternal(); } - }, tenantService.getDomainUser(AuthenticationUtil.getSystemUserName(), tenantDomain)); + }, tenantDeployerService.getDomainUser(AuthenticationUtil.getSystemUserName(), tenantDomain)); report = report + "\n" + tenantReport + " (for tenant: " + tenantDomain + ")"; } diff --git a/source/java/org/alfresco/repo/config/xml/RepoXMLConfigService.java b/source/java/org/alfresco/repo/config/xml/RepoXMLConfigService.java index 223001952c..c2688b049e 100644 --- a/source/java/org/alfresco/repo/config/xml/RepoXMLConfigService.java +++ b/source/java/org/alfresco/repo/config/xml/RepoXMLConfigService.java @@ -46,7 +46,6 @@ import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; import org.alfresco.repo.tenant.TenantDeployer; import org.alfresco.repo.tenant.TenantDeployerService; -import org.alfresco.repo.tenant.TenantService; import org.alfresco.service.transaction.TransactionService; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -71,7 +70,6 @@ public class RepoXMLConfigService extends XMLConfigService implements TenantDepl private TransactionService transactionService; private AuthenticationComponent authenticationComponent; private TenantDeployerService tenantDeployerService; - private TenantService tenantService; // Internal caches that are clusterable private SimpleCache globalConfigCache; @@ -95,12 +93,6 @@ public class RepoXMLConfigService extends XMLConfigService implements TenantDepl { this.tenantDeployerService = tenantDeployerService; } - - public void setTenantService(TenantService tenantService) - { - this.tenantService = tenantService; - } - public void setGlobalConfigCache(SimpleCache globalConfigCache) { @@ -200,7 +192,7 @@ public class RepoXMLConfigService extends XMLConfigService implements TenantDepl } }, AuthenticationUtil.getSystemUserName()); - if (tenantService.isEnabled() && (tenantDeployerService != null)) + if ((tenantDeployerService != null) && (tenantDeployerService.isEnabled())) { tenantDeployerService.deployTenants(this, logger); tenantDeployerService.register(this); @@ -220,7 +212,7 @@ public class RepoXMLConfigService extends XMLConfigService implements TenantDepl } }, AuthenticationUtil.getSystemUserName()); - if (tenantService.isEnabled() && (tenantDeployerService != null)) + if ((tenantDeployerService != null) && (tenantDeployerService.isEnabled())) { tenantDeployerService.undeployTenants(this, logger); 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) private String getTenantDomain() { - return tenantService.getCurrentUserDomain(); + return tenantDeployerService.getCurrentUserDomain(); } } diff --git a/source/java/org/alfresco/repo/dictionary/DictionaryRepositoryBootstrap.java b/source/java/org/alfresco/repo/dictionary/DictionaryRepositoryBootstrap.java index cffe8381d6..798231a2f9 100644 --- a/source/java/org/alfresco/repo/dictionary/DictionaryRepositoryBootstrap.java +++ b/source/java/org/alfresco/repo/dictionary/DictionaryRepositoryBootstrap.java @@ -37,7 +37,6 @@ import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; import org.alfresco.repo.tenant.TenantDeployer; import org.alfresco.repo.tenant.TenantDeployerService; -import org.alfresco.repo.tenant.TenantService; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; import org.alfresco.service.cmr.repository.ContentReader; import org.alfresco.service.cmr.repository.ContentService; @@ -80,9 +79,6 @@ public class DictionaryRepositoryBootstrap extends AbstractLifecycleBean impleme /** The node service */ private NodeService nodeService; - - /** The tenant service */ - private TenantService tenantService; /** The tenant deployer service */ private TenantDeployerService tenantDeployerService; @@ -135,16 +131,6 @@ public class DictionaryRepositoryBootstrap extends AbstractLifecycleBean impleme { 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 @@ -415,7 +401,7 @@ public class DictionaryRepositoryBootstrap extends AbstractLifecycleBean impleme } }, AuthenticationUtil.getSystemUserName()); - if (tenantService.isEnabled()) + if (tenantDeployerService.isEnabled()) { tenantDeployerService.deployTenants(this, logger); } @@ -438,7 +424,7 @@ public class DictionaryRepositoryBootstrap extends AbstractLifecycleBean impleme } }, AuthenticationUtil.getSystemUserName()); - if (tenantService.isEnabled()) + if (tenantDeployerService.isEnabled()) { tenantDeployerService.undeployTenants(this, logger); } @@ -465,7 +451,7 @@ public class DictionaryRepositoryBootstrap extends AbstractLifecycleBean impleme // register with Message Service to allow (re-)init messageService.register(this); - if (tenantService.isEnabled()) + if (tenantDeployerService.isEnabled()) { // register dictionary repository bootstrap tenantDeployerService.register(this); @@ -480,7 +466,7 @@ public class DictionaryRepositoryBootstrap extends AbstractLifecycleBean impleme */ protected void unregister() { - if (tenantService.isEnabled()) + if (tenantDeployerService.isEnabled()) { // register dictionary repository bootstrap tenantDeployerService.unregister(this); diff --git a/source/java/org/alfresco/repo/dictionary/DictionaryRepositoryBootstrapTest.java b/source/java/org/alfresco/repo/dictionary/DictionaryRepositoryBootstrapTest.java index 1a6af76f59..7b678be265 100644 --- a/source/java/org/alfresco/repo/dictionary/DictionaryRepositoryBootstrapTest.java +++ b/source/java/org/alfresco/repo/dictionary/DictionaryRepositoryBootstrapTest.java @@ -9,7 +9,6 @@ import org.alfresco.repo.content.MimetypeMap; import org.alfresco.repo.i18n.MessageService; import org.alfresco.repo.policy.BehaviourFilter; 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.ModelDefinition; import org.alfresco.service.cmr.repository.ContentWriter; @@ -70,9 +69,6 @@ public class DictionaryRepositoryBootstrapTest extends BaseAlfrescoSpringTest /** The transaction service */ private TransactionService transactionService; - /** The tenant service */ - private TenantService tenantService; - /** The tenant deployer service */ private TenantDeployerService tenantDeployerService; @@ -96,8 +92,7 @@ public class DictionaryRepositoryBootstrapTest extends BaseAlfrescoSpringTest this.searchService = (SearchService)this.applicationContext.getBean("searchService"); this.dictionaryDAO = (DictionaryDAO)this.applicationContext.getBean("dictionaryDAO"); - this.transactionService = (TransactionService)this.applicationContext.getBean("transactionComponent"); - this.tenantService = (TenantService)this.applicationContext.getBean("tenantService"); + this.transactionService = (TransactionService)this.applicationContext.getBean("transactionComponent"); this.tenantDeployerService = (TenantDeployerService)this.applicationContext.getBean("tenantAdminService"); this.namespaceService = (NamespaceService)this.applicationContext.getBean("namespaceService"); this.messageService = (MessageService)this.applicationContext.getBean("messageService"); @@ -107,7 +102,6 @@ public class DictionaryRepositoryBootstrapTest extends BaseAlfrescoSpringTest this.bootstrap.setSearchService(this.searchService); this.bootstrap.setDictionaryDAO(this.dictionaryDAO); this.bootstrap.setTransactionService(this.transactionService); - this.bootstrap.setTenantService(this.tenantService); this.bootstrap.setTenantDeployerService(this.tenantDeployerService); this.bootstrap.setNodeService(this.nodeService); this.bootstrap.setNamespaceService(this.namespaceService); diff --git a/source/java/org/alfresco/repo/tenant/MultiTAdminServiceImpl.java b/source/java/org/alfresco/repo/tenant/MultiTAdminServiceImpl.java index 37563f9518..738424c27f 100755 --- a/source/java/org/alfresco/repo/tenant/MultiTAdminServiceImpl.java +++ b/source/java/org/alfresco/repo/tenant/MultiTAdminServiceImpl.java @@ -1012,12 +1012,7 @@ public class MultiTAdminServiceImpl extends AbstractLifecycleBean implements Ten tenantDeployers.remove(deployer); } } - - public boolean isEnabled() - { - return tenantService.isEnabled(); - } - + public void resetCache(String 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 private String getSystemUser(String tenantDomain) diff --git a/source/java/org/alfresco/repo/tenant/SingleTDeployerServiceImpl.java b/source/java/org/alfresco/repo/tenant/SingleTDeployerServiceImpl.java index 6c910a6a9a..c80f12cd01 100644 --- a/source/java/org/alfresco/repo/tenant/SingleTDeployerServiceImpl.java +++ b/source/java/org/alfresco/repo/tenant/SingleTDeployerServiceImpl.java @@ -59,4 +59,24 @@ public class SingleTDeployerServiceImpl implements TenantDeployerService { return new ArrayList(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; + } } \ No newline at end of file diff --git a/source/java/org/alfresco/repo/tenant/TenantBaseService.java b/source/java/org/alfresco/repo/tenant/TenantBaseService.java new file mode 100644 index 0000000000..2fc0ec81af --- /dev/null +++ b/source/java/org/alfresco/repo/tenant/TenantBaseService.java @@ -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. + *

+ * 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(); +} diff --git a/source/java/org/alfresco/repo/tenant/TenantDeployerService.java b/source/java/org/alfresco/repo/tenant/TenantDeployerService.java index 3879983c27..34203014c0 100644 --- a/source/java/org/alfresco/repo/tenant/TenantDeployerService.java +++ b/source/java/org/alfresco/repo/tenant/TenantDeployerService.java @@ -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); diff --git a/source/java/org/alfresco/repo/tenant/TenantService.java b/source/java/org/alfresco/repo/tenant/TenantService.java index 00d1996100..19fafedcfe 100644 --- a/source/java/org/alfresco/repo/tenant/TenantService.java +++ b/source/java/org/alfresco/repo/tenant/TenantService.java @@ -39,7 +39,7 @@ import org.alfresco.service.namespace.QName; * This interface provides methods to support either ST or MT implementations. * */ -public interface TenantService +public interface TenantService extends TenantBaseService { public static final String SEPARATOR = "@"; @@ -88,14 +88,6 @@ public interface TenantService public boolean isTenantName(String name); 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 boolean isEnabled(); } diff --git a/source/java/org/alfresco/repo/usage/UserUsageTrackingComponent.java b/source/java/org/alfresco/repo/usage/UserUsageTrackingComponent.java index c490cb445c..2dd0645e87 100644 --- a/source/java/org/alfresco/repo/usage/UserUsageTrackingComponent.java +++ b/source/java/org/alfresco/repo/usage/UserUsageTrackingComponent.java @@ -36,7 +36,6 @@ import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; import org.alfresco.repo.tenant.Tenant; import org.alfresco.repo.tenant.TenantDeployerService; -import org.alfresco.repo.tenant.TenantService; import org.alfresco.repo.transaction.RetryingTransactionHelper; import org.alfresco.repo.transaction.TransactionServiceImpl; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; @@ -70,7 +69,6 @@ public class UserUsageTrackingComponent private NodeService nodeService; private UsageService usageService; private TenantDeployerService tenantDeployerService; - private TenantService tenantService; private boolean enabled = true; @@ -109,11 +107,6 @@ public class UserUsageTrackingComponent { this.tenantDeployerService = tenantDeployerService; } - - public void setTenantService(TenantService tenantService) - { - this.tenantService = tenantService; - } public void setEnabled(boolean enabled) { @@ -147,7 +140,7 @@ public class UserUsageTrackingComponent // default domain bootstrapInternal(); - if (tenantService.isEnabled()) + if (tenantDeployerService.isEnabled()) { List tenants = tenantDeployerService.getAllTenants(); for (Tenant tenant : tenants) @@ -159,7 +152,7 @@ public class UserUsageTrackingComponent bootstrapInternal(); return null; } - }, tenantService.getDomainUser(AuthenticationUtil.getSystemUserName(), tenant.getTenantDomain())); + }, tenantDeployerService.getDomainUser(AuthenticationUtil.getSystemUserName(), tenant.getTenantDomain())); } } } @@ -395,7 +388,7 @@ public class UserUsageTrackingComponent } return null; } - }, tenantService.getDomainUser(AuthenticationUtil.getSystemUserName(), tenantService.getDomain(usageNodeRef.getStoreRef().getIdentifier()))); + }, tenantDeployerService.getDomainUser(AuthenticationUtil.getSystemUserName(), tenantDeployerService.getDomain(usageNodeRef.getStoreRef().getIdentifier()))); } return null; }