From 77eb167c2bd181f703a9829351b38ee68faf7d15 Mon Sep 17 00:00:00 2001 From: Derek Hulley Date: Fri, 5 Sep 2008 13:04:46 +0000 Subject: [PATCH] Multi-Tenant node interceptor - Actually less happening here than it would first appear - Some MT bean and interface consolidation - The unit test has no meat to it, yet... coming soon! git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@10781 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- config/alfresco/application-context.xml | 2 +- config/alfresco/bootstrap-context.xml | 9 +- config/alfresco/cmis-api-context.xml | 2 +- config/alfresco/module-context.xml | 4 +- .../{bootstrap => mt}/st-admin-context.xml | 2 +- config/alfresco/node-services-context.xml | 9 +- .../alfresco/patch/patch-services-context.xml | 2 +- config/alfresco/policy-context.xml | 2 +- config/alfresco/scheduled-jobs-context.xml | 2 +- .../java/org/alfresco/cmis/CMISService.java | 18 +- .../repo/admin/patch/AbstractPatch.java | 14 +- .../alfresco/repo/audit/AuditableAspect.java | 3 - .../repo/config/xml/RepoXMLConfigService.java | 16 +- .../repo/dictionary/DictionaryModelType.java | 30 +- .../DictionaryRepositoryBootstrap.java | 26 +- .../DictionaryRepositoryBootstrapTest.java | 8 +- .../org/alfresco/repo/model/Repository.java | 48 +- .../repo/module/AbstractModuleComponent.java | 10 +- .../repo/module/ModuleComponentHelper.java | 22 +- .../module/ModuleComponentHelperTest.java | 12 +- .../repo/module/ModuleServiceImpl.java | 6 +- .../NodeRefPropertyMethodInterceptor.java | 20 +- .../repo/tenant/MultiTAdminServiceImpl.java | 45 +- .../tenant/MultiTNodeServiceInterceptor.java | 422 ++++++++++++++++++ .../MultiTNodeServiceInterceptorTest.java | 86 ++++ .../repo/tenant/MultiTServiceImpl.java | 16 +- ...Service.java => MultiTenantBootstrap.java} | 58 ++- .../repo/tenant/SingleTAdminServiceImpl.java | 207 +++++++++ .../tenant/SingleTDeployerServiceImpl.java | 82 ---- .../repo/tenant/SingleTServiceImpl.java | 6 + .../repo/tenant/TenantAdminService.java | 30 +- .../repo/tenant/TenantBaseService.java | 43 -- .../alfresco/repo/tenant/TenantService.java | 8 +- .../repo/tenant/TenantUserService.java | 19 + .../usage/UserUsageTrackingComponent.java | 16 +- 35 files changed, 961 insertions(+), 344 deletions(-) rename config/alfresco/{bootstrap => mt}/st-admin-context.xml (85%) mode change 100755 => 100644 create mode 100644 source/java/org/alfresco/repo/tenant/MultiTNodeServiceInterceptor.java create mode 100644 source/java/org/alfresco/repo/tenant/MultiTNodeServiceInterceptorTest.java rename source/java/org/alfresco/repo/tenant/{TenantDeployerService.java => MultiTenantBootstrap.java} (50%) create mode 100644 source/java/org/alfresco/repo/tenant/SingleTAdminServiceImpl.java delete mode 100644 source/java/org/alfresco/repo/tenant/SingleTDeployerServiceImpl.java mode change 100755 => 100644 source/java/org/alfresco/repo/tenant/TenantAdminService.java delete mode 100644 source/java/org/alfresco/repo/tenant/TenantBaseService.java create mode 100644 source/java/org/alfresco/repo/tenant/TenantUserService.java diff --git a/config/alfresco/application-context.xml b/config/alfresco/application-context.xml index efe014a708..45531fc7b3 100644 --- a/config/alfresco/application-context.xml +++ b/config/alfresco/application-context.xml @@ -18,7 +18,7 @@ - + diff --git a/config/alfresco/bootstrap-context.xml b/config/alfresco/bootstrap-context.xml index 0800298d6e..c35d1cf720 100644 --- a/config/alfresco/bootstrap-context.xml +++ b/config/alfresco/bootstrap-context.xml @@ -122,7 +122,7 @@ - + @@ -328,8 +328,9 @@ - - + + + @@ -570,7 +571,7 @@ - + ${spaces.store} /${spaces.company_home.childname} diff --git a/config/alfresco/cmis-api-context.xml b/config/alfresco/cmis-api-context.xml index 9f219ae22a..9343db2a6f 100644 --- a/config/alfresco/cmis-api-context.xml +++ b/config/alfresco/cmis-api-context.xml @@ -50,7 +50,7 @@ - + diff --git a/config/alfresco/module-context.xml b/config/alfresco/module-context.xml index 910bfdd2a2..018038224f 100644 --- a/config/alfresco/module-context.xml +++ b/config/alfresco/module-context.xml @@ -12,7 +12,7 @@ - + @@ -20,7 +20,7 @@ - + diff --git a/config/alfresco/bootstrap/st-admin-context.xml b/config/alfresco/mt/st-admin-context.xml old mode 100755 new mode 100644 similarity index 85% rename from config/alfresco/bootstrap/st-admin-context.xml rename to config/alfresco/mt/st-admin-context.xml index c73e2f1c74..a02e6d2fad --- a/config/alfresco/bootstrap/st-admin-context.xml +++ b/config/alfresco/mt/st-admin-context.xml @@ -3,6 +3,6 @@ - + diff --git a/config/alfresco/node-services-context.xml b/config/alfresco/node-services-context.xml index 5b694efc20..d309597264 100644 --- a/config/alfresco/node-services-context.xml +++ b/config/alfresco/node-services-context.xml @@ -16,7 +16,7 @@ - + @@ -25,6 +25,12 @@ + + + + + + mlAwareNodeService @@ -38,6 +44,7 @@ nodeRefPropertyInterceptor mlPropertyInterceptor + multiTNodeServiceInterceptor diff --git a/config/alfresco/patch/patch-services-context.xml b/config/alfresco/patch/patch-services-context.xml index 13a77812f2..df1d979c1f 100644 --- a/config/alfresco/patch/patch-services-context.xml +++ b/config/alfresco/patch/patch-services-context.xml @@ -69,7 +69,7 @@ - + diff --git a/config/alfresco/policy-context.xml b/config/alfresco/policy-context.xml index 4e74b39f6f..400f71c943 100644 --- a/config/alfresco/policy-context.xml +++ b/config/alfresco/policy-context.xml @@ -54,7 +54,7 @@ - + diff --git a/config/alfresco/scheduled-jobs-context.xml b/config/alfresco/scheduled-jobs-context.xml index fae447a632..58f7df273d 100644 --- a/config/alfresco/scheduled-jobs-context.xml +++ b/config/alfresco/scheduled-jobs-context.xml @@ -300,7 +300,7 @@ - + diff --git a/source/java/org/alfresco/cmis/CMISService.java b/source/java/org/alfresco/cmis/CMISService.java index 456cf935fc..03332ed24f 100644 --- a/source/java/org/alfresco/cmis/CMISService.java +++ b/source/java/org/alfresco/cmis/CMISService.java @@ -34,8 +34,8 @@ import org.alfresco.repo.model.Repository; import org.alfresco.repo.search.QueryParameterDefImpl; import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.repo.tenant.TenantAdminService; import org.alfresco.repo.tenant.TenantDeployer; -import org.alfresco.repo.tenant.TenantDeployerService; import org.alfresco.repo.transaction.RetryingTransactionHelper; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; import org.alfresco.service.cmr.dictionary.DataTypeDefinition; @@ -95,7 +95,7 @@ public class CMISService implements ApplicationContextAware, ApplicationListener private DictionaryService dictionaryService; private SearchService searchService; private NodeService nodeService; - private TenantDeployerService tenantDeployerService; + private TenantAdminService tenantAdminService; private ProcessorLifecycle lifecycle = new ProcessorLifecycle(); // CMIS supported version @@ -133,13 +133,11 @@ public class CMISService implements ApplicationContextAware, ApplicationListener } /** - * Sets the tenant deployer service - * - * @param tenantDeployerService + * Sets the tenant admin service */ - public void setTenantDeployerService(TenantDeployerService tenantDeployerService) + public void setTenantAdminService(TenantAdminService tenantAdminService) { - this.tenantDeployerService = tenantDeployerService; + this.tenantAdminService = tenantAdminService; } /** @@ -241,7 +239,7 @@ public class CMISService implements ApplicationContextAware, ApplicationListener textDataType = dictionaryService.getDataType(DataTypeDefinition.TEXT); // initialise root node ref - tenantDeployerService.register(this); + tenantAdminService.register(this); if (defaultRootNodeRefs == null) { defaultRootNodeRefs = new HashMap(1); @@ -254,7 +252,7 @@ public class CMISService implements ApplicationContextAware, ApplicationListener */ public void destroy() { - defaultRootNodeRefs.remove(tenantDeployerService.getCurrentUserDomain()); + defaultRootNodeRefs.remove(tenantAdminService.getCurrentUserDomain()); } /** @@ -284,7 +282,7 @@ public class CMISService implements ApplicationContextAware, ApplicationListener */ public NodeRef getDefaultRootNodeRef() { - String tenantDomain = tenantDeployerService.getCurrentUserDomain(); + String tenantDomain = tenantAdminService.getCurrentUserDomain(); NodeRef defaultNodeRef = defaultRootNodeRefs.get(tenantDomain); if (defaultNodeRef == null) { diff --git a/source/java/org/alfresco/repo/admin/patch/AbstractPatch.java b/source/java/org/alfresco/repo/admin/patch/AbstractPatch.java index efdf342668..2caaa41e01 100644 --- a/source/java/org/alfresco/repo/admin/patch/AbstractPatch.java +++ b/source/java/org/alfresco/repo/admin/patch/AbstractPatch.java @@ -37,7 +37,7 @@ import org.alfresco.repo.security.authentication.AuthenticationComponent; 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.TenantAdminService; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; import org.alfresco.service.cmr.admin.PatchException; import org.alfresco.service.cmr.repository.NodeService; @@ -95,7 +95,7 @@ public abstract class AbstractPatch implements Patch /** support service */ protected AuthenticationComponent authenticationComponent; /** support service */ - protected TenantDeployerService tenantDeployerService; + protected TenantAdminService tenantAdminService; /** track completion * */ @@ -176,9 +176,9 @@ public abstract class AbstractPatch implements Patch this.authenticationComponent = authenticationComponent; } - public void setTenantDeployerService(TenantDeployerService tenantDeployerService) + public void setTenantAdminService(TenantAdminService tenantAdminService) { - this.tenantDeployerService = tenantDeployerService; + this.tenantAdminService = tenantAdminService; } /** @@ -385,9 +385,9 @@ public abstract class AbstractPatch implements Patch String report = applyInternal(); - if ((tenantDeployerService != null) && tenantDeployerService.isEnabled() && applyToTenants) + if ((tenantAdminService != null) && tenantAdminService.isEnabled() && applyToTenants) { - List tenants = tenantDeployerService.getAllTenants(); + List tenants = tenantAdminService.getAllTenants(); for (Tenant tenant : tenants) { String tenantDomain = tenant.getTenantDomain(); @@ -397,7 +397,7 @@ public abstract class AbstractPatch implements Patch { return applyInternal(); } - }, tenantDeployerService.getDomainUser(AuthenticationUtil.getSystemUserName(), tenantDomain)); + }, tenantAdminService.getDomainUser(AuthenticationUtil.getSystemUserName(), tenantDomain)); report = report + "\n" + tenantReport + " (for tenant: " + tenantDomain + ")"; } diff --git a/source/java/org/alfresco/repo/audit/AuditableAspect.java b/source/java/org/alfresco/repo/audit/AuditableAspect.java index ab1e1dc9a5..5808869cfa 100644 --- a/source/java/org/alfresco/repo/audit/AuditableAspect.java +++ b/source/java/org/alfresco/repo/audit/AuditableAspect.java @@ -261,9 +261,6 @@ public class AuditableAspect /** * Construct - * - * @param nodeRef - * @param properties */ private SetAuditProperties(NodeService nodeService, NodeRef nodeRef, Map properties) { diff --git a/source/java/org/alfresco/repo/config/xml/RepoXMLConfigService.java b/source/java/org/alfresco/repo/config/xml/RepoXMLConfigService.java index 6e31b57b88..3b925d683e 100644 --- a/source/java/org/alfresco/repo/config/xml/RepoXMLConfigService.java +++ b/source/java/org/alfresco/repo/config/xml/RepoXMLConfigService.java @@ -44,8 +44,8 @@ import org.alfresco.repo.cache.SimpleCache; import org.alfresco.repo.security.authentication.AuthenticationComponent; import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.repo.tenant.TenantAdminService; import org.alfresco.repo.tenant.TenantDeployer; -import org.alfresco.repo.tenant.TenantDeployerService; import org.alfresco.service.transaction.TransactionService; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -69,7 +69,7 @@ public class RepoXMLConfigService extends XMLConfigService implements TenantDepl // Dependencies private TransactionService transactionService; private AuthenticationComponent authenticationComponent; - private TenantDeployerService tenantDeployerService; + private TenantAdminService tenantAdminService; // Internal caches that are clusterable private SimpleCache globalConfigCache; @@ -89,9 +89,9 @@ public class RepoXMLConfigService extends XMLConfigService implements TenantDepl this.authenticationComponent = authenticationComponent; } - public void setTenantDeployerService(TenantDeployerService tenantDeployerService) + public void setTenantAdminService(TenantAdminService tenantAdminService) { - this.tenantDeployerService = tenantDeployerService; + this.tenantAdminService = tenantAdminService; } public void setGlobalConfigCache(SimpleCache globalConfigCache) @@ -192,10 +192,10 @@ public class RepoXMLConfigService extends XMLConfigService implements TenantDepl } }, AuthenticationUtil.getSystemUserName()); - if ((tenantDeployerService != null) && (tenantDeployerService.isEnabled())) + if ((tenantAdminService != null) && (tenantAdminService.isEnabled())) { - tenantDeployerService.deployTenants(this, logger); - tenantDeployerService.register(this); + tenantAdminService.deployTenants(this, logger); + tenantAdminService.register(this); } } @@ -573,6 +573,6 @@ public class RepoXMLConfigService extends XMLConfigService implements TenantDepl // local helper - returns tenant domain (or empty string if default non-tenant) private String getTenantDomain() { - return tenantDeployerService.getCurrentUserDomain(); + return tenantAdminService.getCurrentUserDomain(); } } diff --git a/source/java/org/alfresco/repo/dictionary/DictionaryModelType.java b/source/java/org/alfresco/repo/dictionary/DictionaryModelType.java index e70a4fc92c..30d6f1520e 100644 --- a/source/java/org/alfresco/repo/dictionary/DictionaryModelType.java +++ b/source/java/org/alfresco/repo/dictionary/DictionaryModelType.java @@ -40,7 +40,7 @@ import org.alfresco.repo.policy.PolicyComponent; 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.TenantAdminService; import org.alfresco.repo.tenant.TenantService; import org.alfresco.repo.transaction.AlfrescoTransactionSupport; import org.alfresco.repo.transaction.TransactionListenerAdapter; @@ -119,7 +119,7 @@ public class DictionaryModelType implements ContentServicePolicies.OnContentUpda private TenantService tenantService; /** The tenant deployer service */ - private TenantDeployerService tenantDeployerService; + private TenantAdminService tenantAdminService; /** Transaction listener */ private DictionaryModelTypeTransactionListener transactionListener; @@ -129,8 +129,6 @@ public class DictionaryModelType implements ContentServicePolicies.OnContentUpda /** * Set the dictionary DAO - * - * @param dictionaryDAO the dictionary DAO */ public void setDictionaryDAO(DictionaryDAO dictionaryDAO) { @@ -139,8 +137,6 @@ public class DictionaryModelType implements ContentServicePolicies.OnContentUpda /** * Set the namespace DOA - * - * @param namespaceDAO the namespace DAO */ public void setNamespaceDAO(NamespaceDAO namespaceDAO) { @@ -149,8 +145,6 @@ public class DictionaryModelType implements ContentServicePolicies.OnContentUpda /** * Set the node service - * - * @param nodeService the node service */ public void setNodeService(NodeService nodeService) { @@ -159,8 +153,6 @@ public class DictionaryModelType implements ContentServicePolicies.OnContentUpda /** * Set the content service - * - * @param contentService the content service */ public void setContentService(ContentService contentService) { @@ -169,8 +161,6 @@ public class DictionaryModelType implements ContentServicePolicies.OnContentUpda /** * Set the policy component - * - * @param policyComponent the policy component */ public void setPolicyComponent(PolicyComponent policyComponent) { @@ -179,8 +169,6 @@ public class DictionaryModelType implements ContentServicePolicies.OnContentUpda /** * Set the workflow service - * - * @param workflowService the workflow service */ public void setWorkflowService(WorkflowService workflowService) { @@ -189,8 +177,6 @@ public class DictionaryModelType implements ContentServicePolicies.OnContentUpda /** * Set the search service - * - * @param searchService the search service */ public void setSearchService(SearchService searchService) { @@ -199,8 +185,6 @@ public class DictionaryModelType implements ContentServicePolicies.OnContentUpda /** * Set the namespace service - * - * @param namespaceService the namespace service */ public void setNamespaceService(NamespaceService namespaceService) { @@ -209,8 +193,6 @@ public class DictionaryModelType implements ContentServicePolicies.OnContentUpda /** * Set the tenant service - * - * @param tenantService the tenant service */ public void setTenantService(TenantService tenantService) { @@ -219,12 +201,10 @@ public class DictionaryModelType implements ContentServicePolicies.OnContentUpda /** * Set the tenant admin service - * - * @param tenantAdminService the tenant admin service */ - public void setTenantDeployerService(TenantDeployerService tenantDeployerService) + public void setTenantAdminService(TenantAdminService tenantAdminService) { - this.tenantDeployerService = tenantDeployerService; + this.tenantAdminService = tenantAdminService; } public void setStoreUrls(List storeUrls) @@ -557,7 +537,7 @@ public class DictionaryModelType implements ContentServicePolicies.OnContentUpda if (tenantService.isEnabled() && tenantService.isTenantUser() == false) { // shared model - need to check all tenants (whether enabled or disabled) unless they have overridden - List tenants = tenantDeployerService.getAllTenants(); + List tenants = tenantAdminService.getAllTenants(); for (Tenant tenant : tenants) { // validate model delete within context of tenant domain diff --git a/source/java/org/alfresco/repo/dictionary/DictionaryRepositoryBootstrap.java b/source/java/org/alfresco/repo/dictionary/DictionaryRepositoryBootstrap.java index 457c5bab1c..43a1da6403 100644 --- a/source/java/org/alfresco/repo/dictionary/DictionaryRepositoryBootstrap.java +++ b/source/java/org/alfresco/repo/dictionary/DictionaryRepositoryBootstrap.java @@ -35,8 +35,8 @@ import org.alfresco.repo.i18n.MessageDeployer; import org.alfresco.repo.i18n.MessageService; import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.repo.tenant.TenantAdminService; import org.alfresco.repo.tenant.TenantDeployer; -import org.alfresco.repo.tenant.TenantDeployerService; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; import org.alfresco.service.cmr.repository.ContentReader; import org.alfresco.service.cmr.repository.ContentService; @@ -80,8 +80,8 @@ public class DictionaryRepositoryBootstrap extends AbstractLifecycleBean impleme /** The node service */ private NodeService nodeService; - /** The tenant deployer service */ - private TenantDeployerService tenantDeployerService; + /** The tenant admin service */ + private TenantAdminService tenantAdminService; /** The namespace service */ private NamespaceService namespaceService; @@ -137,9 +137,9 @@ public class DictionaryRepositoryBootstrap extends AbstractLifecycleBean impleme * * @param tenantAdminService the tenant admin service */ - public void setTenantDeployerService(TenantDeployerService tenantDeployerService) + public void setTenantAdminService(TenantAdminService tenantAdminService) { - this.tenantDeployerService = tenantDeployerService; + this.tenantAdminService = tenantAdminService; } /** @@ -397,9 +397,9 @@ public class DictionaryRepositoryBootstrap extends AbstractLifecycleBean impleme } }, AuthenticationUtil.getSystemUserName()); - if (tenantDeployerService.isEnabled()) + if (tenantAdminService.isEnabled()) { - tenantDeployerService.deployTenants(this, logger); + tenantAdminService.deployTenants(this, logger); } register(); @@ -432,13 +432,13 @@ public class DictionaryRepositoryBootstrap extends AbstractLifecycleBean impleme // register with Message Service to allow (re-)init messageService.register(this); - if (tenantDeployerService.isEnabled()) + if (tenantAdminService.isEnabled()) { // register dictionary repository bootstrap - tenantDeployerService.register(this); + tenantAdminService.register(this); // register repository message (I18N) service - tenantDeployerService.register(messageService); + tenantAdminService.register(messageService); } } @@ -447,13 +447,13 @@ public class DictionaryRepositoryBootstrap extends AbstractLifecycleBean impleme */ protected void unregister() { - if (tenantDeployerService.isEnabled()) + if (tenantAdminService.isEnabled()) { // register dictionary repository bootstrap - tenantDeployerService.unregister(this); + tenantAdminService.unregister(this); // register repository message (I18N) service - tenantDeployerService.unregister(messageService); + tenantAdminService.unregister(messageService); } } } diff --git a/source/java/org/alfresco/repo/dictionary/DictionaryRepositoryBootstrapTest.java b/source/java/org/alfresco/repo/dictionary/DictionaryRepositoryBootstrapTest.java index da0646a7e8..169ff410b7 100644 --- a/source/java/org/alfresco/repo/dictionary/DictionaryRepositoryBootstrapTest.java +++ b/source/java/org/alfresco/repo/dictionary/DictionaryRepositoryBootstrapTest.java @@ -8,7 +8,7 @@ import org.alfresco.model.ContentModel; 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.TenantAdminService; import org.alfresco.service.cmr.dictionary.DictionaryException; import org.alfresco.service.cmr.dictionary.ModelDefinition; import org.alfresco.service.cmr.repository.ContentWriter; @@ -70,7 +70,7 @@ public class DictionaryRepositoryBootstrapTest extends BaseAlfrescoSpringTest private TransactionService transactionService; /** The tenant deployer service */ - private TenantDeployerService tenantDeployerService; + private TenantAdminService tenantAdminService; /** The namespace service */ private NamespaceService namespaceService; @@ -93,7 +93,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.tenantDeployerService = (TenantDeployerService)this.applicationContext.getBean("tenantAdminService"); + this.tenantAdminService = (TenantAdminService)this.applicationContext.getBean("tenantAdminService"); this.namespaceService = (NamespaceService)this.applicationContext.getBean("namespaceService"); this.messageService = (MessageService)this.applicationContext.getBean("messageService"); @@ -102,7 +102,7 @@ public class DictionaryRepositoryBootstrapTest extends BaseAlfrescoSpringTest this.bootstrap.setSearchService(this.searchService); this.bootstrap.setDictionaryDAO(this.dictionaryDAO); this.bootstrap.setTransactionService(this.transactionService); - this.bootstrap.setTenantDeployerService(this.tenantDeployerService); + this.bootstrap.setTenantAdminService(this.tenantAdminService); this.bootstrap.setNodeService(this.nodeService); this.bootstrap.setNamespaceService(this.namespaceService); this.bootstrap.setMessageService(this.messageService); diff --git a/source/java/org/alfresco/repo/model/Repository.java b/source/java/org/alfresco/repo/model/Repository.java index f49c28dbe1..4297539a3c 100644 --- a/source/java/org/alfresco/repo/model/Repository.java +++ b/source/java/org/alfresco/repo/model/Repository.java @@ -35,8 +35,8 @@ import org.alfresco.model.ContentModel; import org.alfresco.repo.avm.AVMNodeConverter; import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.repo.tenant.TenantAdminService; import org.alfresco.repo.tenant.TenantDeployer; -import org.alfresco.repo.tenant.TenantDeployerService; import org.alfresco.repo.transaction.RetryingTransactionHelper; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; import org.alfresco.service.cmr.avm.AVMNodeDescriptor; @@ -77,7 +77,7 @@ public class Repository implements ApplicationContextAware, ApplicationListener, private FileFolderService fileFolderService; private PersonService personService; private AVMService avmService; - private TenantDeployerService tenantDeployerService; + private TenantAdminService tenantAdminService; // company home private StoreRef companyHomeStore; @@ -115,8 +115,6 @@ public class Repository implements ApplicationContextAware, ApplicationListener, /** * Sets the namespace service - * - * @param namespaceService */ public void setNamespaceService(NamespaceService namespaceService) { @@ -125,8 +123,6 @@ public class Repository implements ApplicationContextAware, ApplicationListener, /** * Sets the search service - * - * @param searchService */ public void setSearchService(SearchService searchService) { @@ -135,8 +131,6 @@ public class Repository implements ApplicationContextAware, ApplicationListener, /** * Sets the node service - * - * @param nodeService */ public void setNodeService(NodeService nodeService) { @@ -145,8 +139,6 @@ public class Repository implements ApplicationContextAware, ApplicationListener, /** * Sets the file folder service - * - * @param nodeService */ public void setFileFolderService(FileFolderService fileFolderService) { @@ -155,8 +147,6 @@ public class Repository implements ApplicationContextAware, ApplicationListener, /** * Sets the person service - * - * @param personService */ public void setPersonService(PersonService personService) { @@ -164,36 +154,26 @@ public class Repository implements ApplicationContextAware, ApplicationListener, } /** - * Sets the tenant deployer service - * - * @param tenantDeployerService + * Sets the tenant admin service */ - public void setTenantDeployerService(TenantDeployerService tenantDeployerService) + public void setTenantAdminService(TenantAdminService tenantAdminService) { - this.tenantDeployerService = tenantDeployerService; + this.tenantAdminService = tenantAdminService; } /** * Sets the AVM service - * - * @param avmService */ public void setAvmService(AVMService avmService) { this.avmService = avmService; } - /* (non-Javadoc) - * @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext) - */ public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { lifecycle.setApplicationContext(applicationContext); } - /* (non-Javadoc) - * @see org.springframework.context.ApplicationListener#onApplicationEvent(org.springframework.context.ApplicationEvent) - */ public void onApplicationEvent(ApplicationEvent event) { lifecycle.onApplicationEvent(event); @@ -221,7 +201,7 @@ public class Repository implements ApplicationContextAware, ApplicationListener, */ protected void initContext() { - tenantDeployerService.register(this); + tenantAdminService.register(this); if (companyHomeRefs == null) { @@ -249,7 +229,7 @@ public class Repository implements ApplicationContextAware, ApplicationListener, */ public NodeRef getCompanyHome() { - String tenantDomain = tenantDeployerService.getCurrentUserDomain(); + String tenantDomain = tenantAdminService.getCurrentUserDomain(); NodeRef companyHomeRef = companyHomeRefs.get(tenantDomain); if (companyHomeRef == null) { @@ -448,35 +428,23 @@ public class Repository implements ApplicationContextAware, ApplicationListener, return nodeRef; } - /* (non-Javadoc) - * @see org.alfresco.repo.tenant.TenantDeployer#onEnableTenant() - */ public void onEnableTenant() { init(); } - /* (non-Javadoc) - * @see org.alfresco.repo.tenant.TenantDeployer#onDisableTenant() - */ public void onDisableTenant() { destroy(); } - /* (non-Javadoc) - * @see org.alfresco.repo.tenant.TenantDeployer#init() - */ public void init() { initContext(); } - /* (non-Javadoc) - * @see org.alfresco.repo.tenant.TenantDeployer#destroy() - */ public void destroy() { - companyHomeRefs.remove(tenantDeployerService.getCurrentUserDomain()); + companyHomeRefs.remove(tenantAdminService.getCurrentUserDomain()); } } diff --git a/source/java/org/alfresco/repo/module/AbstractModuleComponent.java b/source/java/org/alfresco/repo/module/AbstractModuleComponent.java index 1cc6f6c65a..9329f84b3b 100644 --- a/source/java/org/alfresco/repo/module/AbstractModuleComponent.java +++ b/source/java/org/alfresco/repo/module/AbstractModuleComponent.java @@ -32,7 +32,7 @@ import java.util.Map; import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.i18n.I18NUtil; import org.alfresco.repo.security.authentication.AuthenticationComponent; -import org.alfresco.repo.tenant.TenantDeployerService; +import org.alfresco.repo.tenant.TenantAdminService; import org.alfresco.service.ServiceRegistry; import org.alfresco.service.cmr.module.ModuleService; import org.alfresco.util.EqualsHelper; @@ -59,7 +59,7 @@ public abstract class AbstractModuleComponent implements ModuleComponent, BeanNa protected ServiceRegistry serviceRegistry; protected AuthenticationComponent authenticationComponent; protected ModuleService moduleService; - private TenantDeployerService tenantDeployerService; + private TenantAdminService tenantAdminService; private String moduleId; private String name; @@ -158,9 +158,9 @@ public abstract class AbstractModuleComponent implements ModuleComponent, BeanNa this.serviceRegistry = serviceRegistry; } - public void setTenantDeployerService(TenantDeployerService tenantDeployerService) + public void setTenantAdminService(TenantAdminService tenantAdminService) { - this.tenantDeployerService = tenantDeployerService; + this.tenantAdminService = tenantAdminService; } /** @@ -341,7 +341,7 @@ public abstract class AbstractModuleComponent implements ModuleComponent, BeanNa public final synchronized void execute() { // ensure that this has not been executed already - String tenantDomain = tenantDeployerService.getCurrentUserDomain(); + String tenantDomain = tenantAdminService.getCurrentUserDomain(); if (! executed.containsKey(tenantDomain)) { executed.put(tenantDomain, false); diff --git a/source/java/org/alfresco/repo/module/ModuleComponentHelper.java b/source/java/org/alfresco/repo/module/ModuleComponentHelper.java index 90587dffeb..6d5878b353 100644 --- a/source/java/org/alfresco/repo/module/ModuleComponentHelper.java +++ b/source/java/org/alfresco/repo/module/ModuleComponentHelper.java @@ -41,7 +41,7 @@ import org.alfresco.repo.security.authentication.AuthenticationComponent; 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.TenantAdminService; import org.alfresco.repo.tenant.TenantService; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; import org.alfresco.service.ServiceRegistry; @@ -92,7 +92,7 @@ public class ModuleComponentHelper private AuthenticationComponent authenticationComponent; private RegistryService registryService; private ModuleService moduleService; - private TenantDeployerService tenantDeployerService; + private TenantAdminService tenantAdminService; private Map> componentsByNameByModule; /** Default constructor */ @@ -141,9 +141,9 @@ public class ModuleComponentHelper this.moduleService = moduleService; } - public void setTenantDeployerService(TenantDeployerService tenantDeployerService) + public void setTenantAdminService(TenantAdminService tenantAdminService) { - this.tenantDeployerService = tenantDeployerService; + this.tenantAdminService = tenantAdminService; } /** @@ -206,7 +206,7 @@ public class ModuleComponentHelper PropertyCheck.mandatory(this, "authenticationComponent", authenticationComponent); PropertyCheck.mandatory(this, "registryService", registryService); PropertyCheck.mandatory(this, "moduleService", moduleService); - PropertyCheck.mandatory(this, "tenantDeployerService", tenantDeployerService); + PropertyCheck.mandatory(this, "tenantAdminService", tenantAdminService); /* * Ensure transactionality and the correct authentication */ @@ -227,15 +227,15 @@ public class ModuleComponentHelper final Map> mapStartedModules = new HashMap>(1); // Note: for system bootstrap this will be the default domain, else tenant domain for tenant create/import - final String tenantDomainCtx = tenantDeployerService.getCurrentUserDomain(); + final String tenantDomainCtx = tenantAdminService.getCurrentUserDomain(); mapExecutedComponents.put(tenantDomainCtx, new HashSet(10)); mapStartedModules.put(tenantDomainCtx, new HashSet(2)); final List tenants; - if (tenantDeployerService.isEnabled() && (tenantDomainCtx.equals(TenantService.DEFAULT_DOMAIN))) + if (tenantAdminService.isEnabled() && (tenantDomainCtx.equals(TenantService.DEFAULT_DOMAIN))) { - tenants = tenantDeployerService.getAllTenants(); + tenants = tenantAdminService.getAllTenants(); for (Tenant tenant : tenants) { mapExecutedComponents.put(tenant.getTenantDomain(), new HashSet(10)); @@ -267,7 +267,7 @@ public class ModuleComponentHelper startModule(module, mapStartedModules.get(tenantDomain), mapExecutedComponents.get(tenantDomain)); return null; } - }, tenantDeployerService.getDomainUser(AuthenticationUtil.getSystemUserName(), tenantDomain)); + }, tenantAdminService.getDomainUser(AuthenticationUtil.getSystemUserName(), tenantDomain)); } } @@ -291,7 +291,7 @@ public class ModuleComponentHelper checkForMissingModules(); return null; } - }, tenantDeployerService.getDomainUser(AuthenticationUtil.getSystemUserName(), tenant.getTenantDomain())); + }, tenantAdminService.getDomainUser(AuthenticationUtil.getSystemUserName(), tenant.getTenantDomain())); } } @@ -310,7 +310,7 @@ public class ModuleComponentHelper checkForOrphanComponents(mapExecutedComponents.get(tenantDomain)); return null; } - }, tenantDeployerService.getDomainUser(AuthenticationUtil.getSystemUserName(), tenantDomain)); + }, tenantAdminService.getDomainUser(AuthenticationUtil.getSystemUserName(), tenantDomain)); } } } diff --git a/source/java/org/alfresco/repo/module/ModuleComponentHelperTest.java b/source/java/org/alfresco/repo/module/ModuleComponentHelperTest.java index 568cac16b3..3ca157391e 100644 --- a/source/java/org/alfresco/repo/module/ModuleComponentHelperTest.java +++ b/source/java/org/alfresco/repo/module/ModuleComponentHelperTest.java @@ -31,7 +31,7 @@ import java.util.List; import java.util.Map; import org.alfresco.repo.admin.registry.RegistryService; -import org.alfresco.repo.tenant.TenantDeployerService; +import org.alfresco.repo.tenant.TenantAdminService; import org.alfresco.service.cmr.module.ModuleDetails; import org.alfresco.service.cmr.module.ModuleService; import org.alfresco.service.descriptor.DescriptorService; @@ -85,7 +85,7 @@ public class ModuleComponentHelperTest extends BaseAlfrescoTestCase }; private RegistryService registryService; - private TenantDeployerService tenantDeployerService; + private TenantAdminService tenantDeployerService; private DescriptorService descriptorService; private DummyModuleService moduleService; private ModuleComponentHelper helper; @@ -97,7 +97,7 @@ public class ModuleComponentHelperTest extends BaseAlfrescoTestCase super.setUp(); registryService = (RegistryService) ctx.getBean("RegistryService"); - tenantDeployerService = (TenantDeployerService) ctx.getBean("tenantAdminService"); + tenantDeployerService = (TenantAdminService) ctx.getBean("tenantAdminService"); descriptorService = serviceRegistry.getDescriptorService(); @@ -108,7 +108,7 @@ public class ModuleComponentHelperTest extends BaseAlfrescoTestCase helper.setRegistryService(registryService); helper.setServiceRegistry(serviceRegistry); helper.setDescriptorService(descriptorService); - helper.setTenantDeployerService(tenantDeployerService); + helper.setTenantAdminService(tenantDeployerService); // Register the components components = new DummyModuleComponent[3][3]; // i,j @@ -124,7 +124,7 @@ public class ModuleComponentHelperTest extends BaseAlfrescoTestCase component.setServiceRegistry(serviceRegistry); component.setAuthenticationComponent(authenticationComponent); component.setModuleService(moduleService); - component.setTenantDeployerService(tenantDeployerService); + component.setTenantAdminService(tenantDeployerService); // Don't initialize the component as that will do the registration. We do it manually. helper.registerComponent(component); // Add to array @@ -266,7 +266,7 @@ public class ModuleComponentHelperTest extends BaseAlfrescoTestCase super.setServiceRegistry(serviceRegistry); super.setAuthenticationComponent(authenticationComponent); super.setModuleService(moduleService); - super.setTenantDeployerService(tenantDeployerService); + super.setTenantAdminService(tenantDeployerService); super.setModuleId(moduleId); super.setName(name); diff --git a/source/java/org/alfresco/repo/module/ModuleServiceImpl.java b/source/java/org/alfresco/repo/module/ModuleServiceImpl.java index 26bbc46f2d..d7330cdd4d 100644 --- a/source/java/org/alfresco/repo/module/ModuleServiceImpl.java +++ b/source/java/org/alfresco/repo/module/ModuleServiceImpl.java @@ -37,7 +37,7 @@ import java.util.Properties; import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.repo.admin.registry.RegistryService; import org.alfresco.repo.security.authentication.AuthenticationComponent; -import org.alfresco.repo.tenant.TenantDeployerService; +import org.alfresco.repo.tenant.TenantAdminService; import org.alfresco.service.ServiceRegistry; import org.alfresco.service.cmr.module.ModuleDetails; import org.alfresco.service.cmr.module.ModuleService; @@ -115,9 +115,9 @@ public class ModuleServiceImpl implements ModuleService this.moduleComponentHelper.setRegistryService(registryService); } - public void setTenantDeployerService(TenantDeployerService tenantDeployerService) + public void setTenantAdminService(TenantAdminService tenantAdminService) { - this.moduleComponentHelper.setTenantDeployerService(tenantDeployerService); + this.moduleComponentHelper.setTenantAdminService(tenantAdminService); } /** diff --git a/source/java/org/alfresco/repo/node/NodeRefPropertyMethodInterceptor.java b/source/java/org/alfresco/repo/node/NodeRefPropertyMethodInterceptor.java index 60caa5be73..6b87c637df 100644 --- a/source/java/org/alfresco/repo/node/NodeRefPropertyMethodInterceptor.java +++ b/source/java/org/alfresco/repo/node/NodeRefPropertyMethodInterceptor.java @@ -39,11 +39,9 @@ import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter; import org.alfresco.service.cmr.repository.datatype.TypeConversionException; import org.alfresco.service.namespace.QName; -import org.alfresco.util.ApplicationContextHelper; +import org.alfresco.util.PropertyCheck; import org.aopalliance.intercept.MethodInterceptor; import org.aopalliance.intercept.MethodInvocation; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; /** * A method interceptor to clean up node ref properties as they are passed in and out of the node service. For @@ -55,8 +53,6 @@ import org.apache.commons.logging.LogFactory; */ public class NodeRefPropertyMethodInterceptor implements MethodInterceptor { - private static Log logger = LogFactory.getLog(NodeRefPropertyMethodInterceptor.class); - private boolean filterOnGet = true; private boolean filterOnSet = true; @@ -92,10 +88,6 @@ public class NodeRefPropertyMethodInterceptor implements MethodInterceptor private DictionaryService getDictionaryService() { - if (dictionaryService == null) - { - dictionaryService = (DictionaryService) ApplicationContextHelper.getApplicationContext().getBean("dictionaryService"); - } return dictionaryService; } @@ -106,12 +98,14 @@ public class NodeRefPropertyMethodInterceptor implements MethodInterceptor private NodeService getNodeService() { - if (nodeService == null) - { - nodeService = (NodeService) ApplicationContextHelper.getApplicationContext().getBean("mlAwareNodeService"); - } return nodeService; } + + public void init() + { + PropertyCheck.mandatory(this, "dictionaryService", dictionaryService); + PropertyCheck.mandatory(this, "nodeService", nodeService); + } @SuppressWarnings("unchecked") public Object invoke(MethodInvocation invocation) throws Throwable diff --git a/source/java/org/alfresco/repo/tenant/MultiTAdminServiceImpl.java b/source/java/org/alfresco/repo/tenant/MultiTAdminServiceImpl.java index a98be63d62..de0e20d5b0 100755 --- a/source/java/org/alfresco/repo/tenant/MultiTAdminServiceImpl.java +++ b/source/java/org/alfresco/repo/tenant/MultiTAdminServiceImpl.java @@ -62,23 +62,27 @@ import org.alfresco.service.cmr.view.RepositoryExporterService; import org.alfresco.service.cmr.workflow.WorkflowDefinition; import org.alfresco.service.cmr.workflow.WorkflowService; import org.alfresco.service.transaction.TransactionService; -import org.alfresco.util.AbstractLifecycleBean; import org.alfresco.util.ParameterCheck; import org.alfresco.util.PropertyCheck; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.springframework.context.ApplicationEvent; +import org.springframework.beans.BeansException; +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationContextAware; /** * MT Admin Service Implementation. * */ -public class MultiTAdminServiceImpl extends AbstractLifecycleBean implements TenantAdminService, TenantDeployerService +public class MultiTAdminServiceImpl implements TenantAdminService, ApplicationContextAware { // Logger private static Log logger = LogFactory.getLog(MultiTAdminServiceImpl.class); + // Keep hold of the app context + private ApplicationContext ctx; + // Dependencies private NodeService nodeService; private DictionaryComponent dictionaryComponent; @@ -226,8 +230,12 @@ public class MultiTAdminServiceImpl extends AbstractLifecycleBean implements Ten PropertyCheck.mandatory(this, "ModuleService - see updated alfresco/extension/mt/mt-admin-context.xml.sample", moduleService); } - @Override - protected void onBootstrap(ApplicationEvent event) + public void setApplicationContext(ApplicationContext applicationContext) throws BeansException + { + this.ctx = applicationContext; + } + + public void startTenants() { checkProperties(); @@ -293,8 +301,7 @@ public class MultiTAdminServiceImpl extends AbstractLifecycleBean implements Ten } } - @Override - protected void onShutdown(ApplicationEvent event) + public void stopTenants() { tenantDeployers.clear(); tenantDeployers = null; @@ -325,19 +332,19 @@ public class MultiTAdminServiceImpl extends AbstractLifecycleBean implements Ten tenantFileContentStore.init(); // create tenant-specific stores - ImporterBootstrap userImporterBootstrap = (ImporterBootstrap)getApplicationContext().getBean("userBootstrap"); + ImporterBootstrap userImporterBootstrap = (ImporterBootstrap)ctx.getBean("userBootstrap"); bootstrapUserTenantStore(userImporterBootstrap, tenantDomain, tenantAdminRawPassword); - ImporterBootstrap systemImporterBootstrap = (ImporterBootstrap)getApplicationContext().getBean("systemBootstrap"); + ImporterBootstrap systemImporterBootstrap = (ImporterBootstrap)ctx.getBean("systemBootstrap"); bootstrapSystemTenantStore(systemImporterBootstrap, tenantDomain); - ImporterBootstrap versionImporterBootstrap = (ImporterBootstrap)getApplicationContext().getBean("versionBootstrap"); + ImporterBootstrap versionImporterBootstrap = (ImporterBootstrap)ctx.getBean("versionBootstrap"); bootstrapVersionTenantStore(versionImporterBootstrap, tenantDomain); - ImporterBootstrap spacesArchiveImporterBootstrap = (ImporterBootstrap)getApplicationContext().getBean("spacesArchiveBootstrap"); + ImporterBootstrap spacesArchiveImporterBootstrap = (ImporterBootstrap)ctx.getBean("spacesArchiveBootstrap"); bootstrapSpacesArchiveTenantStore(spacesArchiveImporterBootstrap, tenantDomain); - ImporterBootstrap spacesImporterBootstrap = (ImporterBootstrap)getApplicationContext().getBean("spacesBootstrap"); + ImporterBootstrap spacesImporterBootstrap = (ImporterBootstrap)ctx.getBean("spacesBootstrap"); bootstrapSpacesTenantStore(spacesImporterBootstrap, tenantDomain); // notify listeners that tenant has been created & hence enabled @@ -703,7 +710,7 @@ public class MultiTAdminServiceImpl extends AbstractLifecycleBean implements Ten List bootstrapViews = new ArrayList(1); bootstrapViews.add(bootstrapView); - ImporterBootstrap systemImporterBootstrap = (ImporterBootstrap)getApplicationContext().getBean("systemBootstrap"); + ImporterBootstrap systemImporterBootstrap = (ImporterBootstrap)ctx.getBean("systemBootstrap"); systemImporterBootstrap.setBootstrapViews(bootstrapViews); systemImporterBootstrap.setLog(true); @@ -736,7 +743,7 @@ public class MultiTAdminServiceImpl extends AbstractLifecycleBean implements Ten List bootstrapViews = new ArrayList(1); bootstrapViews.add(bootstrapView); - ImporterBootstrap userImporterBootstrap = (ImporterBootstrap)getApplicationContext().getBean("userBootstrap"); + ImporterBootstrap userImporterBootstrap = (ImporterBootstrap)ctx.getBean("userBootstrap"); userImporterBootstrap.setBootstrapViews(bootstrapViews); userImporterBootstrap.setLog(true); @@ -774,7 +781,7 @@ public class MultiTAdminServiceImpl extends AbstractLifecycleBean implements Ten List bootstrapViews = new ArrayList(1); bootstrapViews.add(bootstrapView); - ImporterBootstrap versionImporterBootstrap = (ImporterBootstrap)getApplicationContext().getBean("versionBootstrap"); + ImporterBootstrap versionImporterBootstrap = (ImporterBootstrap)ctx.getBean("versionBootstrap"); versionImporterBootstrap.setBootstrapViews(bootstrapViews); versionImporterBootstrap.setLog(true); @@ -802,7 +809,7 @@ public class MultiTAdminServiceImpl extends AbstractLifecycleBean implements Ten List bootstrapViews = new ArrayList(1); bootstrapViews.add(bootstrapView); - ImporterBootstrap spacesArchiveImporterBootstrap = (ImporterBootstrap)getApplicationContext().getBean("spacesArchiveBootstrap"); + ImporterBootstrap spacesArchiveImporterBootstrap = (ImporterBootstrap)ctx.getBean("spacesArchiveBootstrap"); spacesArchiveImporterBootstrap.setBootstrapViews(bootstrapViews); spacesArchiveImporterBootstrap.setLog(true); @@ -835,7 +842,7 @@ public class MultiTAdminServiceImpl extends AbstractLifecycleBean implements Ten List bootstrapViews = new ArrayList(1); bootstrapViews.add(bootstrapView); - ImporterBootstrap spacesImporterBootstrap = (ImporterBootstrap)getApplicationContext().getBean("spacesBootstrap"); + ImporterBootstrap spacesImporterBootstrap = (ImporterBootstrap)ctx.getBean("spacesBootstrap"); spacesImporterBootstrap.setBootstrapViews(bootstrapViews); spacesImporterBootstrap.setLog(true); @@ -853,7 +860,7 @@ public class MultiTAdminServiceImpl extends AbstractLifecycleBean implements Ten List bootstrapViews = new ArrayList(1); bootstrapViews.add(bootstrapView); - ImporterBootstrap spacesImporterBootstrap = (ImporterBootstrap)getApplicationContext().getBean("spacesBootstrap"); + ImporterBootstrap spacesImporterBootstrap = (ImporterBootstrap)ctx.getBean("spacesBootstrap"); spacesImporterBootstrap.setBootstrapViews(bootstrapViews); spacesImporterBootstrap.setLog(true); @@ -878,7 +885,7 @@ public class MultiTAdminServiceImpl extends AbstractLifecycleBean implements Ten spacesImporterBootstrap.bootstrap(); // calculate any missing usages - UserUsageTrackingComponent userUsageTrackingComponent = (UserUsageTrackingComponent)getApplicationContext().getBean(UserUsageBootstrapJob.KEY_COMPONENT); + UserUsageTrackingComponent userUsageTrackingComponent = (UserUsageTrackingComponent)ctx.getBean(UserUsageBootstrapJob.KEY_COMPONENT); userUsageTrackingComponent.bootstrapInternal(); logger.debug("Bootstrapped store: " + tenantService.getBaseName(bootstrapStoreRef)); diff --git a/source/java/org/alfresco/repo/tenant/MultiTNodeServiceInterceptor.java b/source/java/org/alfresco/repo/tenant/MultiTNodeServiceInterceptor.java new file mode 100644 index 0000000000..d65fb0ad0f --- /dev/null +++ b/source/java/org/alfresco/repo/tenant/MultiTNodeServiceInterceptor.java @@ -0,0 +1,422 @@ +/* + * 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; + +import java.util.ArrayList; +import java.util.Collection; + +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.service.cmr.repository.AssociationRef; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.StoreRef; +import org.alfresco.util.EqualsHelper; +import org.aopalliance.intercept.MethodInvocation; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.aop.support.DelegatingIntroductionInterceptor; + +/** + * Interceptor to translate Node + * + * @since 3.0 + * @author Derek Hulley + * @author Jan Vonka + */ +public class MultiTNodeServiceInterceptor extends DelegatingIntroductionInterceptor//implements NodeService +{ + private static final long serialVersionUID = -5462852271914961462L; + + private static Log logger = LogFactory.getLog(MultiTNodeServiceInterceptor.class); + + private static ThreadLocal ignoreMT = new ThreadLocal(); + + private TenantService tenantService; + + /** + * Change the filtering behaviour of this interceptor on the current thread. + * Use this to switch off the filtering and pass references in and out as they + * are found. + * + * @param ignoreMT true if the current thread is able to handle + * MultiTenant-enabled references. + * @return true if the current transaction is MT aware + */ + public static boolean setIgnoreMT(boolean ignoreMT) + { + boolean wasIgnoreMT = isIgnoreMT(); + MultiTNodeServiceInterceptor.ignoreMT.set(Boolean.valueOf(ignoreMT)); + return wasIgnoreMT; + } + + /** + * @return Returns true if the current thread has marked itself + * as being able to handle MultiTenant references. + */ + static public boolean isIgnoreMT() + { + if (ignoreMT.get() == null) + { + return false; + } + else + { + return ignoreMT.get(); + } + } + + public void setTenantService(TenantService tenantService) + { + this.tenantService = tenantService; + } +// +// public void addAspect(NodeRef nodeRef, QName aspectTypeQName, Map aspectProperties) throws InvalidNodeRefException, InvalidAspectException +// { +// throw new UnsupportedOperationException(); +// } +// +// public ChildAssociationRef addChild(NodeRef parentRef, NodeRef childRef, QName assocTypeQName, QName qname) throws InvalidNodeRefException +// { +// throw new UnsupportedOperationException(); +// } +// +// public List cleanup() +// { +// throw new UnsupportedOperationException(); +// } +// +// public AssociationRef createAssociation(NodeRef sourceRef, NodeRef targetRef, QName assocTypeQName) throws InvalidNodeRefException, AssociationExistsException +// { +// throw new UnsupportedOperationException(); +// } +// +// public ChildAssociationRef createNode(NodeRef parentRef, QName assocTypeQName, QName assocQName, QName nodeTypeQName, Map properties) +// throws InvalidNodeRefException, InvalidTypeException +// { +// throw new UnsupportedOperationException(); +// } +// +// public ChildAssociationRef createNode(NodeRef parentRef, QName assocTypeQName, QName assocQName, QName nodeTypeQName) throws InvalidNodeRefException, InvalidTypeException +// { +// throw new UnsupportedOperationException(); +// } +// +// public StoreRef createStore(String protocol, String identifier) throws StoreExistsException +// { +// throw new UnsupportedOperationException(); +// } +// +// public void deleteNode(NodeRef nodeRef) throws InvalidNodeRefException +// { +// throw new UnsupportedOperationException(); +// } +// +// public void deleteStore(StoreRef storeRef) +// { +// throw new UnsupportedOperationException(); +// } +// +// public boolean exists(NodeRef nodeRef) +// { +// throw new UnsupportedOperationException(); +// } +// +// public boolean exists(StoreRef storeRef) +// { +// throw new UnsupportedOperationException(); +// } +// +// public Set getAspects(NodeRef nodeRef) throws InvalidNodeRefException +// { +// throw new UnsupportedOperationException(); +// } +// +// public List getChildAssocs(NodeRef nodeRef, QNamePattern typeQNamePattern, QNamePattern qnamePattern) throws InvalidNodeRefException +// { +// throw new UnsupportedOperationException(); +// } +// +// public List getChildAssocs(NodeRef nodeRef) throws InvalidNodeRefException +// { +// throw new UnsupportedOperationException(); +// } +// +// public NodeRef getChildByName(NodeRef nodeRef, QName assocTypeQName, String childName) +// { +// throw new UnsupportedOperationException(); +// } +// +// public Status getNodeStatus(NodeRef nodeRef) +// { +// throw new UnsupportedOperationException(); +// } +// +// public List getParentAssocs(NodeRef nodeRef, QNamePattern typeQNamePattern, QNamePattern qnamePattern) throws InvalidNodeRefException +// { +// throw new UnsupportedOperationException(); +// } +// +// public List getParentAssocs(NodeRef nodeRef) throws InvalidNodeRefException +// { +// throw new UnsupportedOperationException(); +// } +// +// public Path getPath(NodeRef nodeRef) throws InvalidNodeRefException +// { +// throw new UnsupportedOperationException(); +// } +// +// public List getPaths(NodeRef nodeRef, boolean primaryOnly) throws InvalidNodeRefException +// { +// throw new UnsupportedOperationException(); +// } +// +// public ChildAssociationRef getPrimaryParent(NodeRef nodeRef) throws InvalidNodeRefException +// { +// throw new UnsupportedOperationException(); +// } +// +// public Map getProperties(NodeRef nodeRef) throws InvalidNodeRefException +// { +// throw new UnsupportedOperationException(); +// } +// +// public Serializable getProperty(NodeRef nodeRef, QName qname) throws InvalidNodeRefException +// { +// throw new UnsupportedOperationException(); +// } +// +// public NodeRef getRootNode(StoreRef storeRef) throws InvalidStoreRefException +// { +// throw new UnsupportedOperationException(); +// } +// +// public List getSourceAssocs(NodeRef targetRef, QNamePattern qnamePattern) throws InvalidNodeRefException +// { +// throw new UnsupportedOperationException(); +// } +// +// public NodeRef getStoreArchiveNode(StoreRef storeRef) +// { +// throw new UnsupportedOperationException(); +// } +// +// public List getStores() +// { +// throw new UnsupportedOperationException(); +// } +// +// public List getTargetAssocs(NodeRef sourceRef, QNamePattern qnamePattern) throws InvalidNodeRefException +// { +// throw new UnsupportedOperationException(); +// } +// +// public QName getType(NodeRef nodeRef) throws InvalidNodeRefException +// { +// throw new UnsupportedOperationException(); +// } +// +// public boolean hasAspect(NodeRef nodeRef, QName aspectTypeQName) throws InvalidNodeRefException, InvalidAspectException +// { +// throw new UnsupportedOperationException(); +// } +// +// public ChildAssociationRef moveNode(NodeRef nodeToMoveRef, NodeRef newParentRef, QName assocTypeQName, QName assocQName) throws InvalidNodeRefException +// { +// throw new UnsupportedOperationException(); +// } +// +// public void removeAspect(NodeRef nodeRef, QName aspectTypeQName) throws InvalidNodeRefException, InvalidAspectException +// { +// throw new UnsupportedOperationException(); +// } +// +// public void removeAssociation(NodeRef sourceRef, NodeRef targetRef, QName assocTypeQName) throws InvalidNodeRefException +// { +// throw new UnsupportedOperationException(); +// } +// +// public void removeChild(NodeRef parentRef, NodeRef childRef) throws InvalidNodeRefException +// { +// throw new UnsupportedOperationException(); +// } +// +// public boolean removeChildAssociation(ChildAssociationRef childAssocRef) +// { +// throw new UnsupportedOperationException(); +// } +// +// public void removeProperty(NodeRef nodeRef, QName qname) throws InvalidNodeRefException +// { +// throw new UnsupportedOperationException(); +// } +// +// public boolean removeSeconaryChildAssociation(ChildAssociationRef childAssocRef) +// { +// throw new UnsupportedOperationException(); +// } +// +// public NodeRef restoreNode(NodeRef archivedNodeRef, NodeRef destinationParentNodeRef, QName assocTypeQName, QName assocQName) +// { +// throw new UnsupportedOperationException(); +// } +// +// public void setChildAssociationIndex(ChildAssociationRef childAssocRef, int index) throws InvalidChildAssociationRefException +// { +// throw new UnsupportedOperationException(); +// } +// +// public void setProperties(NodeRef nodeRef, Map properties) throws InvalidNodeRefException +// { +// throw new UnsupportedOperationException(); +// } +// +// public void setProperty(NodeRef nodeRef, QName qname, Serializable value) throws InvalidNodeRefException +// { +// throw new UnsupportedOperationException(); +// } +// +// public void setType(NodeRef nodeRef, QName typeQName) throws InvalidNodeRefException +// { +// throw new UnsupportedOperationException(); +// } +// + @SuppressWarnings("unchecked") + public Object invoke(MethodInvocation invocation) throws Throwable + { + // See if we can shortcut + if (EqualsHelper.nullSafeEquals( + AuthenticationUtil.SYSTEM_USER_NAME, + AuthenticationUtil.getCurrentEffectiveUserName()) + || + !AuthenticationUtil.isMtEnabled()) + { + return invocation.proceed(); + } + + if (logger.isDebugEnabled()) + { + logger.debug("Intercepting method " + invocation.getMethod().getName()); + } + + Object[] args = invocation.getArguments(); + // Convert each of the arguments to the underlying (full) reference. + for (int i = 0; i < args.length; i++) + { + Object arg = args[i]; + Object newArg = arg; + if (arg == null) + { + // No conversion possible + } + if (arg instanceof StoreRef) + { + StoreRef ref = (StoreRef) arg; + newArg = tenantService.getName(ref); + } + else if (arg instanceof NodeRef) + { + NodeRef ref = (NodeRef) arg; + newArg = tenantService.getName(ref); + } + else if (arg instanceof ChildAssociationRef) + { + ChildAssociationRef ref = (ChildAssociationRef) arg; + newArg = tenantService.getName(ref); + } + else if (arg instanceof AssociationRef) + { + AssociationRef ref = (AssociationRef) arg; + newArg = tenantService.getName(ref); + } + // Substitute the new value + args[i] = newArg; + } + + // Make the call + Object ret = invocation.proceed(); + + // Convert the outbound value + ret = convertOutboundValue(ret); + + // done + return ret; + } + + /** + * Convert outbound collection to spoofed (no tenant prefix) values. + */ + private Collection convertOutboundValues(Collection rawValues) + { + Collection convertedValues = new ArrayList(rawValues.size()); + for (Object rawValue : rawValues) + { + Object convertedValue = convertOutboundValue(rawValue); + convertedValues.add(convertedValue); + } + // Done + return convertedValues; + } + + /** + * Convert outbound single value to spoofed (no tenant prefix) value. + */ + @SuppressWarnings("unchecked") + private Object convertOutboundValue(Object rawValue) + { + if (rawValue == null) + { + return null; + } + // Deal with collections + Object value = rawValue; + if (rawValue instanceof Collection) + { + value = convertOutboundValues((Collection)rawValue); + } + else if (rawValue instanceof StoreRef) + { + StoreRef ref = (StoreRef) rawValue; + value = tenantService.getName(ref); + } + else if (rawValue instanceof NodeRef) + { + NodeRef ref = (NodeRef) rawValue; + value = tenantService.getName(ref); + } + else if (rawValue instanceof ChildAssociationRef) + { + ChildAssociationRef ref = (ChildAssociationRef) rawValue; + value = tenantService.getName(ref); + } + else if (rawValue instanceof AssociationRef) + { + AssociationRef ref = (AssociationRef) rawValue; + value = tenantService.getName(ref); + } + // Done + return value; + } +} diff --git a/source/java/org/alfresco/repo/tenant/MultiTNodeServiceInterceptorTest.java b/source/java/org/alfresco/repo/tenant/MultiTNodeServiceInterceptorTest.java new file mode 100644 index 0000000000..f32b709694 --- /dev/null +++ b/source/java/org/alfresco/repo/tenant/MultiTNodeServiceInterceptorTest.java @@ -0,0 +1,86 @@ +/* + * 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; + +import junit.framework.TestCase; + +import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; +import org.alfresco.service.transaction.TransactionService; +import org.alfresco.util.ApplicationContextHelper; +import org.springframework.beans.factory.NoSuchBeanDefinitionException; +import org.springframework.context.ApplicationContext; + +/** + * @see MultiTNodeServiceInterceptor + * + * @since 3.0 + * @author Derek Hulley + */ +public class MultiTNodeServiceInterceptorTest extends TestCase +{ + public static ApplicationContext ctx = ApplicationContextHelper.getApplicationContext(); + + private String tenant1 = "tenant1"; + private String tenant1Pwd = "pwd1"; + private boolean enableTest = true; + private TransactionService transactionService; + private TenantAdminService tenantAdminService; + private TenantService tenantService; + private MultiTNodeServiceInterceptor interceptor; + + @Override + public void setUp() throws Exception + { + transactionService = (TransactionService) ctx.getBean("TransactionService"); + tenantAdminService = (TenantAdminService) ctx.getBean("tenantAdminService"); + tenantService = (TenantService) ctx.getBean("tenantService"); + interceptor = (MultiTNodeServiceInterceptor) ctx.getBean("multiTNodeServiceInterceptor"); + + // If MT is disabled, then disable all tests + if (!tenantAdminService.isEnabled()) + { + enableTest = false; + return; + } + + // Create a tenant + RetryingTransactionCallback createTenantCallback = new RetryingTransactionCallback() + { + public Object execute() throws Throwable + { + tenantAdminService.createTenant(tenant1, tenant1Pwd.toCharArray()); + return null; + } + }; + transactionService.getRetryingTransactionHelper().doInTransaction(createTenantCallback, false, true); + } + + /** + * Control case. + */ + public void testSetUp() + { + } +} diff --git a/source/java/org/alfresco/repo/tenant/MultiTServiceImpl.java b/source/java/org/alfresco/repo/tenant/MultiTServiceImpl.java index 887acf287b..82f4c8c114 100755 --- a/source/java/org/alfresco/repo/tenant/MultiTServiceImpl.java +++ b/source/java/org/alfresco/repo/tenant/MultiTServiceImpl.java @@ -29,6 +29,7 @@ import java.util.List; import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.repo.cache.SimpleCache; import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.service.cmr.repository.AssociationRef; import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; @@ -97,7 +98,8 @@ public class MultiTServiceImpl implements TenantService // Check that all the passed values are not null ParameterCheck.mandatory("ChildAssocRef", childAssocRef); - return new ChildAssociationRef(childAssocRef.getTypeQName(), + return new ChildAssociationRef( + childAssocRef.getTypeQName(), getName(childAssocRef.getParentRef()), childAssocRef.getQName(), getName(childAssocRef.getChildRef()), @@ -105,6 +107,18 @@ public class MultiTServiceImpl implements TenantService childAssocRef.getNthSibling()); } + public AssociationRef getName(AssociationRef assocRef) + { + // Check that all the passed values are not null + ParameterCheck.mandatory("assocRef", assocRef); + + return new AssociationRef( + getName(assocRef.getSourceRef()), + assocRef.getTypeQName(), + getName(assocRef.getTargetRef()) + ); + } + public StoreRef getName(String username, StoreRef storeRef) { // Check that all the passed values are not null diff --git a/source/java/org/alfresco/repo/tenant/TenantDeployerService.java b/source/java/org/alfresco/repo/tenant/MultiTenantBootstrap.java similarity index 50% rename from source/java/org/alfresco/repo/tenant/TenantDeployerService.java rename to source/java/org/alfresco/repo/tenant/MultiTenantBootstrap.java index 34203014c0..3447601cdf 100644 --- a/source/java/org/alfresco/repo/tenant/TenantDeployerService.java +++ b/source/java/org/alfresco/repo/tenant/MultiTenantBootstrap.java @@ -15,37 +15,47 @@ * 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: + * 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; -import java.util.List; - -import org.apache.commons.logging.Log; - +import org.alfresco.util.AbstractLifecycleBean; +import org.alfresco.util.PropertyCheck; +import org.springframework.context.ApplicationEvent; /** - * Tenant Deployer Service interface. - *

- * This interface allows components to register with the Tenant Deployer Service. - * Components can then deploy and undeploy tenants during bootstrap and shutdown. - * + * This component is responsible for ensuring that patches are applied + * at the appropriate time. + * + * @author Derek Hulley */ +public class MultiTenantBootstrap extends AbstractLifecycleBean +{ + private TenantAdminService tenantAdminService; -public interface TenantDeployerService extends TenantBaseService -{ - public void deployTenants(final TenantDeployer deployer, Log logger); - - public void undeployTenants(final TenantDeployer deployer, Log logger); + /** + * @param tenantAdminService the service that will perform the bootstrap + */ + public void setTenantAdminService(TenantAdminService tenantAdminService) + { + this.tenantAdminService = tenantAdminService; + } - public void register(TenantDeployer tenantDeployer); - - public void unregister(TenantDeployer tenantDeployer); - - public List getAllTenants(); + @Override + protected void onBootstrap(ApplicationEvent event) + { + PropertyCheck.mandatory(this, "tenantAdminService", tenantAdminService); + tenantAdminService.startTenants(); + } + + @Override + protected void onShutdown(ApplicationEvent event) + { + tenantAdminService.stopTenants(); + } } diff --git a/source/java/org/alfresco/repo/tenant/SingleTAdminServiceImpl.java b/source/java/org/alfresco/repo/tenant/SingleTAdminServiceImpl.java new file mode 100644 index 0000000000..d0d10ada03 --- /dev/null +++ b/source/java/org/alfresco/repo/tenant/SingleTAdminServiceImpl.java @@ -0,0 +1,207 @@ +/* + * Copyright (C) 2005-2007 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; + +import java.io.File; +import java.util.Collections; +import java.util.List; + +import org.apache.commons.logging.Log; + +/** + * Empty Tenant Deployer Service implementation (for Single-Tenant / Single-Instance) + */ + +public class SingleTAdminServiceImpl implements TenantAdminService +{ + /** + * NO-OP + */ + public void startTenants() + { + } + + /** + * NO-OP + */ + public void stopTenants() + { + } + + /** + * @return Returns false always + */ + public boolean isEnabled() + { + return false; + } + + /** + * NO-OP + */ + public void initialiseTenants() + { + } + + /** + * NO-OP + */ + public void deployTenants(final TenantDeployer deployer, Log logger) + { + } + + /** + * NO-OP + */ + public void undeployTenants(final TenantDeployer deployer, Log logger) + { + } + + /** + * NO-OP + */ + public void register(TenantDeployer tenantDeployer) + { + } + + /** + * NO-OP + */ + public void unregister(TenantDeployer tenantDeployer) + { + } + + /** + * @return Returns an empty list always + */ + public List getAllTenants() + { + return Collections.emptyList(); + } + + /** + * @return Returns {@link TenantService#DEFAULT_DOMAIN} always + */ + public String getCurrentUserDomain() + { + return TenantService.DEFAULT_DOMAIN; + } + + /** + * @return Returns the given baseUserName always + */ + public String getDomainUser(String baseUsername, String tenantDomain) + { + return baseUsername; + } + + /** + * @return Returns {@link TenantService#DEFAULT_DOMAIN} always + */ + public String getDomain(String name) + { + return TenantService.DEFAULT_DOMAIN; + } + + /** + * @throws UnsupportedOperationException always + */ + public void createTenant(String tenantDomain, char[] adminRawPassword, String rootContentStoreDir) + { + throw new UnsupportedOperationException("Single tenant mode is active."); + } + + /** + * @throws UnsupportedOperationException always + */ + public void createTenant(String tenantDomain, char[] adminRawPassword) + { + throw new UnsupportedOperationException("Single tenant mode is active."); + } + + /** + * @throws UnsupportedOperationException always + */ + public void deleteTenant(String tenantDomain) + { + throw new UnsupportedOperationException("Single tenant mode is active."); + } + + /** + * @throws UnsupportedOperationException always + */ + public void disableTenant(String tenantDomain) + { + throw new UnsupportedOperationException("Single tenant mode is active."); + } + + /** + * @throws UnsupportedOperationException always + */ + public void enableTenant(String tenantDomain) + { + throw new UnsupportedOperationException("Single tenant mode is active."); + } + + /** + * @throws UnsupportedOperationException always + */ + public boolean existsTenant(String tenantDomain) + { + throw new UnsupportedOperationException("Single tenant mode is active."); + } + + /** + * @throws UnsupportedOperationException always + */ + public void exportTenant(String tenantDomain, File directoryDestination) + { + throw new UnsupportedOperationException("Single tenant mode is active."); + } + + /** + * @throws UnsupportedOperationException always + */ + public Tenant getTenant(String tenantDomain) + { + throw new UnsupportedOperationException("Single tenant mode is active."); + } + + /** + * @throws UnsupportedOperationException always + */ + public void importTenant(String tenantDomain, File directorySource, String rootContentStoreDir) + { + throw new UnsupportedOperationException("Single tenant mode is active."); + } + + /** + * @throws UnsupportedOperationException always + */ + public boolean isEnabledTenant(String tenantDomain) + { + throw new UnsupportedOperationException("Single tenant mode is active."); + } +} \ No newline at end of file diff --git a/source/java/org/alfresco/repo/tenant/SingleTDeployerServiceImpl.java b/source/java/org/alfresco/repo/tenant/SingleTDeployerServiceImpl.java deleted file mode 100644 index c80f12cd01..0000000000 --- a/source/java/org/alfresco/repo/tenant/SingleTDeployerServiceImpl.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (C) 2005-2007 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; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.logging.Log; - -/** - * Empty Tenant Deployer Service implementation (for Single-Tenant / Single-Instance) - */ - -public class SingleTDeployerServiceImpl implements TenantDeployerService -{ - public void deployTenants(final TenantDeployer deployer, Log logger) - { - // NOOP - } - - public void undeployTenants(final TenantDeployer deployer, Log logger) - { - // NOOP - } - - public void register(TenantDeployer tenantDeployer) - { - // NOOP - } - - public void unregister(TenantDeployer tenantDeployer) - { - // NOOP - } - - public List getAllTenants() - { - 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/SingleTServiceImpl.java b/source/java/org/alfresco/repo/tenant/SingleTServiceImpl.java index 44da6d64df..5fa960c612 100644 --- a/source/java/org/alfresco/repo/tenant/SingleTServiceImpl.java +++ b/source/java/org/alfresco/repo/tenant/SingleTServiceImpl.java @@ -24,6 +24,7 @@ */ package org.alfresco.repo.tenant; +import org.alfresco.service.cmr.repository.AssociationRef; import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; @@ -58,6 +59,11 @@ public class SingleTServiceImpl implements TenantService return childAssocRef; } + public AssociationRef getName(AssociationRef assocRef) + { + return assocRef; + } + public StoreRef getName(String username, StoreRef storeRef) { return storeRef; diff --git a/source/java/org/alfresco/repo/tenant/TenantAdminService.java b/source/java/org/alfresco/repo/tenant/TenantAdminService.java old mode 100755 new mode 100644 index b5ea072f6c..b2189690c0 --- a/source/java/org/alfresco/repo/tenant/TenantAdminService.java +++ b/source/java/org/alfresco/repo/tenant/TenantAdminService.java @@ -27,6 +27,8 @@ package org.alfresco.repo.tenant; import java.io.File; import java.util.List; +import org.apache.commons.logging.Log; + /** * Tenant Admin Service interface. @@ -35,8 +37,30 @@ import java.util.List; * */ -public interface TenantAdminService extends TenantDeployerService +public interface TenantAdminService extends TenantUserService { + public void startTenants(); + + public void stopTenants(); + + /* + * Deployer methods + */ + + public void deployTenants(final TenantDeployer deployer, Log logger); + + public void undeployTenants(final TenantDeployer deployer, Log logger); + + public void register(TenantDeployer tenantDeployer); + + public void unregister(TenantDeployer tenantDeployer); + + public List getAllTenants(); + + /* + * Deployer methods + */ + public void createTenant(String tenantDomain, char[] adminRawPassword); public void createTenant(String tenantDomain, char[] adminRawPassword, String rootContentStoreDir); @@ -49,8 +73,6 @@ public interface TenantAdminService extends TenantDeployerService public void deleteTenant(String tenantDomain); - public List getAllTenants(); - public void enableTenant(String tenantDomain); public void disableTenant(String tenantDomain); @@ -58,6 +80,4 @@ public interface TenantAdminService extends TenantDeployerService public Tenant getTenant(String tenantDomain); public boolean isEnabledTenant(String tenantDomain); - - public boolean isEnabled(); } diff --git a/source/java/org/alfresco/repo/tenant/TenantBaseService.java b/source/java/org/alfresco/repo/tenant/TenantBaseService.java deleted file mode 100644 index 2fc0ec81af..0000000000 --- a/source/java/org/alfresco/repo/tenant/TenantBaseService.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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/TenantService.java b/source/java/org/alfresco/repo/tenant/TenantService.java index 36355fcadb..4edcac1d1c 100644 --- a/source/java/org/alfresco/repo/tenant/TenantService.java +++ b/source/java/org/alfresco/repo/tenant/TenantService.java @@ -24,6 +24,7 @@ */ package org.alfresco.repo.tenant; +import org.alfresco.service.cmr.repository.AssociationRef; import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; @@ -39,7 +40,7 @@ import org.alfresco.service.namespace.QName; * This interface provides methods to support either ST or MT implementations. * */ -public interface TenantService extends TenantBaseService +public interface TenantService extends TenantUserService { public static final String SEPARATOR = "@"; @@ -67,6 +68,11 @@ public interface TenantService extends TenantBaseService */ public ChildAssociationRef getName(ChildAssociationRef childAssocRef); + /** + * @return the reference with the tenant-specific ID attached + */ + public AssociationRef getName(AssociationRef assocRef); + /** * @return the reference with the tenant-specific ID attached */ diff --git a/source/java/org/alfresco/repo/tenant/TenantUserService.java b/source/java/org/alfresco/repo/tenant/TenantUserService.java new file mode 100644 index 0000000000..b6dd4268a8 --- /dev/null +++ b/source/java/org/alfresco/repo/tenant/TenantUserService.java @@ -0,0 +1,19 @@ +package org.alfresco.repo.tenant; + +/** + * Interface for Tenant User-Domain functionality. + * + * @author Jan Vonka + * @author Derek Hulley + * @since 3.0 + */ +public interface TenantUserService +{ + 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/usage/UserUsageTrackingComponent.java b/source/java/org/alfresco/repo/usage/UserUsageTrackingComponent.java index ca309b8cf6..0a9dfbb706 100644 --- a/source/java/org/alfresco/repo/usage/UserUsageTrackingComponent.java +++ b/source/java/org/alfresco/repo/usage/UserUsageTrackingComponent.java @@ -35,7 +35,7 @@ import org.alfresco.repo.node.db.NodeDaoService.NodePropertyHandler; 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.TenantAdminService; import org.alfresco.repo.transaction.RetryingTransactionHelper; import org.alfresco.repo.transaction.TransactionServiceImpl; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; @@ -70,7 +70,7 @@ public class UserUsageTrackingComponent private NodeService nodeService; private NodeDaoService nodeDaoService; private UsageService usageService; - private TenantDeployerService tenantDeployerService; + private TenantAdminService tenantAdminService; private boolean enabled = true; @@ -104,9 +104,9 @@ public class UserUsageTrackingComponent this.usageService = usageService; } - public void setTenantDeployerService(TenantDeployerService tenantDeployerService) + public void setTenantAdminService(TenantAdminService tenantAdminService) { - this.tenantDeployerService = tenantDeployerService; + this.tenantAdminService = tenantAdminService; } public void setEnabled(boolean enabled) @@ -141,9 +141,9 @@ public class UserUsageTrackingComponent // default domain bootstrapInternal(); - if (tenantDeployerService.isEnabled()) + if (tenantAdminService.isEnabled()) { - List tenants = tenantDeployerService.getAllTenants(); + List tenants = tenantAdminService.getAllTenants(); for (Tenant tenant : tenants) { AuthenticationUtil.runAs(new RunAsWork() @@ -153,7 +153,7 @@ public class UserUsageTrackingComponent bootstrapInternal(); return null; } - }, tenantDeployerService.getDomainUser(AuthenticationUtil.getSystemUserName(), tenant.getTenantDomain())); + }, tenantAdminService.getDomainUser(AuthenticationUtil.getSystemUserName(), tenant.getTenantDomain())); } } } @@ -423,7 +423,7 @@ public class UserUsageTrackingComponent } return null; } - }, tenantDeployerService.getDomainUser(AuthenticationUtil.getSystemUserName(), tenantDeployerService.getDomain(usageNodeRef.getStoreRef().getIdentifier()))); + }, tenantAdminService.getDomainUser(AuthenticationUtil.getSystemUserName(), tenantAdminService.getDomain(usageNodeRef.getStoreRef().getIdentifier()))); } return null; }