mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
ALF-10419:
o performance improvements: disable/enable auditing behaviour per-transaction rather than per-node o add "disable rules" checkbox to GUI and support disabling of rules during import git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@31243 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -41,8 +41,7 @@ public interface BulkFilesystemImporter
|
||||
* @param source The source directory on the local filesystem to read content from <i>(must not be null and must be a valid, readable directory on the local filesystem)</i>.
|
||||
* @param replaceExisting A flag indicating whether to replace (true) or skip (false) files that are already in the repository.
|
||||
*/
|
||||
// void bulkImport(NodeRef target, NodeImporter importStrategy, boolean replaceExisting);
|
||||
public void bulkImport(BulkImportParameters bulkImportParameters, NodeImporter nodeImporter);
|
||||
void bulkImport(BulkImportParameters bulkImportParameters, NodeImporter nodeImporter);
|
||||
|
||||
/**
|
||||
* Initiates a bulk filesystem import asynchronously i.e. in a background thread.
|
||||
@@ -52,8 +51,7 @@ public interface BulkFilesystemImporter
|
||||
* @param source The source directory on the local filesystem to read content from <i>(must not be null and must be a valid, readable directory on the local filesystem)</i>.
|
||||
* @param replaceExisting A flag indicating whether to replace (true) or skip (false) files that are already in the repository.
|
||||
*/
|
||||
// void asyncBulkImport(NodeRef target, NodeImporter nodeImporter, boolean replaceExisting);
|
||||
public void asyncBulkImport(BulkImportParameters bulkImportParameters, NodeImporter nodeImporter);
|
||||
void asyncBulkImport(BulkImportParameters bulkImportParameters, NodeImporter nodeImporter);
|
||||
|
||||
/**
|
||||
* @return A status object that describes the current state of the bulk filesystem importer.
|
||||
|
@@ -5,11 +5,20 @@ import org.alfresco.service.cmr.repository.NodeRef;
|
||||
public class BulkImportParameters
|
||||
{
|
||||
private NodeRef target;
|
||||
private boolean replaceExisting;
|
||||
private boolean replaceExisting = false;
|
||||
private Integer batchSize;
|
||||
private Integer numThreads;
|
||||
private Integer loggingInterval;
|
||||
private boolean disableRulesService = false;
|
||||
|
||||
public boolean isDisableRulesService()
|
||||
{
|
||||
return disableRulesService;
|
||||
}
|
||||
public void setDisableRulesService(boolean disableRulesService)
|
||||
{
|
||||
this.disableRulesService = disableRulesService;
|
||||
}
|
||||
public Integer getLoggingInterval()
|
||||
{
|
||||
return loggingInterval;
|
||||
|
@@ -47,6 +47,7 @@ import org.alfresco.service.cmr.model.FileFolderService;
|
||||
import org.alfresco.service.cmr.model.FileInfo;
|
||||
import org.alfresco.service.cmr.model.FileNotFoundException;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.rule.RuleService;
|
||||
import org.alfresco.service.cmr.security.AccessStatus;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
@@ -76,6 +77,7 @@ public abstract class AbstractBulkFilesystemImporter implements BulkFilesystemIm
|
||||
protected TransactionService transactionService;
|
||||
protected PermissionService permissionService;
|
||||
protected RetryingTransactionHelper transactionHelper;
|
||||
protected RuleService ruleService;
|
||||
|
||||
protected BulkImportStatusImpl importStatus;
|
||||
protected DirectoryAnalyser directoryAnalyser = null;
|
||||
@@ -84,6 +86,11 @@ public abstract class AbstractBulkFilesystemImporter implements BulkFilesystemIm
|
||||
|
||||
protected BehaviourFilter behaviourFilter;
|
||||
|
||||
public void setRuleService(RuleService ruleService)
|
||||
{
|
||||
this.ruleService = ruleService;
|
||||
}
|
||||
|
||||
public void setBehaviourFilter(BehaviourFilter behaviourFilter)
|
||||
{
|
||||
this.behaviourFilter = behaviourFilter;
|
||||
|
@@ -32,6 +32,7 @@ import org.alfresco.repo.bulkimport.BulkImportParameters;
|
||||
import org.alfresco.repo.bulkimport.FilesystemTracker;
|
||||
import org.alfresco.repo.bulkimport.ImportableItem;
|
||||
import org.alfresco.repo.bulkimport.NodeImporter;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
@@ -64,11 +65,17 @@ public abstract class MultiThreadedBulkFilesystemImporter extends AbstractBulkFi
|
||||
{
|
||||
return bulkImportParameters.getNumThreads() != null ? bulkImportParameters.getNumThreads() : defaultNumThreads;
|
||||
}
|
||||
|
||||
protected void handleRuleService(final BulkImportParameters bulkImportParameters)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected BatchProcessor.BatchProcessWorker<ImportableItem> getWorker(final BulkImportParameters bulkImportParameters, final String lockToken,
|
||||
final NodeImporter nodeImporter, final FilesystemTracker filesystemTracker)
|
||||
{
|
||||
final int batchSize = bulkImportParameters.getBatchSize() != null ? bulkImportParameters.getBatchSize() : defaultBatchSize;
|
||||
final boolean rulesEnabled = ruleService.isEnabled();
|
||||
|
||||
BatchProcessor.BatchProcessWorker<ImportableItem> worker = new BatchProcessor.BatchProcessWorker<ImportableItem>()
|
||||
{
|
||||
@@ -80,30 +87,47 @@ public abstract class MultiThreadedBulkFilesystemImporter extends AbstractBulkFi
|
||||
public void beforeProcess() throws Throwable
|
||||
{
|
||||
refreshLock(lockToken, batchSize * 250L);
|
||||
// TODO this throws exception txn not started??
|
||||
if(bulkImportParameters.isDisableRulesService() && rulesEnabled)
|
||||
{
|
||||
ruleService.disableRules();
|
||||
}
|
||||
|
||||
// Disable the auditable aspect's behaviours for this transaction only, to allow creation & modification dates to be set
|
||||
//behaviourFilter.disableBehaviour(ContentModel.ASPECT_AUDITABLE);
|
||||
transactionHelper.doInTransaction(new RetryingTransactionCallback<Void>()
|
||||
{
|
||||
@Override
|
||||
public Void execute() throws Throwable
|
||||
{
|
||||
behaviourFilter.disableBehaviour(ContentModel.ASPECT_AUDITABLE);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void afterProcess() throws Throwable
|
||||
{
|
||||
if(bulkImportParameters.isDisableRulesService() && rulesEnabled)
|
||||
{
|
||||
ruleService.enableRules();
|
||||
}
|
||||
|
||||
importStatus.incrementNumberOfBatchesCompleted();
|
||||
//behaviourFilter.enableBehaviour(ContentModel.ASPECT_AUDITABLE);
|
||||
|
||||
transactionHelper.doInTransaction(new RetryingTransactionCallback<Void>()
|
||||
{
|
||||
@Override
|
||||
public Void execute() throws Throwable
|
||||
{
|
||||
behaviourFilter.enableBehaviour(ContentModel.ASPECT_AUDITABLE);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void process(final ImportableItem importableItem) throws Throwable
|
||||
{
|
||||
try
|
||||
{
|
||||
behaviourFilter.disableBehaviour(ContentModel.ASPECT_AUDITABLE);
|
||||
NodeRef nodeRef = nodeImporter.importImportableItem(importableItem, bulkImportParameters.isReplaceExisting());
|
||||
filesystemTracker.itemImported(nodeRef, importableItem);
|
||||
// importableItem.setNodeRef(nodeRef);
|
||||
}
|
||||
finally
|
||||
{
|
||||
behaviourFilter.enableBehaviour(ContentModel.ASPECT_AUDITABLE);
|
||||
}
|
||||
NodeRef nodeRef = nodeImporter.importImportableItem(importableItem, bulkImportParameters.isReplaceExisting());
|
||||
filesystemTracker.itemImported(nodeRef, importableItem);
|
||||
}
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user