Search in sources :

Example 6 with TransferEventBegin

use of org.alfresco.service.cmr.transfer.TransferEventBegin 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 7 with TransferEventBegin

use of org.alfresco.service.cmr.transfer.TransferEventBegin in project alfresco-repository by Alfresco.

the class TestTransferCallback method processEvent.

public void processEvent(TransferEvent event) {
    logger.debug(event.toString());
    events.add(event);
    if (event instanceof TransferEventBegin) {
        TransferEventBegin beginEvent = (TransferEventBegin) event;
        transferId = beginEvent.getTransferId();
    }
}
Also used : TransferEventBegin(org.alfresco.service.cmr.transfer.TransferEventBegin)

Aggregations

TransferEventBegin (org.alfresco.service.cmr.transfer.TransferEventBegin)7 TransferDefinition (org.alfresco.service.cmr.transfer.TransferDefinition)5 TransferEvent (org.alfresco.service.cmr.transfer.TransferEvent)5 ArrayList (java.util.ArrayList)4 TransferEventCommittingStatus (org.alfresco.service.cmr.transfer.TransferEventCommittingStatus)3 TransferEventEndState (org.alfresco.service.cmr.transfer.TransferEventEndState)3 TransferEventEnterState (org.alfresco.service.cmr.transfer.TransferEventEnterState)3 TransferEventReport (org.alfresco.service.cmr.transfer.TransferEventReport)3 TransferEventSendingSnapshot (org.alfresco.service.cmr.transfer.TransferEventSendingSnapshot)3 TransferProgress (org.alfresco.service.cmr.transfer.TransferProgress)3 List (java.util.List)2 NodeRef (org.alfresco.service.cmr.repository.NodeRef)2 TransferCallback (org.alfresco.service.cmr.transfer.TransferCallback)2 TransferEventError (org.alfresco.service.cmr.transfer.TransferEventError)2 TransferEventSendingContent (org.alfresco.service.cmr.transfer.TransferEventSendingContent)2 TransferException (org.alfresco.service.cmr.transfer.TransferException)2 TransferFailureException (org.alfresco.service.cmr.transfer.TransferFailureException)2 TransferTarget (org.alfresco.service.cmr.transfer.TransferTarget)2 File (java.io.File)1 OutputStream (java.io.OutputStream)1