AEM 通过 java class 启动 Rollout

AEM launching a Rollout through a java class

如何以编程方式在 AEM 中启动推出流程?

谢谢。

这是一个代码片段,可用于从 JSP 级别推出,方法与您在 JAVA 级别的推出方式相同。

<%@page import="com.day.cq.wcm.msm.api.RolloutManager"%>

<% Page rolloutthispage = pageManager.getPage("/content/geometrixx/en/toolbar"); //source page
RolloutManager.RolloutParams rolloutparams = new RolloutManager.RolloutParams();
rolloutparams.master = rolloutthispage; 
rolloutparams.isDeep = true;
//rolloutmanager is an OSGI service so using here sling.getService to have a reference
com.day.cq.wcm.msm.api.RolloutManager rolloutManager = sling.getService(com.day.cq.wcm.msm.api.RolloutManager.class);
rolloutManager.rollout(rolloutparams);
%>

To Test this code snippet

我创建了一个从 /content/geometrixx/en//content/geometrixx/in 的 Live Copy Added/updated一些文本组件数据如下图

创建了一个仅用于调用此 jsp 逻辑的组件,调用了来自其他项目页面的 JSP 逻辑。一旦调用了 jsp 逻辑,/content/geometrixx/in Live Copy 中的部署就会受到影响。

查看以下 API 以使用更多选项 RolloutManager,Trigger,RolloutParams

希望对您有所帮助

经过一些研究,我找到了如何以编程方式启动发布:

在这个具体案例中,我是在工作流程中完成的:

        @Reference
        private RolloutManager rolloutManager;
        @Reference
        private ResourceResolverFactory resourceResolverFactory;

        private Session session;
        private ResourceResolver resolver;
        private PageManager pageManager;

        public class MyWorkflow implements WorkflowProcess {
            @Override
            public void execute(WorkItem workItem, WorkflowSession workflowSession, MetaDataMap dataMap) throws WorkflowException {
               //get the payload page from the workflow data
               WorkflowData workflowData = workItem.getWorkflowData();
               String payload = workflowData.getPayload().toString();

               final Map<String, Object> authInfo = new HashMap<String, Object>();
               authInfo.put(JcrResourceConstants.AUTHENTICATION_INFO_SESSION, workflowSession.getSession());
               resolver = resourceResolverFactory.getResourceResolver(authInfo);

               //Get Instance of PageManager
               pageManager = resolver.adaptTo(PageManager.class);
               final Page targetPage = pageManager.getPage(payload);

               final RolloutParams params = new RolloutParams();
               params.isDeep = false;
               params.master = targetPage;
               params.reset = false;
               params.trigger = RolloutManager.Trigger.ROLLOUT;
               params.delete = false;
               rolloutManager.rollout(params);

            }
        }

这按预期工作,将页面转至相关的 Live Copy