mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Replication Service transfer report tracking
Make the transfer service report available through the replication service, and add unit tests to show that it turns up as expected git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@21441 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -182,6 +182,9 @@ public class ReplicationActionExecutor extends ActionExecuterAbstractBase {
|
||||
throw new ReplicationServiceException("Unable to execute a disabled replication definition");
|
||||
}
|
||||
|
||||
// Clear the previous transfer report reference
|
||||
replicationDef.setLocalTransferReport(null);
|
||||
|
||||
// Lock the service - only one instance of the replication
|
||||
// should occur at a time
|
||||
ReplicationDefinitionLockExtender lock =
|
||||
@@ -205,11 +208,14 @@ public class ReplicationActionExecutor extends ActionExecuterAbstractBase {
|
||||
buildTransferDefinition(replicationDef, toTransfer);
|
||||
|
||||
// Off we go
|
||||
transferService.transfer(
|
||||
NodeRef transferReport = transferService.transfer(
|
||||
replicationDef.getTargetName(),
|
||||
transferDefinition,
|
||||
lock
|
||||
);
|
||||
|
||||
// Record the details of the transfer report
|
||||
replicationDef.setLocalTransferReport(transferReport);
|
||||
} catch(Exception e) {
|
||||
if(! (e instanceof TransferCancelledException))
|
||||
{
|
||||
|
@@ -46,6 +46,7 @@ import org.alfresco.service.cmr.replication.ReplicationDefinition;
|
||||
import org.alfresco.service.cmr.replication.ReplicationService;
|
||||
import org.alfresco.service.cmr.replication.ReplicationServiceException;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.ContentReader;
|
||||
import org.alfresco.service.cmr.repository.ContentService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
@@ -79,6 +80,7 @@ public class ReplicationServiceIntegrationTest extends TestCase
|
||||
private ReplicationService replicationService;
|
||||
private TransactionService transactionService;
|
||||
private TransferService transferService;
|
||||
private ContentService contentService;
|
||||
private JobLockService jobLockService;
|
||||
private ActionService actionService;
|
||||
private NodeService nodeService;
|
||||
@@ -114,6 +116,7 @@ public class ReplicationServiceIntegrationTest extends TestCase
|
||||
replicationService = (ReplicationService) ctx.getBean("replicationService");
|
||||
transactionService = (TransactionService) ctx.getBean("transactionService");
|
||||
transferService = (TransferService) ctx.getBean("transferService");
|
||||
contentService = (ContentService) ctx.getBean("contentService");
|
||||
jobLockService = (JobLockService) ctx.getBean("jobLockService");
|
||||
actionService = (ActionService) ctx.getBean("actionService");
|
||||
nodeService = (NodeService) ctx.getBean("nodeService");
|
||||
@@ -662,6 +665,8 @@ public class ReplicationServiceIntegrationTest extends TestCase
|
||||
rd.getPayload().add(folder1);
|
||||
rd.getPayload().add(folder2a);
|
||||
|
||||
assertEquals(null, rd.getLocalTransferReport());
|
||||
|
||||
txn = transactionService.getUserTransaction();
|
||||
txn.begin();
|
||||
actionService.executeAction(rd, replicationRoot);
|
||||
@@ -732,6 +737,22 @@ public class ReplicationServiceIntegrationTest extends TestCase
|
||||
fail("Found zone as " + r.getChildRef() + " but it shouldn't be transfered!");
|
||||
}
|
||||
}
|
||||
|
||||
// Check we got a transfer report, and it looks sensible
|
||||
NodeRef transferReport = rd.getLocalTransferReport();
|
||||
assertNotNull(transferReport);
|
||||
|
||||
txn = transactionService.getUserTransaction();
|
||||
txn.begin();
|
||||
|
||||
ContentReader transferReader =
|
||||
contentService.getReader(transferReport, ContentModel.PROP_CONTENT);
|
||||
String report = transferReader.getContentString();
|
||||
|
||||
assertTrue("XML not found in:\n" + report, report.contains("<?xml"));
|
||||
assertTrue("Report XML not found in:\n" + report, report.contains("<report:transferReport"));
|
||||
|
||||
txn.commit();
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user