mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged BRANCHES/V3.2 to HEAD:
18104: Merged in DEV/BELARUS/V3.2-2009_12_15 rev 17847: ETHREEOH-3746 DB2 upgrade issue 18476: Fixed ETHREEOH-3983: NodeLockedException: IncompleteNodeTagger fails for locked nodes 18761: Merged V3.1 to V3.2 18760 (RECORD-ONLY): Merged V2.2 to V3.1 18759: Merged DEV/BELARUS/V2.2-2010_02_03 to V2.2 18553: ResultSet closing was added to methods. This was fixed separately in V3.2. 18787: MT: fix ETHREEOH-4125 - authority migration / batch processor (when upgrading groups from 3.1 to 3.2) 19059: Fix read-only marker in test 19061: Handle missing alf_content_data ID for node cleaning git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@19226 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -34,6 +34,10 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||
import org.alfresco.repo.tenant.TenantService;
|
||||
import org.alfresco.repo.tenant.TenantUserService;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
||||
import org.alfresco.repo.transaction.TransactionListenerAdapter;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||
@@ -63,6 +67,11 @@ public class BatchProcessor<T> implements BatchMonitor
|
||||
|
||||
/** The rule service. */
|
||||
private final RuleService ruleService;
|
||||
|
||||
/** The tenant user service. */
|
||||
private final TenantUserService tenantUserService;
|
||||
|
||||
private final String tenantDomain;
|
||||
|
||||
/** The collection. */
|
||||
private final Collection<T> collection;
|
||||
@@ -125,18 +134,61 @@ public class BatchProcessor<T> implements BatchMonitor
|
||||
* @param batchSize
|
||||
* the number of entries we process at a time in a transaction
|
||||
*/
|
||||
public BatchProcessor(Log logger, RetryingTransactionHelper retryingTransactionHelper, RuleService ruleService,
|
||||
public BatchProcessor(Log logger, RetryingTransactionHelper retryingTransactionHelper, RuleService ruleService,
|
||||
ApplicationEventPublisher applicationEventPublisher, Collection<T> collection, String processName,
|
||||
int loggingInterval, int workerThreads, int batchSize)
|
||||
{
|
||||
this(logger, retryingTransactionHelper, ruleService, null, applicationEventPublisher, collection, processName,
|
||||
loggingInterval, workerThreads, batchSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new batch processor.
|
||||
*
|
||||
* @param logger
|
||||
* the logger to use
|
||||
* @param retryingTransactionHelper
|
||||
* the retrying transaction helper
|
||||
* @param ruleService
|
||||
* the rule service
|
||||
* @param tenantUserService
|
||||
* the tenant user service
|
||||
* @param collection
|
||||
* the collection
|
||||
* @param processName
|
||||
* the process name
|
||||
* @param loggingInterval
|
||||
* the number of entries to process before reporting progress
|
||||
* @param applicationEventPublisher
|
||||
* the application event publisher
|
||||
* @param workerThreads
|
||||
* the number of worker threads
|
||||
* @param batchSize
|
||||
* the number of entries we process at a time in a transaction
|
||||
*/
|
||||
public BatchProcessor(Log logger, RetryingTransactionHelper retryingTransactionHelper, RuleService ruleService,
|
||||
TenantUserService tenantUserService, ApplicationEventPublisher applicationEventPublisher, Collection<T> collection, String processName,
|
||||
int loggingInterval, int workerThreads, int batchSize)
|
||||
{
|
||||
this.logger = logger;
|
||||
this.retryingTransactionHelper = retryingTransactionHelper;
|
||||
this.ruleService = ruleService;
|
||||
this.tenantUserService = tenantUserService;
|
||||
this.collection = collection;
|
||||
this.processName = processName;
|
||||
this.loggingInterval = loggingInterval;
|
||||
this.workerThreads = workerThreads;
|
||||
this.batchSize = batchSize;
|
||||
|
||||
if (tenantUserService != null)
|
||||
{
|
||||
this.tenantDomain = tenantUserService.getUserDomain(AuthenticationUtil.getRunAsUser());
|
||||
}
|
||||
else
|
||||
{
|
||||
this.tenantDomain = TenantService.DEFAULT_DOMAIN;
|
||||
}
|
||||
|
||||
// Let the (enterprise) monitoring side know of our presence
|
||||
applicationEventPublisher.publishEvent(new BatchMonitorEvent(this));
|
||||
}
|
||||
@@ -313,6 +365,7 @@ public class BatchProcessor<T> implements BatchMonitor
|
||||
{
|
||||
batch = new ArrayList<T>(this.batchSize);
|
||||
}
|
||||
|
||||
if (executorService == null)
|
||||
{
|
||||
callback.run();
|
||||
@@ -551,9 +604,24 @@ public class BatchProcessor<T> implements BatchMonitor
|
||||
{
|
||||
// Disable rules for this thread
|
||||
BatchProcessor.this.ruleService.disableRules();
|
||||
|
||||
final BatchProcessor<T>.TxnCallback callback = this;
|
||||
try
|
||||
{
|
||||
BatchProcessor.this.retryingTransactionHelper.doInTransaction(this, false, this.splitTxns);
|
||||
String systemUser = AuthenticationUtil.getSystemUserName();
|
||||
if (tenantUserService != null)
|
||||
{
|
||||
systemUser = tenantUserService.getDomainUser(AuthenticationUtil.getSystemUserName(), tenantDomain);
|
||||
}
|
||||
|
||||
AuthenticationUtil.runAs(new RunAsWork<Void>()
|
||||
{
|
||||
public Void doWork() throws Exception
|
||||
{
|
||||
BatchProcessor.this.retryingTransactionHelper.doInTransaction(callback, false, splitTxns);
|
||||
return null;
|
||||
}
|
||||
}, systemUser);
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
|
Reference in New Issue
Block a user