通过java代码触发Alfresco工作流程

发布于 2024-12-18 06:39:06 字数 215 浏览 4 评论 0原文

我想最好在servlet环境上开发一个应用程序。 我想从我的应用程序触发露天开箱即用工作流程网页脚本。 Alfresco 提供了用于执行此操作的 Restful URL。

谁能告诉我如何调用其余 URL 以从我的 java 代码调用 web 脚本。

任何人都可以给我一个示例代码或手册,因为我在网络服务方面的经验有限。

我需要清晰详细的解释..

谢谢

I want to develop an app preferbly on servlet environment .
I want to trigger alfresco out of box workflow webscripts from my app. Alfresco has provided restful URL for doing that.

can anyone tell me how do i invoke the rest URL to invoke the webscripts from my java code.

can anyone pls give me a sample code or manual for that as I have limited experience in webservice.

I need bit clear and detailed explaination..

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

朦胧时间 2024-12-25 06:39:06

您可以使用 Apache HTTP 客户端库来执行 RESTful(JSON 请求/帖子)。

以下是如何向 Alfresco 之类的服务器进行发布/获取的教程: RESTful Java 客户端

将示例 url 替换为工作流 REST API 中定义的 Alfresco url。
此外,在执行所有这些操作之前,您需要对 Alfresco 进行身份验证

  1. 使用相同的 HTTP 客户端示例获取带有 url http://localhost:8080/alfresco/service/api/login?u=admin&pw=admin 的票证,
  2. 您将得到如下响应: TICKET_887add1e01b5c4c0cd58ac11c768f8e54c1eabf4
  3. 将元素的票证值保存在 Java 变量中
  4. 将票证与工作流 REST API 服务之一一起使用,例如 http://localhost:8080/ alfresco/service/api/workflow-definitions 因此呈现票证如下: http://localhost:8080/alfresco/service/api/workflow-definitions?alf_ticket=TICKET_887add1e01b5c4c0cd58ac11c768f8e54c1eabf4
  5. 对结果做任何你想做的事情:)

You could use the Apache HTTP Client library to perform RESTful (JSON requests/posts).

Here is a tutorial how to do a post/get to an Alfresco like server: RESTful Java client

Replace the example url's with the Alfresco urls defined in the Workflow REST API.
Furthermore before you do all this, you need to authenticate to Alfresco.

  1. Use the same HTTP Client example to get the ticket with url http://localhost:8080/alfresco/service/api/login?u=admin&pw=admin
  2. You will get a response like: <ticket>TICKET_887add1e01b5c4c0cd58ac11c768f8e54c1eabf4</ticket>
  3. Save the ticket value of the element in a Java variable
  4. Use the ticket with one of the workflow REST API services e.g. http://localhost:8080/alfresco/service/api/workflow-definitions so present the Ticket like following: http://localhost:8080/alfresco/service/api/workflow-definitions?alf_ticket=TICKET_887add1e01b5c4c0cd58ac11c768f8e54c1eabf4
  5. Do whatever you'd like with the result :)
〃温暖了心ぐ 2024-12-25 06:39:06

请在此处查看工作流 REST API 的详细说明:http://wiki.alfresco.com/wiki/Workflow_REST_API

以下是如何启动工作流程的示例:http://wiki.alfresco.com/wiki/Workflow_REST_API#Post_Workflow_Instance

示例

使用 spring 调用 alfresco REST 服务:
http://tedwise.com/2010/06/ 14/访问-rest-services-from-spring-3/

Look here for detailed description of Workflow REST API: http://wiki.alfresco.com/wiki/Workflow_REST_API

Here's for example how to start a workflow: http://wiki.alfresco.com/wiki/Workflow_REST_API#Post_Workflow_Instance

Examples:

Calling alfresco REST services using spring:
http://tedwise.com/2010/06/14/accessing-rest-services-from-spring-3/

抱猫软卧 2024-12-25 06:39:06

Alfresco 不公开任何与工作流程相关的 SOAP Web 服务。工作流的首选远程接口是一组 Web 脚本,您可以在 http://your.alfresco.url/alfresco/service/index/uri/ 中列出:

/api/workflow/task/end/{taskId}
/api/workflow/task/end/{taskId}/{transitionId}
/api/workflow-definitions
/api/workflow-definitions/{workflow_definition_id}/workflow-instances
/api/workflow-instances
/api/workflow-instances/{workflow_instance_id}
/api/workflow-instances/{workflow_instance_id}/task-instances

请注意,这些 URL 非常多更像是 API 系列,并且这些链接将向您显示每个项目多个有效的远程 API 调用,可能响应不同的 HTTP 动词(例如 GET、POST、DELETE)或在 URL 模板中包含更多输入参数。

Alfresco doesn't expose any SOAP web service related to workflows. The preferred remote interface to workflows is a set of web scripts you can list at http://your.alfresco.url/alfresco/service/index/uri/ as:

/api/workflow/task/end/{taskId}
/api/workflow/task/end/{taskId}/{transitionId}
/api/workflow-definitions
/api/workflow-definitions/{workflow_definition_id}/workflow-instances
/api/workflow-instances
/api/workflow-instances/{workflow_instance_id}
/api/workflow-instances/{workflow_instance_id}/task-instances

Please note that those URLs are much more like families of APIs, and the links will show you more than one effective remote API call per item, possibly responding to different HTTP verbs (e.g. GET, POST, DELETE) or including more input parameters in the URL template.

巴黎盛开的樱花 2024-12-25 06:39:06

以下是实现此目的的示例 Web 脚本。 调用该脚本

可以使用 URL http://;:/alfresco/service/workflows/approveandreview/start/

这将启动审核和审核批准 URL 中的路径指定的节点上的工作流(/start 之后)。

您可以使用 Apache HTTPClient 从 Java 代码调用 URL。

StartWorkflow.get.desc.xml

<webscript>
  <shortname>Start Review and Approve Workflow</shortname>
  <description>Script to start Review and Approve Workflow on a Node</description>
  <url>/workflows/approveandreview/start/{path}</url>
  <format default="xml">argument</format>
  <authentication>user</authentication>
  <transaction>required</transaction>
</webscript>

StartWorkflow.get.js

// Get the node on which workflow is to be started
var theNode = roothome.childByNamePath(url.extension);

logger.log("theNode=" + theNode);

if (theNode == undefined) {
    status.code = 404;
    status.message = "Node at " + url.extension + " does not exist";
    status.redirect = true;
}
else if (theNode.isContainer) {
    status.code = 404;
    status.message = "Node at " + url.extension + " is not a content node";
    status.redirect = true;
}
else {
    var workflowPackage = workflow.createPackage();
    workflowPackage.addNode(theNode);
    var workflowDef = workflow.getDefinitionByName("activiti$activitiReview");
    var parameters = new Object();
    parameters["bpm:assignee"] = person;
    var workflowPath = workflowDef.startWorkflow(workflowPackage, parameters);

    if (workflowPath == undefined) {
        status.code = 500;
        status.message = "Error starting workflow";
        status.redirect = true;
    }

    status.message = "Done";
}

StartWorkflow.get.xml.ftl

<?xml version="1.0" encoding="UTF-8"?>
<approveandreview>
    <status>${status.code}</status>
    <message>${status.message}</message>
</approveandreview>

希望这有帮助。如果有任何问题请告诉我。

Here is a sample Web Script to achieve this. The script can can be invoked using the URL

http://<server>:<port>/alfresco/service/workflows/approveandreview/start/

This will start the Review & Approve workflow on the node specified by the path in the URL (after /start).

You can use Apache HTTPClient to call the URL from Java code.

StartWorkflow.get.desc.xml

<webscript>
  <shortname>Start Review and Approve Workflow</shortname>
  <description>Script to start Review and Approve Workflow on a Node</description>
  <url>/workflows/approveandreview/start/{path}</url>
  <format default="xml">argument</format>
  <authentication>user</authentication>
  <transaction>required</transaction>
</webscript>

StartWorkflow.get.js

// Get the node on which workflow is to be started
var theNode = roothome.childByNamePath(url.extension);

logger.log("theNode=" + theNode);

if (theNode == undefined) {
    status.code = 404;
    status.message = "Node at " + url.extension + " does not exist";
    status.redirect = true;
}
else if (theNode.isContainer) {
    status.code = 404;
    status.message = "Node at " + url.extension + " is not a content node";
    status.redirect = true;
}
else {
    var workflowPackage = workflow.createPackage();
    workflowPackage.addNode(theNode);
    var workflowDef = workflow.getDefinitionByName("activiti$activitiReview");
    var parameters = new Object();
    parameters["bpm:assignee"] = person;
    var workflowPath = workflowDef.startWorkflow(workflowPackage, parameters);

    if (workflowPath == undefined) {
        status.code = 500;
        status.message = "Error starting workflow";
        status.redirect = true;
    }

    status.message = "Done";
}

StartWorkflow.get.xml.ftl

<?xml version="1.0" encoding="UTF-8"?>
<approveandreview>
    <status>${status.code}</status>
    <message>${status.message}</message>
</approveandreview>

Hope this helps. Let me know if any issues.

苍暮颜 2024-12-25 06:39:06

根据 Tahir 的建议,您可以在下面找到带有 jar 的示例。它将提供主文件夹和子文件夹的响应。您可以输入各自的网址来获取 Jason 回复。

https://drive.google.com/file/d/0B9B1NsG0lyx6Tno2d1F6RElrTk0/edit ?usp=共享

The example with jar you can find below as per Tahir suggestion. It will provide response for home folder and subfolder. You can put your respective url to get jason response.

https://drive.google.com/file/d/0B9B1NsG0lyx6Tno2d1F6RElrTk0/edit?usp=sharing

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文