use of org.alfresco.service.cmr.transfer.NodeCrawler in project alfresco-repository by Alfresco.
the class TransferTreeActionExecuter method executeImpl.
/* (non-Javadoc)
* @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef)
*/
@Override
protected void executeImpl(Action action, NodeRef actionedUponNodeRef) {
TransferTarget target = TransferTestUtil.getTestTarget(transferService);
NodeCrawler crawler = new StandardNodeCrawlerImpl(serviceRegistry);
crawler.setNodeFinders(new ChildAssociatedNodeFinder(ContentModel.ASSOC_CONTAINS));
Set<NodeRef> nodes = crawler.crawl(actionedUponNodeRef);
TransferDefinition td = new TransferDefinition();
td.setNodes(nodes);
transferService.transfer(target.getName(), td);
}
use of org.alfresco.service.cmr.transfer.NodeCrawler in project alfresco-repository by Alfresco.
the class TransferTreeWithCancelActionExecuter method executeImpl.
/* (non-Javadoc)
* @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef)
*/
@Override
protected void executeImpl(Action action, NodeRef actionedUponNodeRef) {
TransferTarget target = serviceRegistry.getTransactionService().getRetryingTransactionHelper().doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<TransferTarget>() {
public TransferTarget execute() throws Throwable {
return TransferTestUtil.getTestTarget(transferService);
}
}, false, true);
NodeCrawler crawler = new StandardNodeCrawlerImpl(serviceRegistry);
crawler.setNodeFinders(new ChildAssociatedNodeFinder(ContentModel.ASSOC_CONTAINS));
Set<NodeRef> nodes = crawler.crawl(actionedUponNodeRef);
TransferDefinition td = new TransferDefinition();
td.setNodes(nodes);
transferService.transferAsync(target.getName(), td, new TransferCallback() {
private String transferId;
public void processEvent(TransferEvent event) {
if (event instanceof TransferEventBegin) {
transferId = ((TransferEventBegin) event).getTransferId();
} else if (event instanceof TransferEventCommittingStatus) {
transferService.cancelAsync(transferId);
}
}
});
}
use of org.alfresco.service.cmr.transfer.NodeCrawler in project alfresco-repository by Alfresco.
the class ReplicationActionExecutor method expandPayload.
/**
* Takes a {@link ReplicationDefinition}, which contains one or
* more payloads {@link NodeRef}s, and expands them into a
* full list of nodes to be transfered.
*/
protected Set<NodeRef> expandPayload(ReplicationDefinition replicationDef) {
// Turn our payload list of root nodes into something that
// the transfer service can work with
Set<NodeRef> toTransfer = new HashSet<NodeRef>(89);
NodeCrawler crawler = nodeCrawlerFactory.getNodeCrawler();
crawler.setNodeFinders(new ChildAssociatedNodeFinder(ContentModel.ASSOC_CONTAINS, RenditionModel.ASSOC_RENDITION));
crawler.setNodeFilters(new ContentClassFilter(ContentModel.TYPE_FOLDER, ContentModel.TYPE_CONTENT, ContentModel.TYPE_THUMBNAIL));
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;
}
use of org.alfresco.service.cmr.transfer.NodeCrawler in project alfresco-repository by Alfresco.
the class NodeCrawlerTest method testCrawler.
@Test
public void testCrawler() {
NodeRef node8 = makeNode(companyHome, ContentModel.TYPE_FOLDER);
NodeRef node9 = makeNode(node8, ContentModel.TYPE_FOLDER);
NodeRef node10 = makeNode(node8, ContentModel.TYPE_FOLDER);
NodeRef node11 = makeNode(node10, ContentModel.TYPE_FOLDER);
NodeRef node12 = makeNode(node10, ContentModel.TYPE_FOLDER);
NodeRef node13 = makeNode(node12, ContentModel.TYPE_FOLDER);
makeNode(node10, ContentModel.TYPE_BASE);
makeNode(node13, ContentModel.TYPE_CONTENT);
makeNode(node10, ContentModel.TYPE_CONTENT);
makeNode(node11, ContentModel.TYPE_CONTENT);
makeNode(node8, ContentModel.TYPE_CONTENT);
makeNode(node8, ContentModel.TYPE_CONTENT);
makeNode(node9, ContentModel.TYPE_CONTENT);
makeNode(node13, ContentModel.TYPE_CONTENT);
NodeRef node15 = makeNode(node13, ContentModel.TYPE_THUMBNAIL);
nodeService.addAspect(node8, RenditionModel.ASPECT_RENDITIONED, null);
nodeService.addChild(node8, node15, RenditionModel.ASSOC_RENDITION, QName.createQName(NamespaceService.APP_MODEL_1_0_URI, "temp"));
NodeCrawler crawler = nodeCrawlerFactory.getNodeCrawler();
crawler.setNodeFinders(new ChildAssociatedNodeFinder(ContentModel.ASSOC_CONTAINS));
Set<NodeRef> crawledNodes = crawler.crawl(node8);
assertEquals(15, crawledNodes.size());
crawler.setNodeFilters(new ContentClassFilter(ContentModel.TYPE_FOLDER));
crawledNodes = crawler.crawl(node8);
assertEquals(6, crawledNodes.size());
}
Aggregations