如何以编程方式在AEM中启动转出过程?
感谢。
答案 0 :(得分:3)
这是一个代码片段,可以用于从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逻辑。一旦jsp逻辑被调用,推出就会在/content/geometrixx/in
实时拷贝中受到影响。
查看以下API以使用更多选项 RolloutManager,Trigger,RolloutParams
希望有所帮助
答案 1 :(得分:0)
经过一些研究,我发现了如何以编程方式启动部署:
在这个特定情况下,我是在工作流程中完成的:
@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);
}
}
这可以按预期工作,将页面推广到相关的实时副本