mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged V3.1 to HEAD
13965: Line-endings only 13967: Enable upgrade of MT env from 3.0.x to 3.1.1+ (with out-of-date config warning on startup rather than errors later) 13976: Line-endings only 13977: MT - add unit test (for dynamic models) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@13980 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -20,12 +20,10 @@
|
||||
|
||||
<bean id="tenantAdminService" parent="baseMultiTAdminService" />
|
||||
|
||||
<bean id="tenantInterpreter" class="org.alfresco.repo.tenant.TenantInterpreter">
|
||||
<property name="transactionService" ref="transactionComponent"/>
|
||||
<bean id="tenantInterpreter" class="org.alfresco.repo.tenant.TenantInterpreter" parent="interpreterBase">
|
||||
<property name="tenantAdminService" ref="tenantAdminService"/>
|
||||
<property name="tenantService" ref="tenantService"/>
|
||||
<property name="authenticationService" ref="AuthenticationService"/>
|
||||
<property name="authorityService" ref="AuthorityService"/>
|
||||
<property name="baseAdminUsername"><value>${alfresco_user_store.adminusername}</value></property>
|
||||
</bean>
|
||||
|
||||
|
@@ -24,4 +24,7 @@ system.openoffice.err.connection_remade=The OpenOffice connection was re-establi
|
||||
system.locks.err.failed_to_acquire_lock=Failed to get lock ''{0}'' using token ''{1}''.
|
||||
system.locks.err.lock_resource_missing=Failed to manipulate lock ''{0}'' using token ''{1}''. The lock resource no longer exists.
|
||||
system.locks.err.lock_update_count=Failed to update lock ''{0}'' using token ''{1}''. {2} locks were updated when {3} should have been.
|
||||
system.locks.err.excl_lock_exists=Failed to get lock ''{0}'' using token ''{1}''. An exclusive lock exists: {2}
|
||||
system.locks.err.excl_lock_exists=Failed to get lock ''{0}'' using token ''{1}''. An exclusive lock exists: {2}
|
||||
|
||||
# Multi-Tenant
|
||||
system.mt.warn.upgrade_mt_admin_context=Please update your alfresco/extension/mt/mt-admin-context.xml (to use latest alfresco/extension/mt/mt-admin-context.xml.sample).>>>>>>> .merge-right.r13967
|
||||
|
@@ -2,7 +2,19 @@
|
||||
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
|
||||
|
||||
<beans>
|
||||
|
||||
|
||||
<!--
|
||||
Bootstrap Data: Prototype beans for the per-tenant bootstrap.
|
||||
These are fetched by the MultiTAdminServiceImpl when new tenant is created.
|
||||
-->
|
||||
<bean id="userBootstrap-mt" parent="userBootstrap-base" singleton="false" />
|
||||
<bean id="systemBootstrap-mt" parent="systemBootstrap-base" singleton="false" />
|
||||
<bean id="versionBootstrap-mt" parent="versionBootstrap-base" singleton="false" />
|
||||
<bean id="version2Bootstrap-mt" parent="version2Bootstrap-base" singleton="false" />
|
||||
<bean id="spacesArchiveBootstrap-mt" parent="spacesArchiveBootstrap-base" singleton="false" />
|
||||
<bean id="spacesBootstrap-mt" parent="spacesBootstrap-base" singleton="false" />
|
||||
|
||||
|
||||
<bean id="baseMultiTAdminService" class="org.alfresco.repo.tenant.MultiTAdminServiceImpl" abstract="true">
|
||||
|
||||
<!--
|
||||
@@ -20,7 +32,7 @@
|
||||
<property name="workflowService" ref="WorkflowService"/>
|
||||
<property name="repositoryExporterService" ref="repositoryExporterComponent"/>
|
||||
<property name="moduleService" ref="moduleService"/>
|
||||
<property name="baseAdminUsername"><value>${alfresco_user_store.adminusername}</value></property>
|
||||
<property name="baseAdminUsername"><value>${alfresco_user_store.adminusername}</value></property>
|
||||
|
||||
<property name="siteAVMBootstrap" ref="siteAVMBootstrap"/>
|
||||
|
||||
|
@@ -3,8 +3,15 @@
|
||||
|
||||
<beans>
|
||||
|
||||
<bean id="repoAdminService" class="org.alfresco.repo.admin.RepoAdminServiceImpl">
|
||||
<bean id="interpreterBase" abstract="true">
|
||||
|
||||
<property name="transactionService" ref="transactionComponent"/>
|
||||
<property name="authorityService" ref="AuthorityService"/>
|
||||
|
||||
</bean>
|
||||
|
||||
<bean id="repoAdminService" class="org.alfresco.repo.admin.RepoAdminServiceImpl">
|
||||
|
||||
<property name="dictionaryDAO" ref="dictionaryDAO"/>
|
||||
<property name="searchService" ref="SearchService"/>
|
||||
<property name="nodeService" ref="NodeService"/>
|
||||
@@ -14,25 +21,23 @@
|
||||
|
||||
<property name="repositoryModelsLocation" ref="customModelsRepositoryLocation"/>
|
||||
<property name="repositoryMessagesLocation" ref="customMessagesRepositoryLocation"/>
|
||||
|
||||
|
||||
</bean>
|
||||
|
||||
<bean id="repoAdminInterpreter" class="org.alfresco.repo.admin.RepoAdminInterpreter">
|
||||
|
||||
<property name="transactionService" ref="transactionComponent"/>
|
||||
<bean id="repoAdminInterpreter" class="org.alfresco.repo.admin.RepoAdminInterpreter" parent="interpreterBase">
|
||||
|
||||
<property name="repoAdminService" ref="RepoAdminService"/>
|
||||
<property name="authorityService" ref="AuthorityService"/>
|
||||
|
||||
|
||||
</bean>
|
||||
|
||||
<bean id="repoAdminInterpreterHelp" class="org.alfresco.i18n.ResourceBundleBootstrapComponent">
|
||||
|
||||
|
||||
<property name="resourceBundles">
|
||||
<list>
|
||||
<value>alfresco.messages.repoadmin-interpreter-help</value>
|
||||
</list>
|
||||
</property>
|
||||
|
||||
|
||||
</bean>
|
||||
|
||||
|
||||
|
@@ -42,7 +42,7 @@
|
||||
<property name="tenantService" ref="tenantService"/>
|
||||
</bean>
|
||||
|
||||
<bean id="workflowInterpreter" class="org.alfresco.repo.workflow.WorkflowInterpreter">
|
||||
<bean id="workflowInterpreter" class="org.alfresco.repo.workflow.WorkflowInterpreter" parent="interpreterBase">
|
||||
<property name="workflowService" ref="WorkflowService"/>
|
||||
<property name="AVMService" ref="AVMService"/>
|
||||
<property name="AVMSyncService" ref="AVMSyncService"/>
|
||||
@@ -50,10 +50,8 @@
|
||||
<property name="namespaceService" ref="namespaceService"/>
|
||||
<property name="personService" ref="PersonService"/>
|
||||
<property name="authorityDAO" ref="authorityDAO"/>
|
||||
<property name="transactionService" ref="transactionService"/>
|
||||
<property name="fileFolderService" ref="FileFolderService"/>
|
||||
<property name="tenantService" ref="tenantService"/>
|
||||
<property name="authorityService" ref="AuthorityService"/>
|
||||
</bean>
|
||||
|
||||
<bean id="workflowInterpreterHelp" class="org.alfresco.i18n.ResourceBundleBootstrapComponent">
|
||||
|
@@ -38,6 +38,7 @@ import javax.transaction.UserTransaction;
|
||||
import net.sf.acegisecurity.providers.encoding.PasswordEncoder;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.i18n.I18NUtil;
|
||||
import org.alfresco.repo.admin.RepoModelDefinition;
|
||||
import org.alfresco.repo.attributes.BooleanAttributeValue;
|
||||
import org.alfresco.repo.attributes.MapAttribute;
|
||||
@@ -68,6 +69,7 @@ import org.alfresco.util.PropertyCheck;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
|
||||
@@ -76,7 +78,7 @@ import org.springframework.context.ApplicationContextAware;
|
||||
*
|
||||
*/
|
||||
|
||||
public class MultiTAdminServiceImpl implements TenantAdminService, ApplicationContextAware
|
||||
public class MultiTAdminServiceImpl implements TenantAdminService, ApplicationContextAware, InitializingBean
|
||||
{
|
||||
// Logger
|
||||
private static Log logger = LogFactory.getLog(MultiTAdminServiceImpl.class);
|
||||
@@ -221,22 +223,31 @@ public class MultiTAdminServiceImpl implements TenantAdminService, ApplicationCo
|
||||
public static final String STORE_BASE_ID_VERSION1 = "lightWeightVersionStore"; // deprecated
|
||||
public static final String STORE_BASE_ID_VERSION2 = "version2Store";
|
||||
public static final String STORE_BASE_ID_SPACES = "SpacesStore";
|
||||
|
||||
|
||||
private static final String TENANTS_ATTRIBUTE_PATH = "alfresco-tenants";
|
||||
private static final String TENANT_ATTRIBUTE_ENABLED = "enabled";
|
||||
private static final String TENANT_ROOT_CONTENT_STORE_DIR = "rootContentStoreDir";
|
||||
|
||||
private List<TenantDeployer> tenantDeployers = new ArrayList<TenantDeployer>();
|
||||
|
||||
private static final String WARN_MSG = "Please update your alfresco/extension/mt/mt-admin-context.xml to use baseMultiTAdminService (see latest alfresco/extension/mt/mt-admin-context.xml.sample)";
|
||||
|
||||
protected void checkProperties()
|
||||
private List<TenantDeployer> tenantDeployers = new ArrayList<TenantDeployer>();
|
||||
|
||||
private static final String WARN_MSG = "system.mt.warn.upgrade_mt_admin_context";
|
||||
|
||||
public void afterPropertiesSet() throws Exception
|
||||
{
|
||||
if (moduleService == null || siteAVMBootstrap == null || baseAdminUsername == null)
|
||||
// for upgrade/backwards compatibility with 3.0.x (mt-admin-context.xml)
|
||||
if (baseAdminUsername == null)
|
||||
{
|
||||
logger.warn(WARN_MSG);
|
||||
logger.warn(I18NUtil.getMessage(WARN_MSG));
|
||||
}
|
||||
|
||||
// for upgrade/backwards compatibility with 3.0.x (mt-admin-context.xml)
|
||||
if (siteAVMBootstrap == null)
|
||||
{
|
||||
logger.warn(I18NUtil.getMessage(WARN_MSG));
|
||||
|
||||
siteAVMBootstrap = (SiteAVMBootstrap) ctx.getBean("siteAVMBootstrap");
|
||||
}
|
||||
|
||||
PropertyCheck.mandatory(this, "NodeService", nodeService);
|
||||
PropertyCheck.mandatory(this, "DictionaryComponent", dictionaryComponent);
|
||||
PropertyCheck.mandatory(this, "RepoAdminService", repoAdminService);
|
||||
@@ -247,9 +258,9 @@ public class MultiTAdminServiceImpl implements TenantAdminService, ApplicationCo
|
||||
PropertyCheck.mandatory(this, "TenantFileContentStore", tenantFileContentStore);
|
||||
PropertyCheck.mandatory(this, "WorkflowService", workflowService);
|
||||
PropertyCheck.mandatory(this, "RepositoryExporterService", repositoryExporterService);
|
||||
PropertyCheck.mandatory(this, "siteAVMBootstrap", siteAVMBootstrap);
|
||||
PropertyCheck.mandatory(this, "moduleService", moduleService);
|
||||
PropertyCheck.mandatory(this, "baseAdminUsername", baseAdminUsername);
|
||||
PropertyCheck.mandatory(this, "moduleService", moduleService);
|
||||
PropertyCheck.mandatory(this, "siteAVMBootstrap", siteAVMBootstrap);
|
||||
}
|
||||
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
|
||||
@@ -259,8 +270,6 @@ public class MultiTAdminServiceImpl implements TenantAdminService, ApplicationCo
|
||||
|
||||
public void startTenants()
|
||||
{
|
||||
checkProperties();
|
||||
|
||||
AuthenticationUtil.setMtEnabled(true);
|
||||
|
||||
// initialise the tenant admin service and status of tenants (using attribute service)
|
||||
|
@@ -24,6 +24,7 @@
|
||||
*/
|
||||
package org.alfresco.repo.tenant;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.Serializable;
|
||||
import java.io.StringWriter;
|
||||
@@ -42,7 +43,10 @@ import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.content.MimetypeMap;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||
import org.alfresco.service.cmr.coci.CheckOutCheckInService;
|
||||
import org.alfresco.service.cmr.admin.RepoAdminService;
|
||||
import org.alfresco.service.cmr.coci.CheckOutCheckInService;
|
||||
import org.alfresco.service.cmr.dictionary.ClassDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.ContentService;
|
||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||
@@ -86,35 +90,37 @@ public class MultiTDemoTest extends TestCase
|
||||
private TenantService tenantService;
|
||||
private AuthorityService authorityService;
|
||||
private CategoryService categoryService;
|
||||
private CheckOutCheckInService cociService;
|
||||
private CheckOutCheckInService cociService;
|
||||
private RepoAdminService repoAdminService;
|
||||
private DictionaryService dictionaryService;
|
||||
|
||||
public static int NUM_TENANTS = 11;
|
||||
public static int NUM_TENANTS = 2;
|
||||
|
||||
public static final String TEST_TENANT_DOMAIN = "my.test";
|
||||
public static final String TEST_TENANT_DOMAIN2 = TEST_TENANT_DOMAIN+"2";
|
||||
|
||||
public static List<String> tenants;
|
||||
|
||||
static
|
||||
{
|
||||
tenants = new ArrayList<String>(NUM_TENANTS);
|
||||
for (int i = 1; i <= NUM_TENANTS; i++)
|
||||
{
|
||||
tenants.add(TEST_TENANT_DOMAIN+i);
|
||||
}
|
||||
public static final String TEST_TENANT_DOMAIN = "my.test";
|
||||
public static final String TEST_TENANT_DOMAIN2 = TEST_TENANT_DOMAIN+"2";
|
||||
|
||||
public static List<String> tenants;
|
||||
|
||||
static
|
||||
{
|
||||
tenants = new ArrayList<String>(NUM_TENANTS);
|
||||
for (int i = 1; i <= NUM_TENANTS; i++)
|
||||
{
|
||||
tenants.add(TEST_TENANT_DOMAIN+i);
|
||||
}
|
||||
}
|
||||
|
||||
public static final String ROOT_DIR = "./tenantstores";
|
||||
|
||||
public static final String DEFAULT_ADMIN_PW = "admin";
|
||||
public static final String DEFAULT_ADMIN_PW = "admin";
|
||||
|
||||
public static final String DEFAULT_GUEST_UN = "guest";
|
||||
public static final String DEFAULT_GUEST_PW = "thiscanbeanything";
|
||||
|
||||
public static final String DEFAULT_GUEST_UN = "guest";
|
||||
public static final String DEFAULT_GUEST_PW = "thiscanbeanything";
|
||||
|
||||
public static final String TEST_USER1 = "alice";
|
||||
public static final String TEST_USER2 = "bob";
|
||||
public static final String TEST_USER3 = "eve";
|
||||
public static final String TEST_USER4 = "fred";
|
||||
public static final String TEST_USER4 = "fred";
|
||||
|
||||
private static final int DEFAULT_STORE_COUNT = 7; // including siteStore
|
||||
|
||||
@@ -142,7 +148,9 @@ public class MultiTDemoTest extends TestCase
|
||||
ownableService = (OwnableService) ctx.getBean("OwnableService");
|
||||
authorityService = (AuthorityService) ctx.getBean("AuthorityService");
|
||||
categoryService = (CategoryService) ctx.getBean("CategoryService");
|
||||
cociService = (CheckOutCheckInService) ctx.getBean("CheckoutCheckinService");
|
||||
cociService = (CheckOutCheckInService) ctx.getBean("CheckoutCheckinService");
|
||||
repoAdminService = (RepoAdminService) ctx.getBean("RepoAdminService");
|
||||
dictionaryService = (DictionaryService) ctx.getBean("DictionaryService");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -154,8 +162,8 @@ public class MultiTDemoTest extends TestCase
|
||||
|
||||
public void testCreateTenants() throws Throwable
|
||||
{
|
||||
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName()); // authenticate as super-admin
|
||||
|
||||
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName()); // authenticate as super-admin
|
||||
|
||||
logger.info("Create tenants");
|
||||
|
||||
Set<NodeRef> personRefs = personService.getAllPeople();
|
||||
@@ -180,8 +188,8 @@ public class MultiTDemoTest extends TestCase
|
||||
{
|
||||
if (! tenantAdminService.existsTenant(tenantDomain))
|
||||
{
|
||||
//tenantAdminService.createTenant(tenantDomain, DEFAULT_ADMIN_PW.toCharArray(), ROOT_DIR + "/" + tenantDomain);
|
||||
tenantAdminService.createTenant(tenantDomain, (DEFAULT_ADMIN_PW+" "+tenantDomain).toCharArray(), null); // use default root dir
|
||||
//tenantAdminService.createTenant(tenantDomain, DEFAULT_ADMIN_PW.toCharArray(), ROOT_DIR + "/" + tenantDomain);
|
||||
tenantAdminService.createTenant(tenantDomain, (DEFAULT_ADMIN_PW+" "+tenantDomain).toCharArray(), null); // use default root dir
|
||||
|
||||
logger.info("Created tenant " + tenantDomain);
|
||||
}
|
||||
@@ -219,18 +227,18 @@ public class MultiTDemoTest extends TestCase
|
||||
{
|
||||
for (final String tenantDomain : tenants)
|
||||
{
|
||||
String tenantAdminName = tenantService.getDomainUser(AuthenticationUtil.getAdminUserName(), tenantDomain);
|
||||
String tenantAdminName = tenantService.getDomainUser(AuthenticationUtil.getAdminUserName(), tenantDomain);
|
||||
|
||||
AuthenticationUtil.runAs(new RunAsWork<Object>()
|
||||
{
|
||||
public Object doWork() throws Exception
|
||||
{
|
||||
createUser(TEST_USER1, tenantDomain, TEST_USER1+" "+tenantDomain);
|
||||
createUser(TEST_USER2, tenantDomain, TEST_USER2+" "+tenantDomain);
|
||||
createUser(TEST_USER1, tenantDomain, TEST_USER1+" "+tenantDomain);
|
||||
createUser(TEST_USER2, tenantDomain, TEST_USER2+" "+tenantDomain);
|
||||
|
||||
if (tenantDomain.equals(TEST_TENANT_DOMAIN2))
|
||||
{
|
||||
createUser(TEST_USER3, tenantDomain, TEST_USER3+" "+tenantDomain);
|
||||
createUser(TEST_USER3, tenantDomain, TEST_USER3+" "+tenantDomain);
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -240,7 +248,7 @@ public class MultiTDemoTest extends TestCase
|
||||
|
||||
for (final String tenantDomain : tenants)
|
||||
{
|
||||
String tenantAdminName = tenantService.getDomainUser(AuthenticationUtil.getAdminUserName(), tenantDomain);
|
||||
String tenantAdminName = tenantService.getDomainUser(AuthenticationUtil.getAdminUserName(), tenantDomain);
|
||||
|
||||
AuthenticationUtil.runAs(new RunAsWork<Object>()
|
||||
{
|
||||
@@ -248,17 +256,17 @@ public class MultiTDemoTest extends TestCase
|
||||
{
|
||||
Set<NodeRef> personRefs = personService.getAllPeople();
|
||||
|
||||
for (NodeRef personRef : personRefs)
|
||||
{
|
||||
String userName = (String)nodeService.getProperty(personRef, ContentModel.PROP_USERNAME);
|
||||
assertTrue(userName.endsWith(tenantDomain));
|
||||
|
||||
logger.info("Create users: get all people - found user: "+userName);
|
||||
|
||||
NodeRef homeSpaceRef = (NodeRef)nodeService.getProperty(personRef, ContentModel.PROP_HOMEFOLDER);
|
||||
assertNotNull(homeSpaceRef);
|
||||
}
|
||||
|
||||
for (NodeRef personRef : personRefs)
|
||||
{
|
||||
String userName = (String)nodeService.getProperty(personRef, ContentModel.PROP_USERNAME);
|
||||
assertTrue(userName.endsWith(tenantDomain));
|
||||
|
||||
logger.info("Create users: get all people - found user: "+userName);
|
||||
|
||||
NodeRef homeSpaceRef = (NodeRef)nodeService.getProperty(personRef, ContentModel.PROP_HOMEFOLDER);
|
||||
assertNotNull(homeSpaceRef);
|
||||
}
|
||||
|
||||
if (tenantDomain.equals(TEST_TENANT_DOMAIN2))
|
||||
{
|
||||
assertEquals(5, personRefs.size()); // admin@tenant, guest@tenant, alice@tenant, bob@tenant, eve@tenant
|
||||
@@ -269,7 +277,7 @@ public class MultiTDemoTest extends TestCase
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
}, tenantAdminName);
|
||||
@@ -284,9 +292,9 @@ public class MultiTDemoTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
public void testLoginTenantUsers() throws Throwable
|
||||
public void testLoginTenantUsers() throws Throwable
|
||||
{
|
||||
logger.info("Login tenant users");
|
||||
logger.info("Login tenant users");
|
||||
|
||||
try
|
||||
{
|
||||
@@ -294,13 +302,13 @@ public class MultiTDemoTest extends TestCase
|
||||
|
||||
for (final String tenantDomain : tenants)
|
||||
{
|
||||
loginLogoutUser(tenantService.getDomainUser(TEST_USER1, tenantDomain), TEST_USER1+" "+tenantDomain);
|
||||
loginLogoutUser(tenantService.getDomainUser(TEST_USER1, tenantDomain), TEST_USER1+" "+tenantDomain);
|
||||
|
||||
loginLogoutUser(tenantService.getDomainUser(TEST_USER2, tenantDomain), TEST_USER2+" "+tenantDomain);
|
||||
loginLogoutUser(tenantService.getDomainUser(TEST_USER2, tenantDomain), TEST_USER2+" "+tenantDomain);
|
||||
|
||||
if (tenantDomain.equals(TEST_TENANT_DOMAIN2))
|
||||
{
|
||||
loginLogoutUser(tenantService.getDomainUser(TEST_USER3, tenantDomain), TEST_USER3+" "+tenantDomain);
|
||||
loginLogoutUser(tenantService.getDomainUser(TEST_USER3, tenantDomain), TEST_USER3+" "+tenantDomain);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -313,57 +321,57 @@ public class MultiTDemoTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
public void testLoginTenantGuests() throws Throwable
|
||||
{
|
||||
logger.info("Login tenant guests");
|
||||
|
||||
try
|
||||
{
|
||||
AuthenticationUtil.clearCurrentSecurityContext();
|
||||
|
||||
for (final String tenantDomain : tenants)
|
||||
{
|
||||
loginLogoutUser(tenantService.getDomainUser(DEFAULT_GUEST_UN, tenantDomain), DEFAULT_GUEST_UN);
|
||||
}
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
StringWriter stackTrace = new StringWriter();
|
||||
t.printStackTrace(new PrintWriter(stackTrace));
|
||||
System.err.println(stackTrace.toString());
|
||||
throw t;
|
||||
}
|
||||
}
|
||||
|
||||
public void testLoginTenantAdmin() throws Throwable
|
||||
{
|
||||
logger.info("Login tenant admins");
|
||||
|
||||
try
|
||||
{
|
||||
AuthenticationUtil.clearCurrentSecurityContext();
|
||||
|
||||
for (final String tenantDomain : tenants)
|
||||
{
|
||||
loginLogoutUser(tenantService.getDomainUser(AuthenticationUtil.getAdminUserName(), tenantDomain), DEFAULT_ADMIN_PW+" "+tenantDomain);
|
||||
}
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
StringWriter stackTrace = new StringWriter();
|
||||
t.printStackTrace(new PrintWriter(stackTrace));
|
||||
System.err.println(stackTrace.toString());
|
||||
throw t;
|
||||
}
|
||||
}
|
||||
|
||||
public void testLoginTenantGuests() throws Throwable
|
||||
{
|
||||
logger.info("Login tenant guests");
|
||||
|
||||
try
|
||||
{
|
||||
AuthenticationUtil.clearCurrentSecurityContext();
|
||||
|
||||
for (final String tenantDomain : tenants)
|
||||
{
|
||||
loginLogoutUser(tenantService.getDomainUser(DEFAULT_GUEST_UN, tenantDomain), DEFAULT_GUEST_UN);
|
||||
}
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
StringWriter stackTrace = new StringWriter();
|
||||
t.printStackTrace(new PrintWriter(stackTrace));
|
||||
System.err.println(stackTrace.toString());
|
||||
throw t;
|
||||
}
|
||||
}
|
||||
|
||||
public void testLoginTenantAdmin() throws Throwable
|
||||
{
|
||||
logger.info("Login tenant admins");
|
||||
|
||||
try
|
||||
{
|
||||
AuthenticationUtil.clearCurrentSecurityContext();
|
||||
|
||||
for (final String tenantDomain : tenants)
|
||||
{
|
||||
loginLogoutUser(tenantService.getDomainUser(AuthenticationUtil.getAdminUserName(), tenantDomain), DEFAULT_ADMIN_PW+" "+tenantDomain);
|
||||
}
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
StringWriter stackTrace = new StringWriter();
|
||||
t.printStackTrace(new PrintWriter(stackTrace));
|
||||
System.err.println(stackTrace.toString());
|
||||
throw t;
|
||||
}
|
||||
}
|
||||
|
||||
public void testCreateGroups()
|
||||
{
|
||||
logger.info("Create demo groups");
|
||||
|
||||
for (final String tenantDomain : tenants)
|
||||
{
|
||||
String tenantAdminName = tenantService.getDomainUser(AuthenticationUtil.getAdminUserName(), tenantDomain);
|
||||
String tenantAdminName = tenantService.getDomainUser(AuthenticationUtil.getAdminUserName(), tenantDomain);
|
||||
|
||||
AuthenticationUtil.runAs(new RunAsWork<Object>()
|
||||
{
|
||||
@@ -394,7 +402,7 @@ public class MultiTDemoTest extends TestCase
|
||||
|
||||
for (final String tenantDomain : tenants)
|
||||
{
|
||||
String tenantAdminName = tenantService.getDomainUser(AuthenticationUtil.getAdminUserName(), tenantDomain);
|
||||
String tenantAdminName = tenantService.getDomainUser(AuthenticationUtil.getAdminUserName(), tenantDomain);
|
||||
|
||||
AuthenticationUtil.runAs(new RunAsWork<Object>()
|
||||
{
|
||||
@@ -524,11 +532,11 @@ public class MultiTDemoTest extends TestCase
|
||||
assertTrue("Super admin: ", (nodeService.getStores().size() >= DEFAULT_STORE_COUNT));
|
||||
return null;
|
||||
}
|
||||
}, AuthenticationUtil.getAdminUserName());
|
||||
}, AuthenticationUtil.getAdminUserName());
|
||||
|
||||
for (final String tenantDomain : tenants)
|
||||
{
|
||||
String tenantAdminName = tenantService.getDomainUser(AuthenticationUtil.getAdminUserName(), tenantDomain);
|
||||
String tenantAdminName = tenantService.getDomainUser(AuthenticationUtil.getAdminUserName(), tenantDomain);
|
||||
|
||||
AuthenticationUtil.runAs(new RunAsWork<Object>()
|
||||
{
|
||||
@@ -542,118 +550,171 @@ public class MultiTDemoTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
public void testGetProperty()
|
||||
{
|
||||
logger.info("Test get property");
|
||||
|
||||
for (final String tenantDomain : tenants)
|
||||
{
|
||||
String tenantAdminName = tenantService.getDomainUser(AuthenticationUtil.getAdminUserName(), tenantDomain);
|
||||
|
||||
AuthenticationUtil.runAs(new RunAsWork<Object>()
|
||||
{
|
||||
public Object doWork() throws Exception
|
||||
{
|
||||
NodeRef personNodeRef = createUser(TEST_USER4, tenantDomain, TEST_USER4+" "+tenantDomain);
|
||||
|
||||
// Test nodeRef property
|
||||
NodeRef homeFolderNodeRef = (NodeRef)nodeService.getProperty(personNodeRef, ContentModel.PROP_HOMEFOLDER);
|
||||
assertFalse(homeFolderNodeRef.toString().contains(tenantDomain));
|
||||
|
||||
Map<QName, Serializable> props = (Map<QName, Serializable>)nodeService.getProperties(personNodeRef);
|
||||
assertFalse(props.get(ContentModel.PROP_HOMEFOLDER).toString().contains(tenantDomain));
|
||||
|
||||
// Test "store-identifier" property
|
||||
String storeId = (String)nodeService.getProperty(personNodeRef, ContentModel.PROP_STORE_IDENTIFIER);
|
||||
assertFalse(storeId.contains(tenantDomain));
|
||||
|
||||
assertFalse(props.get(ContentModel.PROP_STORE_IDENTIFIER).toString().contains(tenantDomain));
|
||||
|
||||
return null;
|
||||
}
|
||||
}, tenantAdminName);
|
||||
}
|
||||
}
|
||||
|
||||
public void testCOCIandSearch()
|
||||
{
|
||||
logger.info("Test checkout/checkin and search");
|
||||
|
||||
for (final String tenantDomain : tenants)
|
||||
{
|
||||
final String tenantAdminName = tenantService.getDomainUser(AuthenticationUtil.getAdminUserName(), tenantDomain);
|
||||
|
||||
AuthenticationUtil.runAs(new RunAsWork<Object>()
|
||||
{
|
||||
public Object doWork() throws Exception
|
||||
{
|
||||
// search for local copy of bootstrapped file 'invite_user_email.ftl' (see email_templates.acp)
|
||||
String origText = "You have been invited to";
|
||||
String query = "+PATH:\"/app:company_home/app:dictionary/app:email_templates/*\" +TEXT:\""+origText+"\"";
|
||||
ResultSet resultSet = searchService.query(SPACES_STORE, SearchService.LANGUAGE_LUCENE, query);
|
||||
assertEquals(1, resultSet.length());
|
||||
|
||||
NodeRef nodeRef = resultSet.getNodeRef(0);
|
||||
|
||||
// checkout, update and checkin
|
||||
|
||||
NodeRef workingCopyNodeRef = cociService.checkout(nodeRef);
|
||||
|
||||
ContentWriter writer = contentService.getWriter(workingCopyNodeRef, ContentModel.PROP_CONTENT, true);
|
||||
|
||||
writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);
|
||||
writer.setEncoding("UTF-8");
|
||||
|
||||
String updateText = "Updated by "+tenantAdminName;
|
||||
writer.putContent(updateText);
|
||||
|
||||
cociService.checkin(workingCopyNodeRef, null);
|
||||
|
||||
query = "+PATH:\"/app:company_home/app:dictionary/app:email_templates/*\" +TEXT:\""+origText+"\"";
|
||||
resultSet = searchService.query(SPACES_STORE, SearchService.LANGUAGE_LUCENE, query);
|
||||
assertEquals(0, resultSet.length());
|
||||
|
||||
query = "+PATH:\"/app:company_home/app:dictionary/app:email_templates/*\" +TEXT:\""+updateText+"\"";
|
||||
resultSet = searchService.query(SPACES_STORE, SearchService.LANGUAGE_LUCENE, query);
|
||||
assertEquals(1, resultSet.length());
|
||||
|
||||
return null;
|
||||
}
|
||||
}, tenantAdminName);
|
||||
}
|
||||
}
|
||||
|
||||
public void testDeleteArchiveAndRestoreContent()
|
||||
{
|
||||
logger.info("test delete/archive & restore content");
|
||||
|
||||
for (final String tenantDomain : tenants)
|
||||
{
|
||||
final String tenantUserName = tenantService.getDomainUser(TEST_USER1, tenantDomain);
|
||||
|
||||
AuthenticationUtil.runAs(new RunAsWork<Object>()
|
||||
{
|
||||
public Object doWork() throws Exception
|
||||
{
|
||||
NodeRef homeSpaceRef = getHomeSpaceFolderNode(tenantUserName);
|
||||
NodeRef contentRef = addTextContent(homeSpaceRef, tenantUserName+" tqbfjotld.txt", "The quick brown fox jumps over the lazy dog (tenant " + tenantDomain + ")");
|
||||
|
||||
NodeRef storeArchiveNode = nodeService.getStoreArchiveNode(contentRef.getStoreRef());
|
||||
|
||||
nodeService.deleteNode(contentRef);
|
||||
|
||||
// deduce archived nodeRef
|
||||
StoreRef archiveStoreRef = storeArchiveNode.getStoreRef();
|
||||
NodeRef archivedContentRef = new NodeRef(archiveStoreRef, contentRef.getId());
|
||||
|
||||
nodeService.restoreNode(archivedContentRef, null, null, null);
|
||||
|
||||
return null;
|
||||
}
|
||||
}, tenantUserName);
|
||||
}
|
||||
}
|
||||
|
||||
public void testGetProperty()
|
||||
{
|
||||
logger.info("Test get property");
|
||||
|
||||
for (final String tenantDomain : tenants)
|
||||
{
|
||||
String tenantAdminName = tenantService.getDomainUser(AuthenticationUtil.getAdminUserName(), tenantDomain);
|
||||
|
||||
AuthenticationUtil.runAs(new RunAsWork<Object>()
|
||||
{
|
||||
public Object doWork() throws Exception
|
||||
{
|
||||
NodeRef personNodeRef = createUser(TEST_USER4, tenantDomain, TEST_USER4+" "+tenantDomain);
|
||||
|
||||
// Test nodeRef property
|
||||
NodeRef homeFolderNodeRef = (NodeRef)nodeService.getProperty(personNodeRef, ContentModel.PROP_HOMEFOLDER);
|
||||
assertFalse(homeFolderNodeRef.toString().contains(tenantDomain));
|
||||
|
||||
Map<QName, Serializable> props = (Map<QName, Serializable>)nodeService.getProperties(personNodeRef);
|
||||
assertFalse(props.get(ContentModel.PROP_HOMEFOLDER).toString().contains(tenantDomain));
|
||||
|
||||
// Test "store-identifier" property
|
||||
String storeId = (String)nodeService.getProperty(personNodeRef, ContentModel.PROP_STORE_IDENTIFIER);
|
||||
assertFalse(storeId.contains(tenantDomain));
|
||||
|
||||
assertFalse(props.get(ContentModel.PROP_STORE_IDENTIFIER).toString().contains(tenantDomain));
|
||||
|
||||
return null;
|
||||
}
|
||||
}, tenantAdminName);
|
||||
}
|
||||
}
|
||||
|
||||
public void testCOCIandSearch()
|
||||
{
|
||||
logger.info("Test checkout/checkin and search");
|
||||
|
||||
for (final String tenantDomain : tenants)
|
||||
{
|
||||
final String tenantAdminName = tenantService.getDomainUser(AuthenticationUtil.getAdminUserName(), tenantDomain);
|
||||
|
||||
AuthenticationUtil.runAs(new RunAsWork<Object>()
|
||||
{
|
||||
public Object doWork() throws Exception
|
||||
{
|
||||
// search for local copy of bootstrapped file 'invite_user_email.ftl' (see email_templates.acp)
|
||||
String origText = "You have been invited to";
|
||||
String query = "+PATH:\"/app:company_home/app:dictionary/app:email_templates/*\" +TEXT:\""+origText+"\"";
|
||||
ResultSet resultSet = searchService.query(SPACES_STORE, SearchService.LANGUAGE_LUCENE, query);
|
||||
assertEquals(1, resultSet.length());
|
||||
|
||||
NodeRef nodeRef = resultSet.getNodeRef(0);
|
||||
|
||||
// checkout, update and checkin
|
||||
|
||||
NodeRef workingCopyNodeRef = cociService.checkout(nodeRef);
|
||||
|
||||
ContentWriter writer = contentService.getWriter(workingCopyNodeRef, ContentModel.PROP_CONTENT, true);
|
||||
|
||||
writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);
|
||||
writer.setEncoding("UTF-8");
|
||||
|
||||
String updateText = "Updated by "+tenantAdminName;
|
||||
writer.putContent(updateText);
|
||||
|
||||
cociService.checkin(workingCopyNodeRef, null);
|
||||
|
||||
query = "+PATH:\"/app:company_home/app:dictionary/app:email_templates/*\" +TEXT:\""+origText+"\"";
|
||||
resultSet = searchService.query(SPACES_STORE, SearchService.LANGUAGE_LUCENE, query);
|
||||
assertEquals(0, resultSet.length());
|
||||
|
||||
query = "+PATH:\"/app:company_home/app:dictionary/app:email_templates/*\" +TEXT:\""+updateText+"\"";
|
||||
resultSet = searchService.query(SPACES_STORE, SearchService.LANGUAGE_LUCENE, query);
|
||||
assertEquals(1, resultSet.length());
|
||||
|
||||
return null;
|
||||
}
|
||||
}, tenantAdminName);
|
||||
}
|
||||
}
|
||||
|
||||
public void testDeleteArchiveAndRestoreContent()
|
||||
{
|
||||
logger.info("test delete/archive & restore content");
|
||||
|
||||
for (final String tenantDomain : tenants)
|
||||
{
|
||||
final String tenantUserName = tenantService.getDomainUser(TEST_USER1, tenantDomain);
|
||||
|
||||
AuthenticationUtil.runAs(new RunAsWork<Object>()
|
||||
{
|
||||
public Object doWork() throws Exception
|
||||
{
|
||||
NodeRef homeSpaceRef = getHomeSpaceFolderNode(tenantUserName);
|
||||
NodeRef contentRef = addTextContent(homeSpaceRef, tenantUserName+" tqbfjotld.txt", "The quick brown fox jumps over the lazy dog (tenant " + tenantDomain + ")");
|
||||
|
||||
NodeRef storeArchiveNode = nodeService.getStoreArchiveNode(contentRef.getStoreRef());
|
||||
|
||||
nodeService.deleteNode(contentRef);
|
||||
|
||||
// deduce archived nodeRef
|
||||
StoreRef archiveStoreRef = storeArchiveNode.getStoreRef();
|
||||
NodeRef archivedContentRef = new NodeRef(archiveStoreRef, contentRef.getId());
|
||||
|
||||
nodeService.restoreNode(archivedContentRef, null, null, null);
|
||||
|
||||
return null;
|
||||
}
|
||||
}, tenantUserName);
|
||||
}
|
||||
}
|
||||
|
||||
public void testCustomDynamicModels()
|
||||
{
|
||||
logger.info("test custom/dynamic models");
|
||||
|
||||
final int defaultModelCnt = dictionaryService.getAllModels().size();
|
||||
|
||||
for (final String tenantDomain : tenants)
|
||||
{
|
||||
final String tenantAdminName = tenantService.getDomainUser(AuthenticationUtil.getAdminUserName(), tenantDomain);
|
||||
|
||||
AuthenticationUtil.runAs(new RunAsWork<Object>()
|
||||
{
|
||||
public Object doWork() throws Exception
|
||||
{
|
||||
// no custom models should be deployed yet (note: will fail if re-run)
|
||||
assertEquals(0, repoAdminService.getModels().size());
|
||||
assertEquals(defaultModelCnt, dictionaryService.getAllModels().size());
|
||||
assertNull(dictionaryService.getClass(QName.createQName("{my.new.model}sop")));
|
||||
|
||||
// deploy custom model
|
||||
InputStream modelStream = getClass().getClassLoader().getResourceAsStream("tenant/exampleModel.xml");
|
||||
repoAdminService.deployModel(modelStream, "exampleModel.xml");
|
||||
|
||||
assertEquals(1, repoAdminService.getModels().size());
|
||||
assertEquals(defaultModelCnt+1, dictionaryService.getAllModels().size());
|
||||
|
||||
ClassDefinition myType = dictionaryService.getClass(QName.createQName("{my.new.model}sop"));
|
||||
assertNotNull(myType);
|
||||
assertEquals(QName.createQName("{my.new.model}mynewmodel"),myType.getModel().getName());
|
||||
|
||||
// deactivate model
|
||||
repoAdminService.deactivateModel("exampleModel.xml");
|
||||
|
||||
assertEquals(1, repoAdminService.getModels().size()); // still deployed, although not active
|
||||
assertEquals(defaultModelCnt, dictionaryService.getAllModels().size());
|
||||
assertNull(dictionaryService.getClass(QName.createQName("{my.new.model}sop")));
|
||||
|
||||
// re-activate model
|
||||
repoAdminService.activateModel("exampleModel.xml");
|
||||
|
||||
assertEquals(1, repoAdminService.getModels().size());
|
||||
assertEquals(defaultModelCnt+1, dictionaryService.getAllModels().size());
|
||||
|
||||
myType = dictionaryService.getClass(QName.createQName("{my.new.model}sop"));
|
||||
assertNotNull(myType);
|
||||
assertEquals(QName.createQName("{my.new.model}mynewmodel"),myType.getModel().getName());
|
||||
|
||||
return null;
|
||||
}
|
||||
}, tenantAdminName);
|
||||
}
|
||||
}
|
||||
|
||||
private void createGroup(String shortName, String parentShortName)
|
||||
{
|
||||
// create new Group using authority Service
|
||||
@@ -681,12 +742,12 @@ public class MultiTDemoTest extends TestCase
|
||||
}
|
||||
|
||||
|
||||
private NodeRef createUser(String baseUserName, String tenantDomain, String password)
|
||||
private NodeRef createUser(String baseUserName, String tenantDomain, String password)
|
||||
{
|
||||
String userName = tenantService.getDomainUser(baseUserName, tenantDomain);
|
||||
|
||||
NodeRef personNodeRef = null;
|
||||
|
||||
NodeRef personNodeRef = null;
|
||||
|
||||
if (! this.authenticationService.authenticationExists(userName))
|
||||
{
|
||||
NodeRef baseHomeFolder = getUserHomesNodeRef(SPACES_STORE);
|
||||
@@ -708,24 +769,24 @@ public class MultiTDemoTest extends TestCase
|
||||
personProperties.put(ContentModel.PROP_LASTNAME, baseUserName+"-"+tenantDomain); // add domain suffix here for demo only
|
||||
personProperties.put(ContentModel.PROP_EMAIL, userName);
|
||||
|
||||
personNodeRef = this.personService.createPerson(personProperties);
|
||||
personNodeRef = this.personService.createPerson(personProperties);
|
||||
|
||||
// ensure the user can access their own Person object
|
||||
this.permissionService.setPermission(personNodeRef, userName, permissionService.getAllPermission(), true);
|
||||
this.permissionService.setPermission(personNodeRef, userName, permissionService.getAllPermission(), true);
|
||||
|
||||
NodeRef checkHomeSpaceRef = (NodeRef)nodeService.getProperty(personNodeRef, ContentModel.PROP_HOMEFOLDER);
|
||||
assertNotNull(checkHomeSpaceRef);
|
||||
|
||||
NodeRef checkHomeSpaceRef = (NodeRef)nodeService.getProperty(personNodeRef, ContentModel.PROP_HOMEFOLDER);
|
||||
assertNotNull(checkHomeSpaceRef);
|
||||
|
||||
logger.info("Created user " + userName);
|
||||
}
|
||||
else
|
||||
{
|
||||
personNodeRef = personService.getPerson(userName);
|
||||
|
||||
logger.info("Found existing user " + userName);
|
||||
}
|
||||
|
||||
return personNodeRef;
|
||||
else
|
||||
{
|
||||
personNodeRef = personService.getPerson(userName);
|
||||
|
||||
logger.info("Found existing user " + userName);
|
||||
}
|
||||
|
||||
return personNodeRef;
|
||||
}
|
||||
|
||||
private void loginLogoutUser(String username, String password)
|
||||
@@ -736,8 +797,8 @@ public class MultiTDemoTest extends TestCase
|
||||
// set the user name as stored by the back end
|
||||
username = authenticationService.getCurrentUserName();
|
||||
|
||||
NodeRef personRef = personService.getPerson(username);
|
||||
NodeRef homeSpaceRef = (NodeRef)nodeService.getProperty(personRef, ContentModel.PROP_HOMEFOLDER);
|
||||
NodeRef personRef = personService.getPerson(username);
|
||||
NodeRef homeSpaceRef = (NodeRef)nodeService.getProperty(personRef, ContentModel.PROP_HOMEFOLDER);
|
||||
|
||||
// check that the home space node exists - else user cannot login
|
||||
if (nodeService.exists(homeSpaceRef) == false)
|
||||
@@ -751,21 +812,24 @@ public class MultiTDemoTest extends TestCase
|
||||
|
||||
private NodeRef getUserHomesNodeRef(StoreRef storeRef)
|
||||
{
|
||||
// get the users' home location
|
||||
String path = "/app:company_home/app:user_homes";
|
||||
// get the "User Homes" location
|
||||
return findFolderNodeRef(storeRef, "/app:company_home/app:user_homes");
|
||||
}
|
||||
|
||||
private NodeRef findFolderNodeRef(StoreRef storeRef, String folderXPath)
|
||||
{
|
||||
ResultSet rs = this.searchService.query(storeRef, SearchService.LANGUAGE_XPATH, folderXPath);
|
||||
|
||||
ResultSet rs = this.searchService.query(storeRef, SearchService.LANGUAGE_XPATH, path);
|
||||
|
||||
NodeRef usersHomeNodeRef = null;
|
||||
if (rs.length() == 0)
|
||||
NodeRef folderNodeRef = null;
|
||||
if (rs.length() != 1)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Cannot find user homes location: " + path);
|
||||
throw new AlfrescoRuntimeException("Cannot find folder location: " + folderXPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
usersHomeNodeRef = rs.getNodeRef(0);
|
||||
folderNodeRef = rs.getNodeRef(0);
|
||||
}
|
||||
return usersHomeNodeRef;
|
||||
return folderNodeRef;
|
||||
}
|
||||
|
||||
private NodeRef createFolderNode(NodeRef parentFolderNodeRef, String nameValue)
|
||||
|
@@ -37,23 +37,36 @@ import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||
import org.alfresco.service.cmr.security.AuthenticationService;
|
||||
import org.alfresco.service.cmr.security.AuthorityService;
|
||||
import org.alfresco.util.PropertyCheck;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
|
||||
/**
|
||||
* An interactive console for Tenants.
|
||||
*
|
||||
*/
|
||||
public class TenantInterpreter extends BaseInterpreter
|
||||
public class TenantInterpreter extends BaseInterpreter implements ApplicationContextAware, InitializingBean
|
||||
{
|
||||
private static Log logger = LogFactory.getLog(TenantInterpreter.class);
|
||||
|
||||
// Service dependencies
|
||||
|
||||
private ApplicationContext ctx;
|
||||
|
||||
private TenantAdminService tenantAdminService;
|
||||
protected TenantService tenantService;
|
||||
private AuthenticationService authenticationService;
|
||||
|
||||
private String baseAdminUsername = null; // default for backwards compatibility only - eg. upgrade of existing MT instance (mt-admin-context.xml.sample)
|
||||
|
||||
private String baseAdminUsername = null;
|
||||
|
||||
private static final String WARN_MSG = "system.mt.warn.upgrade_mt_admin_context";
|
||||
|
||||
public void setTenantAdminService(TenantAdminService tenantAdminService)
|
||||
{
|
||||
this.tenantAdminService = tenantAdminService;
|
||||
@@ -83,6 +96,11 @@ public class TenantInterpreter extends BaseInterpreter
|
||||
return AuthenticationUtil.getAdminUserName();
|
||||
}
|
||||
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
|
||||
{
|
||||
this.ctx = applicationContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Main entry point.
|
||||
*/
|
||||
@@ -91,6 +109,22 @@ public class TenantInterpreter extends BaseInterpreter
|
||||
runMain("tenantInterpreter");
|
||||
}
|
||||
|
||||
public void afterPropertiesSet() throws Exception
|
||||
{
|
||||
// for upgrade/backwards compatibility with 3.0.x (mt-admin-context.xml)
|
||||
if (authorityService == null || baseAdminUsername == null)
|
||||
{
|
||||
logger.warn(I18NUtil.getMessage(WARN_MSG));
|
||||
}
|
||||
|
||||
if (authorityService == null)
|
||||
{
|
||||
authorityService = (AuthorityService)ctx.getBean("AuthorityService");
|
||||
}
|
||||
|
||||
PropertyCheck.mandatory(this, "TransactionService", transactionService);
|
||||
PropertyCheck.mandatory(this, "TenantService", tenantService);
|
||||
}
|
||||
|
||||
protected boolean hasAuthority(String username)
|
||||
{
|
||||
|
90
source/test-resources/tenant/exampleModel.xml
Normal file
90
source/test-resources/tenant/exampleModel.xml
Normal file
@@ -0,0 +1,90 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!-- Definition of new Model -->
|
||||
|
||||
<!-- The important part here is the name - Note: the use of the my: namespace
|
||||
which is defined further on in the document -->
|
||||
<model name="my:mynewmodel" xmlns="http://www.alfresco.org/model/dictionary/1.0">
|
||||
|
||||
<!-- Optional meta-data about the model -->
|
||||
<description>Example custom Model</description>
|
||||
<author></author>
|
||||
<version>1.0</version>
|
||||
|
||||
<!-- Imports are required to allow references to definitions in other models -->
|
||||
<imports>
|
||||
<!-- Import Alfresco Dictionary Definitions -->
|
||||
<import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
|
||||
<!-- Import Alfresco Content Domain Model Definitions -->
|
||||
<import uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
|
||||
</imports>
|
||||
|
||||
<!-- Introduction of new namespaces defined by this model -->
|
||||
<!-- NOTE: The following namespace my.new.model should be changed to reflect your own namespace -->
|
||||
<namespaces>
|
||||
<namespace uri="my.new.model" prefix="my"/>
|
||||
</namespaces>
|
||||
|
||||
<types>
|
||||
|
||||
<!-- Definition of new Content Type: Standard Operating Procedure -->
|
||||
<type name="my:sop">
|
||||
<title>Standard Operating Procedure</title>
|
||||
<parent>cm:content</parent>
|
||||
<properties>
|
||||
<property name="my:publishedDate">
|
||||
<type>d:datetime</type>
|
||||
</property>
|
||||
<property name="my:authorisedBy">
|
||||
<type>d:text</type>
|
||||
</property>
|
||||
</properties>
|
||||
<associations>
|
||||
<association name="my:signOff">
|
||||
<source>
|
||||
<mandatory>false</mandatory>
|
||||
<many>false</many>
|
||||
</source>
|
||||
<target>
|
||||
<class>cm:content</class>
|
||||
<mandatory>false</mandatory>
|
||||
<many>false</many>
|
||||
</target>
|
||||
</association>
|
||||
<child-association name="my:processSteps">
|
||||
<source>
|
||||
<mandatory>false</mandatory>
|
||||
<many>false</many>
|
||||
</source>
|
||||
<target>
|
||||
<class>cm:content</class>
|
||||
<mandatory>false</mandatory>
|
||||
<many>true</many>
|
||||
</target>
|
||||
</child-association>
|
||||
</associations>
|
||||
</type>
|
||||
|
||||
</types>
|
||||
|
||||
<aspects>
|
||||
|
||||
<!-- Definition of new Content Aspect: Image Classification -->
|
||||
<aspect name="my:imageClassification">
|
||||
<title>Image Classfication</title>
|
||||
<properties>
|
||||
<property name="my:width">
|
||||
<type>d:int</type>
|
||||
</property>
|
||||
<property name="my:height">
|
||||
<type>d:int</type>
|
||||
</property>
|
||||
<property name="my:resolution">
|
||||
<type>d:int</type>
|
||||
</property>
|
||||
</properties>
|
||||
</aspect>
|
||||
|
||||
</aspects>
|
||||
|
||||
</model>
|
@@ -20,10 +20,9 @@
|
||||
|
||||
<bean id="tenantAdminService" parent="baseMultiTAdminService" />
|
||||
|
||||
<bean id="tenantInterpreter" class="org.alfresco.repo.tenant.TenantInterpreter">
|
||||
<property name="transactionService" ref="transactionComponent"/>
|
||||
<property name="tenantAdminService" ref="tenantAdminService"/>
|
||||
<property name="tenantService" ref="tenantService"/>
|
||||
<bean id="tenantInterpreter" class="org.alfresco.repo.tenant.TenantInterpreter" parent="interpreterBase">
|
||||
<property name="tenantAdminService" ref="tenantAdminService"/>
|
||||
<property name="tenantService" ref="tenantService"/>
|
||||
<property name="authenticationService" ref="AuthenticationService"/>
|
||||
</bean>
|
||||
|
||||
|
Reference in New Issue
Block a user