mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
29057: ALF-9491: Bitrock 7.2.2 29063: ALF-8766 Concatenated strings in EN webclient file 29066: Merge DEV/DEV/BELARUS/V3.4-BUG-FIX-2011_07_13 to DEV/V3.4-BUG-FIX 29010: ALF-7396: Japanese- Untranslated 29072: HomeFolderProvider work - Changes as a result of Dave Ward's comments (HomeFolderManager not fully done as there is a spring issue with using NodeService, FileFolderService, fileFolderService, SearchService or searchService) 29074: ALF-7637 - Share displays incorrect folder contents after copy-on-outbound rule against working copy 29075: ALF-8406 - Configuring the datalist display for sub-types does not work 29082: ALF-6847 translation: "Collega" should be reverted to English: "Link" as per term list. 29087: ALF-5717 property names for wcm quickstart website-model had an invalid format or did not end in .description or .title 29093: Merge V3.3 to DEV/V3.4-BUG-FIX (28596) 28596: Remove dependency between subsystems and all the object factories in the parent context! - Do not allow eager initialization when looking up parent post processors - Removes circular dependencies from sysAdmin subsystem 29094: Merge HEAD to DEV/V3.4-BUG-FIX () 28892: Broke circular references between NodeService beans, NodeIndexer, Lucene and back to NodeService. - NodeIndexer is now bootstrapped to pull out reference to the Lucene beans 29100: Revert Merge V3.3 to DEV/V3.4-BUG-FIX (28596) Caused RepositoryStartupTest to fail 28596: Remove dependency between subsystems and all the object factories in the parent context! - Do not allow eager initialization when looking up parent post processors - Removes circular dependencies from sysAdmin subsystem 29102: ALF-9048: Make apply_amps.bat work from its installed location 29103: ALF-8746: Restored Japanese choice format translations 29104: Merged V3.3 to V3.4-BUG-FIX (Reinstated this revision as it is required) 28596: Remove dependency between subsystems and all the object factories in the parent context! - Do not allow eager initialization when looking up parent post processors - Removes circular dependencies from sysAdmin subsystem 29105: Use org.springframework.aop.target.LazyInitTargetSource in the NodeService public proxy to break a circular dependency 29106: Make PersonService interact with HomeFolderManager via a lazy proxy to prevent another circular dependency - Simple HomeFolderManager interface created - Implementation class renamed to PortableHomeFolderManager - Removed TODOs from authentication-services-context.xml 29107: Forgot to remove the serviceRegistry dependency from homeFolderManager 29108: ALF-9529: Installer memory consumption and startup time improvements - Bitrock discover the for loop! 29109: ALF-9530: Postgres installed as Windows service should run as a postgres user, not System - Fix from Bitrock 29118: Fix for ALF-6737 - It's impossible to view any version of the wiki page if it was renamed with native characters 29119: Fix for ALF-5787 - strings extracted for L10N in Web form creation help text 29124: ALF-9530: Follow up fix from Bitrock 29126: Fix for ALF-8344 - Incorrect message is displayed while recover deleted file 29127: Fix for ALF-9445 - French - Share, translation on Transfer Target configuration 29129: ALF-9476: Make FTPS work on IBM JDK 29133: Fix failing DictionaryRestApiTest 29136: Fix build issues from 29104: - run as system when creating home folders (PortableHomeFolderManager) - re-factored onCreateNode out of PortableHomeFolderManager into PersonServiceImpl - re-factored property PortableHomeFolderManager.enableHomeFolderCreationAsPeopleAreCreated to PersonServiceImpl.homeFolderCreationEager 29137: Fix for ALF-8831 - Internal error occurs in My Tasks Webscripts component 29138: Fix for ALF-8765 - Layout is displaced if translated string occupies more than 1 line 29140: Fix for ALF-8668 - Deleting author account causes Failed to load the forum posts 29142: - PortableHomeFolderManager: Moved code to run as System into PersonServiceImpl so that one must have a valid authority to call the publick makeHomeFolder method. The authority should already be valid if called via PersonServiceImpl. - Removed unused policyBehaviourFilter property from PersonServiceImpl 29146: ALF-8701: partially translated string in html-upload.get_fr 29147: ALF-8727: DE - changes to Root Category 29149: ALF-8731: DE - Wiki changes (space before full stop) 29152: ALF-9503: Add space after colon in strings in file wdr-messages.properties 29153: Fixed ALF-7899: association.ftl does not render when showTargetLink=true in workflow 29165: ALF-8749: on submit action properties in wcn-workflow-messages.properties 29166: Fix for ALF-6220 - Language pack - .ftl localization 29167: ALF-9550 - Typos in new section of webclient.properties 29169: Fix for ALF-7844 - W3C: Impossible to activate 'Choose from popular tags in this site' link by Enter/Space keys 29170: Merge V3.4-TEAM to V3.4-BUG-FIX (3.4.4) 27471: Fix for ALF-8150 - check for visibility before applying focus to element for IE. 29171: Fixes: ALF-8922, removes date formatting from API (now returns ISO8601) and instead formats it on the client, using L10N strings. 29172: Fix for ALF-2023 - Repository Action - Copy item to specific space doesn not include content. The option to 'deep copy' is now exposed in the UI for Run Action and Rules in Explorer. 29173: Fix for ALF-1446 - Sorting of inline descendants is not observed 29175: ALF-241 - The item is not coppied via 'Paste All' in Shelf when 'Details' page is opened 29177: Fix for ALF-9520 - confusing sample config. Reordered sample config file as suggested. 29178: Fixed ALF-6400: GERMAN: Explorer mouse over hints for TinyMCE are not localized Fixed ALF-5766: ALL translations errors in Explorer - Calendars are not localizable for content based on webforms 29202: Merge DEV/BELARUS/V3.4-BUG-FIX-2011_04_12 to V3.4-BUG-FIX (3.4.4) 27836: ALF-8524: CLONE - Sharepoint doesn't work with HTTPS Changes in url links required for HTTPS support. 29203: Restored removal of postgresCreateSymLinksLinuxBuildingFromWindows tag (32 bit Linux) from revision 26582 29211: Fix for ALF-1051 - It is impossible to find link by tag from link details page 29212: Fix for ALF-5301 - TinyMCE is replacing carriage return with white spaces 29250: Latest L10N update for all languages (DE, ES, FR, IT, JA) from Gloria (based on r29172) 29253: L10N Update from Gloria 29270: Fixed ALF-516: Unable to add content/delete tables in webform content when using FireFox 29271: Update from Gloria 29272: Merged BRANCHES/DEV/BELARUS/V3.4-BUG-FIX-2011_07_13 to BRANCHES/DEV/V3.4-BUG-FIX: (with minor modification) 29223: ALF-7619: When document A has an association with a document B editing A's properties fails if user has no permission to edit B 29274: ALF-9517 Incorrect behaviour of versions on Copy action. Version is 0.1 rather than 1.0 29283: Resolve ALF-8273: Valid datetime value cannot be parsed by CMIS AtomPub interface 29284: Update from Gloria 29286: ALF-9596: Merged PATCHES/V3.4.1 to V3.4-BUG-FIX 28150: ALF-8607: Detailed debug logging when out of sync transaction detected by index checker / tracker 28177: ALF-8607: Corrections to debug logging in AbstractReindexComponent 28213: ALF-8607: Further corrections to debug logging in AbstractReindexComponent - Log attributes from indexes, rather than nodeService properties 28341: ALF-8607: Stop index checker from 'lying' - isTxnPresentInIndex() call must be made in a new transaction in order to get a database view in sync with the current indexes 28352: ALF-8607: Revisit transaction delineation. Nested transaction only required in checkTxnsImpl() 28403: ALF-8607: Merged PATCHES/V3.3.4 to PATCHES/V3.4.1 27823: ALF-7237: Index tracker needs to perform a cascade reindex on updated nodes in order to cope with node moves 28406: ALF-8607: Improvement to FTS fix. Prevent FTS from restoring documents that have been deleted! 28412: ALF-8607: Invalidate properties and aspects as well as parent assocs when stale cache entry dected during transaction tracking 28427: ALF-8607: Prevent NPE with bad NodeRef in ADMLuceneIndexerImpl.createDocumentsImpl() 28705: ALF-8607: Validate transaction IDs when fetching parent associations - Compare the cached child node transaction ID against one fetched from the DB - Stops us from pairing up the cached node for an older or newer transaction with the wrong parent associations 28707: ALF-8607: Merged PATCHES/V3.3.4 to PATCHES/V3.4.1 28588: ALF-7237: Prevent FTS from ever wiping out a document that still exists and ignore duplicates 28708: ALF-8607: Make FTS capable of recovering from cache concurrency issues by using a RetryingTransactionHelper and better exception handling. - Also avoids skipping the entire batch when the reindexing of a particular document fails. 28710: ALF-8607: Corrected transaction delineation 28753: ALF-8607: Prevent errors caused by AbstractReindexComponent diagnostics trying to parse FTSREF document IDs as NodeRefs (which they aren't!) 28755: ALF-8607: When 'failing over' during FTS indexing, don't bother adding a FTS status document so we don't get stuck in a loop with a problematic document 28815: ALF-8607: Do two way validation of cached / fetched nodes and their parent associations to avoid skew - Should resolve problem of tracking moves to the archive store and moves in general 28862: ALF-8607: Lucene indexers now support 'read through' behaviour for FTS and Index tracking batches - Small discrete read only transactions used to read each reindexed node from the database / cache - Avoids cache 'drift' and 'skew' after long running indexing transactions 28863: ALF-8607: Missing file 28869: ALF-8607: isTxnPresentInIndex() needs to 'read through' so index tracker and checker don't pollute the cache 28872: ALF-8607: Optimization to prevent constant writing to AVM indexes whilst 'ticking over'. 28950: ALF-8607: Improved logic in AbstractReindexComponent.isTxnPresentInIndex() so that we can reliably cope with multi-store transactions (e.g. archive store + spaces store) - Due to FTS, the txn ID may have 'drifted in' to one store but not the other so we must validate all stores in the txn 29098: ALF-8607: Use getNodeRefStatus as a cache validation point for reindexing 'read through' transactions - Guarantees that FTS reindexed node will see correct state (well if we had consistent read behaviour it would!) - Removes stale nodeRef -> ID mappings (e.g. when original node moved to archive store and substituted with deleted node) - Inexplicably seems to produce a ~30x speedup in performance tests on MySQL! Appears to remove a contention point. More investigation required to find out what! 29287: ALF-9598: Merged PATCHES/V3.4.1 to V3.4-BUG-FIX 28653: ALF-9189: More efficient usage of IndexReaders to avoid huge memory churn with large indexes - A single reading thread could block out all other reading threads because a write lock is obtained whilst constructing a set of FilterIndexReaderByStringId readers and all deletions across all indexes have to be evaluated. We now cache a FilterIndexReaderByStringId for each 'layer' of the index so that we get some reuse. We also defer evaluation of deletions to AFTER the write lock is returned and in some cases never have to evaluate the deletions at all. - When merging deletions we now make use of a cached index reader for locating the documents, and only resort to a new reader if deletions have to be performed. Hopefully this will mean that the reader for the largest indexes, containing the least recently used stuff, will get left alone most of the time. 28690: ALF-9189: Corrections to previous fix - Forgot to remove non-lazy reader initialization - Fixed NPE - Reinstated correct looping behaviour - each processed delta must be considered as one of the indexes to search for the next processed delta 29099: ALF-9189: Avoid having to allocate a byte array full of number ones for all occurrences of a term to 'fake' norms. - Severe Lucene memory hog during FTS 29262: ALF-9189: Fixed memory leak during index tracking / reindexing and further memory leak regression - Fixed up Lucene refcounting again - remember to propagate through decrefs on ReferenceCounting readers - Refined ALF-9189 fix to guarantee mainreader clean up - Remember to flush the delta during reindexing / tracking - Some extra trace diagnostics to help 29288: ALF-9600: Merged PATCHES/V3.4.1 to V3.4-BUG_FIX 28876: ALF-9041: Merged HEAD to PATCHES/V3.4.1 28850: Latest SpringSurf libs - Fix to SSO connector passing empty username 29289: ALF-8241: assemble-tomcat populates endorsed directory with xalan.jar and serializer.jar and Bitrock installer installs these too 29291: Merged DEV/SWIFT to V3.4-BUG-FIX (3.4.4) - already merged to HEAD as part of a larger merge 26104: RM: Remove incomplete and unnecessary unit test 29302: Fix for ALF-8885 - Unable to paste item due to system error:null git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@29325 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
943 lines
36 KiB
Java
943 lines
36 KiB
Java
/*
|
|
* Copyright (C) 2005-2011 Alfresco Software Limited.
|
|
*
|
|
* This file is part of Alfresco
|
|
*
|
|
* Alfresco is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Lesser General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* Alfresco 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 Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
package org.alfresco.repo.security.person;
|
|
|
|
import static org.junit.Assert.assertEquals;
|
|
import static org.junit.Assert.assertFalse;
|
|
import static org.junit.Assert.assertNotNull;
|
|
import static org.junit.Assert.assertNull;
|
|
import static org.junit.Assert.assertTrue;
|
|
|
|
import java.util.Arrays;
|
|
import java.util.HashSet;
|
|
import java.util.List;
|
|
import java.util.Locale;
|
|
import java.util.Properties;
|
|
import java.util.Set;
|
|
|
|
import javax.transaction.Status;
|
|
import javax.transaction.UserTransaction;
|
|
|
|
import org.alfresco.model.ContentModel;
|
|
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.TenantAdminService;
|
|
import org.alfresco.repo.tenant.TenantService;
|
|
import org.alfresco.service.ServiceRegistry;
|
|
import org.alfresco.service.cmr.model.FileFolderService;
|
|
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
|
import org.alfresco.service.cmr.repository.ContentData;
|
|
import org.alfresco.service.cmr.repository.ContentService;
|
|
import org.alfresco.service.cmr.repository.ContentWriter;
|
|
import org.alfresco.service.cmr.repository.NodeRef;
|
|
import org.alfresco.service.cmr.repository.NodeService;
|
|
import org.alfresco.service.cmr.repository.Path;
|
|
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
|
|
import org.alfresco.service.cmr.security.AuthorityService;
|
|
import org.alfresco.service.cmr.security.PersonService;
|
|
import org.alfresco.service.namespace.NamespaceService;
|
|
import org.alfresco.service.namespace.QName;
|
|
import org.alfresco.service.transaction.TransactionService;
|
|
import org.alfresco.util.ApplicationContextHelper;
|
|
import org.alfresco.util.PropertyMap;
|
|
import org.junit.After;
|
|
import org.junit.Before;
|
|
import org.junit.BeforeClass;
|
|
import org.junit.ComparisonFailure;
|
|
import org.junit.Test;
|
|
import org.springframework.context.ApplicationContext;
|
|
|
|
/**
|
|
* Integration test for HomeFolderProviderSynchronizer.
|
|
*
|
|
* @author Alan Davis
|
|
*/
|
|
public class HomeFolderProviderSynchronizerTest
|
|
{
|
|
private static final QName PROP_PARENT_PATH = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "parentPath");
|
|
|
|
private static ApplicationContext applicationContext;
|
|
private static ServiceRegistry serviceRegistry;
|
|
private static TransactionService transactionService;
|
|
private static FileFolderService fileFolderService;
|
|
private static PersonServiceImpl personService;
|
|
private static NodeService nodeService;
|
|
private static ContentService contentService;
|
|
private static AuthorityService authorityService;
|
|
private static TenantAdminService tenantAdminService;
|
|
private static TenantService tenantService;
|
|
private static PortableHomeFolderManager homeFolderManager;
|
|
private static RegexHomeFolderProvider largeHomeFolderProvider;
|
|
private static String largeHomeFolderProviderName;
|
|
private static RegexHomeFolderProvider testHomeFolderProvider;
|
|
private static String testHomeFolderProviderName;
|
|
private static String storeUrl;
|
|
private static String origRootPath;
|
|
private static NodeRef rootNodeRef;
|
|
private static HomeFolderProviderSynchronizer homeFolderProviderSynchronizer;
|
|
private static boolean firstTest = true;
|
|
|
|
private UserTransaction trans;
|
|
|
|
@BeforeClass
|
|
public static void classSetup() throws Exception
|
|
{
|
|
applicationContext = ApplicationContextHelper.getApplicationContext();
|
|
serviceRegistry = (ServiceRegistry) applicationContext.getBean("ServiceRegistry");
|
|
transactionService = (TransactionService) applicationContext.getBean("transactionService");
|
|
fileFolderService = (FileFolderService) applicationContext.getBean("fileFolderService");
|
|
personService = (PersonServiceImpl) applicationContext.getBean("personService");
|
|
nodeService = (NodeService) applicationContext.getBean("nodeService");
|
|
contentService = (ContentService) applicationContext.getBean("contentService");
|
|
authorityService = (AuthorityService) applicationContext.getBean("authorityService");
|
|
tenantAdminService = (TenantAdminService) applicationContext.getBean("tenantAdminService");
|
|
tenantService = (TenantService) applicationContext.getBean("tenantService");
|
|
homeFolderManager = (PortableHomeFolderManager) applicationContext.getBean("homeFolderManager");
|
|
largeHomeFolderProvider = (RegexHomeFolderProvider) applicationContext.getBean("largeHomeFolderProvider");
|
|
largeHomeFolderProviderName = largeHomeFolderProvider.getName();
|
|
storeUrl = largeHomeFolderProvider.getStoreUrl();
|
|
origRootPath = largeHomeFolderProvider.getRootPath();
|
|
|
|
personService.setCreateMissingPeople(true);
|
|
|
|
// Create test home folder provider that gets its path from a property and the username
|
|
testHomeFolderProvider = new RegexHomeFolderProvider()
|
|
{
|
|
@Override
|
|
public List<String> getHomeFolderPath(NodeRef person)
|
|
{
|
|
String parentPath = DefaultTypeConverter.INSTANCE.convert(String.class, nodeService.getProperty(person, PROP_PARENT_PATH));
|
|
String propPath = ((parentPath == null || parentPath.length() == 0) ? "" : parentPath+'/')+
|
|
homeFolderManager.getPersonProperty(person, ContentModel.PROP_USERNAME);
|
|
return Arrays.asList(propPath.split("/"));
|
|
}
|
|
};
|
|
testHomeFolderProvider.setPropertyName(ContentModel.PROP_USERNAME.getLocalName());
|
|
testHomeFolderProvider.setPattern("(..)");
|
|
testHomeFolderProvider.setBeanName("testHomeFolderProvider");
|
|
testHomeFolderProvider.setHomeFolderManager(homeFolderManager);
|
|
testHomeFolderProvider.setRootPath(origRootPath);
|
|
testHomeFolderProvider.setStoreUrl(storeUrl);
|
|
testHomeFolderProvider.setOnCreatePermissionsManager((PermissionsManager)applicationContext.getBean("defaultOnCreatePermissionsManager"));
|
|
testHomeFolderProvider.setOnCreatePermissionsManager((PermissionsManager)applicationContext.getBean("defaultOnCreatePermissionsManager"));
|
|
testHomeFolderProvider.setOnReferencePermissionsManager((PermissionsManager)applicationContext.getBean("defaultOnReferencePermissionsManager"));
|
|
testHomeFolderProviderName = testHomeFolderProvider.getName();
|
|
homeFolderManager.addProvider(testHomeFolderProvider);
|
|
|
|
homeFolderProviderSynchronizer = new HomeFolderProviderSynchronizer(
|
|
transactionService, authorityService,
|
|
personService, fileFolderService, nodeService,
|
|
homeFolderManager, tenantAdminService);
|
|
}
|
|
|
|
@Before
|
|
public void setUp() throws Exception
|
|
{
|
|
homeFolderProviderSynchronizer.setEnabled("true");
|
|
homeFolderProviderSynchronizer.setOverrideHomeFolderProviderName(null);
|
|
homeFolderProviderSynchronizer.setKeepEmptyParents("false");
|
|
|
|
largeHomeFolderProvider.setPattern("^(..)");
|
|
testHomeFolderProvider.setRootPath(origRootPath);
|
|
largeHomeFolderProvider.setRootPath(origRootPath);
|
|
|
|
// Just in case we killed a test last time - tidy up
|
|
if (firstTest)
|
|
{
|
|
firstTest = false;
|
|
|
|
AuthenticationUtil.setRunAsUserSystem();
|
|
trans = transactionService.getUserTransaction();
|
|
trans.begin();
|
|
rootNodeRef = homeFolderManager.getRootPathNodeRef(largeHomeFolderProvider);
|
|
trans.commit();
|
|
trans = null;
|
|
|
|
tearDown();
|
|
}
|
|
|
|
AuthenticationUtil.setRunAsUserSystem();
|
|
trans = transactionService.getUserTransaction();
|
|
trans.begin();
|
|
// System.out.println(NodeStoreInspector.dumpNode(nodeService, rootNodeRef));
|
|
}
|
|
|
|
@After
|
|
public void tearDown() throws Exception
|
|
{
|
|
if (trans != null)
|
|
{
|
|
try
|
|
{
|
|
trans.commit();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
if ((trans.getStatus() == Status.STATUS_ACTIVE) ||
|
|
(trans.getStatus() == Status.STATUS_MARKED_ROLLBACK))
|
|
{
|
|
trans.rollback();
|
|
trans = null;
|
|
}
|
|
}
|
|
}
|
|
|
|
trans = transactionService.getUserTransaction();
|
|
trans.begin();
|
|
Set<NodeRef> adminGuestUserHomeFolders = deleteNonAdminGuestUsers();
|
|
deleteNonAdminGuestFolders(adminGuestUserHomeFolders);
|
|
deleteAllTenants();
|
|
trans.commit();
|
|
trans = null;
|
|
AuthenticationUtil.clearCurrentSecurityContext();
|
|
}
|
|
|
|
private Set<NodeRef> deleteNonAdminGuestUsers()
|
|
{
|
|
final Set<NodeRef> adminGuestUserHomeFolders = new HashSet<NodeRef>();
|
|
for (final NodeRef nodeRef : personService.getAllPeople())
|
|
{
|
|
final String username = DefaultTypeConverter.INSTANCE.convert(String.class,
|
|
nodeService.getProperty(nodeRef, ContentModel.PROP_USERNAME));
|
|
final String domainUsername = tenantService.getBaseNameUser(username);
|
|
String tenantDomain = tenantService.getUserDomain(username);
|
|
String systemUser = tenantAdminService.getDomainUser(AuthenticationUtil.getSystemUserName(), tenantDomain);
|
|
boolean disabled = !TenantService.DEFAULT_DOMAIN.equals(tenantDomain) &&
|
|
!tenantAdminService.isEnabledTenant(tenantDomain);
|
|
try
|
|
{
|
|
if (disabled)
|
|
{
|
|
tenantAdminService.enableTenant(tenantDomain);
|
|
}
|
|
AuthenticationUtil.runAs(new RunAsWork<Object>()
|
|
{
|
|
public Object doWork() throws Exception
|
|
{
|
|
deleteUser(adminGuestUserHomeFolders, nodeRef, username, domainUsername);
|
|
return null;
|
|
}
|
|
}, systemUser);
|
|
}
|
|
finally
|
|
{
|
|
if (disabled)
|
|
{
|
|
tenantAdminService.disableTenant(tenantDomain);
|
|
}
|
|
}
|
|
}
|
|
return adminGuestUserHomeFolders;
|
|
}
|
|
|
|
// Delete users other than admin and guest. The home folders of
|
|
// admin and guest are added to internalUserHomeFolders.
|
|
private void deleteUser(final Set<NodeRef> adminGuestUserHomeFolders,
|
|
NodeRef person, String username, String domainUsername)
|
|
{
|
|
if (!domainUsername.equals("admin") && !domainUsername.equals("guest"))
|
|
{
|
|
personService.deletePerson(person);
|
|
System.out.println("deleted user "+username);
|
|
}
|
|
else
|
|
{
|
|
NodeRef homeFolder = DefaultTypeConverter.INSTANCE.convert(
|
|
NodeRef.class, nodeService.getProperty(person,
|
|
ContentModel.PROP_HOMEFOLDER));
|
|
adminGuestUserHomeFolders.add(homeFolder);
|
|
}
|
|
}
|
|
|
|
private void deleteNonAdminGuestFolders(final Set<NodeRef> adminGuestUserHomeFolders)
|
|
{
|
|
// Delete folders from under the home folder root path in case they have been left over
|
|
// from another test. Admin and Guest home folder should not be under here, but lets
|
|
// double check.
|
|
for (ChildAssociationRef childAssocs: nodeService.getChildAssocs(rootNodeRef))
|
|
{
|
|
NodeRef nodeRef = childAssocs.getChildRef();
|
|
if (!adminGuestUserHomeFolders.contains(nodeRef))
|
|
{
|
|
System.out.println("TearDown remove '"+childAssocs.getQName().getLocalName()+
|
|
"' from under the home folder root.");
|
|
nodeService.deleteNode(nodeRef);
|
|
}
|
|
}
|
|
}
|
|
|
|
private NodeRef createUser(String parentPath, String username) throws Exception
|
|
{
|
|
return createUser(TenantService.DEFAULT_DOMAIN, parentPath, username);
|
|
}
|
|
|
|
private NodeRef createUser(String parentPath,
|
|
String username, String homeFolderProviderName, boolean createHomeDirectory) throws Exception
|
|
{
|
|
return createUser(TenantService.DEFAULT_DOMAIN, parentPath, username,
|
|
homeFolderProviderName, createHomeDirectory);
|
|
}
|
|
|
|
private NodeRef createUser(String tenantDomain, String parentPath, String username) throws Exception
|
|
{
|
|
return createUser(tenantDomain, parentPath, username, largeHomeFolderProviderName, true);
|
|
}
|
|
|
|
private NodeRef createUser(String tenantDomain, final String parentPath,
|
|
final String username, final String homeFolderProviderName,
|
|
final boolean createHomeDirectory) throws Exception
|
|
{
|
|
final String domainUsername = tenantService.getDomainUser(username, tenantDomain);
|
|
String systemUser = tenantAdminService.getDomainUser(AuthenticationUtil.getSystemUserName(), tenantDomain);
|
|
return AuthenticationUtil.runAs(new RunAsWork<NodeRef>()
|
|
{
|
|
public NodeRef doWork() throws Exception
|
|
{
|
|
String firstName = username;
|
|
String lastName = "Smith";
|
|
String emailAddress = String.format("%s.%s@xyz.com", firstName,
|
|
lastName);
|
|
PropertyMap properties = new PropertyMap();
|
|
properties.put(ContentModel.PROP_USERNAME, domainUsername);
|
|
properties.put(ContentModel.PROP_FIRSTNAME, firstName);
|
|
properties.put(ContentModel.PROP_LASTNAME, lastName);
|
|
properties.put(ContentModel.PROP_EMAIL, emailAddress);
|
|
properties.put(ContentModel.PROP_HOME_FOLDER_PROVIDER, testHomeFolderProviderName);
|
|
properties.put(PROP_PARENT_PATH, parentPath);
|
|
personService.setHomeFolderCreationEager(createHomeDirectory);
|
|
NodeRef person = personService.createPerson(properties);
|
|
assertNotNull("The person nodeRef for "+domainUsername+" should have been created", person);
|
|
NodeRef homeFolder = DefaultTypeConverter.INSTANCE.convert(
|
|
NodeRef.class, nodeService.getProperty(person,
|
|
ContentModel.PROP_HOMEFOLDER));
|
|
if (createHomeDirectory)
|
|
{
|
|
assertNotNull("The homeFolder for "+domainUsername+" should have been created", homeFolder);
|
|
}
|
|
else
|
|
{
|
|
assertNull("The homeFolder for "+domainUsername+" should NOT have been created", homeFolder);
|
|
}
|
|
|
|
if (!testHomeFolderProviderName.equals(homeFolderProviderName))
|
|
{
|
|
if (homeFolderProviderName == null)
|
|
{
|
|
nodeService.removeProperty(person, ContentModel.PROP_HOME_FOLDER_PROVIDER);
|
|
}
|
|
else
|
|
{
|
|
nodeService.setProperty(person, ContentModel.PROP_HOME_FOLDER_PROVIDER,
|
|
homeFolderProviderName);
|
|
}
|
|
}
|
|
return person;
|
|
}
|
|
}, systemUser);
|
|
}
|
|
|
|
private NodeRef createFolder(String path) throws Exception
|
|
{
|
|
NodeRef parent = rootNodeRef;
|
|
if (path.length() > 0)
|
|
{
|
|
StringBuilder currentPath = new StringBuilder();
|
|
for (String pathElement: path.split("/"))
|
|
{
|
|
if (currentPath.length() > 0)
|
|
{
|
|
currentPath.append("/");
|
|
}
|
|
currentPath.append(pathElement);
|
|
NodeRef nodeRef = nodeService.getChildByName(parent,
|
|
ContentModel.ASSOC_CONTAINS, pathElement);
|
|
if (nodeRef == null)
|
|
{
|
|
parent = fileFolderService.create(parent, pathElement,
|
|
ContentModel.TYPE_FOLDER).getNodeRef();
|
|
}
|
|
else
|
|
{
|
|
assertTrue("Expected "+currentPath+" to be a folder",
|
|
fileFolderService.getFileInfo(nodeRef).isFolder());
|
|
parent = nodeRef;
|
|
}
|
|
}
|
|
}
|
|
return parent;
|
|
}
|
|
|
|
private NodeRef createContent(String parentPath, String name) throws Exception
|
|
{
|
|
NodeRef parent = createFolder(parentPath);
|
|
PropertyMap propertyMap = new PropertyMap();
|
|
propertyMap.put(ContentModel.PROP_CONTENT, new ContentData(null, "text/plain",
|
|
0L, "UTF-16", Locale.ENGLISH));
|
|
propertyMap.put(ContentModel.PROP_NAME, name);
|
|
NodeRef content = nodeService.createNode(
|
|
parent,
|
|
ContentModel.ASSOC_CONTAINS,
|
|
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, name),
|
|
ContentModel.TYPE_CONTENT,
|
|
propertyMap).getChildRef();
|
|
ContentWriter writer = contentService.getWriter(content, ContentModel.TYPE_CONTENT, true);
|
|
writer.putContent("The cat sat on the mat.");
|
|
|
|
// System.out.println(NodeStoreInspector.dumpNode(nodeService, rootNodeRef));
|
|
return content;
|
|
}
|
|
|
|
private String toPath(NodeRef root, NodeRef homeFolder)
|
|
{
|
|
if (root == null || homeFolder == null)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
Path rootPath = nodeService.getPath(root);
|
|
Path homeFolderPath = nodeService.getPath(homeFolder);
|
|
int rootSize = rootPath.size();
|
|
int homeFolderSize = homeFolderPath.size();
|
|
if (rootSize >= homeFolderSize)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
StringBuilder sb = new StringBuilder("");
|
|
|
|
// Check homeFolder is under root
|
|
for (int i=0; i < rootSize; i++)
|
|
{
|
|
if (!rootPath.get(i).equals(homeFolderPath.get(i)))
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
|
|
// Build up path of sub folders
|
|
for (int i = rootSize; i < homeFolderSize; i++)
|
|
{
|
|
Path.Element element = homeFolderPath.get(i);
|
|
if (!(element instanceof Path.ChildAssocElement))
|
|
{
|
|
return null;
|
|
}
|
|
QName folderQName = ((Path.ChildAssocElement) element).getRef().getQName();
|
|
if (sb.length() > 0)
|
|
{
|
|
sb.append('/');
|
|
}
|
|
sb.append(folderQName.getLocalName());
|
|
}
|
|
return sb.toString();
|
|
}
|
|
|
|
private void createTenant(final String tenantDomain)
|
|
{
|
|
AuthenticationUtil.runAs(new RunAsWork<Object>()
|
|
{
|
|
public Object doWork() throws Exception
|
|
{
|
|
if (!tenantAdminService.existsTenant(tenantDomain))
|
|
{
|
|
tenantAdminService.createTenant(tenantDomain,
|
|
("admin "+tenantDomain).toCharArray(), null);
|
|
}
|
|
return null;
|
|
}
|
|
}, AuthenticationUtil.getSystemUserName());
|
|
}
|
|
|
|
private void deleteAllTenants() throws Exception
|
|
{
|
|
List<Tenant> tenants = tenantAdminService.getAllTenants();
|
|
for (Tenant tenant : tenants)
|
|
{
|
|
deleteTenant(tenant.getTenantDomain());
|
|
}
|
|
|
|
}
|
|
|
|
// DbNodeServiceImpl does not support deleteStore() at the moment,
|
|
// even though it supports createStore(), so just disable them for now.
|
|
private void deleteTenant(final String tenantDomain) throws Exception
|
|
{
|
|
AuthenticationUtil.runAs(new RunAsWork<Object>()
|
|
{
|
|
public Object doWork() throws Exception
|
|
{
|
|
if (tenantAdminService.existsTenant(tenantDomain))
|
|
{
|
|
// Can't delete so disable
|
|
// tenantAdminService.deleteTenant(tenantDomain);
|
|
|
|
if (tenantAdminService.isEnabledTenant(tenantDomain))
|
|
{
|
|
tenantAdminService.disableTenant(tenantDomain);
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
}, AuthenticationUtil.getSystemUserName());
|
|
}
|
|
|
|
private void assertHomeFolderLocation(String username, String expectedPath) throws Exception
|
|
{
|
|
assertHomeFolderLocation(TenantService.DEFAULT_DOMAIN, username, expectedPath);
|
|
}
|
|
|
|
private void assertHomeFolderLocation(String tenantDomain, final String username,
|
|
final String expectedPath) throws Exception
|
|
{
|
|
try
|
|
{
|
|
final String domainUsername = tenantService.getDomainUser(username, tenantDomain);
|
|
String systemUser = tenantAdminService.getDomainUser(AuthenticationUtil.getSystemUserName(), tenantDomain);
|
|
AuthenticationUtil.runAs(new RunAsWork<Object>()
|
|
{
|
|
public NodeRef doWork() throws Exception
|
|
{
|
|
NodeRef person = personService.getPerson(domainUsername, false);
|
|
NodeRef homeFolder = DefaultTypeConverter.INSTANCE.convert(NodeRef.class,
|
|
nodeService.getProperty(person, ContentModel.PROP_HOMEFOLDER));
|
|
assertNotNull("User: "+domainUsername+" home folder should exist", homeFolder);
|
|
|
|
NodeRef rootPath = homeFolderManager.getRootPathNodeRef(largeHomeFolderProvider);
|
|
String actualPath = toPath(rootPath, homeFolder);
|
|
assertEquals("User: "+domainUsername+" home folder location", expectedPath, actualPath);
|
|
return null;
|
|
}
|
|
}, systemUser);
|
|
}
|
|
catch (RuntimeException e)
|
|
{
|
|
final Throwable cause = e.getCause();
|
|
if (cause instanceof ComparisonFailure || cause instanceof AssertionError)
|
|
{
|
|
throw (ComparisonFailure)cause;
|
|
}
|
|
else
|
|
{
|
|
throw e;
|
|
}
|
|
}
|
|
}
|
|
|
|
private boolean exists(String path) throws Exception
|
|
{
|
|
NodeRef parent = rootNodeRef;
|
|
boolean exists = true;
|
|
for (String pathElement: path.split("/"))
|
|
{
|
|
NodeRef nodeRef = nodeService.getChildByName(parent,
|
|
ContentModel.ASSOC_CONTAINS, pathElement);
|
|
if (nodeRef == null)
|
|
{
|
|
exists = false;
|
|
break;
|
|
}
|
|
else
|
|
{
|
|
parent = nodeRef;
|
|
}
|
|
}
|
|
return exists;
|
|
}
|
|
|
|
private void moveUserHomeFolders() throws Exception
|
|
{
|
|
trans.commit();
|
|
trans = null;
|
|
|
|
homeFolderProviderSynchronizer.onBootstrap(null);
|
|
|
|
trans = transactionService.getUserTransaction();
|
|
trans.begin();
|
|
}
|
|
|
|
@Test
|
|
public void testCorrectLocation() throws Exception
|
|
{
|
|
createUser("te", "tess");
|
|
|
|
moveUserHomeFolders();
|
|
|
|
assertHomeFolderLocation("tess", "te/tess");
|
|
}
|
|
|
|
@Test
|
|
public void testCreateParentFolder() throws Exception
|
|
{
|
|
createUser("", "fred");
|
|
|
|
moveUserHomeFolders();
|
|
|
|
assertHomeFolderLocation("fred", "fr/fred");
|
|
}
|
|
|
|
@Test
|
|
public void testNotEnabled() throws Exception
|
|
{
|
|
createUser("", "fred");
|
|
homeFolderProviderSynchronizer.setEnabled("false");
|
|
|
|
moveUserHomeFolders();
|
|
|
|
// If performed, the home folder will have been moved to fr/fred
|
|
// We must force the creation of the home folder as it will not
|
|
// have been done
|
|
personService.getPerson("fred");
|
|
assertHomeFolderLocation("fred", "fred");
|
|
}
|
|
|
|
@Test
|
|
public void testHomeFolderNotYetCreated() throws Exception
|
|
{
|
|
NodeRef person = createUser("", "fred", largeHomeFolderProviderName, false);
|
|
|
|
moveUserHomeFolders();
|
|
|
|
NodeRef homeFolder = DefaultTypeConverter.INSTANCE.convert(NodeRef.class,
|
|
nodeService.getProperty(person, ContentModel.PROP_HOMEFOLDER));
|
|
assertNull("The homeFolder should NOT have been created", homeFolder);
|
|
|
|
person = personService.getPerson("fred");
|
|
homeFolder = DefaultTypeConverter.INSTANCE.convert(NodeRef.class,
|
|
nodeService.getProperty(person, ContentModel.PROP_HOMEFOLDER));
|
|
assertNotNull("The homeFolder should have been created", homeFolder);
|
|
}
|
|
|
|
@Test
|
|
public void testCreateMultipleParentFolders() throws Exception
|
|
{
|
|
largeHomeFolderProvider.setPattern("^(.?)(.?)(.?)(.?)(.?)");
|
|
|
|
createUser("", "fred");
|
|
createUser("", "peter");
|
|
createUser("", "tess");
|
|
|
|
moveUserHomeFolders();
|
|
|
|
assertHomeFolderLocation("fred", "f/r/e/d/fred");
|
|
assertHomeFolderLocation("peter", "p/e/t/e/r/peter");
|
|
assertHomeFolderLocation("tess", "t/e/s/s/tess");
|
|
}
|
|
|
|
@Test
|
|
public void testMoveToRoot() throws Exception
|
|
{
|
|
// i.e. there are no parent folders after the sync
|
|
largeHomeFolderProvider.setPattern("");
|
|
|
|
createUser("fr", "fred");
|
|
|
|
moveUserHomeFolders();
|
|
|
|
assertHomeFolderLocation("fred", "fred");
|
|
}
|
|
|
|
@Test
|
|
public void testRemoveEmptyParents() throws Exception
|
|
{
|
|
createUser("a/bb/ccc", "peter");
|
|
|
|
moveUserHomeFolders();
|
|
|
|
assertHomeFolderLocation("peter", "pe/peter");
|
|
assertFalse("Expected the empty parent 'a' to have been removed.", exists("a"));
|
|
}
|
|
|
|
@Test
|
|
public void testKeepEmptyParents() throws Exception
|
|
{
|
|
createUser("a/bb/ccc", "peter");
|
|
homeFolderProviderSynchronizer.setKeepEmptyParents("true");
|
|
|
|
moveUserHomeFolders();
|
|
|
|
assertHomeFolderLocation("peter", "pe/peter");
|
|
assertTrue("Expected the empty parent 'a/bb/ccc' to still exist as global " +
|
|
"property was set.", exists("a/bb/ccc"));
|
|
}
|
|
|
|
@Test
|
|
public void testKeepNonEmptyParents() throws Exception
|
|
{
|
|
createUser("a/bb/ccc", "peter");
|
|
createFolder("a/bb/ddd");
|
|
|
|
moveUserHomeFolders();
|
|
|
|
assertHomeFolderLocation("peter", "pe/peter");
|
|
assertFalse("Expected the empty parent 'a/bb/ccc' to have been removed.", exists("a/bb/ccc"));
|
|
assertTrue("Expected the non empty parent 'a/bb' to have been kept.", exists("a/bb/ddd"));
|
|
}
|
|
|
|
@Test
|
|
public void testPathAlreadyInUseByFolder() throws Exception
|
|
{
|
|
createUser("", "fred");
|
|
createFolder("fr");
|
|
|
|
moveUserHomeFolders();
|
|
|
|
assertHomeFolderLocation("fred", "fr/fred");
|
|
}
|
|
|
|
@Test
|
|
public void testPathAlreadyInUseByContent() throws Exception
|
|
{
|
|
createUser("", "fred");
|
|
createContent("", "fr");
|
|
|
|
moveUserHomeFolders();
|
|
|
|
assertHomeFolderLocation("fred", "fred"); // unchanged
|
|
assertFalse("Did not expect there to be a folder in the prefered location.", exists("fr/fred"));
|
|
assertTrue("Expected the content to still exist.", exists("fr"));
|
|
}
|
|
|
|
@Test
|
|
public void testPathInUseByUser() throws Exception
|
|
{
|
|
// i.e. test clash between home folder names and parent folders
|
|
// which requires a temporary folder to be created
|
|
createUser("", "fr");
|
|
createUser("", "fred");
|
|
createUser("", "peter");
|
|
createUser("", "pe");
|
|
|
|
moveUserHomeFolders();
|
|
|
|
assertHomeFolderLocation("fr", "fr/fr");
|
|
assertHomeFolderLocation("fred", "fr/fred");
|
|
assertHomeFolderLocation("peter", "pe/peter");
|
|
assertHomeFolderLocation("pe", "pe/pe");
|
|
|
|
assertFalse("The Temporary1 folder should have been removed", exists("Temporary1"));
|
|
}
|
|
|
|
@Test
|
|
public void testUseFirstAvailableTemporaryFolder() throws Exception
|
|
{
|
|
createUser("", "fr");
|
|
createUser("", "fred");
|
|
createFolder("Temporary1");
|
|
createFolder("Temporary2");
|
|
createFolder("Temporary3");
|
|
|
|
// Don't delete the temporary folder
|
|
homeFolderProviderSynchronizer.setKeepEmptyParents("true");
|
|
|
|
moveUserHomeFolders();
|
|
|
|
assertTrue("The existing Temporary1 folder should still exist", exists("Temporary1"));
|
|
assertTrue("The existing Temporary2 folder should still exist", exists("Temporary2"));
|
|
assertTrue("The existing Temporary3 folder should still exist", exists("Temporary3"));
|
|
assertTrue("The existing Temporary4 folder should still exist", exists("Temporary4"));
|
|
}
|
|
|
|
@Test
|
|
public void testException() throws Exception
|
|
{
|
|
// Force the need for a temporary folder
|
|
createUser("", "fr");
|
|
createUser("", "fred");
|
|
|
|
// Use up all possible temporary folder names
|
|
for (int i=1; i<=100; i++)
|
|
{
|
|
createFolder("Temporary"+i);
|
|
}
|
|
|
|
moveUserHomeFolders();
|
|
|
|
// normally would have changed to fr/fred if there had not been an exception
|
|
assertHomeFolderLocation("fred", "fred");
|
|
}
|
|
|
|
@Test
|
|
public void testMultipleRoots() throws Exception
|
|
{
|
|
createFolder("root");
|
|
String rootPath = origRootPath + "/cm:root";
|
|
testHomeFolderProvider.setRootPath(rootPath);
|
|
|
|
createUser("a/b/c", "tess", testHomeFolderProviderName, true);
|
|
createUser("a/b/c", "fred", largeHomeFolderProviderName, true);
|
|
|
|
moveUserHomeFolders();
|
|
|
|
assertHomeFolderLocation("fred", "fr/fred");
|
|
assertHomeFolderLocation("tess", "root/a/b/c/tess");
|
|
}
|
|
|
|
@Test
|
|
public void testPathNotUnderRoot() throws Exception
|
|
{
|
|
createUser("a/b/c", "fred");
|
|
|
|
createFolder("root");
|
|
String rootPath = origRootPath + "/cm:root";
|
|
largeHomeFolderProvider.setRootPath(rootPath);
|
|
|
|
assertHomeFolderLocation("fred", null);
|
|
|
|
moveUserHomeFolders();
|
|
|
|
assertHomeFolderLocation("fred", "fr/fred");
|
|
}
|
|
|
|
@Test
|
|
public void testMultipleUsers() throws Exception
|
|
{
|
|
// Tried 2000 users and the HomeFolderProviderSynchronizer.onBootstrap(null)
|
|
// took 33 seconds. The setup and tear down takes a while too.
|
|
|
|
// Use a value larger than the batch size of 20 and log every 100.
|
|
int userCount = 110;
|
|
for (int i=1; i<=userCount; i++)
|
|
{
|
|
String name = "f"+i+"red";
|
|
createUser("", name);
|
|
}
|
|
|
|
moveUserHomeFolders();
|
|
|
|
for (int i=1; i<=userCount; i++)
|
|
{
|
|
String name = "f"+i+"red";
|
|
assertHomeFolderLocation(name, name.substring(0,2)+'/'+name);
|
|
}
|
|
}
|
|
|
|
@Test
|
|
public void testOverrideProvider() throws Exception
|
|
{
|
|
NodeRef person = createUser("a/b/c", "fred");
|
|
moveUserHomeFolders();
|
|
assertHomeFolderLocation("fred", "fr/fred");
|
|
|
|
homeFolderProviderSynchronizer.setOverrideHomeFolderProviderName(
|
|
testHomeFolderProviderName);
|
|
moveUserHomeFolders();
|
|
|
|
assertHomeFolderLocation("fred", "a/b/c/fred");
|
|
String providerName = (String) nodeService.getProperty(person,
|
|
ContentModel.PROP_HOME_FOLDER_PROVIDER);
|
|
assertEquals(testHomeFolderProviderName , providerName);
|
|
}
|
|
|
|
@Test
|
|
public void testNoOriginalProvider() throws Exception
|
|
{
|
|
createUser("a/b/c", "fred", null, true);
|
|
homeFolderProviderSynchronizer.setOverrideHomeFolderProviderName(
|
|
largeHomeFolderProviderName);
|
|
|
|
moveUserHomeFolders();
|
|
|
|
assertHomeFolderLocation("fred", "fr/fred"); // unchanged
|
|
assertTrue("Expected the empty parent 'a/b/c' to still exist as original " +
|
|
"root was unknown, because the original home folder provider was not set.",
|
|
exists("a/b/c"));
|
|
}
|
|
|
|
@Test
|
|
@SuppressWarnings("deprecation")
|
|
public void testVersion1HomeFolderProvider() throws Exception
|
|
{
|
|
// Should just log a message to say it can't do anything
|
|
final String name = "v1Provider";
|
|
HomeFolderProvider v1Provider = new HomeFolderProvider()
|
|
{
|
|
@Override
|
|
public void onCreateNode(ChildAssociationRef childAssocRef)
|
|
{
|
|
}
|
|
|
|
@Override
|
|
public String getName()
|
|
{
|
|
return name;
|
|
}
|
|
};
|
|
homeFolderManager.addProvider(v1Provider);
|
|
|
|
createUser("a/b/c", "fred");
|
|
|
|
homeFolderProviderSynchronizer.setOverrideHomeFolderProviderName(name);
|
|
moveUserHomeFolders();
|
|
|
|
assertHomeFolderLocation("fred", "a/b/c/fred");
|
|
}
|
|
|
|
@Test
|
|
@SuppressWarnings("deprecation")
|
|
public void testExtendsAbstractHomeFolderProvider() throws Exception
|
|
{
|
|
// Should work through the V2Adaptor
|
|
final String name = "v1Provider";
|
|
AbstractHomeFolderProvider v1Provider = new UIDBasedHomeFolderProvider();
|
|
v1Provider.setBeanName(name);
|
|
v1Provider.setHomeFolderManager(homeFolderManager);
|
|
v1Provider.setOnCreatePermissionsManager(largeHomeFolderProvider.getOnCreatePermissionsManager());
|
|
v1Provider.setOnReferencePermissionsManager(largeHomeFolderProvider.getOnReferencePermissionsManager());
|
|
v1Provider.setOwnerOnCreate(largeHomeFolderProvider.getOwner());
|
|
v1Provider.setPath(largeHomeFolderProvider.getRootPath());
|
|
v1Provider.setServiceRegistry(serviceRegistry);
|
|
v1Provider.setStoreUrl(largeHomeFolderProvider.getStoreUrl());
|
|
v1Provider.setTenantService(tenantService);
|
|
v1Provider.afterPropertiesSet();
|
|
|
|
createUser("a/b/c", "fred");
|
|
|
|
homeFolderProviderSynchronizer.setOverrideHomeFolderProviderName(name);
|
|
moveUserHomeFolders();
|
|
|
|
assertHomeFolderLocation("fred", "fred");
|
|
}
|
|
|
|
@Test
|
|
public void testTenantService() throws Exception
|
|
{
|
|
// Only test if running multi-tenant
|
|
if (tenantAdminService.isEnabled())
|
|
{
|
|
long time = System.currentTimeMillis();
|
|
final String tenant1 = time+".tenant1";
|
|
final String tenant2 = time+".tenant2";
|
|
|
|
createTenant(tenant1);
|
|
createTenant(tenant2);
|
|
|
|
createUser("", "fred");
|
|
createUser(tenant1, "", "fred");
|
|
createUser(tenant2, "", "fred");
|
|
|
|
moveUserHomeFolders();
|
|
|
|
assertHomeFolderLocation("fred", "fr/fred");
|
|
assertHomeFolderLocation(tenant1, "fred", "fr/"+tenantService.getDomainUser("fred", tenant1));
|
|
assertHomeFolderLocation(tenant2, "fred", "fr/"+tenantService.getDomainUser("fred", tenant2));
|
|
}
|
|
}
|
|
}
|