mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged HEAD-BUG-FIX (5.0/Cloud) to HEAD (5.0/Cloud)
76911: Merged PLATFORM1 (5.0/Cloud) to HEAD-BUG-FIX (5.0/Cloud) 66893: Clean up use of deprecated 'UserRegistrySynchronizer.synchronize' and general code clean up git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@77754 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -125,9 +125,6 @@ public class ChainingUserRegistrySynchronizer extends AbstractLifecycleBean
|
||||
/** The label under which the status is stored for each zone. */
|
||||
private static final String LAST_ERROR_ATTRIBUTE = "LAST_ERROR";
|
||||
|
||||
/** The label under which the status is stored for each zone. */
|
||||
private static final String LAST_HOST_ATTRIBUTE = "LAST_HOST";
|
||||
|
||||
/** The label under which the status is stored for each zone. */
|
||||
private static final String START_TIME_ATTRIBUTE = "START_TIME";
|
||||
|
||||
@@ -426,16 +423,6 @@ public class ChainingUserRegistrySynchronizer extends AbstractLifecycleBean
|
||||
throw new AuthenticationException("authentication.err.validation.authenticator.notfound", params);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.repo.security.sync.UserRegistrySynchronizer#synchronize(boolean, boolean, boolean)
|
||||
*/
|
||||
@Override
|
||||
public void synchronize(boolean forceUpdate, boolean isFullSync, final boolean splitTxns)
|
||||
{
|
||||
synchronizeInternal(forceUpdate, isFullSync, splitTxns);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void synchronize(boolean forceUpdate, boolean isFullSync)
|
||||
{
|
||||
@@ -813,26 +800,22 @@ public class ChainingUserRegistrySynchronizer extends AbstractLifecycleBean
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.repo.security.sync.UserRegistrySynchronizer#createMissingPerson(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public boolean createMissingPerson(String userName)
|
||||
{
|
||||
// synchronize or auto-create the missing person if we are allowed
|
||||
// synchronise or auto-create the missing person if we are allowed
|
||||
if (userName != null && !userName.equals(AuthenticationUtil.getSystemUserName()))
|
||||
{
|
||||
if (this.syncWhenMissingPeopleLogIn)
|
||||
{
|
||||
try
|
||||
{
|
||||
synchronize(false, false, false);
|
||||
synchronizeInternal(false, false, false);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// We don't want to fail the whole login if we can help it
|
||||
ChainingUserRegistrySynchronizer.logger.warn(
|
||||
"User authenticated but failed to sync with user registry", e);
|
||||
ChainingUserRegistrySynchronizer.logger.warn("User authenticated but failed to sync with user registry", e);
|
||||
}
|
||||
if (this.personService.personExists(userName))
|
||||
{
|
||||
@@ -968,8 +951,7 @@ public class ChainingUserRegistrySynchronizer extends AbstractLifecycleBean
|
||||
final BatchProcessor<NodeDescription> groupProcessor = new BatchProcessor<NodeDescription>(
|
||||
SyncProcess.GROUP_ANALYSIS.getTitle(zone),
|
||||
this.transactionService.getRetryingTransactionHelper(),
|
||||
userRegistry
|
||||
.getGroups(lastModified),
|
||||
userRegistry.getGroups(lastModified),
|
||||
this.workerThreads,
|
||||
20,
|
||||
this.applicationEventPublisher,
|
||||
@@ -1565,8 +1547,8 @@ public class ChainingUserRegistrySynchronizer extends AbstractLifecycleBean
|
||||
// Batch 5 Group Association Creation
|
||||
BatchProcessor<Map.Entry<String, Set<String>>> groupCreator = new BatchProcessor<Map.Entry<String, Set<String>>>(
|
||||
SyncProcess.GROUP_ASSOCIATION_CREATION.getTitle(zone),
|
||||
ChainingUserRegistrySynchronizer.this.transactionService
|
||||
.getRetryingTransactionHelper(), this.groupParentAssocsToCreate.entrySet(),
|
||||
ChainingUserRegistrySynchronizer.this.transactionService.getRetryingTransactionHelper(),
|
||||
this.groupParentAssocsToCreate.entrySet(),
|
||||
ChainingUserRegistrySynchronizer.this.workerThreads, 20,
|
||||
ChainingUserRegistrySynchronizer.this.applicationEventPublisher,
|
||||
ChainingUserRegistrySynchronizer.logger,
|
||||
@@ -1597,8 +1579,8 @@ public class ChainingUserRegistrySynchronizer extends AbstractLifecycleBean
|
||||
// Batch 6 Person Association
|
||||
BatchProcessor<Map.Entry<String, Set<String>>> groupCreator = new BatchProcessor<Map.Entry<String, Set<String>>>(
|
||||
SyncProcess.PERSON_ASSOCIATION.getTitle(zone),
|
||||
ChainingUserRegistrySynchronizer.this.transactionService
|
||||
.getRetryingTransactionHelper(), this.personParentAssocsToDelete.entrySet(),
|
||||
ChainingUserRegistrySynchronizer.this.transactionService.getRetryingTransactionHelper(),
|
||||
this.personParentAssocsToDelete.entrySet(),
|
||||
ChainingUserRegistrySynchronizer.this.workerThreads, 20,
|
||||
ChainingUserRegistrySynchronizer.this.applicationEventPublisher,
|
||||
ChainingUserRegistrySynchronizer.logger,
|
||||
@@ -1719,8 +1701,12 @@ public class ChainingUserRegistrySynchronizer extends AbstractLifecycleBean
|
||||
final BatchProcessor<NodeDescription> personProcessor = new BatchProcessor<NodeDescription>(
|
||||
SyncProcess.USER_CREATION.getTitle(zone),
|
||||
this.transactionService.getRetryingTransactionHelper(),
|
||||
userRegistry.getPersons(lastModified), this.workerThreads, 10, this.applicationEventPublisher,
|
||||
ChainingUserRegistrySynchronizer.logger, this.loggingInterval);
|
||||
userRegistry.getPersons(lastModified),
|
||||
this.workerThreads,
|
||||
10,
|
||||
this.applicationEventPublisher,
|
||||
ChainingUserRegistrySynchronizer.logger,
|
||||
this.loggingInterval);
|
||||
class PersonWorker extends BaseBatchProcessWorker<NodeDescription>
|
||||
{
|
||||
private long latestTime;
|
||||
@@ -1856,8 +1842,12 @@ public class ChainingUserRegistrySynchronizer extends AbstractLifecycleBean
|
||||
BatchProcessor<String> authorityDeletionProcessor = new BatchProcessor<String>(
|
||||
SyncProcess.AUTHORITY_DELETION.getTitle(zone),
|
||||
this.transactionService.getRetryingTransactionHelper(),
|
||||
deletionCandidates, this.workerThreads, 10, this.applicationEventPublisher,
|
||||
ChainingUserRegistrySynchronizer.logger, this.loggingInterval);
|
||||
deletionCandidates,
|
||||
this.workerThreads,
|
||||
10,
|
||||
this.applicationEventPublisher,
|
||||
ChainingUserRegistrySynchronizer.logger,
|
||||
this.loggingInterval);
|
||||
class AuthorityDeleter extends BaseBatchProcessWorker<String>
|
||||
{
|
||||
private int personProcessedCount;
|
||||
@@ -2007,10 +1997,6 @@ public class ChainingUserRegistrySynchronizer extends AbstractLifecycleBean
|
||||
/**
|
||||
* Modifies an authority's zone set from oldZones to newZones in the most efficient manner (avoiding unnecessary
|
||||
* reindexing cost).
|
||||
*
|
||||
* @param authorityName
|
||||
* @param oldZones
|
||||
* @param newZones
|
||||
*/
|
||||
private void updateAuthorityZones(String authorityName, Set<String> oldZones, final Set<String> newZones)
|
||||
{
|
||||
@@ -2031,11 +2017,6 @@ public class ChainingUserRegistrySynchronizer extends AbstractLifecycleBean
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @seeorg.springframework.extensions.surf.util.AbstractLifecycleBean#onBootstrap(org.springframework.context.
|
||||
* ApplicationEvent)
|
||||
*/
|
||||
@Override
|
||||
protected void onBootstrap(ApplicationEvent event)
|
||||
{
|
||||
@@ -2049,7 +2030,7 @@ public class ChainingUserRegistrySynchronizer extends AbstractLifecycleBean
|
||||
{
|
||||
try
|
||||
{
|
||||
synchronize(false, false, true);
|
||||
synchronizeInternal(false, false, true);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -2409,5 +2390,4 @@ public class ChainingUserRegistrySynchronizer extends AbstractLifecycleBean
|
||||
super.onApplicationEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -44,35 +44,7 @@ public interface UserRegistrySynchronizer
|
||||
/**
|
||||
* Retrieves timestamped user and group information from configured external sources and compares it with the local
|
||||
* users and groups last retrieved from the same sources. Any updates and additions made to those users and groups
|
||||
* are applied to the local Alfresco copies.
|
||||
* <p>
|
||||
* This method is <b>deprecated</b>, use {@link #synchronize(boolean forceUpdate, boolean isFullSync)} instead.
|
||||
* </p>
|
||||
*
|
||||
* @param forceUpdate
|
||||
* Should the complete set of users and groups be updated / created locally or just those known to have
|
||||
* changed since the last sync? When <code>true</code> then <i>all</i> users and groups are queried from
|
||||
* the user registry and updated locally. When <code>false</code> then each source is only queried for
|
||||
* those users and groups modified since the most recent modification date of all the objects last
|
||||
* queried from that same source.
|
||||
* @param isFullSync
|
||||
* Should a complete set of user and group IDs be queried from the user registries in order to determine
|
||||
* deletions? This parameter is independent of <code>force</code> as a separate query is run to process
|
||||
* updates.
|
||||
* @param splitTxns
|
||||
* Can the modifications to Alfresco be split across multiple transactions for maximum performance? If
|
||||
* <code>true</code>, users and groups are created/updated in batches of 10 for increased performance. If
|
||||
* <code>false</code>, all users and groups are processed in the current transaction. This is required if
|
||||
* calling synchronously (e.g. in response to an authentication event in the same transaction).
|
||||
*/
|
||||
@Deprecated
|
||||
public void synchronize(boolean forceUpdate, boolean isFullSync, boolean splitTxns);
|
||||
|
||||
/**
|
||||
* Retrieves timestamped user and group information from configured external sources and compares it with the local
|
||||
* users and groups last retrieved from the same sources. Any updates and additions made to those users and groups
|
||||
* are applied to the local Alfresco copies. Unlike deprecated {@link #synchronize(boolean, boolean, boolean)},
|
||||
* this process is always run in different transactions and threads.
|
||||
* are applied to the local Alfresco copies. This process is always run in different transactions and threads.
|
||||
*
|
||||
* @param forceUpdate
|
||||
* Should the complete set of users and groups be updated / created locally or just those known to have
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2014 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
@@ -34,25 +34,18 @@ import org.quartz.JobExecutionException;
|
||||
*/
|
||||
public class UserRegistrySynchronizerJob implements Job
|
||||
{
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.quartz.Job#execute(org.quartz.JobExecutionContext)
|
||||
*/
|
||||
public void execute(JobExecutionContext executionContext) throws JobExecutionException
|
||||
{
|
||||
final UserRegistrySynchronizer userRegistrySynchronizer = (UserRegistrySynchronizer) executionContext
|
||||
.getJobDetail().getJobDataMap().get("userRegistrySynchronizer");
|
||||
final String synchronizeChangesOnly = (String) executionContext.getJobDetail().getJobDataMap().get(
|
||||
"synchronizeChangesOnly");
|
||||
final String synchronizeChangesOnly = (String) executionContext.getJobDetail().getJobDataMap().get("synchronizeChangesOnly");
|
||||
AuthenticationUtil.runAs(new RunAsWork<Object>()
|
||||
{
|
||||
public Object doWork() throws Exception
|
||||
{
|
||||
userRegistrySynchronizer.synchronize(synchronizeChangesOnly == null
|
||||
|| !Boolean.parseBoolean(synchronizeChangesOnly), true, true);
|
||||
userRegistrySynchronizer.synchronize(synchronizeChangesOnly == null || !Boolean.parseBoolean(synchronizeChangesOnly), true);
|
||||
return null;
|
||||
}
|
||||
}, AuthenticationUtil.getSystemUserName());
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user