use of org.alfresco.repo.batch.BatchProcessor.BatchProcessWorkerAdaptor in project alfresco-repository by Alfresco.
the class RenameUser method execute.
/*
* (non-Javadoc)
* @see org.alfresco.tools.Tool#execute()
*/
@Override
protected int execute() throws ToolException {
// Used for ability to be final and have a set
final AtomicInteger status = new AtomicInteger(0);
BatchProcessWorker<User> worker = new BatchProcessWorkerAdaptor<User>() {
public void process(final User user) throws Throwable {
RunAsWork<Void> runAsWork = new RunAsWork<Void>() {
@Override
public Void doWork() throws Exception {
try {
renameUser(user.getOldUsername(), user.getNewUsername());
} catch (Throwable t) {
status.set(handleError(t));
}
return null;
}
};
AuthenticationUtil.runAs(runAsWork, context.getUsername());
}
};
// Use 2 threads, 20 User objects per transaction. Log every 100 entries.
BatchProcessor<User> processor = new BatchProcessor<User>("HomeFolderProviderSynchronizer", getServiceRegistry().getTransactionService().getRetryingTransactionHelper(), new WorkProvider(context), 2, 20, null, logger, 100);
processor.process(worker, true);
return status.get();
}
Aggregations