mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merge DEV/V3.4-BUG-FIX to HEAD (28799-28800,28864,28875,28879,28916,28941,28956,28970,28993)
28993: HomeFolderProviderSynchronizer: Provider used for LDAP to continue to use username as home folder name directly under .../app:company_home/app:user_homes Property spaces.user_homes.regex.pattern now set to "" rather than "^(..)" which would have given a single level hash structure. 28970: Merge DEV/ALAN/HOME_FOLDER to DEV/V3.4-BUG-FIX 28947: - Introduction of version 2 HomeFolderProvider2 and re-factor of version 1 so that the code used to create the folders is now in the HomeFolderManager. - Re-factor homeFolderProviderSynchronizer to handle HomeFolderProvider2. - Addition of AbstractHomeFolderProvider.V2Adaptor to allow external providers that extend AbstractHomeFolderPathProvider to be handled by homeFolderProviderSynchronizer. 28860: Minor change to class comment and removed unused imports 28858: ALF-4727 Hashed home folder provider added and used by default for LDAP sync users - based on Romain Guinot work. ALF-7797 HomeFolderProviderSynchronizer added to move existing users (normally those added by LDAP sync) into location preferred by home folder provider. - HomeFolderProviderSynchronizer bug fixes - tenant accounts supported for first time - addition of a phase to create parent folders before moving home folder to avoid a race condition - check for conditions that would result in FileExistExceptions as we don't want a the transaction to be discarded as this results in retries. - HomeFolderProviderSynchronizerTest integration test including tenant services - HomeFolderManager now sets the HOME_FOLDER_PROVIDER if it uses a default when HOME_FOLDER_PROVIDER is not set. - AbstractHomeFolderProvider clears cache when path reset as it will be invalid. - UIDBasedHomeFolderProvider.createNewParent creates its own mutable List as the one passed in may not be mutable. 28580: Save code changes - added comments to do with LDAP syn overriding the HFP value and related to this added a global property to keep empty parent folders. 28347: HomeFolderProviderSynchronizer - issue to do with new run of sync having created a user via UI that has a home folder as one of the parent folders. - issue to do with catching exception when creating temporary folder - transaction is gone - give up if error in any phase 28298: Addition of HomeFolderPathProvider (based on Romain's work) and addition of HomeFolderProviderSynchronizer. 28956: Merged DEV to V3.4-BUG-FIX ALF-9428: Multitenancy users not preserved after upgrade from 3.2.2.7 to 3.4.2 - Provide correct RunAs context in FixUserQNamesPatch batching. 28941: ALF-9361 : CLONE -sync Flat IMAP client with Alfresco is slow and inaccurate 28916: ALF-9421 The AlfrescoJavaScript action now includes company home in the JavaScript scope. 28879: Fixed ALF-9296: Alfresco Dashboard: Impossible to approve/reject task from My Tasks dashlet on My Alfresco 28875: Fixed ALF-6329: SPANISH - Share, translation on Transfer Target configuration 28864: Message: ALF-9430: RuntimeExec waitForCompletion logic is obscure - Only a single flag 'isCompleted' - Set flag in try-finally - Added notify() However, the wait() code doesn't, in practice, get called because the waitForCompletion is synchronized with the run() and is called a while after the reading thread is triggered. So the logic is less obscure and safer for the finally. 28800: File for rev 28799: ALF-9240 28799: Merged DEV to V3.4-BUG-FIX 28797: ALF-9240: Issue with adding an aspect with large multivalued list Added unit test to stress, but could not reproduce git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@28995 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2011 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
@@ -19,17 +19,12 @@
|
||||
package org.alfresco.repo.security.person;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.tenant.TenantService;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
|
||||
import org.alfresco.util.PropertyCheck;
|
||||
import org.springframework.beans.factory.BeanNameAware;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
@@ -38,6 +33,9 @@ import org.springframework.beans.factory.InitializingBean;
|
||||
* Common support for creating home folders This is hooked into node creation events from Person type objects via the
|
||||
* homeFolderManager. Provider must all be wired up to the homeFolderManager.
|
||||
*
|
||||
* @deprecated
|
||||
* Depreciated since 4.0. {@link AbstractHomeFolderProvider2} should now be used.
|
||||
*
|
||||
* @author Andy Hind
|
||||
*/
|
||||
public abstract class AbstractHomeFolderProvider implements HomeFolderProvider, BeanNameAware, InitializingBean
|
||||
@@ -58,40 +56,34 @@ public abstract class AbstractHomeFolderProvider implements HomeFolderProvider,
|
||||
private StoreRef storeRef;
|
||||
|
||||
/**
|
||||
* Service registry to get hold of public services (so taht actions are audited)
|
||||
* Service registry to get hold of public services (so that actions are audited)
|
||||
*/
|
||||
private ServiceRegistry serviceRegistry;
|
||||
|
||||
/**
|
||||
* Tenant service - required for MT-enabled environment, else optional
|
||||
*/
|
||||
private TenantService tenantService;
|
||||
|
||||
/**
|
||||
* The path to a folder
|
||||
*/
|
||||
private String path;
|
||||
|
||||
/**
|
||||
* Cache the result of the path look up.
|
||||
*/
|
||||
private Map<String, NodeRef> pathNodeRefs; // MT-aware
|
||||
|
||||
/**
|
||||
* The owner to set on creation of a home folder (if unset this will be the uid).
|
||||
*/
|
||||
private String ownerOnCreate;
|
||||
|
||||
private PermissionsManager onCreatePermissionsManager;
|
||||
/**
|
||||
* PermissionsManager used on creating the home folder
|
||||
*/
|
||||
private PermissionsManager onCreatePermissionsManager;
|
||||
|
||||
private PermissionsManager onReferencePermissionsManager;
|
||||
/**
|
||||
* PermissionsManager used on referencing the home folder
|
||||
*/
|
||||
private PermissionsManager onReferencePermissionsManager;
|
||||
|
||||
public AbstractHomeFolderProvider()
|
||||
{
|
||||
super();
|
||||
|
||||
pathNodeRefs = new ConcurrentHashMap<String, NodeRef>();
|
||||
}
|
||||
/**
|
||||
* Adaptor for this instance to be a HomeFolderProvider2
|
||||
*/
|
||||
private V2Adaptor v2Adaptor = new V2Adaptor(this);
|
||||
|
||||
/**
|
||||
* Register with the homeFolderManagewr
|
||||
@@ -99,13 +91,9 @@ public abstract class AbstractHomeFolderProvider implements HomeFolderProvider,
|
||||
public void afterPropertiesSet() throws Exception
|
||||
{
|
||||
PropertyCheck.mandatory(this, "homeFolderManager", homeFolderManager);
|
||||
homeFolderManager.addProvider(this);
|
||||
homeFolderManager.addProvider(v2Adaptor);
|
||||
}
|
||||
|
||||
// === //
|
||||
// IOC //
|
||||
// === //
|
||||
|
||||
/**
|
||||
* Get the home folder manager.
|
||||
*/
|
||||
@@ -116,7 +104,6 @@ public abstract class AbstractHomeFolderProvider implements HomeFolderProvider,
|
||||
|
||||
/**
|
||||
* Set the home folder manager.
|
||||
*
|
||||
* @param homeFolderManager
|
||||
*/
|
||||
public void setHomeFolderManager(HomeFolderManager homeFolderManager)
|
||||
@@ -127,6 +114,7 @@ public abstract class AbstractHomeFolderProvider implements HomeFolderProvider,
|
||||
/**
|
||||
* Get the provider name
|
||||
*/
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
@@ -135,6 +123,7 @@ public abstract class AbstractHomeFolderProvider implements HomeFolderProvider,
|
||||
/**
|
||||
* The provider name is taken from the bean name
|
||||
*/
|
||||
@Override
|
||||
public void setBeanName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
@@ -153,7 +142,14 @@ public abstract class AbstractHomeFolderProvider implements HomeFolderProvider,
|
||||
*/
|
||||
public void setPath(String path)
|
||||
{
|
||||
boolean reset = this.path != null;
|
||||
this.path = path;
|
||||
|
||||
// If a reset need to clear caches
|
||||
if (reset)
|
||||
{
|
||||
homeFolderManager.clearCaches(v2Adaptor);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -201,7 +197,7 @@ public abstract class AbstractHomeFolderProvider implements HomeFolderProvider,
|
||||
*/
|
||||
public void setTenantService(TenantService tenantService)
|
||||
{
|
||||
this.tenantService = tenantService;
|
||||
// keep class signature but no longer use value
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -212,10 +208,26 @@ public abstract class AbstractHomeFolderProvider implements HomeFolderProvider,
|
||||
this.onCreatePermissionsManager = onCreatePermissionsManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the PermissionsManager used on creating the home folder
|
||||
*/
|
||||
public PermissionsManager getOnCreatePermissionsManager()
|
||||
{
|
||||
return onCreatePermissionsManager;
|
||||
}
|
||||
|
||||
public void setOnReferencePermissionsManager(PermissionsManager onReferencePermissionsManager)
|
||||
{
|
||||
this.onReferencePermissionsManager = onReferencePermissionsManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the PermissionsManager used on referencing the home folder
|
||||
*/
|
||||
public PermissionsManager getOnReferencePermissionsManager()
|
||||
{
|
||||
return onReferencePermissionsManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the authority to use as the owner of all home folder nodes.
|
||||
@@ -225,34 +237,28 @@ public abstract class AbstractHomeFolderProvider implements HomeFolderProvider,
|
||||
this.ownerOnCreate = ownerOnCreate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the authority to use as the owner of all home folder nodes.
|
||||
*/
|
||||
public String getOwnerOnCreate()
|
||||
{
|
||||
return ownerOnCreate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cache path to node resolution
|
||||
*/
|
||||
protected NodeRef getPathNodeRef()
|
||||
{
|
||||
String tenantDomain = (tenantService != null ? tenantService.getCurrentUserDomain() : TenantService.DEFAULT_DOMAIN);
|
||||
|
||||
NodeRef pathNodeRef = pathNodeRefs.get(tenantDomain);
|
||||
if (pathNodeRef == null)
|
||||
{
|
||||
pathNodeRef = resolvePath(path);
|
||||
pathNodeRefs.put(tenantDomain, pathNodeRef);
|
||||
}
|
||||
return pathNodeRef;
|
||||
return homeFolderManager.getRootPathNodeRef(v2Adaptor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility metho to resolve paths to nodes.
|
||||
* Utility method to resolve paths to nodes.
|
||||
*/
|
||||
protected NodeRef resolvePath(String pathToResolve)
|
||||
{
|
||||
List<NodeRef> refs = serviceRegistry.getSearchService().selectNodes(serviceRegistry.getNodeService().getRootNode(storeRef), pathToResolve, null,
|
||||
serviceRegistry.getNamespaceService(), false);
|
||||
if (refs.size() != 1)
|
||||
{
|
||||
throw new IllegalStateException("Non-unique path: found : " + pathToResolve + " " + refs.size());
|
||||
}
|
||||
return refs.get(0);
|
||||
return homeFolderManager.resolvePath(v2Adaptor, pathToResolve);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -260,69 +266,98 @@ public abstract class AbstractHomeFolderProvider implements HomeFolderProvider,
|
||||
*/
|
||||
public void onCreateNode(ChildAssociationRef childAssocRef)
|
||||
{
|
||||
AuthenticationUtil.RunAsWork<NodeRef> action = new OnCreateNode(childAssocRef);
|
||||
AuthenticationUtil.runAs(action, AuthenticationUtil.getSystemUserName());
|
||||
homeFolderManager.homeFolderCreateAndSetPermissions(v2Adaptor, childAssocRef.getChildRef());
|
||||
}
|
||||
|
||||
/**
|
||||
* Abstract implementation to find/create the approriate home space.
|
||||
* Abstract implementation to find/create the appropriate home space.
|
||||
*/
|
||||
protected abstract HomeSpaceNodeRef getHomeFolder(NodeRef person);
|
||||
|
||||
|
||||
/**
|
||||
* Helper class to encapsulate the createion settinhg permissions etc
|
||||
*
|
||||
* @author Andy Hind
|
||||
* Get adaptor for this instance to be a HomeFolderProvider2
|
||||
*/
|
||||
private class OnCreateNode implements AuthenticationUtil.RunAsWork<NodeRef>
|
||||
protected V2Adaptor getV2Adaptor()
|
||||
{
|
||||
ChildAssociationRef childAssocRef;
|
||||
|
||||
OnCreateNode(ChildAssociationRef childAssocRef)
|
||||
return v2Adaptor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adaptor to the HomeFolderProvider2 interface.
|
||||
*/
|
||||
public class V2Adaptor implements HomeFolderProvider2
|
||||
{
|
||||
AbstractHomeFolderProvider abstractHomeFolderProvider;
|
||||
|
||||
public V2Adaptor(AbstractHomeFolderProvider abstractHomeFolderProvider)
|
||||
{
|
||||
this.childAssocRef = childAssocRef;
|
||||
this.abstractHomeFolderProvider = abstractHomeFolderProvider;
|
||||
abstractHomeFolderProvider.v2Adaptor = this;
|
||||
}
|
||||
|
||||
public NodeRef doWork() throws Exception
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return abstractHomeFolderProvider.getName();
|
||||
}
|
||||
|
||||
// Find person
|
||||
NodeRef personNodeRef = childAssocRef.getChildRef();
|
||||
// Get home folder
|
||||
HomeSpaceNodeRef homeFolder = getHomeFolder(personNodeRef);
|
||||
// If it exists
|
||||
if (homeFolder.getNodeRef() != null)
|
||||
{
|
||||
// Get uid and keep
|
||||
String uid = DefaultTypeConverter.INSTANCE.convert(String.class, serviceRegistry.getNodeService().getProperty(personNodeRef, ContentModel.PROP_USERNAME));
|
||||
@Override
|
||||
public String getStoreUrl()
|
||||
{
|
||||
return abstractHomeFolderProvider.getStoreRef().toString();
|
||||
}
|
||||
|
||||
// If created or found then set (other wise it was already set correctly)
|
||||
if (homeFolder.getStatus() != HomeSpaceNodeRef.Status.VALID)
|
||||
{
|
||||
serviceRegistry.getNodeService().setProperty(personNodeRef, ContentModel.PROP_HOMEFOLDER, homeFolder.getNodeRef());
|
||||
}
|
||||
@Override
|
||||
public String getRootPath()
|
||||
{
|
||||
return abstractHomeFolderProvider.getPath();
|
||||
}
|
||||
|
||||
String ownerToSet = ownerOnCreate == null ? uid : ownerOnCreate;
|
||||
// If created..
|
||||
if (homeFolder.getStatus() == HomeSpaceNodeRef.Status.CREATED)
|
||||
{
|
||||
if (onCreatePermissionsManager != null)
|
||||
{
|
||||
onCreatePermissionsManager.setPermissions(homeFolder.getNodeRef(), ownerToSet, uid);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (onReferencePermissionsManager != null)
|
||||
{
|
||||
onReferencePermissionsManager.setPermissions(homeFolder.getNodeRef(), ownerToSet, uid);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return homeFolder.getNodeRef();
|
||||
@Override
|
||||
public List<String> getHomeFolderPath(NodeRef person)
|
||||
{
|
||||
return (abstractHomeFolderProvider instanceof UIDBasedHomeFolderProvider)
|
||||
? ((UIDBasedHomeFolderProvider)abstractHomeFolderProvider).getHomeFolderPath(person)
|
||||
: null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NodeRef getTemplateNodeRef()
|
||||
{
|
||||
return (abstractHomeFolderProvider instanceof UIDBasedHomeFolderProvider)
|
||||
? ((UIDBasedHomeFolderProvider)abstractHomeFolderProvider).getTemplateNodeRef()
|
||||
: null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOwner()
|
||||
{
|
||||
return abstractHomeFolderProvider.getOwnerOnCreate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PermissionsManager getOnCreatePermissionsManager()
|
||||
{
|
||||
return abstractHomeFolderProvider.getOnReferencePermissionsManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PermissionsManager getOnReferencePermissionsManager()
|
||||
{
|
||||
return abstractHomeFolderProvider.getOnReferencePermissionsManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HomeSpaceNodeRef getHomeFolder(NodeRef person)
|
||||
{
|
||||
return abstractHomeFolderProvider.getHomeFolder(person);
|
||||
}
|
||||
|
||||
// The old way to create the home folder, so must still call it in case
|
||||
// the method is overridden
|
||||
public void onCreateNode(ChildAssociationRef childAssocRef)
|
||||
{
|
||||
abstractHomeFolderProvider.onCreateNode(childAssocRef);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user