mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
ALF-4948 - If the replication definition payload contains deleted nodes, issue a warning but skip over them, rather than raising an error
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@22766 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -37,6 +37,7 @@ import org.alfresco.service.cmr.action.ParameterDefinition;
|
||||
import org.alfresco.service.cmr.replication.ReplicationDefinition;
|
||||
import org.alfresco.service.cmr.replication.ReplicationServiceException;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.transfer.NodeCrawler;
|
||||
import org.alfresco.service.cmr.transfer.NodeCrawlerFactory;
|
||||
import org.alfresco.service.cmr.transfer.TransferCallback;
|
||||
@@ -63,6 +64,7 @@ public class ReplicationActionExecutor extends ActionExecuterAbstractBase {
|
||||
*/
|
||||
private static Log logger = LogFactory.getLog(ReplicationActionExecutor.class);
|
||||
|
||||
private NodeService nodeService;
|
||||
private JobLockService jobLockService;
|
||||
private TransferService2 transferService;
|
||||
private NodeCrawlerFactory nodeCrawlerFactory;
|
||||
@@ -76,6 +78,16 @@ public class ReplicationActionExecutor extends ActionExecuterAbstractBase {
|
||||
*/
|
||||
private long replicationActionLockDuration = 30*60*1000;
|
||||
|
||||
/**
|
||||
* Injects the NodeService bean.
|
||||
*
|
||||
* @param nodeService the NodeService.
|
||||
*/
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Injects the JobLockService bean.
|
||||
*
|
||||
@@ -167,9 +179,17 @@ public class ReplicationActionExecutor extends ActionExecuterAbstractBase {
|
||||
ContentModel.TYPE_CONTENT
|
||||
));
|
||||
|
||||
for(NodeRef payload : replicationDef.getPayload()) {
|
||||
Set<NodeRef> crawledNodes = crawler.crawl(payload);
|
||||
toTransfer.addAll(crawledNodes);
|
||||
for(NodeRef payload : replicationDef.getPayload())
|
||||
{
|
||||
if(nodeService.exists(payload))
|
||||
{
|
||||
Set<NodeRef> crawledNodes = crawler.crawl(payload);
|
||||
toTransfer.addAll(crawledNodes);
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.warn("Skipping replication of non-existant node " + payload);
|
||||
}
|
||||
}
|
||||
|
||||
return toTransfer;
|
||||
|
@@ -116,6 +116,7 @@ public class ReplicationServiceIntegrationTest extends TestCase
|
||||
private NodeRef content2a_1;
|
||||
private NodeRef thumbnail2a_2; // Thumbnail extends content
|
||||
private NodeRef zone2a_3; // Zone doesn't
|
||||
private NodeRef deletedFolder;
|
||||
|
||||
private final String ACTION_NAME = "testName";
|
||||
private final String ACTION_NAME2 = "testName2";
|
||||
@@ -173,6 +174,9 @@ public class ReplicationServiceIntegrationTest extends TestCase
|
||||
thumbnail2a_2 = makeNode(folder2a, ContentModel.TYPE_THUMBNAIL);
|
||||
zone2a_3 = makeNode(folder2a, ContentModel.TYPE_ZONE);
|
||||
|
||||
deletedFolder = makeNode(repositoryHelper.getCompanyHome(), ContentModel.TYPE_FOLDER);
|
||||
nodeService.deleteNode(deletedFolder);
|
||||
|
||||
// Tell the transfer service not to use HTTP
|
||||
makeTransferServiceLocal();
|
||||
|
||||
@@ -558,6 +562,8 @@ public class ReplicationServiceIntegrationTest extends TestCase
|
||||
rd = replicationService.createReplicationDefinition(ACTION_NAME, "Test");
|
||||
rd.setTargetName(TRANSFER_TARGET);
|
||||
rd.getPayload().add( folder1 );
|
||||
// A deleted folder is fine, will be skipped
|
||||
rd.getPayload().add( deletedFolder );
|
||||
|
||||
// Will execute without error
|
||||
txn = transactionService.getUserTransaction();
|
||||
|
Reference in New Issue
Block a user