Search in sources :

Example 1 with NodeCrawler

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);
}
Also used : TransferDefinition(org.alfresco.service.cmr.transfer.TransferDefinition) NodeRef(org.alfresco.service.cmr.repository.NodeRef) NodeCrawler(org.alfresco.service.cmr.transfer.NodeCrawler) TransferTarget(org.alfresco.service.cmr.transfer.TransferTarget)

Example 2 with NodeCrawler

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);
            }
        }
    });
}
Also used : NodeCrawler(org.alfresco.service.cmr.transfer.NodeCrawler) RetryingTransactionHelper(org.alfresco.repo.transaction.RetryingTransactionHelper) TransferEvent(org.alfresco.service.cmr.transfer.TransferEvent) TransferEventBegin(org.alfresco.service.cmr.transfer.TransferEventBegin) TransferTarget(org.alfresco.service.cmr.transfer.TransferTarget) TransferCallback(org.alfresco.service.cmr.transfer.TransferCallback) TransferDefinition(org.alfresco.service.cmr.transfer.TransferDefinition) NodeRef(org.alfresco.service.cmr.repository.NodeRef) TransferEventCommittingStatus(org.alfresco.service.cmr.transfer.TransferEventCommittingStatus)

Example 3 with NodeCrawler

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;
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) ChildAssociatedNodeFinder(org.alfresco.repo.transfer.ChildAssociatedNodeFinder) NodeCrawler(org.alfresco.service.cmr.transfer.NodeCrawler) ContentClassFilter(org.alfresco.repo.transfer.ContentClassFilter) HashSet(java.util.HashSet)

Example 4 with NodeCrawler

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());
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) NodeCrawler(org.alfresco.service.cmr.transfer.NodeCrawler) BaseAlfrescoSpringTest(org.alfresco.util.BaseAlfrescoSpringTest) Test(org.junit.Test)

Aggregations

NodeRef (org.alfresco.service.cmr.repository.NodeRef)4 NodeCrawler (org.alfresco.service.cmr.transfer.NodeCrawler)4 TransferDefinition (org.alfresco.service.cmr.transfer.TransferDefinition)2 TransferTarget (org.alfresco.service.cmr.transfer.TransferTarget)2 HashSet (java.util.HashSet)1 RetryingTransactionHelper (org.alfresco.repo.transaction.RetryingTransactionHelper)1 ChildAssociatedNodeFinder (org.alfresco.repo.transfer.ChildAssociatedNodeFinder)1 ContentClassFilter (org.alfresco.repo.transfer.ContentClassFilter)1 TransferCallback (org.alfresco.service.cmr.transfer.TransferCallback)1 TransferEvent (org.alfresco.service.cmr.transfer.TransferEvent)1 TransferEventBegin (org.alfresco.service.cmr.transfer.TransferEventBegin)1 TransferEventCommittingStatus (org.alfresco.service.cmr.transfer.TransferEventCommittingStatus)1 BaseAlfrescoSpringTest (org.alfresco.util.BaseAlfrescoSpringTest)1 Test (org.junit.Test)1