Search code examples
workflowaem

Rollout is not being executed when triggered through a custom workflow


We have custom workflow which has a process step to trigger rollout [Standard Rollout]. The process step is completing successful but with no rollout performed.

@Component(
    service = WorkflowProcess.class,
    property = {
        "service.description=Workflow description",
        "service.vendor=Project",
        "process.label=Project"
    }
)
public class RolloutProcessStep implements WorkflowProcess {

    private static final Logger LOG = LoggerFactory.getLogger(RolloutProcessStep.class);

    @Reference
    private ResourceResolverFactory resourceResolverFactory;

    @Reference
    private RolloutManager rolloutManager;

    public void execute(WorkItem item, WorkflowSession workflowSession, MetaDataMap args) throws WorkflowException {

        try (ResourceResolver resolver = resourceResolverFactory.getServiceResourceResolver(Collections.singletonMap(
            ResourceResolverFactory.SUBSERVICE, RolloutProcessStep.class.getName()))) {

            triggerRollout(path, resolver);

        } catch (LoginException e) {
            LOG.error("Error in getting the resolver. Aborting.", e);
            throw new WorkflowException("Error in getting the resolver.");
        } catch (Exception e) {
            LOG.error("Error in during the step. Aborting.", e);
            throw new WorkflowException("Error in during the Rollout Process Step.");
        }
    }

    private void triggerRollout(String path, ResourceResolver resolver) {

        Resource source = resolver.getResource(path);
        if (source == null) {
            return;
        }

        try {
            LiveRelationshipManager relationshipManager = resolver.adaptTo(LiveRelationshipManager.class);
            PageManager pageManager = resolver.adaptTo(PageManager.class);
            // Checks if the given source is the source of a Live Copy relationship.
            if (!relationshipManager.isSource(source)) {
                LOG.warn("Resource Not a valid source {}.", source);
                return;
            }

            Page page = pageManager.getPage(source.getPath());
            if (page == null) {
                LOG.warn("Failed to resolve source page {}.", source);
            }

            final RolloutManager.RolloutParams params = new RolloutManager.RolloutParams();
            params.master = page;
            params.isDeep = false;
            params.reset = false;
            params.trigger = RolloutManager.Trigger.ROLLOUT;
            LOG.info("RolloutParams {}.", params.toString());
            rolloutManager.rollout(params);
        } catch (WCMException e) {
            LOG.error("Failed to get live relationships.", e);

        }
    }
}

PS: We have the blueprints configured already and rollouts performed using touch UI is working as expected.

Please let me know if I'm missing anything.


Solution

  • Issue was resolved by providing permission to the service user to access this Process Step.