13
A
回答
16
经过一段时间,我写了一个运行工作流模型的servlet。
下面是评论代码:
@Component
@Service
@Properties({
@Property(name = "sling.servlet.paths", value = "/bin/runmodel"),
@Property(name = "sling.servlet.methods", value = "GET")
})
public class RunWorkflowModel extends SlingSafeMethodsServlet {
static private final Logger log = LoggerFactory.getLogger(RunWorkflowModel.class);
@Reference
private WorkflowService workflowService;
@Override
protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws IOException {
ResourceResolver resourceResolver = request.getResourceResolver();
Session session = resourceResolver.adaptTo(Session.class);
/* Get Parameters
* @param path = path you want to run the workflow on
* @param model = workflow model name you want to run. Typically found in /etc/workflow/models
*/
RequestParameterMap params = request.getRequestParameterMap();
String path = params.getValue("path").getString();
String model = params.getValue("model").getString();
// Create a workflow session
WorkflowSession wfSession = workflowService.getWorkflowSession(session);
try {
// Get the workflow model
WorkflowModel wfModel = wfSession.getModel(model);
// Get the workflow data
// The first param in the newWorkflowData method is the payloadType. Just a fancy name to let it know what type of workflow it is working with.
WorkflowData wfData = wfSession.newWorkflowData("JCR_PATH", path);
// Run the Workflow.
wfSession.startWorkflow(wfModel, wfData);
} catch (WorkflowException ex) {
response.getWriter().write("failed");
log.error("Error starting workflow.", ex);
}
response.getWriter().write("success");
}
}
这里是Ajax调用
CQ.Ext.Ajax.request({
url: "/bin/runmodel",
method: "GET",
params : {
"path" : "/content/path to item you want the workflow run on",
"model" : "/etc/workflow/models/name of model/jcr:content/model"
},
success: function() {
console.log("success");
},
failure: function(response) {
CQ.Notification.notifyFromResponse(response);
}
});
相关问题
- 1. 在liferay中以编程方式执行工作流转换?
- 2. 工作流程4运行时编译
- 3. 以编程方式创建SharePoint工作流程
- 4. 以编程方式取消SharePoint工作流程
- 5. 如何以编程方式在第二个工作台中的模型上运行Xpand工作流程?
- 6. 以编程方式在流程图工作流中创建分配
- 7. 从另一个工作流程中运行工作流程
- 8. 以编程方式创建流程图
- 9. 以编程方式运行Cakefile
- 10. Android |以编程方式运行命令
- 11. 以编程方式运行多个类
- 12. SharePoint 2007:以编程方式启动工作流命中错误
- 13. 以编程方式删除SharePoint工作流模板
- 14. 以编程方式生成工作流服务
- 15. 以root用户身份以编程方式运行C程序
- 16. 通过命令行以编程方式运行程序
- 17. 在SharePoint 2010中以编程方式创建网站工作流程?
- 18. 如何启动以编程方式上传的文件的工作流程
- 19. 以编程方式运行SQL Server 2000作业
- 20. 以编程方式运行Spring批处理作业?
- 21. npm运行脚本流程不工作
- 22. 在运行时显示工作流程
- 23. 使用Python运行Informatica工作流程
- 24. ASP.NET中的运行时工作流程
- 25. 以编程方式更改Excel工作表的行高
- 26. 编辑工作流程
- 27. Matlab:以编程方式运行Matlab应用程序
- 28. Node.js + Loopback:以编程方式运行远程挂钩
- 29. 以编程方式运行.net控制台应用程序
- 30. Python鼻子 - 以编程方式运行多进程
需要注意的是,因为这改变了服务器的状态,使用POST会更好。 – 2013-03-07 08:14:08
感谢您指出:) – Woodifer 2013-03-07 22:22:33