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
This commit is contained in:
Derek Hulley
2008-09-05 13:04:46 +00:00
parent f074588b0c
commit 77eb167c2b
35 changed files with 961 additions and 344 deletions

View File

@@ -18,7 +18,7 @@
<import resource="classpath:alfresco/network-protocol-context.xml" />
<import resource="classpath:alfresco/emailserver/email-service-context.xml" />
<import resource="classpath:alfresco/content-services-context.xml" />
<import resource="classpath*:alfresco/extension/mt/mt-contentstore-context.xml"/>
<import resource="classpath*:alfresco/mt/*-context.xml"/>
<import resource="classpath:alfresco/hibernate-context.xml" />
<import resource="classpath:alfresco/ownable-services-context.xml" />
<import resource="classpath:alfresco/template-services-context.xml" />

View File

@@ -122,7 +122,7 @@
<property name="namespaceService" ref="namespaceService"/>
<property name="nodeService" ref="NodeService"/>
<property name="messageService" ref="messageService"/>
<property name="tenantDeployerService" ref="tenantAdminService"/>
<property name="tenantAdminService" ref="tenantAdminService"/>
<property name="repositoryModelsLocations">
<list>
@@ -328,8 +328,9 @@
</property>
</bean>
<import resource="classpath:alfresco/bootstrap/st-admin-context.xml"/>
<import resource="classpath*:alfresco/extension/mt/mt-admin-context.xml"/>
<bean id="multiTenantBootstrap" class="org.alfresco.repo.tenant.MultiTenantBootstrap" >
<property name="tenantAdminService" ref="tenantAdminService" />
</bean>
<bean id="workflowBootstrap" parent="workflowDeployer">
<property name="workflowDefinitions">
@@ -570,7 +571,7 @@
<property name="personService" ref="personService" />
<property name="fileFolderService" ref="fileFolderService" />
<property name="searchService" ref="searchService" />
<property name="tenantDeployerService" ref="tenantAdminService" />
<property name="tenantAdminService" ref="tenantAdminService" />
<property name="avmService" ref="AVMService" />
<property name="companyHomeStore"><value>${spaces.store}</value></property>
<property name="companyHomePath"><value>/${spaces.company_home.childname}</value></property>

View File

@@ -50,7 +50,7 @@
<property name="dictionaryService" ref="dictionaryService" />
<property name="searchService" ref="SearchService" />
<property name="transactionHelper" ref="retryingTransactionHelper" />
<property name="tenantDeployerService" ref="tenantAdminService" />
<property name="tenantAdminService" ref="tenantAdminService" />
<property name="nodeService" ref="NodeService" />
<property name="repository" ref="repositoryHelper" />
</bean>

View File

@@ -12,7 +12,7 @@
<property name="descriptorService" ref="DescriptorService" />
<property name="authenticationComponent" ref="AuthenticationComponent" />
<property name="registryService" ref="RegistryService" />
<property name="tenantDeployerService" ref="tenantAdminService" />
<property name="tenantAdminService" ref="tenantAdminService" />
</bean>
<!-- Parent bean for beans derived from AbstractModuleComponent -->
@@ -20,7 +20,7 @@
<property name="serviceRegistry" ref="ServiceRegistry" />
<property name="authenticationComponent" ref="AuthenticationComponent" />
<property name="moduleService" ref="ModuleService" />
<property name="tenantDeployerService" ref="tenantAdminService" />
<property name="tenantAdminService" ref="tenantAdminService" />
</bean>
<!-- Import of installed modules -->

View File

@@ -3,6 +3,6 @@
<beans>
<bean id="tenantAdminService" class="org.alfresco.repo.tenant.SingleTDeployerServiceImpl" />
<bean id="tenantAdminService" class="org.alfresco.repo.tenant.SingleTAdminServiceImpl" />
</beans>

View File

@@ -16,7 +16,7 @@
</property>
</bean>
<bean id="nodeRefPropertyInterceptor" class="org.alfresco.repo.node.NodeRefPropertyMethodInterceptor">
<bean id="nodeRefPropertyInterceptor" class="org.alfresco.repo.node.NodeRefPropertyMethodInterceptor" init-method="init">
<property name="nodeService">
<ref bean="mlAwareNodeService" />
</property>
@@ -25,6 +25,12 @@
</property>
</bean>
<bean id="multiTNodeServiceInterceptor" class="org.alfresco.repo.tenant.MultiTNodeServiceInterceptor">
<property name="tenantService">
<ref bean="tenantService" />
</property>
</bean>
<bean id="nodeService" class="org.springframework.aop.framework.ProxyFactoryBean" >
<property name="targetName">
<value>mlAwareNodeService</value>
@@ -38,6 +44,7 @@
<list>
<value>nodeRefPropertyInterceptor</value>
<value>mlPropertyInterceptor</value>
<value>multiTNodeServiceInterceptor</value>
</list>
</property>
</bean>

View File

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

View File

@@ -54,7 +54,7 @@
<property name="searchService" ref="SearchService"/>
<property name="namespaceService" ref="namespaceService"/>
<property name="tenantService" ref="tenantService"/>
<property name="tenantDeployerService" ref="tenantAdminService"/>
<property name="tenantAdminService" ref="tenantAdminService"/>
<property name="storeUrls">
<list>

View File

@@ -300,7 +300,7 @@
<property name="usageService">
<ref bean="usageService"/>
</property>
<property name="tenantDeployerService">
<property name="tenantAdminService">
<ref bean="tenantAdminService" />
</property>
<property name="enabled">

View File

@@ -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<String, NodeRef>(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)
{

View File

@@ -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<Tenant> tenants = tenantDeployerService.getAllTenants();
List<Tenant> 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 + ")";
}

View File

@@ -261,9 +261,6 @@ public class AuditableAspect
/**
* Construct
*
* @param nodeRef
* @param properties
*/
private SetAuditProperties(NodeService nodeService, NodeRef nodeRef, Map<QName, Serializable> properties)
{

View File

@@ -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<String, ConfigImpl> 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<String, ConfigImpl> 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();
}
}

View File

@@ -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<String> 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<Tenant> tenants = tenantDeployerService.getAllTenants();
List<Tenant> tenants = tenantAdminService.getAllTenants();
for (Tenant tenant : tenants)
{
// validate model delete within context of tenant domain

View File

@@ -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);
}
}
}

View File

@@ -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);

View File

@@ -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());
}
}

View File

@@ -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);

View File

@@ -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<String, Map<String, ModuleComponent>> 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<String, Set<String>> mapStartedModules = new HashMap<String, Set<String>>(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<ModuleComponent>(10));
mapStartedModules.put(tenantDomainCtx, new HashSet<String>(2));
final List<Tenant> 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<ModuleComponent>(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));
}
}
}

View File

@@ -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);

View File

@@ -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);
}
/**

View File

@@ -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

View File

@@ -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<Properties> bootstrapViews = new ArrayList<Properties>(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<Properties> bootstrapViews = new ArrayList<Properties>(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<Properties> bootstrapViews = new ArrayList<Properties>(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<Properties> bootstrapViews = new ArrayList<Properties>(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<Properties> bootstrapViews = new ArrayList<Properties>(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<Properties> bootstrapViews = new ArrayList<Properties>(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));

View File

@@ -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<Boolean> ignoreMT = new ThreadLocal<Boolean>();
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 <tt>true</tt> if the current thread is able to handle
* MultiTenant-enabled references.
* @return <tt>true</tt> 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 <tt>true</tt> 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<QName, Serializable> 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<String> 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<QName, Serializable> 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<QName> getAspects(NodeRef nodeRef) throws InvalidNodeRefException
// {
// throw new UnsupportedOperationException();
// }
//
// public List<ChildAssociationRef> getChildAssocs(NodeRef nodeRef, QNamePattern typeQNamePattern, QNamePattern qnamePattern) throws InvalidNodeRefException
// {
// throw new UnsupportedOperationException();
// }
//
// public List<ChildAssociationRef> 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<ChildAssociationRef> getParentAssocs(NodeRef nodeRef, QNamePattern typeQNamePattern, QNamePattern qnamePattern) throws InvalidNodeRefException
// {
// throw new UnsupportedOperationException();
// }
//
// public List<ChildAssociationRef> getParentAssocs(NodeRef nodeRef) throws InvalidNodeRefException
// {
// throw new UnsupportedOperationException();
// }
//
// public Path getPath(NodeRef nodeRef) throws InvalidNodeRefException
// {
// throw new UnsupportedOperationException();
// }
//
// public List<Path> getPaths(NodeRef nodeRef, boolean primaryOnly) throws InvalidNodeRefException
// {
// throw new UnsupportedOperationException();
// }
//
// public ChildAssociationRef getPrimaryParent(NodeRef nodeRef) throws InvalidNodeRefException
// {
// throw new UnsupportedOperationException();
// }
//
// public Map<QName, Serializable> 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<AssociationRef> getSourceAssocs(NodeRef targetRef, QNamePattern qnamePattern) throws InvalidNodeRefException
// {
// throw new UnsupportedOperationException();
// }
//
// public NodeRef getStoreArchiveNode(StoreRef storeRef)
// {
// throw new UnsupportedOperationException();
// }
//
// public List<StoreRef> getStores()
// {
// throw new UnsupportedOperationException();
// }
//
// public List<AssociationRef> 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<QName, Serializable> 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<Object> convertOutboundValues(Collection<Object> rawValues)
{
Collection<Object> convertedValues = new ArrayList<Object>(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<Object>)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;
}
}

View File

@@ -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<Object> createTenantCallback = new RetryingTransactionCallback<Object>()
{
public Object execute() throws Throwable
{
tenantAdminService.createTenant(tenant1, tenant1Pwd.toCharArray());
return null;
}
};
transactionService.getRetryingTransactionHelper().doInTransaction(createTenantCallback, false, true);
}
/**
* Control case.
*/
public void testSetUp()
{
}
}

View File

@@ -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

View File

@@ -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.
* <p>
* 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<Tenant> getAllTenants();
@Override
protected void onBootstrap(ApplicationEvent event)
{
PropertyCheck.mandatory(this, "tenantAdminService", tenantAdminService);
tenantAdminService.startTenants();
}
@Override
protected void onShutdown(ApplicationEvent event)
{
tenantAdminService.stopTenants();
}
}

View File

@@ -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 <tt>false</tt> 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<Tenant> getAllTenants()
{
return Collections.emptyList();
}
/**
* @return Returns {@link TenantService#DEFAULT_DOMAIN} always
*/
public String getCurrentUserDomain()
{
return TenantService.DEFAULT_DOMAIN;
}
/**
* @return Returns the given <tt>baseUserName</tt> 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.");
}
}

View File

@@ -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<Tenant> getAllTenants()
{
return new ArrayList<Tenant>(0); // empty list
}
public String getCurrentUserDomain()
{
return TenantService.DEFAULT_DOMAIN;
}
public String getDomainUser(String baseUsername, String tenantDomain)
{
return baseUsername;
}
public String getDomain(String name)
{
return TenantService.DEFAULT_DOMAIN;
}
public boolean isEnabled()
{
return false;
}
}

View File

@@ -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;

View File

@@ -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<Tenant> 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<Tenant> 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();
}

View File

@@ -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.
* <p>
* Common for TenantService and TenantDeployerService
*
*/
public interface TenantBaseService
{
public String getCurrentUserDomain();
public String getDomainUser(String baseUsername, String tenantDomain);
public String getDomain(String name);
public boolean isEnabled();
}

View File

@@ -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 <b>with</b> the tenant-specific ID attached
*/
public AssociationRef getName(AssociationRef assocRef);
/**
* @return the reference <b>with</b> the tenant-specific ID attached
*/

View File

@@ -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();
}

View File

@@ -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<Tenant> tenants = tenantDeployerService.getAllTenants();
List<Tenant> tenants = tenantAdminService.getAllTenants();
for (Tenant tenant : tenants)
{
AuthenticationUtil.runAs(new RunAsWork<Object>()
@@ -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;
}