mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Tests for the RetryingTransactionHelper
- Tests new inner transactions - Tests various modes of failure, including silent mark for rollback Archive restore uses retries git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5953 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -30,8 +30,8 @@ import java.util.List;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.node.archive.RestoreNodeReport.RestoreStatus;
|
||||
import org.alfresco.repo.security.permissions.AccessDeniedException;
|
||||
import org.alfresco.repo.transaction.TransactionUtil;
|
||||
import org.alfresco.repo.transaction.TransactionUtil.TransactionWork;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
@@ -129,14 +129,15 @@ public class NodeArchiveServiceImpl implements NodeArchiveService
|
||||
try
|
||||
{
|
||||
// Transactional wrapper to attempt the restore
|
||||
TransactionWork<NodeRef> restoreWork = new TransactionWork<NodeRef>()
|
||||
RetryingTransactionHelper txnHelper = transactionService.getRetryingTransactionHelper();
|
||||
RetryingTransactionCallback<NodeRef> restoreCallback = new RetryingTransactionCallback<NodeRef>()
|
||||
{
|
||||
public NodeRef doWork() throws Exception
|
||||
public NodeRef execute() throws Exception
|
||||
{
|
||||
return nodeService.restoreNode(archivedNodeRef, destinationNodeRef, assocTypeQName, assocQName);
|
||||
}
|
||||
};
|
||||
NodeRef newNodeRef = TransactionUtil.executeInNonPropagatingUserTransaction(transactionService, restoreWork);
|
||||
NodeRef newNodeRef = txnHelper.doInTransaction(restoreCallback, false, true);
|
||||
// success
|
||||
report.setRestoredNodeRef(newNodeRef);
|
||||
report.setStatus(RestoreStatus.SUCCESS);
|
||||
@@ -274,9 +275,10 @@ public class NodeArchiveServiceImpl implements NodeArchiveService
|
||||
*/
|
||||
public void purgeArchivedNode(final NodeRef archivedNodeRef)
|
||||
{
|
||||
TransactionWork<Object> deleteWork = new TransactionWork<Object>()
|
||||
RetryingTransactionHelper txnHelper = transactionService.getRetryingTransactionHelper();
|
||||
RetryingTransactionCallback<Object> deleteCallback = new RetryingTransactionCallback<Object>()
|
||||
{
|
||||
public Object doWork() throws Exception
|
||||
public Object execute() throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -289,7 +291,7 @@ public class NodeArchiveServiceImpl implements NodeArchiveService
|
||||
return null;
|
||||
}
|
||||
};
|
||||
TransactionUtil.executeInNonPropagatingUserTransaction(transactionService, deleteWork);
|
||||
txnHelper.doInTransaction(deleteCallback, false, true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user