如何以编程方式在 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);
%>
测试此代码段
我已经创建了一个实时副本/content/geometrixx/en/
,/content/geometrixx/in
添加/更新了一些文本组件数据,如下所示
创建了一个仅用于调用此 jsp 逻辑的组件,该组件称为来自其他项目页面的 JSP 逻辑。/content/geometrixx/in
一旦调用了 jsp 逻辑, live 副本
中的推出就会受到影响。
查看以下 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