Search in sources :

Example 1 with PublishExecutor

use of org.alfresco.module.org_alfresco_module_rm.job.publish.PublishExecutor in project records-management by Alfresco.

the class PublishUpdatesJobExecuter method publishUpdates.

/**
 * Publish the updates made to the node.
 * @param nodeRef   node reference
 */
private void publishUpdates(final NodeRef nodeRef) {
    RetryingTransactionHelper.RetryingTransactionCallback<Void> execution = new RetryingTransactionHelper.RetryingTransactionCallback<Void>() {

        @Override
        public Void execute() {
            behaviourFilter.disableBehaviour(nodeRef, TYPE_DISPOSITION_ACTION_DEFINITION);
            try {
                // Get the update to value for the node
                String updateTo = (String) nodeService.getProperty(nodeRef, PROP_UPDATE_TO);
                if (updateTo != null) {
                    if (logger.isDebugEnabled()) {
                        logger.debug("Node update to " + updateTo + " (noderef=" + nodeRef.toString() + ")");
                    }
                    // Get the publish executor
                    PublishExecutor executor = publishExecutorRegistry.get(updateTo);
                    if (executor == null) {
                        if (logger.isDebugEnabled()) {
                            logger.debug("Unable to find a corresponding publish executor. (noderef=" + nodeRef.toString() + ", updateTo=" + updateTo + ")");
                        }
                        throw new AlfrescoRuntimeException("Unable to find a corresponding publish executor. (noderef=" + nodeRef.toString() + ", updateTo=" + updateTo + ")");
                    }
                    if (logger.isDebugEnabled()) {
                        logger.debug("Attempting to publish updates. (nodeRef=" + nodeRef.toString() + ")");
                    }
                    // Publish
                    executor.publish(nodeRef);
                } else {
                    if (logger.isDebugEnabled()) {
                        logger.debug("Unable to publish, because publish executor is not set.");
                    }
                }
                // Remove the unpublished update aspect
                nodeService.removeAspect(nodeRef, ASPECT_UNPUBLISHED_UPDATE);
                if (logger.isDebugEnabled()) {
                    logger.debug("Publish updates complete. (nodeRef=" + nodeRef.toString() + ")");
                }
            } finally {
                behaviourFilter.enableBehaviour(nodeRef, TYPE_DISPOSITION_ACTION_DEFINITION);
            }
            return null;
        }
    };
    retryingTransactionHelper.doInTransaction(execution);
}
Also used : PublishExecutor(org.alfresco.module.org_alfresco_module_rm.job.publish.PublishExecutor) RetryingTransactionHelper(org.alfresco.repo.transaction.RetryingTransactionHelper) RetryingTransactionCallback(org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback) AlfrescoRuntimeException(org.alfresco.error.AlfrescoRuntimeException)

Example 2 with PublishExecutor

use of org.alfresco.module.org_alfresco_module_rm.job.publish.PublishExecutor in project records-management by Alfresco.

the class DispositionServiceImplTest method publishDispositionActionDefinitionChange.

private void publishDispositionActionDefinitionChange(DispositionActionDefinition dad) {
    PublishExecutorRegistry reg = (PublishExecutorRegistry) applicationContext.getBean("publishExecutorRegistry");
    PublishExecutor pub = reg.get(RecordsManagementModel.UPDATE_TO_DISPOSITION_ACTION_DEFINITION);
    assertNotNull(pub);
    pub.publish(dad.getNodeRef());
}
Also used : PublishExecutorRegistry(org.alfresco.module.org_alfresco_module_rm.job.publish.PublishExecutorRegistry) PublishExecutor(org.alfresco.module.org_alfresco_module_rm.job.publish.PublishExecutor)

Aggregations

PublishExecutor (org.alfresco.module.org_alfresco_module_rm.job.publish.PublishExecutor)2 AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)1 PublishExecutorRegistry (org.alfresco.module.org_alfresco_module_rm.job.publish.PublishExecutorRegistry)1 RetryingTransactionHelper (org.alfresco.repo.transaction.RetryingTransactionHelper)1 RetryingTransactionCallback (org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback)1