Activiti REST原则
安装
Activiti包含一个Activiti引擎的REST API:
把activiti-rest.war 部署到Apache Tomcat 这样的servlet 容器就可以使用
也可以使用在其他web 应用中,把activiti-rest 的依赖都加入classpath, 添加servlet, 并映射到应用中
默认情况下,Activiti引擎会连接内存数据库H2. 可以修改WEB-INF/classes 目录下的db.properties 来修改数据库设置
REST API 使用JSON格式 ,是基于Restlet 开发的
认证
默认所有REST资源都需要先使用有效的Activiti用户认证后才能使用
会使用Basic HTTP 认证:
要一直在请求的HTTP 头中包含一个Authorization: Basic …== 属性
在请求url 中包含用户名和密码 :http://username:password@localhost…
建议把Basic认证与HTTPS一起使用
可以从删除对应资源的认证,添加额外的授权给一个认证的用户(比如把用户加入一个组,让它可以执行URL).可以使用org.activiti.rest.common.filter.RestAuthenticator 的实现,有两种方法:
boolean requestRequiresAuthentication(Request request):
在请求认证检查之前调用
通过头部传递合法的账号和密码:
如果方法返回true, 这个方法就需要认证才能访问
如果返回false, 无论请求是否认证都可以访问
如果返回false, 就不会为这个方法调用isRequestAuthorized
boolean isRequestAuthorized(Request request):
在用户已经通过activiti账号管理认证后,请求实际之前调用
可以用来检查认证用户是否可以访问对应请求:
如果返回true, 会允许请求执行
如果返回false, 请求不会执行,客户端会收到对应的错误
自定义的RestAuthenticator 应该设置到RestletServlet 的org.activiti.rest.service.application.ActivitiRestServicesApplication 中
最简单的方法是创建ActivitiRestServicesApplication 的子类,并在servlet-mapping 中设置自定义的类名:
< servlet>
< servlet-name> RestletServlet</ servlet-name>
< servlet-class> org.restlet.ext.servlet.ServerServlet</ servlet-class>
< init-param>
< param-name> org.restlet.application</ param-name>
< param-value> com.my.company.CustomActivitiRestServicesApplication</ param-value>
</ init-param>
</ servlet>
Tomcat使用
根据Tomcat的默认安全配置:
这可能对部署资源和数据URL造成影响,URL可能会包含转移的前斜线
当出现预期外的400问题,设置下面这个系统参数:
Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true
REST方法
方法
操作
GET
获得一个资源或获得多个资源
POST
创建一个新资源(不常用:当请求结果太复杂,无法放到GET请求的URL中,也用来查询资源)
PUT
更新已有资源的属性(也用来调用现存资源的功能)
DELETE
删除现存资源
响应码
描述
200 - Ok
操作成功,响应返回:GET 和PUT 请求
201 - Created
操作成功,实体已创建,并返回到响应体中:POST 请求
204 - No content
操作成功,实体已删除,不会返回响应体:DELETE 请求
401 - Unauthorized
操作失败.操作要求设置Authentication 头部.如果请求中已经设置了头部,对应的凭证是无效的或者用户不允许执行这个操作
403 - Forbidden
禁止操作,不要重试.这不是认证和授权的问题,这是禁止操作:删除一个执行中流程的任务是不允许的,无论用户或流程任务的状态是什么
404 - Not found
操作失败.找不到请求的资源
405 - Method not allowed
操作失败,使用的资源方法不允许调用:想更新PUT 已部署的资源会返回405结果
409 - Conflict
操作失败.更新其他操作应更新的资源,会导致更新不合法.也可以表示一个集合中新创建的资源id已经存在
415 - Unsupported Media Type
操作失败.请求体包含了不支持的媒体类型.当请求体的JSON 中包含未知的属性或值时,也会返回这个响应,一般是因为无法处理的错误格式或类型
500 - Internal server error
操作失败.执行操作时出现了预期外的异常-一般是代码出错.响应体中包含错误的细节
media-type 和HTTP 响应永远都是application/json
只有需要使用二进制内容:发布资源数据,才会使用内容的media-type
错误响应体
当发生错误时 (包括客户端和服务端,4XX和5XX状态码), 响应体会包含描述发生错误的描述
任务不存在时出现的404状态:
{
"statusCode" : 404 ,
"errorMessage" : "Could not find a task with id '444'."
}
请求参数
URL片段
url上的参数都需要转义:比如http://host/actviti-rest/service/repository/deployments/{deploymentId}的deploymentId
特别是对于可能包含前斜线 (部署资源)的情况
大多数框架都有这种内置功能,但要把这个问题考虑在内
Rest URL查询参数
设置在URL中的查询参数:
http://host/activiti-rest/service/deployments?name=Deployment中的name 参数
URL查询参数类型如下,对应着REST-API文档:
类型
格式
String
纯文本参数.可以包含任何URL允许的合法的字符.对于XXXLike 参数,字符串应该包含通配符% (要通过url编码),可以指定模糊搜索 的意图:比如’Tas%'匹配所有以’Tas’开头的值
Integer
整数参数.只能包含非小数 的整数值.在 -2.147.483.648 与2.147.483.647 之间
Long
长整型参数.只能包含非小数 的长整型值.在 -9.223.372.036.854.775.808 与9.223.372.036.854.775.807 之间
Boolean
布尔类型参数.可以是true或false.如果使用了其他值, 会返回405 - Bad request 响应
Date
日期类型.使用ISO-8601 日期格式,用于时间和日期组件:比如2013-04-03T23:45Z
JSON内容参数
类型
格式
String
纯文本参数.可以包含任何URL允许的合法的字符.对于XXXLike 参数,字符串应该包含通配符% (要通过url编码),可以指定模糊搜索 的意图:比如’Tas%'匹配所有以’Tas’开头的值
Integer
整数参数.只能包含非小数 的整数值.在 -2.147.483.648 与2.147.483.647 之间
Long
长整型参数.只能包含非小数 的长整型值.在 -9.223.372.036.854.775.808 与9.223.372.036.854.775.807 之间
Boolean
布尔类型参数.可以是true或false.如果使用了其他值, 会返回405 - Bad request 响应
Date
日期类型.使用ISO-8601 日期格式,用于时间和日期组件:比如2013-04-03T23:45Z
分页与排序
分页与排序参数可以添加到URL 的query-string 中
http://host/activiti-rest/service/deployments?sort=name中的name 参数
查询JSON参数类型:
参数
默认值
描述
sort
根据查询实现而不同
查询的名称.对于不同的查询实现,默认值也不同
order
asc(升序)
排序的方式.可以为asc(升序) 或desc(降序)
start
0
分页查询开始的值,即从第几条数据起开始查询,第一条为0.默认从0开始
size
10
分页查询每页显示的记录数.默认为10
JSON查询变量格式
{
"name" : "variableName" ,
"value" : "variableValue" ,
"operation" : "equals" ,
"type" : "string"
}
参数
是否必须
描述
name
否
查询包含的变量名称.在一些查询中使用equals 查询对应资源的所有值时,可以为空
value
是
查询包含的变量值,要包含给定类型的正确格式
operation
是
查询使用的参数,可以是以下值:equals, notEquals, equalsIgnoreCase, notEqualsIgnoreCase, lessThan, greaterThan, lessThanOrEquals, greaterThanOrEquals和like
type
否
使用的变量的类型.如果省略,类型会根据value 参数决定.所以JSON文本值 都会对应string 类型 ,JSON布尔型 对应boolean,JSON数字型 根据数字的长度对应long 或integer 在不确定时,建议使用精确的类型
类型
描述
string
对应java.lang.String
short
对应java.lang.Integer
integer
对应java.lang.Integer
long
对应java.lang.Long
double
对应java.lang.Double
boolean
对应java.lang.Boolean
date
对应java.util.Date.JSON字符串会使用ISO-8601 格式进行转换
变量格式
在使用变量时(执行,流程和任务)REST API使用一些通用原则和JSON格式实现读写
变量的JSON格式如下所示:
{
"name" : "variableName" ,
"value" : "variableValue" ,
"valueUrl" : "http://..." ,
"scope" : "local" ,
"type" : "string"
}
参数
是否必须
描述
name
是
变量名称
value
否
变量值.写入变量时,如果没有设置value,会认为值是null
valueUrl
否
当读取变量的类型为binary 或serializable 时,这个属性会指向获取原始二进制数据的URL
scope
否
变量的范围.如果为local, 变量会对应到请求的资源.如果为global, 变量会定义到请求资源的上级(或上级树的任何上级).当写入变量,没有设置scope 时,默认使用global
type
否
变量类型.当写入变量,没有设置类型时,会根据请求的JSON属性来推断它的类型,限制为string,double,integer和boolean.如果不确定会用到的类型,建议还是要设置一个类型
类型名
描述
string
对应java.lang.String.写入时使用JSON文本
integer
对应java.lang.Integer.写入时,先使用JSON数字进行转换,如果失败就使用JSON文本
short
对应java.lang.Short.写入时,先使用JSON数字进行转换,如果失败就使用JSON文本
long
对应java.lang.Long.写入时,先使用JSON数字进行转换,如果失败就使用JSON文本
double
对应java.lang.Double.写入时,先使用JSON数字进行转换,如果失败就使用JSON文本
boolean
对应java.lang.Boolean.写入时,使用JSON布尔进行转换
date
对应java.util.Date.写入时,使用ISO-8601日期格式转换为JSON文本
binary
二进制变量,对应字节数组.value属性为null,valueUrl包含指向原始二进制流的URL
serializable
可序列化的Java对象序列化后的结果.和binary类型相同,value属性为null,valueUrl包含指向原始二进制流的URL.所有可以序列化变量(上面不包含的类型)都会使用这个类型
可以通过自定义JSON格式来支持更多变量类型:
扩展org.activiti.rest.api.RestResponseFactory 的initializeVariableConverters() 方法
可以添加自定义的org.activiti.rest.api.service.engine.variable.RestVariableConverter 类来支持POJO与对应REST数据的相互转换
实际的JSON转换是通过Jackson实现的
部署
部署列表
GET repository/deployments
参数
是否必须
值
描述
name
否
String
只返回指定名称的部署
nameLike
否
String
只返回名称与指定值相似的部署
category
否
String
只返回指定分类的部署
categoryNotEquals
否
String
只返回与指定分类不同的部署
tenantId
否
String
只返回指定tenantId的部署
tenantIdLike
否
String
只返回与指定tenantId值相似的部署
withoutTenantId
否
Boolean
如果为 true, 只返回没有设置tenantId的部署. 如果为false, 忽略 withoutTenantId参数
sort
否
id(默认),name,deploytime或tenantId
排序属性,与order一起使用
sort的通用分页和排序查询参数都可以使用
200 请求成功
{
"data" : [
{
"id" : "10" ,
"name" : "activiti-examples.bar" ,
"deploymentTime" : "2010-10-13T14:54:26.750+02:00" ,
"category" : "examples" ,
"url" : "http://localhost:8081/service/repository/deployments/10" ,
"tenantId" : null
}
] ,
"total" : 1 ,
"start" : 0 ,
"sort" : "id" ,
"order" : "asc" ,
"size" : 1
}
获取一个部署
GET repository/deployments/{deploymentId}
参数
是否必须
值
描述
deploymentId
是
String
获取部署的id
响应码
描述
200
表示找到了部署,并返回相应的部署
404
表示找不到请求的部署
{
"id" : "10" ,
"name" : "activiti-examples.bar" ,
"deploymentTime" : "2010-10-13T14:54:26.750+02:00" ,
"category" : "examples" ,
"url" : "http://localhost:8081/service/repository/deployments/10" ,
"tenantId" : null
}
创建新部署
POST repository/deployments
请求体:
请求体包含的数据类型应该是multipart 或者form-data
请求里应该只包含一个文件, 其他额外的任务都会被忽略
部署的名称就是文件域的名称
如果需要在一个部署中包含多个资源,把这些文件压缩成zip 包,并要确认文件名是以 .bar 或 .zip 结尾
可以在请求体中传递一个额外的参数(表单域)tenantId.字段的值会用来设置部署的租户id
创建新部署-响应码:
响应码
描述
201
表示部署已经创建成功
400
表示请求内没有内容,或部署不支持内容的mime-type.在状态描述中包含更新信息
{
"id" : "10" ,
"name" : "activiti-examples.bar" ,
"deploymentTime" : "2010-10-13T14:54:26.750+02:00" ,
"category" : null ,
"url" : "http://localhost:8081/service/repository/deployments/10" ,
"tenantId" : "myTenant"
}
删除部署
DELETE repository/deployments/{deploymentId}
参数
是否必须
类型
描述
deploymentId
是
String
输出部署的Id
响应码
描述
204
表示找到了部署并已经删除.响应体为空
404
表示没有找到请求的部署
列出部署资源
GET repository/deployments/{deploymentId}/resources
参数
是否必须
类型
描述
deploymentId
是
String
获取的资源的部署的Id
响应码
描述
200
表示找到了部署,并返回资源列表
404
表示找不到请求的部署
{
"id" : "diagrams/my-process.bpmn20.xml" ,
"url" : "http://localhost:8081/activiti-rest/service/repository/deployments/10/resources/diagrams%2Fmy-process.bpmn20.xml" ,
"dataUrl" : "http://localhost:8081/activiti-rest/service/repository/deployments/10/resourcedata/diagrams%2Fmy-process.bpmn20.xml" ,
"mediaType" : "text/xml" ,
"type" : "processDefinition"
} ,
{
"id" : "image.png" ,
"url" : "http://localhost:8081/activiti-rest/service/repository/deployments/10/resources/image.png" ,
"dataUrl" : "http://localhost:8081/activiti-rest/service/repository/deployments/10/resourcedata/image.png" ,
"mediaType" : "image/png" ,
"type" : "resource"
}
mediaType: 包含资源的media-type.
这是使用(可插拔的)MediaTypeResolver 处理的,默认已经支持了一些有限的mime-type 映射
type: 资源类型
resource: 原始资源
processDefinition: 包含一个或多个流程定义的资源,会被发布器处理
processImage: 展示一个已发布流程定义的图形布局
结果json 中的dataUrl 属性包含了用来获取二进制资源 的真实URL
获取部署资源
GET repository/deployments/{deploymentId}/resources/{resourceId}
参数
是否必须
类型
描述
deploymentId
是
String
获取资源的部署Id,部署Id是请求资源的一部分
resourceId
是
String
获取资源的Id,确保URL对资源Id进行编码的情况下,包含斜杠.比如:使用 ‘diagrams%2Fmy-process.bpmn20.xml’ 代替 ‘diagrams/Fmy-process.bpmn20.xml’
响应码
描述
200
表示部署和资源都已经找到并且部署的资源已经成功返回
404
表示请求的部署并没有找到或者目前的部署对象并没有该资源Id.状态描述还包含一些额外信息
{
"id" : "diagrams/my-process.bpmn20.xml" ,
"url" : "http://localhost:8081/activiti-rest/service/repository/deployments/10/resources/diagrams%2Fmy-process.bpmn20.xml" ,
"dataUrl" : "http://localhost:8081/activiti-rest/service/repository/deployments/10/resourcedata/diagrams%2Fmy-process.bpmn20.xml" ,
"mediaType" : "text/xml" ,
"type" : "processDefinition"
}
mediaType: 包含资源的media-type.
这是使用(可插拔的)MediaTypeResolver 处理的,默认已经支持了一些有限的mime-type 映射
type: 资源类型
resource: 原始资源
processDefinition: 包含一个或多个流程定义的资源,会被发布器处理
processImage: 展示一个已发布流程定义的图形布局
结果json 中的dataUrl 属性包含了用来获取二进制资源 的真实URL
获取部署资源内容
GET repository/deployments/{deploymentId}/resourcedata/{resourceId}
参数
是否必须
类型
描述
deploymentId
是
String
获取资源的部署Id,部署Id是请求资源的一部分
resourceId
是
String
获取资源的Id,确保URL对资源Id进行编码的情况下,包含斜杠.比如:使用 ‘diagrams%2Fmy-process.bpmn20.xml’ 代替 ‘diagrams/Fmy-process.bpmn20.xml’
响应码
描述
200
表示部署和资源都已经找到并且部署的资源已经成功返回
404
表示请求的部署并没有找到或者目前的部署对象并没有该资源Id.状态描述还包含一些额外信息
成功响应体:
根据请求的资源响应体将包含二进制的资源内容:
响应体的content-type 的mimeType 属性将会和资源的返回类型相同
响应头设置content-disposition, 允许浏览器下载该文件而不是去显示
流程定义
流程定义列表
GET repository/process-definitions
参数
是否必须
类型
描述
version
否
Integer
只返回给定版本的流程定义
name
否
String
只返回给定名称的流程定义
nameLike
否
String
只返回与给定名称匹配相似的流程定义
key
否
String
只返回给定key的流程定义
keyLike
否
String
只返回与给定key匹配相似的流程定义
resourceName
否
String
只返回给定资源名称的流程定义
resourceNameLike
否
String
只返回与给定资源名称匹配相似的流程定义
category
否
String
只返回给定分类的流程定义
categoryLike
否
String
只返回与给定分类匹配相似的流程定义
categoryNotEquals
否
String
只返回非给定分类的流程定义
deploymentId
否
String
只返回包含在与给定Id一致的部署中的流程定义
startableByUser
否
String
只返回给定用户可以启动的流程定义
latest
否
Boolean
只返回最新的流程定义版本.只能与key 或keyLike 参数一起使用,如果使用了其它参数会返回400 的响应
suspended
否
Boolean
如果为true,只返回挂起的流程定义.如果为false,只返回活动的即未挂起的流程定义
sort
否
name(默认),id,key,category,deploymentId和version
排序的属性,可以与order一起使用
sort的通用分页和排序查询参数都可以使用
响应码
描述
200
表示请求成功,流程定义已返回
404
表示传递的参数格式错误,或latest 与key,keyLike 之外的其他参数一起使用了.状态信息包含更多信息
{
"data" : [
{
"id" : "oneTaskProcess:1:4" ,
"url" : "http://localhost:8182/repository/process-definitions/oneTaskProcess%3A1%3A4" ,
"version" : 1 ,
"key" : "oneTaskProcess" ,
"category" : "Examples" ,
"suspended" : false ,
"name" : "The One Task Process" ,
"description" : "This is a process for testing purposes" ,
"deploymentId" : "2" ,
"deploymentUrl" : "http://localhost:8081/repository/deployments/2" ,
"graphicalNotationDefined" : true ,
"resource" : "http://localhost:8182/repository/deployments/2/resources/testProcess.xml" ,
"diagramResource" : "http://localhost:8182/repository/deployments/2/resources/testProcess.png" ,
"startFormDefined" : false
}
] ,
"total" : 1 ,
"start" : 0 ,
"sort" : "name" ,
"order" : "asc" ,
"size" : 1
}
graphicalNotationDefined: 表示流程定义包含图形信息(BPMN DI)
resource: 包含实际部署的BPMN 2.0 xml
diagramResource: 包含流程的图形内容,如果没有图形就返回null
获得流程定义
GET repository/process-definitions/{processDefinitionId}
参数
是否必须
值
描述
processDefinitionId
是
String
需要获取的流程定义的Id
响应码
描述
200
表示获得到流程定义,并返回获得到的流程定义
404
表示找不到请求的流程定义
{
"id" : "oneTaskProcess:1:4" ,
"url" : "http://localhost:8182/repository/process-definitions/oneTaskProcess%3A1%3A4" ,
"version" : 1 ,
"key" : "oneTaskProcess" ,
"category" : "Examples" ,
"suspended" : false ,
"name" : "The One Task Process" ,
"description" : "This is a process for testing purposes" ,
"deploymentId" : "2" ,
"deploymentUrl" : "http://localhost:8081/repository/deployments/2" ,
"graphicalNotationDefined" : true ,
"resource" : "http://localhost:8182/repository/deployments/2/resources/testProcess.xml" ,
"diagramResource" : "http://localhost:8182/repository/deployments/2/resources/testProcess.png" ,
"startFormDefined" : false
}
graphicalNotationDefined: 表示流程定义包含图形信息 (BPMN DI)
resource: 包含实际部署的BPMN 2.0 xml
diagramResource: 包含流程的图形内容,如果没有图形就返回null
更新流程定义分类
PUT repository/process-definitions/{processDefinitionId}
{
"category" : "updatedcategory"
}
响应码
描述
200
表示已经修改了流程的分类
400
表示请求体中没有传递分类
404
表示找不到请求的流程定义
{
"id" : "oneTaskProcess:1:4" ,
"url" : "http://localhost:8182/repository/process-definitions/oneTaskProcess%3A1%3A4" ,
"version" : 1 ,
"key" : "oneTaskProcess" ,
"category" : "Examples" ,
"suspended" : false ,
"name" : "The One Task Process" ,
"description" : "This is a process for testing purposes" ,
"deploymentId" : "2" ,
"deploymentUrl" : "http://localhost:8081/repository/deployments/2" ,
"graphicalNotationDefined" : true ,
"resource" : "http://localhost:8182/repository/deployments/2/resources/testProcess.xml" ,
"diagramResource" : "http://localhost:8182/repository/deployments/2/resources/testProcess.png" ,
"startFormDefined" : false
}
graphicalNotationDefined: 表示流程定义包含图形信息 (BPMN DI)
resource: 包含实际部署的BPMN 2.0 xml
diagramResource: 包含流程的图形内容,如果没有图形就返回null
获得流程定义资源内容
GET repository/process-definitions/{processDefinitionId}/resourcedata
参数
是否必须
类型
描述
processDefinitionId
是
String
需要获得资源数据的流程定义的Id
成功响应体:
根据请求的资源响应体将包含二进制的资源内容:
响应体的content-type 的mimeType 属性将会和资源的返回类型相同
响应头设置content-disposition, 允许浏览器下载该文件而不是去显示
获得流程定义BPMN模型
GET repository/process-definitions/{processDefinitionId}/model
参数
是否必须
类型
描述
processDefinitionId
是
String
需要获得资源数据的流程定义的Id
响应码
描述
200
表示已找到流程定义,并返回了模型
404
表示找不到请求的流程定义
成功响应体:
响应体是一个转换为JSON 格式的org.activiti.bpmn.model.BpmnModel, 包含整个流程定义模型
{
"processes" : [
{
"id" : "oneTaskProcess" ,
"xmlRowNumber" : 7 ,
"xmlColumnNumber" : 60 ,
"extensionElements" : {
} ,
"name" : "The One Task Process" ,
"executable" : true ,
"documentation" : "One task process description" ,
...
] ,
...
}
暂停流程定义
PUT repository/process-definitions/{processDefinitionId}
{
"action" : "suspend" ,
"includeProcessInstances" : "false" ,
"date" : "2013-04-15T00:42:12Z"
}
参数
是否必须
描述
action
是
执行的动作 :activate 或suspend, 这里执行暂停使用suspend
includeProcessInstances
否
是否把流程定义下正在运行的流程实例也暂停或激活.如果忽略,不改变流程实例的状态
date
否
执行暂停或激活的日期(ISO-8601格式).如果忽略,会立即执行暂停或激活
响应码
描述
200
表示暂停流程成功
404
表示找不到请求的流程定义
409
表示请求的流程定义已经暂停
{
"id" : "oneTaskProcess:1:4" ,
"url" : "http://localhost:8182/repository/process-definitions/oneTaskProcess%3A1%3A4" ,
"version" : 1 ,
"key" : "oneTaskProcess" ,
"category" : "Examples" ,
"suspended" : false ,
"name" : "The One Task Process" ,
"description" : "This is a process for testing purposes" ,
"deploymentId" : "2" ,
"deploymentUrl" : "http://localhost:8081/repository/deployments/2" ,
"graphicalNotationDefined" : true ,
"resource" : "http://localhost:8182/repository/deployments/2/resources/testProcess.xml" ,
"diagramResource" : "http://localhost:8182/repository/deployments/2/resources/testProcess.png" ,
"startFormDefined" : false
}
graphicalNotationDefined: 表示流程定义包含图形信息 (BPMN DI)
resource: 包含实际部署的BPMN 2.0 xml
diagramResource: 包含流程的图形内容,如果没有图形就返回null
激活流程定义
PUT repository/process-definitions/{processDefinitionId}
{
"action" : "activate" ,
"includeProcessInstances" : "true" ,
"date" : "2013-04-15T00:42:12Z"
}
参数
是否必须
描述
action
是
执行的动作 :activate 或suspend, 这里执行激活使用activate
includeProcessInstances
否
是否把流程定义下正在运行的流程实例也暂停或激活.如果忽略,不改变流程实例的状态
date
否
执行暂停或激活的日期(ISO-8601格式).如果忽略,会立即执行暂停或激活
响应码
描述
200
表示激活流程成功
404
表示找不到请求的流程定义
409
表示请求的流程定义已经激活
{
"id" : "oneTaskProcess:1:4" ,
"url" : "http://localhost:8182/repository/process-definitions/oneTaskProcess%3A1%3A4" ,
"version" : 1 ,
"key" : "oneTaskProcess" ,
"category" : "Examples" ,
"suspended" : false ,
"name" : "The One Task Process" ,
"description" : "This is a process for testing purposes" ,
"deploymentId" : "2" ,
"deploymentUrl" : "http://localhost:8081/repository/deployments/2" ,
"graphicalNotationDefined" : true ,
"resource" : "http://localhost:8182/repository/deployments/2/resources/testProcess.xml" ,
"diagramResource" : "http://localhost:8182/repository/deployments/2/resources/testProcess.png" ,
"startFormDefined" : false
}
graphicalNotationDefined: 表示流程定义包含图形信息 (BPMN DI)
resource: 包含实际部署的BPMN 2.0 xml
diagramResource: 包含流程的图形内容,如果没有图形就返回null
获得流程定义所有候选启动者
GET repository/process-definitions/{processDefinitionId}/identitylinks
参数
是否必须
类型
描述
processDefinitionId
是
String
需要获得IdentityLink 的流程定义Id
响应码
描述
200
表示已找到流程定义,并返回请求的IdentityLink
404
表示找不到请求的流程定义
[
{
"url" : "http://localhost:8182/repository/process-definitions/oneTaskProcess%3A1%3A4/identitylinks/groups/admin" ,
"user" : null ,
"group" : "admin" ,
"type" : "candidate"
} ,
{
"url" : "http://localhost:8182/repository/process-definitions/oneTaskProcess%3A1%3A4/identitylinks/users/kermit" ,
"user" : "kermit" ,
"group" : null ,
"type" : "candidate"
}
]
流程定义添加一个候选启动者
POST repository/process-definitions/{processDefinitionId}/identitylinks
参数
是否必须
类型
描述
processDefinitionId
是
String
流程定义的Id
{
"user" : "kermit"
}
{
"groupId" : "sales"
}
响应码
描述
201
表示找到流程定义,并创建了IdentityLink
404
表示找不到请求的流程定义
{
"url" : "http://localhost:8182/repository/process-definitions/oneTaskProcess%3A1%3A4/identitylinks/users/kermit" ,
"user" : "kermit" ,
"group" : null ,
"type" : "candidate"
}
删除流程定义候选启动者
DELETE repository/process-definitions/{processDefinitionId}/identitylinks/{family}/{identityId}
参数
是否必须
类型
描述
processDefinitionId
是
String
流程定义Id
family
是
String
users 或groups, 依赖IdentityLink 的类型
identityId
是
String
需要删除的候选启动者身份的userId 或groupId
响应码
描述
204
表示找到了流程定义,并删除了IdentityLink. 响应体为空
404
表示找不到请求的流程定义,或者在流程定义中找不到与url 匹配的IdentityLink
获得流程定义一个候选启动者
GET repository/process-definitions/{processDefinitionId}/identitylinks/{family}/{identityId}
参数
是否必须
类型
描述
processDefinitionId
是
String
流程定义Id
family
是
String
users 或groups, 依赖IdentityLink 的类型
identityId
是
String
需要删除的候选启动者身份的userId 或groupId
响应码
描述
204
表示找到流程定义,并返回了IdentityLink
404
表示找不到请求的流程定义,或者在流程定义中找不到与url 匹配的IdentityLink
{
"url" : "http://localhost:8182/repository/process-definitions/oneTaskProcess%3A1%3A4/identitylinks/users/kermit" ,
"user" : "kermit" ,
"group" : null ,
"type" : "candidate"
}
模型
获得模型列表
GET repository/models
参数
是否必须
类型
描述
id
否
String
只返回指定id的模型
category
否
String
只返回指定分类的模型
categoryLike
否
String
只返回与给定分类匹配相似的模型.使用 % 作为通配符
categoryNotEquals
否
String
只返回非指定分类的模型
name
否
String
只返回指定名称的模型
nameLike
否
String
只返回与指定名称匹配相似的模型.使用 % 作为通配符
key
否
String
只返回指定key的模型
deploymentId
否
String
只返回包含在指定部署包中的模型
version
否
Integer
只返回指定版本的模型
latestVersion
否
Boolean
如果为true, 只返回最新版本的模型.最好与key 一起使用.如果为false, 就会返回所有版本
deployed
否
Boolean
如果为true,只返回已部署的模型.如果为 false, 只返回未部署的模型并且deploymentId 为null
tenantId
否
String
只返回指定tenantId的模型
tenantIdLike
否
String
只返回与指定tenantId匹配相似的模型
withoutTenantId
否
Boolean
如果为true, 只返回没有设置tenantId 的模型.如果为false, 会忽略withoutTenantId 参数
sort
否
id(默认),category,createTime,key,lastUpdateTime,name,version或tenantId
排序的字段,和order 一起使用
可以使用通用的分页和排序查询参数
响应码
描述
200
表示请求成功,并返回模型
400
表示传递的参数格式错误.状态信息中包含更多信息
{
"data" : [
{
"name" : "Model name" ,
"key" : "Model key" ,
"category" : "Model category" ,
"version" : 2 ,
"metaInfo" : "Model metainfo" ,
"deploymentId" : "7" ,
"id" : "10" ,
"url" : "http://localhost:8182/repository/models/10" ,
"createTime" : "2013-06-12T14:31:08.612+0000" ,
"lastUpdateTime" : "2013-06-12T14:31:08.612+0000" ,
"deploymentUrl" : "http://localhost:8182/repository/deployments/7" ,
"tenantId" : null
} ,
...
] ,
"total" : 2 ,
"start" : 0 ,
"sort" : "id" ,
"order" : "asc" ,
"size" : 2
}
更新模型
PUT repository/models/{modelId}
{
"name" : "Model name" ,
"key" : "Model key" ,
"category" : "Model category" ,
"version" : 1 ,
"metaInfo" : "Model metainfo" ,
"deploymentId" : "2" ,
"tenantId" : "tenant"
}
所有请求参数都是可选的
可以只在请求体的JSON 对象中包含name 属性,只更新模型的名称,其它的字段都不会受到影响
如果显示包含了一个属性,并设置为null, 模型值会被更新为null. 比如:{“metaInfo” : null} 会清空模型的metaInfo
更新模型-响应码:
响应码
描述
200
表示找到模型,并成功更新
404
表示找不到请求的模型
{
"id" : "5" ,
"url" : "http://localhost:8182/repository/models/5" ,
"name" : "Model name" ,
"key" : "Model key" ,
"category" : "Model category" ,
"version" : 2 ,
"metaInfo" : "Model metainfo" ,
"deploymentId" : "2" ,
"deploymentUrl" : "http://localhost:8182/repository/deployments/2" ,
"createTime" : "2013-06-12T12:31:19.861+0000" ,
"lastUpdateTime" : "2013-06-12T12:31:19.861+0000" ,
"tenantId" : "" updatedTenant"
}
新建模型
POST repository/models
{
"name" : "Model name" ,
"key" : "Model key" ,
"category" : "Model category" ,
"version" : 1 ,
"metaInfo" : "Model metainfo" ,
"deploymentId" : "2" ,
"tenantId" : "tenant"
}
所有请求参数都是可选的
可以只在请求体的JSON 对象中包含name 属性,只设置模型的名称,其它的字段都会设置为null
新建模型-响应码:
{
"id" : "5" ,
"url" : "http://localhost:8182/repository/models/5" ,
"name" : "Model name" ,
"key" : "Model key" ,
"category" : "Model category" ,
"version" : 1 ,
"metaInfo" : "Model metainfo" ,
"deploymentId" : "2" ,
"deploymentUrl" : "http://localhost:8182/repository/deployments/2" ,
"createTime" : "2013-06-12T12:31:19.861+0000" ,
"lastUpdateTime" : "2013-06-12T12:31:19.861+0000" ,
"tenantId" : "tenant"
}
删除模型
DELETE repository/models/{modelId}
参数
是否必须
类型
描述
modelId
是
String
需要删除的模型Id
响应码
描述
204
表示找到模型并成功删除.响应体为空
404
表示找不到请求的模型
获得模型可编译源码
GET repository/models/{modelId}/source
参数
是否必须
类型
描述
modelId
是
String
模型Id
响应码
描述
200
表示找到了模型并返回源码
404
表示找不到请求的模型
成功响应体:
响应体包含了模型的原始可编译源码
无论源码的内容是什么,响应的content-type 都设置为application/octet-stream
设置模型可编译源码
PUT repository/models/{modelId}/source
参数
是否必须
类型
描述
modelId
是
String
模型Id
请求JSON体:
请求应该是multipart/form-data 类型
只有一个文件区域,包含源码的二进制内容
设置模型可编译源码-响应码:
响应码
描述
200
表示找到了模型并更新源码
404
表示找不到请求的模型
成功响应体:
响应体包含了模型的原始可编译源码
无论源码的内容是什么,响应的content-type 都设置为application/octet-stream
获得模型附加可编译源码
GET repository/models/{modelId}/source-extra
参数
是否必须
类型
描述
modelId
是
String
模型Id
响应码
描述
200
表示找到了模型并返回源码
404
表示找不到请求的模型
成功响应体:
响应体包含了模型的原始可编译源码
无论源码的内容是什么,响应的content-type 都设置为application/octet-stream
设置模型附加可编译源码
PUT repository/models/{modelId}/source-extra
参数
是否必须
类型
描述
modelId
是
String
模型Id
请求JSON体:
请求应该是multipart/form-data 类型
只有一个文件区域,包含源码的二进制内容
设置模型附加可编译源码-响应码:
响应码
描述
200
表示找到了模型并更新附加源码
404
表示找不到请求的模型
成功响应体:
响应体包含了模型的原始可编译源码
无论附加源码的内容是什么,响应的content-type 都设置为application/octet-stream
流程实例
获得流程实例
GET runtime/process-instances/{processInstanceId}
参数
是否必须
类型
描述
processInstanceId
是
是
流程实例Id
响应码
描述
200
表示找到流程实例并成功返回
404
表示找不到请求的流程实例
"id" : "7" ,
"url" : "http://localhost:8182/runtime/process-instances/7" ,
"businessKey" : "myBusinessKey" ,
"suspended" : false ,
"processDefinitionUrl" : "http://localhost:8182/repository/process-definitions/processOne%3A1%3A4" ,
"activityId" : "processTask" ,
"tenantId" : null
}
删除流程实例
DELETE runtime/process-instances/{processInstanceId}
参数
是否必须
类型
描述
processInstanceId
是
String
需要删除的流程实例Id
响应码
描述
204
表示找到流程实例并删除,响应内容为空
404
表示找不到请求的流程实例
激活或挂起流程实例
PUT runtime/process-instances/{processInstanceId}
参数
是否必须
类型
描述
processInstanceId
是
String
需要激活或挂起的流程实例Id
{
"action" : "suspend"
}
{
"action" : "activate"
}
响应码
描述
200
表示找到了流程实例并执行对应操作
400
表示提供的操作不合法
404
表示找不到请求的流程实例
409
表示无法执行请求的流程实例操作,因为流程实例已经激活或挂起
启动流程实例
POST runtime/process-instances
{
"processDefinitionId" : "oneTaskProcess:1:158" ,
"businessKey" : "myBusinessKey" ,
"variables" : [
{
"name" : "myVar" ,
"value" : "This is a variable" ,
} ,
...
]
}
{
"processDefinitionKey" : "oneTaskProcess" ,
"businessKey" : "myBusinessKey" ,
"tenantId" : "tenant1" ,
"variables" : [
{
"name" : "myVar" ,
"value" : "This is a variable" ,
} ,
...
]
}
{
"message" : "newOrderMessage" ,
"businessKey" : "myBusinessKey" ,
"tenantId" : "tenant1" ,
"variables" : [
{
"name" : "myVar" ,
"value" : "This is a variable" ,
} ,
...
]
}
请求体中只能使用processDefinitionId,processDefinitionKey 或message 三者之一
参数businessKey,variables 和tenantId 是可选的
注意忽略变量作用域,流程变量总是local
启动流程实例-响应码:
响应码
描述
201
表示成功启动流程实例
400
表示要么找到不到流程定义 ( 基于id 或key), 要么指定的message 不会启动流程,要么传递了非法的变量.状态描述中包含了错误相关的额外信息
{
"id" : "7" ,
"url" : "http://localhost:8182/runtime/process-instances/7" ,
"businessKey" : "myBusinessKey" ,
"suspended" : false ,
"processDefinitionUrl" : "http://localhost:8182/repository/process-definitions/processOne%3A1%3A4" ,
"activityId" : "processTask" ,
"tenantId" : null
}
显示流程实例列表
GET runtime/process-instances
参数
是否必须
类型
描述
id
否
String
只返回指定id的流程实例
processDefinitionKey
否
String
只返回指定流程定义key的流程实例
processDefinitionId
否
String
只返回指定流程定义id的流程实例
businessKey
否
String
只返回指定businessKey的流程实例
involvedUser
否
String
只返回指定用户参与过的流程实例
suspended
否
Boolean
如果为true, 只返回挂起的流程实例.如果为false, 只返回未挂起即激活的流程实例
superProcessInstanceId
否
String
只返回指定上级流程实例id的流程实例.对应call-activity
subProcessInstanceId
否
String
只返回指定子流程id的流程实例.对应call-activity
excludeSubprocesses
否
Boolean
只返回非子流程的流程实例
includeProcessVariables
否
Boolean
表示结果中包含流程变量
tenantId
否
String
只返回指定tenantId的流程实例
tenantIdLike
否
String
只返回与指定tenantId匹配相似的流程实例
withoutTenantId
否
Boolean
如果为true, 只返回未设置tenantId 的流程实例.如果为false, 会忽略withoutTenantId 参数
sort
否
String
排序字段,应该为id (默认),processDefinitionId,tenantId 或processDefinitionKey 三者之一
可以使用通用的分页和排序查询参数
响应码
描述
200
表示请求成功,并返回流程实例
400
表示传递了错误格式的参数,状态信息包含详细信息
{
"data" : [
{
"id" : "7" ,
"url" : "http://localhost:8182/runtime/process-instances/7" ,
"businessKey" : "myBusinessKey" ,
"suspended" : false ,
"processDefinitionUrl" : "http://localhost:8182/repository/process-definitions/processOne%3A1%3A4" ,
"activityId" : "processTask" ,
"tenantId" : null
} ,
...
] ,
"total" : 2 ,
"start" : 0 ,
"sort" : "id" ,
"order" : "asc" ,
"size" : 2
}
查询流程实例
POST query/process-instances
{
"processDefinitionKey" : "oneTaskProcess" ,
"variables" :
[
{
"name" : "myVariable" ,
"value" : 1234 ,
"operation" : "equals" ,
"type" : "long"
} ,
...
] ,
...
}
请求体:
可以包含所有用于显示流程实例列表中的查询参数
查询条件中也可以使用变量列表
可以使用通用的分页和排序查询参数
查询流程实例-响应码:
响应码
描述
200
表示请求成功,并返回流程实例
400
表示传递了错误格式的参数,状态信息包含详细信息
{
"data" : [
{
"id" : "7" ,
"url" : "http://localhost:8182/runtime/process-instances/7" ,
"businessKey" : "myBusinessKey" ,
"suspended" : false ,
"processDefinitionUrl" : "http://localhost:8182/repository/process-definitions/processOne%3A1%3A4" ,
"activityId" : "processTask" ,
"tenantId" : null
} ,
...
] ,
"total" : 2 ,
"start" : 0 ,
"sort" : "id" ,
"order" : "asc" ,
"size" : 2
}
获得流程实例流程图
GET runtime/process-instances/{processInstanceId}
参数
是否必须
类型
描述
processInstanceId
是
String
需要获得流程图的流程实例Id
响应码
描述
200
表示找到了流程实例,并返回流程图
400
表示找不到请求的流程实例,或者流程不包含信息 -BPMN:DI, 所以没有创建图片
404
表示找不到请求的流程实例
{
"id" : "7" ,
"url" : "http://localhost:8182/runtime/process-instances/7" ,
"businessKey" : "myBusinessKey" ,
"suspended" : false ,
"processDefinitionUrl" : "http://localhost:8182/repository/process-definitions/processOne%3A1%3A4" ,
"activityId" : "processTask"
}
获得流程实例参与者
GET runtime/process-instances/{processInstanceId}/identitylinks
参数
是否必须
类型
描述
processInstanceId
是
String
关联的流程实例Id
响应码
描述
200
表示找到了流程实例,并返回IdentityLink
404
表示找不到请求的流程实例
[
{
"url" : "http://localhost:8182/runtime/process-instances/5/identitylinks/users/john/customType" ,
"user" : "john" ,
"group" : null ,
"type" : "customType"
} ,
{
"url" : "http://localhost:8182/runtime/process-instances/5/identitylinks/users/paul/candidate" ,
"user" : "paul" ,
"group" : null ,
"type" : "candidate"
}
]
注意: groupId总是null,因为只有用户才能实际参与到流程实例中
流程实例添加一个参与者
POST runtime/process-instances/{processInstanceId}/identitylinks
参数
是否必须
类型
描述
processInstanceId
是
String
关联的流程实例Id
{
"userId" : "kermit" ,
"type" : "participant"
}
userId和type都是必填项
响应码
描述
201
表示找到了流程实例,并创建关联
400
表示请求体没有包含userId 或type
404
表示找不到请求的流程实例
{
"url" : "http://localhost:8182/runtime/process-instances/5/identitylinks/users/john/customType" ,
"user" : "john" ,
"group" : null ,
"type" : "customType"
}
注意: groupId总是null,因为只有用户才能实际参与到流程实例中
删除一个流程实例参与者
DELETE runtime/process-instances/{processInstanceId}/identitylinks/users/{userId}/{type}
参数
是否必须
类型
描述
processInstanceId
是
String
流程实Id
userId
是
String
需要删除关联的用户id
type
是
String
需要删除的关联类型
响应码
描述
204
表示找到了流程实例,并删除关联.响应体为空
404
表示找不到请求的流程实例,或找不到期望删除的关联.响应状态包含了错误的详细信息
列出流程实例变量
GET runtime/process-instances/{processInstanceId}/variables
参数
是否必须
类型
描述
processInstanceId
是
String
变量对应的流程实例Id
响应码
描述
200
表示找到了流程实例,并返回变量
404
表示找不到请求的流程实例
[
{
"name" : "intProcVar" ,
"type" : "integer" ,
"value" : 123 ,
"scope" : "local"
} ,
{
"name" : "byteArrayProcVar" ,
"type" : "binary" ,
"value" : null ,
"valueUrl" : "http://localhost:8182/runtime/process-instances/5/variables/byteArrayProcVar/data" ,
"scope" : "local"
} ,
...
]
当变量为二进制 或序列化 类型时 ,valueUrl 给出了获得原始数据的URL
如果是普通变量, 变量值就会直接包含在响应中
注意只会返回local 作用域的变量,因为流程实例变量没有global作用域
获得流程实例一个变量
GET runtime/process-instances/{processInstanceId}/variables/{variableName}
参数
是否必须
类型
描述
processInstanceId
是
String
变量对应的流程实例Id
variableName
是
String
获得变量的名称
响应码
描述
200
表示找到了流程实例和变量,并返回变量
400
表示请求体不完全,或包含非法值.状态描述包含对应错误的详细信息
404
表示找不到请求的流程实例,或流程实例中不包含指定名称的变量.状态描述中包含对应错误的详细信息
{
"name" : "intProcVar" ,
"type" : "integer" ,
"value" : 123 ,
"scope" : "local"
}
当变量为二进制或序列化类型时 ,valueUrl 给出了获得原始数据的URL
如果是普通变量,变量值就会直接包含在响应中
注意只会返回local 作用域的变量,因为流程实例变量没有global 作用域
创建(更新)流程实例变量
POST runtime/process-instances/{processInstanceId}/variables
使用POST 时,会创建所有传递的变量.如果流程实例中已经存在了其中一个变量,就会返回一个错误 (409-CONFLICT)
PUT runtime/process-instances/{processInstanceId}/variables
使用PUT 时,流程实例中不存在的变量会被创建,已存在的变量会被更新,不会有任何错误
建议使用PUT进行创建更新操作
创建(更新)流程实例变量-URL参数:
参数
是否必须
类型
描述
processInstanceId
是
String
变量对应的流程实例Id
[
{
"name" : "intProcVar"
"type" : "integer"
"value" : 123
} ,
...
]
请求体的数组中可以包含任意多个变量
注意此处忽略作用域,流程实例只能设置local 作用域
创建(更新)流程实例变量-响应码:
响应码
描述
201
表示找到了流程实例,并创建变量
400
表示请求体不完整,或包含非法值.状态描述包含对应错误的详细信息
404
表示找不到请求的流程实例
409
表示找到了流程实例,但是已经存在一个相同名称的变量(只在使用POST 方法时抛出).可以使用更新方法PUT 替代
[
{
"name" : "intProcVar" ,
"type" : "integer" ,
"value" : 123 ,
"scope" : "local"
} ,
...
]
更新一个流程实例变量
PUT runtime/process-instances/{processInstanceId}/variables/{variableName}
参数
是否必须
类型
描述
processInstanceId
是
String
变量对应的流程实例Id
variableName
是
String
需要更新的变量名称
{
"name" : "intProcVar"
"type" : "integer"
"value" : 123
}
请求体的数组中可以包含任意多个变量
注意此处忽略作用域,流程实例只能设置local 作用域
更新一个流程实例变量-响应码:
响应码
描述
200
表示找到了流程实例和变量,并更新变量
404
表示找不到请求的流程实例,或找不到给定名称的流程实例变量.状态描述包含对应错误的详细信息
{
"name" : "intProcVar" ,
"type" : "integer" ,
"value" : 123 ,
"scope" : "local"
}
当变量为二进制或序列化类型时 ,valueUrl 给出了获得原始数据的URL
如果是普通变量,变量值就会直接包含在响应中
注意只会返回local 作用域的变量,因为流程实例变量没有global 作用域
创建一个新二进制流程变量
POST runtime/process-instances/{processInstanceId}/variables
参数
是否必须
类型
描述
processInstanceId
是
String
创建新二进制变量对应的流程实例Id
请求JSON体:
请求应该是multipart/form-data 类型
应该只有一个文件区域, 包含源码的二进制 内容
需要提供以下表单域:
name: 变量名称,不可省略
type: 变量类型.如果忽略,会假设使用binary, 请求的二进制数据会当做二进制数组 保存起来
创建一个新二进制流程变量-响应码:
响应码
描述
201
表示成功创建了变量,并返回结果
400
表示没有提供希望创建的二进制变量名称,状态消息包含详细信息
404
表示找不到请求的流程实例
409
表示流程实例中已经包含了给定名称的变量,可以使用PUT方法来更新变量
415
表示序列化数据包含的对象的类并不在运行Activiti引擎的JVM中,所以无法反序列化
{
"name" : "binaryVariable" ,
"scope" : "local" ,
"type" : "binary" ,
"value" : null ,
"valueUrl" : "http://.../runtime/process-instances/123/variables/binaryVariable/data"
}
更新一个二进制流程实例变量
PUT runtime/process-instances/{processInstanceId}/variables
参数
是否必须
类型
描述
processInstanceId
是
String
更新新二进制变量对应的流程实例Id
请求JSON体:
请求应该是multipart/form-data 类型
应该只有一个文件区域, 包含源码的二进制 内容
需要提供以下表单域:
name: 变量名称,不可省略
type: 变量类型.如果忽略,会假设使用binary, 请求的二进制数据会当做二进制数组 保存起来
更新一个二进制流程实例变量-响应码:
响应码
描述
201
表示成功更新了变量,并返回结果
400
表示没有提供希望更新的二进制变量名称,状态消息包含详细信息
404
表示找不到请求的流程实例
415
表示序列化数据包含的对象的类并不在运行Activiti引擎的JVM中,所以无法反序列化
{
"name" : "binaryVariable" ,
"scope" : "local" ,
"type" : "binary" ,
"value" : null ,
"valueUrl" : "http://.../runtime/process-instances/123/variables/binaryVariable/data"
}
分支
获得一个分支
GET runtime/executions/{executionId}
参数
是否必须
类型
描述
executionId
是
String
获得分支的Id
响应码
描述
200
表示找到了分支,并成功返回
404
表示找不到分支
{
"id" : "5" ,
"url" : "http://localhost:8182/runtime/executions/5" ,
"parentId" : null ,
"parentUrl" : null ,
"processInstanceId" : "5" ,
"processInstanceUrl" : "http://localhost:8182/runtime/process-instances/5" ,
"suspended" : false ,
"activityId" : null ,
"tenantId" : null
}
分支执行操作
PUT runtime/executions/{executionId}
参数
是否必须
类型
描述
executionId
是
String
需要执行操作的分支Id
{
"action" : "signal"
}
{
"action" : "signalEventReceived" ,
"signalName" : "mySignal"
"variables" : [ ... ]
}
提醒分支接收了一个信号事件,要使用一个signalName 参数
可以传递variables 参数,会在执行操作之前设置到分支中
请求JSON体-分支接收消息事件:
{
"action" : "messageEventReceived" ,
"messageName" : "myMessage"
"variables" : [ ... ]
}
提醒分支接收了一个信号事件,要使用一个messageName 参数
可以传递variables 参数,会在执行操作之前设置到分支中
分支执行操作-响应码:
响应码
描述
200
表示找到了分支,并执行操作
204
表示找到了分支,执行操作,并且操作导致分支结束
400
表示请求的操作不合法,请求中缺少必须的参数,或传递了非法的变量.状态描述中包含错误相关的详细信息
404
表示找不到分支
{
"id" : "5" ,
"url" : "http://localhost:8182/runtime/executions/5" ,
"parentId" : null ,
"parentUrl" : null ,
"processInstanceId" : "5" ,
"processInstanceUrl" : "http://localhost:8182/runtime/process-instances/5" ,
"suspended" : false ,
"activityId" : null ,
"tenantId" : null
}
获得一个分支的所有活动节点
GET runtime/executions/{executionId}/activities
返回分支以及子分支当前所有活动的节点,递归所有下级
参数
是否必须
类型
描述
executionId
是
String
需要获得所有活动节点对应的分支Id
响应码
描述
200
表示找到了分支,并返回节点
404
表示找不到分支
[
"userTaskForManager" ,
"receiveTask"
]
获得分支列表
GET runtime/executions
参数
是否必须
类型
描述
id
否
String
只返回指定id的分支
activityId
否
String
只返回指定节点id的分支
processDefinitionKey
否
String
只返回指定流程定义key的分支
processDefinitionId
否
String
只返回指定流程定义id的分支
processInstanceId
否
String
只返回作为指定流程实例Id一部分的分支
messageEventSubscriptionName
否
String
只返回订阅了指定名称消息的分支
signalEventSubscriptionName
否
String
只返回订阅了指定名称信号的分支
parentId
否
String
只返回指定分支直接下级的分支
tenantId
否
String
只返回指定tenantId的分支
tenantIdLike
否
String
只返回与指定tenantId匹配相似的分支
withoutTenantId
否
Boolean
如果为true, 只返回未设置tenantId 的分支.如果为false, 会忽略withoutTenantId 参数
sort
否
String
排序字段,应该和processInstanceId(默认),processDefinitionId,processDefinitionKey 或tenantId 之一一起使用
可以使用通用的分页和排序查询参数
响应码
描述
200
表示请求成功,并返回分支
400
表示传递了错误格式的参数.状态信息包含错误详细信息
{
"data" : [
{
"id" : "5" ,
"url" : "http://localhost:8182/runtime/executions/5" ,
"parentId" : null ,
"parentUrl" : null ,
"processInstanceId" : "5" ,
"processInstanceUrl" : "http://localhost:8182/runtime/process-instances/5" ,
"suspended" : false ,
"activityId" : null ,
"tenantId" : null
} ,
{
"id" : "7" ,
"url" : "http://localhost:8182/runtime/executions/7" ,
"parentId" : "5" ,
"parentUrl" : "http://localhost:8182/runtime/executions/5" ,
"processInstanceId" : "5" ,
"processInstanceUrl" : "http://localhost:8182/runtime/process-instances/5" ,
"suspended" : false ,
"activityId" : "processTask" ,
"tenantId" : null
}
] ,
"total" : 2 ,
"start" : 0 ,
"sort" : "processInstanceId" ,
"order" : "asc" ,
"size" : 2
}
查询分支
POST query/executions
{
"processDefinitionKey" : "oneTaskProcess" ,
"variables" :
[
{
"name" : "myVariable" ,
"value" : 1234 ,
"operation" : "equals" ,
"type" : "long"
} ,
...
] ,
"processInstanceVariables" :
[
{
"name" : "processVariable" ,
"value" : "some string" ,
"operation" : "equals" ,
"type" : "string"
} ,
...
] ,
...
}
请求体可以包含在获得分支列表中可以使用的查询条件
可以在查询中提供variables 和processInstanceVariables 列表
可以使用通用的分页和排序查询参数
查询分支-响应码:
响应码
描述
200
表示请求成功,并返回分支
400
表示传递了错误格式的参数,状态信息包含错误详细信息
{
"data" : [
{
"id" : "5" ,
"url" : "http://localhost:8182/runtime/executions/5" ,
"parentId" : null ,
"parentUrl" : null ,
"processInstanceId" : "5" ,
"processInstanceUrl" : "http://localhost:8182/runtime/process-instances/5" ,
"suspended" : false ,
"activityId" : null ,
"tenantId" : null
} ,
{
"id" : "7" ,
"url" : "http://localhost:8182/runtime/executions/7" ,
"parentId" : "5" ,
"parentUrl" : "http://localhost:8182/runtime/executions/5" ,
"processInstanceId" : "5" ,
"processInstanceUrl" : "http://localhost:8182/runtime/process-instances/5" ,
"suspended" : false ,
"activityId" : "processTask" ,
"tenantId" : null
}
] ,
"total" : 2 ,
"start" : 0 ,
"sort" : "processInstanceId" ,
"order" : "asc" ,
"size" : 2
}
获取分支变量列表
GET runtime/executions/{executionId}/variables?scope={scope}
参数
是否必须
类型
描述
executionId
是
String
变量对应的分支Id
scope
否
String
local 或global. 如果忽略,会返回local 和global 作用域下的所有变量
响应码
描述
200
表示找到了分支,并返回变量
404
表示找不到请求的分支
[
{
"name" : "intProcVar" ,
"type" : "integer" ,
"value" : 123 ,
"scope" : "global"
} ,
{
"name" : "byteArrayProcVar" ,
"type" : "binary" ,
"value" : null ,
"valueUrl" : "http://localhost:8182/runtime/process-instances/5/variables/byteArrayProcVar/data" ,
"scope" : "local"
} ,
...
]
当变量为二进制或序列化类型时 ,valueUrl 给出了获得原始数据的URL
如果是普通变量,变量值就会直接包含在响应中
获得分支一个变量
GET runtime/executions/{executionId}/variables/{variableName}?scope={scope}
参数
是否必须
类型
描述
executionId
是
String
变量对应的分支Id
variableName
是
String
获得的变量名称
scope
否
String
local 或global. 如果忽略,返回local 变量(如果存在).如果不存在局部变量,返回global 变量(如果存在)
响应码
描述
200
表示找到了分支和变量,并返回了变量
400
表示请求体不完全,或包含非法数值.状态描述中包含错误相关的详细信息
404
表示找不到请求的分支,,或分支在请求作用域中不包含指定名称的变量(如果忽略scope 参数,既不存在local 变量也不存在global 变量).状态描述中包含了错误相关的详细信息
{
"name" : "intProcVar" ,
"type" : "integer" ,
"value" : 123 ,
"scope" : "local"
}
当变量为二进制或序列化类型时 ,valueUrl 给出了获得原始数据的URL
如果是普通变量,变量值就会直接包含在响应中
创建(更新)分支变量
POST runtime/executions/{executionId}/variables
使用POST 时,会创建所有传递的变量.如果流程实例中已经存在了其中一个变量,就会返回一个错误 (409-CONFLICT)
PUT runtime/executions/{executionId}/variables
使用PUT 时,流程实例中不存在的变量会被创建,已存在的变量会被更新,不会有任何错误
建议使用PUT
创建(更新)分支变量-URL参数:
参数
是否必须
类型
描述
executionId
是
String
变量对应的分支id
[
{
"name" : "intProcVar"
"type" : "integer"
"value" : 123 ,
"scope" : "local"
} ,
...
]
注意只能提供作用域相同的变量: 如果请求体数组中包含了不同作用域的变量,请求会返回一个错误**(400-BAD REQUEST)**
请求体数据中可以传递任意个数的变量
注意: 如果忽略了作用域,只有local 作用域的变量可以设置到流程实例中
创建(更新)分支变量-响应码:
响应码
描述
201
表示找到了分支,并成功创建变量
400
表示请求体不完全或包含了非法数据.状态描述中包含错误相关的详细信息
404
表示找不到请求的分支
409
表示找到了流程实例,但是已经存在一个相同名称的变量(只在使用POST 方法时抛出).可以使用更新方法替代
[
{
"name" : "intProcVar" ,
"type" : "integer" ,
"value" : 123 ,
"scope" : "local"
} ,
...
]
更新一个分支变量
PUT runtime/executions/{executionId}/variables/{variableName}
参数
是否必须
类型
描述
executionId
是
String
需要更新的变量对应的分支Id
variableName
是
String
需要更新的变量名称
{
"name" : "intProcVar"
"type" : "integer"
"value" : 123 ,
"scope" : "global"
}
响应码
描述
200
表示找到了分支和变量,并成功更新变量
404
表示找不到请求的分支,或分支不包含指定名称的变量.状态描述中包含错误相关的详细信息
{
"name" : "intProcVar" ,
"type" : "integer" ,
"value" : 123 ,
"scope" : "global"
}
当变量为二进制或序列化类型时 ,valueUrl 给出了获得原始数据的URL
如果是普通变量,变量值就会直接包含在响应中
创建一个二进制变量
POST runtime/executions/{executionId}/variables
参数
是否必须
类型
描述
executionId
是
String
需要创建的二进制变量对应的分支Id
请求JSON体:
请求应该是multipart/form-data 类型
应该只有一个文件区域, 包含源码的二进制 内容
需要提供表单域:
name: 变量名称,必须要有
type: 变量类型.如果忽略,会假设使用binary, 请求的二进制数据会当做作二进制数组保存起来
创建一个二进制变量-响应码:
响应码
描述
201
表示成功创建了变量,并返回结果
400
表示没有提供希望创建的变量名称,状态信息包含错误详细信息
404
表示找不到请求的分支
409
表示分支已经拥有一个与指定名称相同的变量,使用PUT 方法代替来更新分支变量
415
表示序列化数据包含的对象的类并不在运行Activiti引擎的JVM中,所以无法反序列化
{
"name" : "binaryVariable" ,
"scope" : "local" ,
"type" : "binary" ,
"value" : null ,
"valueUrl" : "http://.../runtime/executions/123/variables/binaryVariable/data"
}
更新已经存在的二进制分支变量
PUT runtime/executions/{executionId}/variables/{variableName}
参数
是否必须
类型
描述
executionId
是
String
需要希望更新的变量对应的分支Id
variableName
是
String
希需要更新的变量名称
请求JSON体:
请求应该是multipart/form-data 类型
应该只有一个文件区域, 包含源码的二进制 内容
需要提供表单域:
name: 变量名称,必须要有
type: 变量类型.如果忽略,会假设使用binary, 请求的二进制数据会当做作二进制数组保存起来
scope: 变量作用域.如果忽略,默认为local
更新已经存在的二进制分支变量-响应码:
响应码
描述
200
表示变量已成功更薪,并返回结果
400
表示没有提供需要更新的变量名称,状态信息包含错误详细信息
404
表示没有找到分支,或分支不包含指定名称的变量
415
表示序列化数据包含的对象的类并不在运行Activiti引擎的JVM中,所以无法反序列化
{
"name" : "binaryVariable" ,
"scope" : "local" ,
"type" : "binary" ,
"value" : null ,
"valueUrl" : "http://.../runtime/executions/123/variables/binaryVariable/data"
}
任务
获得任务
GET runtime/tasks/{taskId}
参数
是否必须
类型
描述
taskId
是
String
需要获得的任务Id
响应码
描述
200
表示找到了任务并返回
404
表示找不到任务
{
"assignee" : "kermit" ,
"createTime" : "2013-04-17T10:17:43.902+0000" ,
"delegationState" : "pending" ,
"description" : "Task description" ,
"dueDate" : "2013-04-17T10:17:43.902+0000" ,
"execution" : "http://localhost:8182/runtime/executions/5" ,
"id" : "8" ,
"name" : "My task" ,
"owner" : "owner" ,
"parentTask" : "http://localhost:8182/runtime/tasks/9" ,
"priority" : 50 ,
"processDefinition" : "http://localhost:8182/repository/process-definitions/oneTaskProcess%3A1%3A4" ,
"processInstance" : "http://localhost:8182/runtime/process-instances/5" ,
"suspended" : false ,
"taskDefinitionKey" : "theTask" ,
"url" : "http://localhost:8182/runtime/tasks/8" ,
"tenantId" : null
}
delegationState: 任务的代理状态.值的类型可以为
获得任务列表
GET runtime/tasks
参数
是否必须
类型
描述
name
否
String
只返回指定的名称的任务
nameLike
否
String
只返回与指定名称匹配相似的任务
description
否
String
只返回指定描述的任务
priority
否
Integer
只返回指定优先级的任务
minimumPriority
否
Integer
只返回比指定优先级大的任务
maximumPriority
否
Integer
只返回比指定优先级小的任务
assignee
否
String
只返回分配给指定用户的任务
assigneeLike
否
String
只返回与指定匹配相似的用户的任务
owner
否
String
只返回原拥有人为指定用户的任务
ownerLike
否
String
只返回与指定匹配相似的原拥有人的任务
unassigned
否
Boolean
只返回没有分配给任何人的任务.如果传递false, 这个值就会被忽略
delegationState
否
String
只返回指定代理状态的任务.可选值为pending 和resolved
candidateUser
否
String
只返回可以被指定用户领取的任务.这包含将用户设置为直接候选人和用户作为候选群组一员的情况
candidateGroup
否
String
只返回可以被指定群组中用户领取的任务
candidateGroups
否
String
只返回可以被指定群组列表中用户领取的任务.使用逗号分隔
involvedUser
否
String
只返回指定用户参与过的任务
taskDefinitionKey
否
String
只返回指定任务定义Id的任务
taskDefinitionKeyLike
否
String
只返回与指定任务定义Id匹配相似的任务
processInstanceId
否
String
只返回作为指定Id的流程实例的一部分的任务
processInstanceBusinessKey
否
String
只返回作为指定key的流程实例的一部分的任务
processInstanceBusinessKeyLike
否
String
只返回与指定值key匹配相似的流程实例的一部分的任务
processDefinitionKey
否
String
只返回指定流程定义key的流程实例的一部分的任务
processDefinitionKeyLike
否
String
只返回与指定流程定义key匹配相似的流程实例的一部分的任务
processDefinitionName
否
String
只返回指定流程定义名称的流程实例的一部分的任务
processDefinitionNameLike
否
String
只返回与指定流程定义名称匹配相似的流程实例的一部分的任务
executionId
否
String
只返回作为指定Id分支的一部分的任务
createdOn
否
ISO Date
只返回指定创建时间的任务
createdBefore
否
ISO Date
只返回在指定时间之前创建的任务
createdAfter
否
ISO Date
只返回在指定时间之后创建的任务
dueOn
否
ISO Date
只返回指定持续时间的任务
dueBefore
否
ISO Date
只返回持续时间在指定时间之前的任务
dueAfter
否
ISO Date
只返回持续时间在指定时间之后的任务
withoutDueDate
否
Boolean
只返回没有设置持续时间的任务.如果值为false 就会忽略这个属性
excludeSubTasks
否
Boolean
只返回非子任务的任务
active
否
Boolean
如果为true, 只返回未挂起的任务(作为未挂起流程的一部分,或者不属于任何流程).如果为false, 只返回作为挂起流程一部分的任务
includeTaskLocalVariables
否
Boolean
表示在结果中包含任务的局部变量
includeProcessVariables
否
Boolean
表示在结果中包含流程变量
tenantId
否
String
只返回指定tenantId的任务
tenantIdLike
否
String
只返回与指定tenantId匹配相似的任务
withoutTenantId
否
Boolean
如果为true, 只返回未设置tenantId 的任务.如果为false, 会忽略withoutTenantId 参数
candidateOrAssigned
否
String
选择已经被领取,或分配给某个用户,或者可以被用户领取(候选用户或组)
可以使用通用的分页和排序查询参数
响应码
描述
200
表示请求成功,并返回任务
400
表示传递的参数格式错误,或delegationState 使用了不合法的数据(pending 和resolved 以外的数据).状态信息包含错误详细信息
{
"data" : [
{
"assignee" : "kermit" ,
"createTime" : "2013-04-17T10:17:43.902+0000" ,
"delegationState" : "pending" ,
"description" : "Task description" ,
"dueDate" : "2013-04-17T10:17:43.902+0000" ,
"execution" : "http://localhost:8182/runtime/executions/5" ,
"id" : "8" ,
"name" : "My task" ,
"owner" : "owner" ,
"parentTask" : "http://localhost:8182/runtime/tasks/9" ,
"priority" : 50 ,
"processDefinition" : "http://localhost:8182/repository/process-definitions/oneTaskProcess%3A1%3A4" ,
"processInstance" : "http://localhost:8182/runtime/process-instances/5" ,
"suspended" : false ,
"taskDefinitionKey" : "theTask" ,
"url" : "http://localhost:8182/runtime/tasks/8" ,
"tenantId" : null
}
] ,
"total" : 1 ,
"start" : 0 ,
"sort" : "name" ,
"order" : "asc" ,
"size" : 1
}
查询任务
POST query/tasks
{
"name" : "My task" ,
"description" : "The task description" ,
...
"taskVariables" : [
{
"name" : "myVariable" ,
"value" : 1234 ,
"operation" : "equals" ,
"type" : "long"
}
] ,
"processInstanceVariables" : [
{
...
}
]
]
}
此处所有被支持的JSON 参数都和获得任务集合完全一样,除了candidateGroupIn, 只能使用在任务查询REST 服务中
只是使用JSON 体参数的方式替代URL 参数,这样就可以使用更加高级的查询方式,并能预防请求URI 过长导致的问题
可以基于任务和流程变量进行查询 .taskVariables 和processInstanceVariables 都可以包含此处描述的JSON数组
查询任务-响应码:
响应码
描述
200
表示请求成功,并返回任务
400
表示传递的参数格式错误,或delegationState 使用了不合法的数据(pending 和resolved 以外的数据).状态信息包含错误详细信息
{
"data" : [
{
"assignee" : "kermit" ,
"createTime" : "2013-04-17T10:17:43.902+0000" ,
"delegationState" : "pending" ,
"description" : "Task description" ,
"dueDate" : "2013-04-17T10:17:43.902+0000" ,
"execution" : "http://localhost:8182/runtime/executions/5" ,
"id" : "8" ,
"name" : "My task" ,
"owner" : "owner" ,
"parentTask" : "http://localhost:8182/runtime/tasks/9" ,
"priority" : 50 ,
"processDefinition" : "http://localhost:8182/repository/process-definitions/oneTaskProcess%3A1%3A4" ,
"processInstance" : "http://localhost:8182/runtime/process-instances/5" ,
"suspended" : false ,
"taskDefinitionKey" : "theTask" ,
"url" : "http://localhost:8182/runtime/tasks/8" ,
"tenantId" : null
}
] ,
"total" : 1 ,
"start" : 0 ,
"sort" : "name" ,
"order" : "asc" ,
"size" : 1
}
更新任务
PUT runtime/tasks/{taskId}
{
"assignee" : "assignee" ,
"delegationState" : "resolved" ,
"description" : "New task description" ,
"dueDate" : "2013-04-17T13:06:02.438+02:00" ,
"name" : "New task name" ,
"owner" : "owner" ,
"parentTaskId" : "3" ,
"priority" : 20
}
所有请求参数都是可选的:比如可以在请求体的JSON 对象中只包含assignee 属性,只更新任务的负责人,其他字段都不填
当包含的字段值为null时,任务的对应属性会被更新为null:比如{“dueDate” : null}会清空任务的持续时间
更新任务-响应码:
响应码
描述
200
表示成功更新了任务
404
表示找不到任务
409
表示请求的任务正在被更新
{
"assignee" : "kermit" ,
"createTime" : "2013-04-17T10:17:43.902+0000" ,
"delegationState" : "pending" ,
"description" : "Task description" ,
"dueDate" : "2013-04-17T10:17:43.902+0000" ,
"execution" : "http://localhost:8182/runtime/executions/5" ,
"id" : "8" ,
"name" : "My task" ,
"owner" : "owner" ,
"parentTask" : "http://localhost:8182/runtime/tasks/9" ,
"priority" : 50 ,
"processDefinition" : "http://localhost:8182/repository/process-definitions/oneTaskProcess%3A1%3A4" ,
"processInstance" : "http://localhost:8182/runtime/process-instances/5" ,
"suspended" : false ,
"taskDefinitionKey" : "theTask" ,
"url" : "http://localhost:8182/runtime/tasks/8" ,
"tenantId" : null
}
delegationState: 任务的代理状态.值的类型可以为
操作任务
POST runtime/tasks/{taskId}
{
"action" : "complete" ,
"variables" : ...
}
完成任务:
可以使用variables 参数传递可选的variable 数组
注意: 此处忽略变量作用域,变量会设置到上级作用域,除非本地作用域应包含了同名变量
与TaskService.completeTask(taskId,variables) 的行为是相同的
请求JSON体-认领任务:
{
"action" : "claim" ,
"assignee" : "userWhoClaims"
}
认领任务:
根据指定的assignee 认领任务
如果assignee 为null, 任务的执行人会变成空,就可以重新认领任务
请求JSON体-代理任务:
{
"action" : "delegate" ,
"assignee" : "userToDelegateTo"
}
代理任务:
指定assignee 代理任务
assignee 是必填项
请求JSON体-处理任务:
{
"action" : "resolve"
}
处理任务:
处理任务代理,任务会返回给任务的原负责人,如果任务的原负责人存在的话
操作任务-响应码:
响应码
描述
200
表示操作成功执行
400
当请求包含了非法数据或当操作需要assignee 参数时没有传入
404
表示找不到任务
409
表示因为冲突导致无法执行操作.可能任务正在被更新,或者在claim 认清任务时,任务已经被其他用户认领
{
"assignee" : "kermit" ,
"createTime" : "2013-04-17T10:17:43.902+0000" ,
"delegationState" : "pending" ,
"description" : "Task description" ,
"dueDate" : "2013-04-17T10:17:43.902+0000" ,
"execution" : "http://localhost:8182/runtime/executions/5" ,
"id" : "8" ,
"name" : "My task" ,
"owner" : "owner" ,
"parentTask" : "http://localhost:8182/runtime/tasks/9" ,
"priority" : 50 ,
"processDefinition" : "http://localhost:8182/repository/process-definitions/oneTaskProcess%3A1%3A4" ,
"processInstance" : "http://localhost:8182/runtime/process-instances/5" ,
"suspended" : false ,
"taskDefinitionKey" : "theTask" ,
"url" : "http://localhost:8182/runtime/tasks/8" ,
"tenantId" : null
}
delegationState: 任务的代理状态.值的类型可以为
删除任务
DELETE runtime/tasks/{taskId}?cascadeHistory={cascadeHistory}&deleteReason={deleteReason}
参数
是否必须
类型
描述
taskId
是
String
希望删除的任务Id
cascadeHistory
否
Boolean
删除任务时是否删除对应的任务历史,如果存在任务历史.如果没有设置这个参数,默认为false
deleteReason
否
Boolean
删除任务的原因 .cascadeHistory 为true 时,忽略此参数
响应码
描述
204
表示找到任务,并成功删除.响应体为空
403
表示无法删除任务,因为是流程的一部分
404
表示找不到任务
获得任务变量
GET runtime/tasks/{taskId}/variables?scope={scope}
参数
是否必须
类型
描述
taskId
是
String
变量对应的任务Id
scope
否
String
返回的变量作用域.如果为local, 只返回任务本身的变量.如果为global, 只返回任务上级分支的变量.如果不指定这个变量,会返回所有局部和全局的变量
响应码
描述
200
表示找到了任务并返回请求的变量
404
表示找不到任务
[
{
"name" : "doubleTaskVar" ,
"scope" : "local" ,
"type" : "double" ,
"value" : 99.99
} ,
{
"name" : "stringProcVar" ,
"scope" : "global" ,
"type" : "string" ,
"value" : "This is a ProcVariable"
} ,
...
]
获取任务一个变量
GET runtime/tasks/{taskId}/variables/{variableName}?scope={scope}
参数
是否必须
类型
描述
taskId
是
String
获取变量对应的任务Id
variableName
是
String
获取变量对应的名称
scope
否
String
返回的变量作用域.如果为local, 只返回任务本身的变量.如果为global, 只返回任务上级分支的变量.如果不指定这个变量,会返回所有局部和全局的变量
响应码
描述
200
表示找到了任务并返回请求的变量
404
表示找不到任务,或者任务不包含指定名称的变量(在指定作用域下).状态信息包含错误详细信息
{
"name" : "myTaskVariable" ,
"scope" : "local" ,
"type" : "string" ,
"value" : "Hello my friend"
}
获得任务变量二进制数据
GET runtime/tasks/{taskId}/variables/{variableName}/data?scope={scope}
参数
是否必须
类型
描述
taskId
是
String
获取变量数据对应的任务Id
variableName
是
String
获取数据对应的变量名称.只能使用binary 和serializable 类型的变量.如果使用了其他类型的变量,会返回 404
scope
否
String
返回的变量作用域.如果为local, 只返回任务本身的变量.如果为global, 只返回任务上级分支的变量.如果不指定这个变量,会返回所有局部和全局的变量
响应码
描述
200
表示找到了任务并返回请求的变量
404
表示找不到任务,或者任务不包含指定名称的变量(在指定作用域下),或变量的二进制流不可用.状态信息包含错误详细信息
成功响应体:
响应体包含变量的二进制值:
当类型为binary 时:
无论请求的accept-type 头部设置了什么值,响应的content-type 都为application/octet-stream
当类型为serializable 时:
content-type 为application/x-java-serialized-object
创建任务变量
POST runtime/tasks/{taskId}/variables
参数
是否必须
类型
描述
taskId
是
String
创建新变量对应的任务Id
[
{
"name" : "myTaskVariable" ,
"scope" : "local" ,
"type" : "string" ,
"value" : "Hello my friend"
} ,
{
...
}
]
请求体应该是包含一个或多个JSON对象的数组, 对应着应该创建的变量:
name: 变量名称,不可省略
scope: 变量的作用域.如果忽略,假设为local
type: 变量的类型.如果忽略,转换为对应的JSON的类型: string,boolean,integer和 double
value: 变量值
创建任务变量-响应码:
响应码
描述
201
表示创建了变量,并返回结果
400
表示没有传变量名,或尝试使用global 作用域为独立任务(没有关联到流程)创建变量,或请求中的变量为空,或请求没有包含变量数组.状态信息包含错误详细信息
404
表示找不到任务
409
表示任务已经存在指定名称的变量.可以使用PUT 方法来更新任务变量
[
{
"name" : "myTaskVariable" ,
"scope" : "local" ,
"type" : "string" ,
"value" : "Hello my friend"
} ,
{
...
}
]
创建二进制任务变量
POST runtime/tasks/{taskId}/variables
参数
是否必须
类型
描述
taskId
是
String
创建新变量对应的任务Id
请求JSON体:
请求应该是multipart/form-data 类型,应该只有一个文件区域,包含源码的二进制 内容.除此之外,需要提供表单域 :
name: 变量名称,不可省略
scope: 变量作用域.如果忽略,默认使用local
type: 变量类型.如果忽略,会假设使用binary, 请求的二进制数据会当作二进制数组保存起来
创建二进制任务变量-响应码:
响应码
描述
201
表示创建了变量,并返回结果
400
表示没有传变量名,或尝试使用global 作用域为独立任务(没有关联到流程)创建变量.状态信息包含错误详细信息
404
表示找不到任务
409
表示任务已经存在指定名称的变量.可以使用PUT 方法来更新任务变量
415
表示序列化数据包含的对象的类并不在运行Activiti引擎的JVM中,所以无法反序列化
{
"name" : "binaryVariable" ,
"scope" : "local" ,
"type" : "binary" ,
"value" : null ,
"valueUrl" : "http://.../runtime/tasks/123/variables/binaryVariable/data"
}
更新一个任务变量
PUT runtime/tasks/{taskId}/variables/{variableName}
参数
是否必须
类型
描述
taskId
是
String
需要更新的变量对应的任务Id
variableName
是
String
需要更新的变量名称
{
"name" : "myTaskVariable" ,
"scope" : "local" ,
"type" : "string" ,
"value" : "Hello my friend"
}
请求体应该是一个JSON对象, 对应着应该更新的变量:
name: 变量名称,不可省略
scope: 变量的作用域.如果忽略,假设为local
type: 变量的类型.如果忽略,转换为对应的JSON的类型: string,boolean,integer和 double
value: 变量值
更新一个任务变量-响应码:
响应码
描述
200
表示成功更新了变量,并返回结果
400
表示没有传变量名,或尝试使用global 作用域为独立任务(没有关联到流程)创建变量.状态信息包含错误详细信息
404
表示找不到任务,或任务在指定作用域不包含指定名称的变量.状态信息包含错误的详细信息
更新一个二进制任务变量
PUT runtime/tasks/{taskId}/variables/{variableName}
参数
是否必须
类型
描述
taskId
是
String
需要更新的变量对应的任务Id
variableName
是
String
需要更新的变量名称
请求JSON体:
请求应该是multipart/form-data 类型,应该只有一个文件区域,包含源码的二进制 内容.除此之外,需要提供表单域 :
name: 变量名称,不可省略
scope: 变量作用域.如果忽略,默认使用local
type: 变量类型.如果忽略,会假设使用binary, 请求的二进制数据会当作二进制数组保存起来
更新一个二进制任务变量-响应码:
响应码
描述
200
表示更新了变量,并返回结果
400
表示没有传变量名,或尝试使用global 作用域为独立任务9没有关联到流程)创建变量.状态信息包含错误详细信息
404
表示找不到任务,或任务在指定作用域不包含指定名称的变量
415
表示序列化数据包含的对象的类并不在运行Activiti引擎的JVM中,所以无法反序列化
{
"name" : "binaryVariable" ,
"scope" : "local" ,
"type" : "binary" ,
"value" : null ,
"valueUrl" : "http://.../runtime/tasks/123/variables/binaryVariable/data"
}
删除任务变量
DELETE runtime/tasks/{taskId}/variables/{variableName}?scope={scope}
参数
是否必须
类型
描述
taskId
是
String
需要删除的变量对应的任务Id
variableName
是
String
需要删除的变量名称
scope
否
String
需要删除的变量的作用域.可以是local 或global. 如果忽略,默认为local
响应码
描述
204
表示找到了任务变量,并成功删除.响应体为空
404
表示找不到任务,或任务不包含指定名称的变量.状态信息包含错误的详细信息
删除任务所有局部变量
DELETE runtime/tasks/{taskId}/variables
参数
是否必须
类型
描述
taskId
是
String
需要删除的变量对应的任务Id
响应码
描述
204
表示已经删除了任务的所有局部变量.响应体为空
404
表示找不到任务
获得任务所有IdentityLink
GET runtime/tasks/{taskId}/identitylinks
获得任务所有IdentityLink-URL参数:
参数
是否必须
类型
描述
taskId
是
String
需要获得IdentityLink 对应的任务Id
响应码
描述
200
表示找到了任务,并返回IdentityLink
404
表示找不到任务
[
{
"userId" : "kermit" ,
"groupId" : null ,
"type" : "candidate" ,
"url" : "http://localhost:8081/activiti-rest/service/runtime/tasks/100/identitylinks/users/kermit/candidate"
} ,
{
"userId" : null ,
"groupId" : "sales" ,
"type" : "candidate" ,
"url" : "http://localhost:8081/activiti-rest/service/runtime/tasks/100/identitylinks/groups/sales/candidate"
} ,
...
]
获得一个任务所有组或用户的IdentityLink
GET runtime/tasks/{taskId}/identitylinks/users
GET runtime/tasks/{taskId}/identitylinks/groups
获得一个任务所有组或用户的IdentityLink-URL参数:
参数
是否必须
类型
描述
taskId
是
String
需要获得IdentityLink 对应的任务Id
响应码
描述
200
表示找到了任务,并返回IdentityLink
404
表示找不到任务
[
{
"userId" : "kermit" ,
"groupId" : null ,
"type" : "candidate" ,
"url" : "http://localhost:8081/activiti-rest/service/runtime/tasks/100/identitylinks/users/kermit/candidate"
} ,
{
"userId" : null ,
"groupId" : "sales" ,
"type" : "candidate" ,
"url" : "http://localhost:8081/activiti-rest/service/runtime/tasks/100/identitylinks/groups/sales/candidate"
} ,
...
]
获得一个任务的一个IdentityLink
GET runtime/tasks/{taskId}/identitylinks/{family}/{identityId}/{type}
获得一个任务的一个IdentityLink-URL参数:
参数
是否必须
类型
描述
taskId
是
String
任务的Id
family
是
String
groups 或users, 对应需要获得哪种IdentityLink
identityId
是
String
IdentityLink 的Id
type
是
String
IdentityLink 的类型
获得一个任务的一个IdentityLink-响应码:
响应码
描述
200
表示找到了任务和IdentityLink, 并成功返回
404
表示找不到任务,或任务不包含请求的IdentityLink. 状态包含错误的详细信息
{
"userId" : null ,
"groupId" : "sales" ,
"type" : "candidate" ,
"url" : "http://localhost:8081/activiti-rest/service/runtime/tasks/100/identitylinks/groups/sales/candidate"
}
创建任务的一个IdentityLink
POST runtime/tasks/{taskId}/identitylinks
参数
是否必须
类型
描述
taskId
是
String
任务Id
{
"userId" : "kermit" ,
"type" : "candidate" ,
}
{
"groupId" : "sales" ,
"type" : "candidate" ,
}
响应码
描述
201
表示找到了任务,并创建IdentityLink
404
表示找不到任务,或任务不包含请求的IdentityLink. 状态包含错误的详细信息
{
"userId" : null ,
"groupId" : "sales" ,
"type" : "candidate" ,
"url" : "http://localhost:8081/activiti-rest/service/runtime/tasks/100/identitylinks/groups/sales/candidate"
}
删除任务的一个IdentityLink
DELETE runtime/tasks/{taskId}/identitylinks/{family}/{identityId}/{type}
删除任务的一个IdentityLink-URL参数:
参数
是否必须
类型
描述
taskId
是
String
任务的Id
family
是
String
groups 或users, 对应需要获得哪种IdentityLink
identityId
是
String
IdentityLink 的Id
type
是
String
IdentityLink 的类型
响应码
描述
204
表示找到了任务和IdentityLInk, 并成功删除IdentityLink. 响应体为空
404
表示找不到任务,或任务不包含请求的IdentityLink. 状态包含错误的详细信息
创建任务评论
POST runtime/tasks/{taskId}/comments
参数
是否必须
类型
描述
taskId
是
String
创建评论对应的任务Id
{
"message" : "This is a comment on the task." ,
"saveProcessInstanceId" : true
}
saveProcessInstanceId 参数是可选的,如果为true 会为评论保存任务的流程实例Id
响应码
描述
201
表示创建了评论,并返回结果
400
表示请求不包含评论
404
表示找不到任务
{
"id" : "123" ,
"taskUrl" : "http://localhost:8081/activiti-rest/service/runtime/tasks/101/comments/123" ,
"processInstanceUrl" : "http://localhost:8081/activiti-rest/service/history/historic-process-instances/100/comments/123" ,
"message" : "This is a comment on the task." ,
"author" : "kermit" ,
"time" : "2014-07-13T13:13:52.232+08:00"
"taskId" : "101" ,
"processInstanceId" : "100"
}
获得任务所有评论
GET runtime/tasks/{taskId}/comments
参数
是否必须
类型
描述
taskId
是
String
获取评论对应的任务Id
响应码
描述
200
表示找到了任务,并返回评论
404
表示找不到任务
获得任务的一个评论
GET runtime/tasks/{taskId}/comments/{commentId}
参数
是否必须
类型
描述
taskId
是
String
获取评论对应的任务Id
commentId
是
String
评论的Id
响应码
描述
200
表示找到了任务和评论,并返回评论
404
表示找不到任务,或任务不包含指定Id的评论
{
"id" : "123" ,
"taskUrl" : "http://localhost:8081/activiti-rest/service/runtime/tasks/101/comments/123" ,
"processInstanceUrl" : "http://localhost:8081/activiti-rest/service/history/historic-process-instances/100/comments/123" ,
"message" : "This is a comment on the task." ,
"author" : "kermit" ,
"time" : "2014-07-13T13:13:52.232+08:00"
"taskId" : "101" ,
"processInstanceId" : "100"
}
删除任务的一条评论
DELETE runtime/tasks/{taskId}/comments/{commentId}
参数
是否必须
类型
描述
taskId
是
String
删除评论对应的任务Id
commentId
是
String
评论的Id
响应码
描述
204
表示找到了任务和评论,并删除评论.响应体为空
404
表示找不到任务,或任务不包含Id的评论
获得任务所有事件
GET runtime/tasks/{taskId}/events
参数
是否必须
类型
描述
taskId
是
String
需要获得事件对应的任务Id
响应码
描述
200
表示找到了任务,并返回事件
404
表示找不到任务
获得任务的一个事件
GET runtime/tasks/{taskId}/events/{eventId}
参数
是否必须
类型
描述
taskId
是
String
需要获得事件对应的任务Id
eventId
是
String
事件的Id
响应码
描述
200
表示找到了任务和事件,并返回事件
404
表示找不到任务,或任务不包含对应Id的事件
{
"action" : "AddUserLink" ,
"id" : "4" ,
"message" : [ "gonzo" , "contributor" ] ,
"taskUrl" : "http://localhost:8182/runtime/tasks/2" ,
"time" : "2013-05-17T11:50:50.000+0000" ,
"url" : "http://localhost:8182/runtime/tasks/2/events/4" ,
"userId" : null
}
创建任务的一个包含外部资源链接附件
POST runtime/tasks/{taskId}/attachments
参数
是否必须
类型
描述
taskId
是
类型
创建附件对应的任务Id
{
"name" : "Simple attachment" ,
"description" : "Simple attachment description" ,
"type" : "simpleType" ,
"externalUrl" : "http://activiti.org"
}
创建附件只有name 是必填的
响应码
描述
201
表示创建了附件,并返回结果
400
表示请求中缺少附件名称
404
表示找不到任务
{
"id" : "3" ,
"url" : "http://localhost:8182/runtime/tasks/2/attachments/3" ,
"name" : "Simple attachment" ,
"description" : "Simple attachment description" ,
"type" : "simpleType" ,
"taskUrl" : "http://localhost:8182/runtime/tasks/2" ,
"processInstanceUrl" : null ,
"externalUrl" : "http://activiti.org" ,
"contentUrl" : null
}
创建任务的一个包含附件文件附件
POST runtime/tasks/{taskId}/attachments
参数
是否必须
类型
描述
taskId
是
类型
创建附件对应的任务Id
请求JSON体:
请求应该是multipart/form-data 类型,应该只有一个文件区域,包含源码的二进制 内容.需要提供表单域:
name: 变量名称,不可省略
description: 附件的描述,可选
type: 变量类型.如果忽略,会假设使用binary, 请求的二进制数据会当作二进制数组保存起来
创建任务的一个包含附件文件附件-响应码:
响应码
描述
201
表示创建了附件,并返回结果
400
表示请求中缺少附件名称,或请求中未包含文件.错误信息中包含详细信息
404
表示找不到任务
{
"id" : "5" ,
"url" : "http://localhost:8182/runtime/tasks/2/attachments/5" ,
"name" : "Binary attachment" ,
"description" : "Binary attachment description" ,
"type" : "binaryType" ,
"taskUrl" : "http://localhost:8182/runtime/tasks/2" ,
"processInstanceUrl" : null ,
"externalUrl" : null ,
"contentUrl" : "http://localhost:8182/runtime/tasks/2/attachments/5/content"
}
获取任务所有附件
GET runtime/tasks/{taskId}/attachments
参数
是否必须
类型
描述
taskId
是
String
获取附件对应的任务Id
响应码
描述
200
表示找到了任务,并返回附件
404
表示找不到任务
[
{
"id" : "3" ,
"url" : "http://localhost:8182/runtime/tasks/2/attachments/3" ,
"name" : "Simple attachment" ,
"description" : "Simple attachment description" ,
"type" : "simpleType" ,
"taskUrl" : "http://localhost:8182/runtime/tasks/2" ,
"processInstanceUrl" : null ,
"externalUrl" : "http://activiti.org" ,
"contentUrl" : null
} ,
{
"id" : "5" ,
"url" : "http://localhost:8182/runtime/tasks/2/attachments/5" ,
"name" : "Binary attachment" ,
"description" : "Binary attachment description" ,
"type" : "binaryType" ,
"taskUrl" : "http://localhost:8182/runtime/tasks/2" ,
"processInstanceUrl" : null ,
"externalUrl" : null ,
"contentUrl" : "http://localhost:8182/runtime/tasks/2/attachments/5/content"
}
]
获取任务一个附件
GET runtime/tasks/{taskId}/attachments/{attachmentId}
参数
是否必须
类型
描述
taskId
是
String
获取附件对应的任务Id
attachmentId
是
String
附件的Id
响应码
描述
200
表示找到了任务和附件,并返回了附件
404
表示找不到任务,或任务不包含对应Id的附件
{
"id" : "5" ,
"url" : "http://localhost:8182/runtime/tasks/2/attachments/5" ,
"name" : "Binary attachment" ,
"description" : "Binary attachment description" ,
"type" : "binaryType" ,
"taskUrl" : "http://localhost:8182/runtime/tasks/2" ,
"processInstanceUrl" : null ,
"externalUrl" : null ,
"contentUrl" : "http://localhost:8182/runtime/tasks/2/attachments/5/content"
}
externalUrl: 如果附件是一个外部资源链接 ,externalUrl 包含外部内容的URL
contentUrl: 如果附件内容保存在Activiti引擎中 ,contentUrl 会包含获取二进制流内容的URL
type: 可以是任何有效值.包含一个格式合法的media-type 时(比如application/xml, text/plain), 二进制HTTP 响应的content-type 会被设置为对应值
获取附件内容
GET runtime/tasks/{taskId}/attachment/{attachmentId}/content
参数
是否必须
类型
描述
taskId
是
String
获取附件内容对应的任务Id
attachmentId
是
String
附件的Id,当附件指向外部URL, 而不是Activiti中的内容,就会返回404
响应码
描述
200
表示找到了任务和附件,并返回请求的内容
404
表示找不到任务,或任务不包含对应Id的附件,或附件不包含二进制流.状态信息包含错误详细信息
成功响应体:
响应体包含二进制内容
默认响应的content-type 设置为application/octet-stream, 除非附件类型包含合法的Content-Type
删除任务一个附件
DELETE runtime/tasks/{taskId}/attachments/{attachmentId}
参数
是否必须
类型
描述
taskId
是
String
需要删除附件对应的任务Id
attachmentId
是
String
附件的I
响应码
描述
204
表示找到了任务和附件,并删除附件.响应体为空
404
表示找不到任务,或任务不包含对应Id的附件
历史
获得历史流程实例
GET history/historic-process-instances/{processInstanceId}
响应码
描述
200
表示找到了历史流程实例
404
表示找不到历史流程实例
{
"data" : [
{
"id" : "5" ,
"businessKey" : "myKey" ,
"processDefinitionId" : "oneTaskProcess%3A1%3A4" ,
"processDefinitionUrl" : "http://localhost:8182/repository/process-definitions/oneTaskProcess%3A1%3A4" ,
"startTime" : "2013-04-17T10:17:43.902+0000" ,
"endTime" : "2013-04-18T14:06:32.715+0000" ,
"durationInMillis" : 86400056 ,
"startUserId" : "kermit" ,
"startActivityId" : "startEvent" ,
"endActivityId" : "endEvent" ,
"deleteReason" : null ,
"superProcessInstanceId" : "3" ,
"url" : "http://localhost:8182/history/historic-process-instances/5" ,
"variables" : null ,
"tenantId" : null
}
] ,
"total" : 1 ,
"start" : 0 ,
"sort" : "name" ,
"order" : "asc" ,
"size" : 1
}
获得历史流程实例列表
GET history/historic-process-instances
参数
是否必须
类型
描述
processInstanceId
否
String
历史流程实例Id
processDefinitionKey
否
String
历史流程实例的流程定义key
processDefinitionId
否
String
历史流程实例的流程定义Id
businessKey
否
String
历史流程实例的businessKey
involvedUser
否
String
历史流程实例的参与者
finished
否
Boolean
表示历史流程实例是否结束
superProcessInstanceId
否
String
历史流程实例的上级流程实例Id
excludeSubprocesses
否
Boolean
只返回非子流程的历史流程实例
finishedAfter
否
Date
只返回指定时间之后结束的历史流程实例
finishedBefore
否
Date
只返回指定时间之前结束的历史流程实例
startedAfter
否
Date
只返回指定时间之后开始的历史流程实例
startedBefore
否
Date
只返回指定时间之前开始的历史流程实例
startedBy
否
String
只返回由指定用户启动的历史流程实例
includeProcessVariables
否
Boolean
表示是否应该返回历史流程实例变量
tenantId
否
String
只返回指定tenantId的实例
tenantIdLike
否
String
只返回与指定tenantId匹配相似的实例
withoutTenantId
否
Boolean
如果为true, 只返回未设置tenantId 的实例.如果为false, 会忽略withoutTenantId 参数
可以使用通用的分页和排序查询参数
响应码
描述
200
表示成功返回了历史流程实例
400
表示传递了错误格式的参数.状态信息包含错误详细信息
{
"data" : [
{
"id" : "5" ,
"businessKey" : "myKey" ,
"processDefinitionId" : "oneTaskProcess%3A1%3A4" ,
"processDefinitionUrl" : "http://localhost:8182/repository/process-definitions/oneTaskProcess%3A1%3A4" ,
"startTime" : "2013-04-17T10:17:43.902+0000" ,
"endTime" : "2013-04-18T14:06:32.715+0000" ,
"durationInMillis" : 86400056 ,
"startUserId" : "kermit" ,
"startActivityId" : "startEvent" ,
"endActivityId" : "endEvent" ,
"deleteReason" : null ,
"superProcessInstanceId" : "3" ,
"url" : "http://localhost:8182/history/historic-process-instances/5" ,
"variables" : [
{
"name" : "test" ,
"variableScope" : "local" ,
"value" : "myTest"
}
] ,
"tenantId" : null
}
] ,
"total" : 1 ,
"start" : 0 ,
"sort" : "name" ,
"order" : "asc" ,
"size" : 1
}
查询历史流程实例
POST query/historic-process-instances
{
"processDefinitionId" : "oneTaskProcess%3A1%3A4" ,
...
"variables" : [
{
"name" : "myVariable" ,
"value" : 1234 ,
"operation" : "equals" ,
"type" : "long"
}
]
}
所有支持的JSON 参数字段和获得历史流程实例集合完全一样,但是传递的是JSON 参数,而不是URL 参数,这样可以支持更高级的参数,同时避免请求uri 过长
查询支持基于流程变量查询 :variables 属性是一个json 数组
查询历史流程实例-响应码:
响应码
描述
200
表示请求成功,并返回结果
400
表示传递了错误格式的参数.状态信息包含错误详细信息
{
"data" : [
{
"id" : "5" ,
"businessKey" : "myKey" ,
"processDefinitionId" : "oneTaskProcess%3A1%3A4" ,
"processDefinitionUrl" : "http://localhost:8182/repository/process-definitions/oneTaskProcess%3A1%3A4" ,
"startTime" : "2013-04-17T10:17:43.902+0000" ,
"endTime" : "2013-04-18T14:06:32.715+0000" ,
"durationInMillis" : 86400056 ,
"startUserId" : "kermit" ,
"startActivityId" : "startEvent" ,
"endActivityId" : "endEvent" ,
"deleteReason" : null ,
"superProcessInstanceId" : "3" ,
"url" : "http://localhost:8182/history/historic-process-instances/5" ,
"variables" : [
{
"name" : "test" ,
"variableScope" : "local" ,
"value" : "myTest"
}
] ,
"tenantId" : null
}
] ,
"total" : 1 ,
"start" : 0 ,
"sort" : "name" ,
"order" : "asc" ,
"size" : 1
}
删除历史流程实例
DELETE history/historic-process-instances/{processInstanceId}
响应码
描述
200
表示成功删除了历史流程实例
404
表示找不到历史流程实例
获取历史流程实例IdentityLink
GET history/historic-process-instance/{processInstanceId}/identitylinks
获取历史流程实例IdentityLink-响应码:
响应码
描述
200
表示请求成功,并返回IdentityLink
404
表示找不到历史流程实例
[
{
"type" : "participant" ,
"userId" : "kermit" ,
"groupId" : null ,
"taskId" : null ,
"taskUrl" : null ,
"processInstanceId" : "5" ,
"processInstanceUrl" : "http://localhost:8182/history/historic-process-instances/5"
}
]
获取历史流程实例变量二进制数据
GET history/historic-process-instances/{processInstanceId}/variables/{variableName}/data
响应码
描述
200
表示找到了历史流程实例,并返回请求的变量数据
404
表示找不到请求的历史流程实例,或流程实例不包含指定名称的变量,或变量不是二进制流.状态信息包含错误详细信息
成功响应体:
响应体包含变量的二进制值:
当类型为binary 时,无论请求的accept-type 头部设置了什么值,响应的content-type 都为application/octet-stream
当类型为serializable 时 ,content-type 为application/x-java-serialized-object
创建历史流程实例一条评论
POST history/historic-process-instances/{processInstanceId}/comments
参数
是否必须
类型
描述
processInstanceId
是
String
需要创建评论的流程实例Id
{
"message" : "This is a comment." ,
"saveProcessInstanceId" : true
}
saveProcessInstanceId 参数是可选的,如果为true 会为评论保存流程实例Id
响应码
描述
201
表示创建了评论,并返回结果
400
表示请求中未包含评论
404
表示找不到请求的历史流程实例
{
"id" : "123" ,
"taskUrl" : "http://localhost:8081/activiti-rest/service/runtime/tasks/101/comments/123" ,
"processInstanceUrl" : "http://localhost:8081/activiti-rest/service/history/historic-process-instances/100/comments/123" ,
"message" : "This is a comment on the task." ,
"author" : "kermit" ,
"time" : "2014-07-13T13:13:52.232+08:00" ,
"taskId" : "101" ,
"processInstanceId" : "100"
}
获得历史流程实例所有评论
GET history/historic-process-instances/{processInstanceId}/comments
参数
是否必须
类型
描述
processInstanceId
是
String
获取评论对应的流程实例Id
响应码
描述
200
表示找到了流程实例,并返回评论
404
表示找不到请求的流程实例
获得历史流程实例一条评论
GET history/historic-process-instances/{processInstanceId}/comments/{commentId}
参数
是否必须
类型
描述
processInstanceId
是
String
获得评论对应的历史流程实例Id
commentId
是
String
评论的Id
响应码
描述
200
表示找到了历史流程实例和评论,并返回评论
404
表示找不到请求的历史流程实例,或历史流程实例不包含指定Id的评论
{
"id" : "123" ,
"processInstanceUrl" : "http://localhost:8081/activiti-rest/service/history/historic-process-instances/100/comments/456" ,
"message" : "This is another comment." ,
"author" : "gonzo" ,
"time" : "2014-07-14T15:16:52.232+08:00" ,
"processInstanceId" : "100"
}
删除历史流程实例一条评论
DELETE history/historic-process-instances/{processInstanceId}/comments/{commentId}
参数
是否必须
类型
描述
processInstanceId
是
String
需要删除的评论对应的历史流程实例Id
commentId
是
String
评论Id
响应码
描述
204
表示找到了历史流程实例,并删除评论.响应体为空
404
表示找不到请求的历史流程实例,或历史流程实例不包含指定Id的评论
获得一个历史任务实例
GET history/historic-task-instances/{taskId}
响应码
描述
200
表示找到了历史任务实例
404
表示找不到历史任务实例
{
"id" : "5" ,
"processDefinitionId" : "oneTaskProcess%3A1%3A4" ,
"processDefinitionUrl" : "http://localhost:8182/repository/process-definitions/oneTaskProcess%3A1%3A4" ,
"processInstanceId" : "3" ,
"processInstanceUrl" : "http://localhost:8182/history/historic-process-instances/3" ,
"executionId" : "4" ,
"name" : "My task name" ,
"description" : "My task description" ,
"deleteReason" : null ,
"owner" : "kermit" ,
"assignee" : "fozzie" ,
"startTime" : "2013-04-17T10:17:43.902+0000" ,
"endTime" : "2013-04-18T14:06:32.715+0000" ,
"durationInMillis" : 86400056 ,
"workTimeInMillis" : 234890 ,
"claimTime" : "2013-04-18T11:01:54.715+0000" ,
"taskDefinitionKey" : "taskKey" ,
"formKey" : null ,
"priority" : 50 ,
"dueDate" : "2013-04-20T12:11:13.134+0000" ,
"parentTaskId" : null ,
"url" : "http://localhost:8182/history/historic-task-instances/5" ,
"variables" : null ,
"tenantId" : null
}
获取历史任务实例
GET history/historic-task-instances
参数
是否必须
类型
描述
taskId
否
String
历史任务实例Id
processInstanceId
否
String
历史任务实例的流程实例Id
processDefinitionKey
否
String
历史任务实例的流程定义key
processDefinitionKeyLike
否
String
与指定历史任务实例的流程定义key匹配相似的值
processDefinitionId
否
String
历史任务实例的流程定义Id
processDefinitionName
否
String
历史任务实例的流程定义名称
processDefinitionNameLike
否
String
与指定历史任务实例的流程定义名称匹配相似的值
processBusinessKey
否
String
历史任务实例的流程实例businessKey
processBusinessKeyLike
否
String
与指定历史任务实例的流程实例businessKey 匹配相似的值
executionId
否
String
历史任务实例的分支Id
taskDefinitionKey
否
String
流程的任务部分的流程定义key
taskName
否
String
历史任务实例的任务名称
taskNameLike
否
String
历史任务实例的任务名称匹配相似的值
taskDescription
否
String
历史任务实例的任务描述
taskDescriptionLike
否
String
与历史任务实例的任务描述匹配相似的值
taskDefinitionKey
否
String
历史任务实例对应的流程定义的任务定义key
taskDeleteReason
否
String
历史任务实例的删除任务原因
taskDeleteReasonLike
否
String
与历史任务实例的删除任务原因匹配相似的值
taskAssignee
否
String
历史任务实例的负责人
taskAssigneeLike
否
String
与历史任务实例的负责人匹配相似的值
taskOwner
否
String
历史任务实例的原拥有者
taskOwnerLike
否
String
与历史任务实例的原拥有者匹配相似的值
taskInvolvedUser
否
String
历史任务实例的参与者
taskPriority
否
String
历史任务实例的优先级
finished
否
Boolean
表示是否历史任务实例已经结束
processFinished
否
Boolean
表示历史任务实例的流程实例是否已经结束
parentTaskId
否
String
历史任务实例的可能的上级任务Id
dueDate
否
Date
只返回指定持续时间的历史任务实例
dueDateAfter
否
Date
只返回指定持续时间之后的历史任务实例
dueDateBefore
否
Date
只返回指定持续时间之前的历史任务实例
withoutDueDate
否
Boolean
只返回没有设置持续时间的历史任务实例.当设置为false 时会忽略这个参数
taskCompletedOn
否
Date
只返回在指定时间完成的历史任务实例
taskCompletedAfter
否
Date
只返回在指定时间之后完成的历史任务实例
taskCompletedBefore
否
Date
只返回在指定时间之前完成的历史任务实例
taskCreatedOn
否
Date
只返回指定时间创建的历史任务实例
taskCreatedBefore
否
Date
只返回在指定时间前创建的历史任务实例
taskCreatedAfter
否
Date
只返回在指定时间后创建的历史任务实例
includeTaskLocalVariables
否
Boolean
表示是否应该返回历史任务实例局部变量
includeProcessVariables
否
Boolean
表示是否应该返回历史任务实例全局变量
tenantId
否
String
只返回指定tenantId 的历史任务
tenantIdLike
否
String
只返回与指定tenantId 匹配相似的历史任务
withoutTenantId
否
Boolean
如果为true, 只返回未设置tenantId 的历史任务.如果为 false, 会忽略withoutTenantId 参数
可以使用通用的分页和排序查询参数
响应码
描述
200
表示可以查询到历史任务实例
404
表示传递了错误格式的参数.状态信息包含错误详细信息
{
"data" : [
{
"id" : "5" ,
"processDefinitionId" : "oneTaskProcess%3A1%3A4" ,
"processDefinitionUrl" : "http://localhost:8182/repository/process-definitions/oneTaskProcess%3A1%3A4" ,
"processInstanceId" : "3" ,
"processInstanceUrl" : "http://localhost:8182/history/historic-process-instances/3" ,
"executionId" : "4" ,
"name" : "My task name" ,
"description" : "My task description" ,
"deleteReason" : null ,
"owner" : "kermit" ,
"assignee" : "fozzie" ,
"startTime" : "2013-04-17T10:17:43.902+0000" ,
"endTime" : "2013-04-18T14:06:32.715+0000" ,
"durationInMillis" : 86400056 ,
"workTimeInMillis" : 234890 ,
"claimTime" : "2013-04-18T11:01:54.715+0000" ,
"taskDefinitionKey" : "taskKey" ,
"formKey" : null ,
"priority" : 50 ,
"dueDate" : "2013-04-20T12:11:13.134+0000" ,
"parentTaskId" : null ,
"url" : "http://localhost:8182/history/historic-task-instances/5" ,
"taskVariables" : [
{
"name" : "test" ,
"variableScope" : "local" ,
"value" : "myTest"
}
] ,
"processVariables" : [
{
"name" : "processTest" ,
"variableScope" : "global" ,
"value" : "myProcessTest"
}
] ,
"tenantId" : null
}
] ,
"total" : 1 ,
"start" : 0 ,
"sort" : "name" ,
"order" : "asc" ,
"size" : 1
}
查询历史任务实例
POST query/historic-task-instances
{
"processDefinitionId" : "oneTaskProcess%3A1%3A4" ,
...
"variables" : [
{
"name" : "myVariable" ,
"value" : 1234 ,
"operation" : "equals" ,
"type" : "long"
}
]
}
所有支持的JSON 参数字段和获得历史任务实例集合完全一样,但是传递的是JSON 参数,而不是URL 参数,这样可以支持更高级的参数,同时避免请求uri 过长
查询支持基于流程变量查询
taskVariables 和processVariables 属性是一个json 数组
查询历史任务实例-响应码:
响应码
描述
200
表示请求成功,并返回任务
400
表示传递了错误格式的参数.状态信息包含错误详细信息
{
"data" : [
{
"id" : "5" ,
"processDefinitionId" : "oneTaskProcess%3A1%3A4" ,
"processDefinitionUrl" : "http://localhost:8182/repository/process-definitions/oneTaskProcess%3A1%3A4" ,
"processInstanceId" : "3" ,
"processInstanceUrl" : "http://localhost:8182/history/historic-process-instances/3" ,
"executionId" : "4" ,
"name" : "My task name" ,
"description" : "My task description" ,
"deleteReason" : null ,
"owner" : "kermit" ,
"assignee" : "fozzie" ,
"startTime" : "2013-04-17T10:17:43.902+0000" ,
"endTime" : "2013-04-18T14:06:32.715+0000" ,
"durationInMillis" : 86400056 ,
"workTimeInMillis" : 234890 ,
"claimTime" : "2013-04-18T11:01:54.715+0000" ,
"taskDefinitionKey" : "taskKey" ,
"formKey" : null ,
"priority" : 50 ,
"dueDate" : "2013-04-20T12:11:13.134+0000" ,
"parentTaskId" : null ,
"url" : "http://localhost:8182/history/historic-task-instances/5" ,
"taskVariables" : [
{
"name" : "test" ,
"variableScope" : "local" ,
"value" : "myTest"
}
] ,
"processVariables" : [
{
"name" : "processTest" ,
"variableScope" : "global" ,
"value" : "myProcessTest"
}
]
}
] ,
"total" : 1 ,
"start" : 0 ,
"sort" : "name" ,
"order" : "asc" ,
"size" : 1
}
删除历史任务实例
DELETE history/historic-task-instances/{taskId}
响应码
描述
200
表示删除了历史任务实例
404
表示找不到历史任务实例
获得历史任务实例IdentityLink
GET history/historic-task-instance/{taskId}/identitylinks
获得历史任务实例IdentityLink-响应码:
响应码
描述
200
表示请求成功,并返回IdentityLink
404
表示找不到任务实例
[
{
"type" : "assignee" ,
"userId" : "kermit" ,
"groupId" : null ,
"taskId" : "6" ,
"taskUrl" : "http://localhost:8182/history/historic-task-instances/5" ,
"processInstanceId" : null ,
"processInstanceUrl" : null
}
]
获取历史任务实例变量的二进制值
GET history/historic-task-instances/{taskId}/variables/{variableName}/data
响应码
描述
200
表示找到了任务实例,并返回请求的变量数据
404
表示找不到任务实例,或任务实例不包含指定名称的变量,或变量没有有效的二进制流.状态信息包含错误详细信息
成功响应体:
响应体包含变量的二进制值:
当类型为binary 时,无论请求的accept-type 头部设置了什么值,响应的content-type 都为application/octet-stream
当类型为serializable 时 ,content-type 为application/x-java-serialized-object
获得历史活动实例
GET history/historic-activity-instances
参数
是否必须
类型
描述
activityId
否
String
历史活动Id
activityInstanceId
否
String
历史活动实例Id
activityName
否
String
历史活动实例的名称
activityType
否
String
历史活动实例的元素类型
executionId
否
String
历史活动实例的分支Id
finished
否
Boolean
表示历史活动实例是否完成
taskAssignee
否
String
历史活动实例的负责人
processInstanceId
否
String
历史活动实例的流程实例Id
processDefinitionId
否
String
历史活动实例的流程定义Id
tenantId
否
String
只返回指定tenantId的实例
tenantIdLike
否
String
只返回与指定tenantId匹配相似的实例
withoutTenantId
否
Boolean
如果为true, 只返回未设置tenantId 的历史活动实例,如果为false, 会忽略withoutTenantId 参数
响应码
描述
200
表示返回了查询的历史活动实例
400
表示传递了错误格式的参数.状态信息包含错误详细信息
{
"data" : [
{
"id" : "5" ,
"activityId" : "4" ,
"activityName" : "My user task" ,
"activityType" : "userTask" ,
"processDefinitionId" : "oneTaskProcess%3A1%3A4" ,
"processDefinitionUrl" : "http://localhost:8182/repository/process-definitions/oneTaskProcess%3A1%3A4" ,
"processInstanceId" : "3" ,
"processInstanceUrl" : "http://localhost:8182/history/historic-process-instances/3" ,
"executionId" : "4" ,
"taskId" : "4" ,
"calledProcessInstanceId" : null ,
"assignee" : "fozzie" ,
"startTime" : "2013-04-17T10:17:43.902+0000" ,
"endTime" : "2013-04-18T14:06:32.715+0000" ,
"durationInMillis" : 86400056 ,
"tenantId" : null
}
] ,
"total" : 1 ,
"start" : 0 ,
"sort" : "name" ,
"order" : "asc" ,
"size" : 1
}
查询历史活动实例
POST query/historic-activity-instances
{
"processDefinitionId" : "oneTaskProcess%3A1%3A4"
}
所有支持的JSON 参数字段和获得历史任务实例集合完全一样,但是传递的是JSON 参数,而不是URL 参数,这样可以支持更高级的参数,同时避免请求uri 过长
响应码
描述
200
表示请求成功,并返回历史活动实例
400
表示传递了错误格式的参数.状态信息包含错误详细信息
{
"data" : [
{
"id" : "5" ,
"activityId" : "4" ,
"activityName" : "My user task" ,
"activityType" : "userTask" ,
"processDefinitionId" : "oneTaskProcess%3A1%3A4" ,
"processDefinitionUrl" : "http://localhost:8182/repository/process-definitions/oneTaskProcess%3A1%3A4" ,
"processInstanceId" : "3" ,
"processInstanceUrl" : "http://localhost:8182/history/historic-process-instances/3" ,
"executionId" : "4" ,
"taskId" : "4" ,
"calledProcessInstanceId" : null ,
"assignee" : "fozzie" ,
"startTime" : "2013-04-17T10:17:43.902+0000" ,
"endTime" : "2013-04-18T14:06:32.715+0000" ,
"durationInMillis" : 86400056 ,
"tenantId" : null
}
] ,
"total" : 1 ,
"start" : 0 ,
"sort" : "name" ,
"order" : "asc" ,
"size" : 1
}
获得历史变量实例
GET history/historic-variable-instances
参数
是否必须
类型
描述
processInstanceId
否
String
历史变量实例的流程实例Id
taskId
否
String
历史变量实例的任务Id
excludeTaskVariables
否
Boolean
表示从结果中排除任务变量
variableName
否
String
历史变量实例的变量名称
variableNameLike
否
String
与历史变量实例的变量名称匹配相似的值
可以使用通用的分页和排序查询参数
响应码
描述
200
表示获得了历史变量实例
400
表示传递了错误格式的参数.状态信息包含错误详细信息
{
"data" : [
{
"id" : "14" ,
"processInstanceId" : "5" ,
"processInstanceUrl" : "http://localhost:8182/history/historic-process-instances/5" ,
"taskId" : "6" ,
"variable" : {
"name" : "myVariable" ,
"variableScope" , "global" ,
"value" : "test"
}
}
] ,
"total" : 1 ,
"start" : 0 ,
"sort" : "name" ,
"order" : "asc" ,
"size" : 1
}
查询历史变量实例
POST query/historic-variable-instances
{
"processDefinitionId" : "oneTaskProcess%3A1%3A4" ,
...
"variables" : [
{
"name" : "myVariable" ,
"value" : 1234 ,
"operation" : "equals" ,
"type" : "long"
}
]
}
所有支持的JSON 参数字段和获得历史变量实例集合完全一样,但是传递的是JSON 参数,而不是URL 参数,这样可以支持更高级的参数,同时避免请求uri 过长.
查询支持基于流程变量查询
variables 属性是一个json 数组,包含此处描述的格式
查询历史变量实例-响应码:
响应码
描述
200
表示请求成功,并返回任务
400
表示传递了错误格式的参数.状态信息包含错误详细信息
{
"data" : [
{
"id" : "14" ,
"processInstanceId" : "5" ,
"processInstanceUrl" : "http://localhost:8182/history/historic-process-instances/5" ,
"taskId" : "6" ,
"variable" : {
"name" : "myVariable" ,
"variableScope" , "global" ,
"value" : "test"
}
}
] ,
"total" : 1 ,
"start" : 0 ,
"sort" : "name" ,
"order" : "asc" ,
"size" : 1
}
获得历史变量实例二进制值
GET history/historic-variable-instances/{varInstanceId}/data
响应码
描述
200
表示找到了变量实例,并返回请求的变量数据
404
表示找不到变量实例,或找不到对应名称的变量实例,或变量不包含合法的二进制流.状态信息包含了详细信息
成功响应体:
响应体包含变量的二进制值:
当类型为binary 时,无论请求的accept-type 头部设置了什么值,响应的content-type 都为application/octet-stream
当类型为serializable 时 ,content-type 为application/x-java-serialized-object
获得历史细节
GET history/historic-detail
参数
是否必须
类型
描述
id
否
String
历史细节的Id
processInstanceId
否
String
历史细节的流程实例Id
executionId
否
String
历史细节的分支Id
activityInstanceId
否
String
历史细节的活动实例Id
taskId
否
String
历史细节的任务Id
selectOnlyFormProperties
否
Boolean
表示结果中只返回FormProperties
selectOnlyVariableUpdates
否
String
表示结果中只返回变量更新信息
响应码
描述
200
表示返回了查询的历史细节
400
表示传递了错误格式的参数.状态信息包含错误详细信息
{
"data" : [
{
"id" : "26" ,
"processInstanceId" : "5" ,
"processInstanceUrl" : "http://localhost:8182/history/historic-process-instances/5" ,
"executionId" : "6" ,
"activityInstanceId" , "10" ,
"taskId" : "6" ,
"taskUrl" : "http://localhost:8182/history/historic-task-instances/6" ,
"time" : "2013-04-17T10:17:43.902+0000" ,
"detailType" : "variableUpdate" ,
"revision" : 2 ,
"variable" : {
"name" : "myVariable" ,
"variableScope" , "global" ,
"value" : "test"
} ,
"propertyId" , null ,
"propertyValue" , null
}
] ,
"total" : 1 ,
"start" : 0 ,
"sort" : "name" ,
"order" : "asc" ,
"size" : 1
}
查询历史细节
POST query/historic-detail
{
"processInstanceId" : "5" ,
}
所有支持的JSON 参数字段和获得历史变量实例集合完全一样,但是传递的是JSON 参数,而不是URL 参数,这样可以支持更高级的参数,同时避免请求uri 过长
响应码
描述
200
表示请求成功,并返回历史细节
400
表示传递了错误格式的参数.状态信息包含错误详细信息
{
"data" : [
{
"id" : "26" ,
"processInstanceId" : "5" ,
"processInstanceUrl" : "http://localhost:8182/history/historic-process-instances/5" ,
"executionId" : "6" ,
"activityInstanceId" , "10" ,
"taskId" : "6" ,
"taskUrl" : "http://localhost:8182/history/historic-task-instances/6" ,
"time" : "2013-04-17T10:17:43.902+0000" ,
"detailType" : "variableUpdate" ,
"revision" : 2 ,
"variable" : {
"name" : "myVariable" ,
"variableScope" , "global" ,
"value" : "test"
} ,
"propertyId" , null ,
"propertyValue" , null
}
] ,
"total" : 1 ,
"start" : 0 ,
"sort" : "name" ,
"order" : "asc" ,
"size" : 1
}
获得历史细节变量二进制数据
GET history/historic-detail/{detailId}/data
响应码
描述
200
表示找到了历史细节实例,并返回请求的变量数据
404
表示找不到历史细节实例,或历史细节实例不包含指定名称的变量,或变量不包含合法的二进制流.状态信息包含错误详细信息
成功响应体:
响应体包含变量的二进制值:
当类型为binary 时,无论请求的accept-type 头部设置了什么值,响应的content-type 都为application/octet-stream
当类型为serializable 时 ,content-type 为application/x-java-serialized-object
表单
获得表单数据
GET form/form-data
参数
是否必须
类型
描述
taskId
是(如果没有processDefinitionId )
String
获取表单数据需要对应的任务Id
processDefinitionId
是(如果没有taskId )
String
获取startEvent 表单数据需要对应的流程定义Id
响应码
描述
200
表示返回了查询的表单数据
404
表示找不到表单数据
{
"data" : [
{
"formKey" : null ,
"deploymentId" : "2" ,
"processDefinitionId" : "3" ,
"processDefinitionUrl" : "http://localhost:8182/repository/process-definition/3" ,
"taskId" : "6" ,
"taskUrl" : "http://localhost:8182/runtime/task/6" ,
"formProperties" : [
{
"id" : "room" ,
"name" : "Room" ,
"type" : "string" ,
"value" : null ,
"readable" : true ,
"writable" : true ,
"required" : true ,
"datePattern" : null ,
"enumValues" : [
{
"id" : "normal" ,
"name" : "Normal bed"
} ,
{
"id" : "kingsize" ,
"name" : "Kingsize bed"
} ,
]
}
]
}
] ,
"total" : 1 ,
"start" : 0 ,
"sort" : "name" ,
"order" : "asc" ,
"size" : 1
}
提交任务表单数据
POST form/form-data
{
"taskId" : "5" ,
"properties" : [
{
"id" : "room" ,
"value" : "normal"
}
]
}
{
"processDefinitionId" : "5" ,
"businessKey" : "myKey" , ( optional)
"properties" : [
{
"id" : "room" ,
"value" : "normal"
}
]
}
响应码
描述
200
表示请求成功,并提交表单数据
400
表示传递了错误格式的参数.状态信息包含错误详细信息
任务表单数据成功响应体为空
成功响应体-startEvent表单数据:
{
"id" : "5" ,
"url" : "http://localhost:8182/history/historic-process-instances/5" ,
"businessKey" : "myKey" ,
"suspended" , false ,
"processDefinitionId" : "3" ,
"processDefinitionUrl" : "http://localhost:8182/repository/process-definition/3" ,
"activityId" : "myTask"
}
数据库
获得数据库表列表
GET management/tables
[
{
"name" : "ACT_RU_VARIABLE" ,
"url" : "http://localhost:8182/management/tables/ACT_RU_VARIABLE" ,
"count" : 4528
} ,
{
"name" : "ACT_RU_EVENT_SUBSCR" ,
"url" : "http://localhost:8182/management/tables/ACT_RU_EVENT_SUBSCR" ,
"count" : 3
} ,
...
]
获得数据库一张表
GET management/tables/{tableName}
参数
是否必须
类型
描述
tableName
是
String
需要获得的数据库表名
响应码
描述
200
表示表存在,并返回表的记录数
404
表示表不存在
{
"name" : "ACT_RE_PROCDEF" ,
"url" : "http://localhost:8182/management/tables/ACT_RE_PROCDEF" ,
"count" : 60
}
获得数据库表的列信息
GET management/tables/{tableName}/columns
参数
是否必须
类型
描述
tableName
是
String
需要获得的数据库表列信息的表名
响应码
描述
200
表示表存在,并返回表的列信息
404
表示表不存在
获得数据库表的行数据
GET management/tables/{tableName}/data
参数
是否必须
类型
描述
tableName
是
String
获得数据库表的行数据的表名称
start
否
Integer
从哪一行开始获取.默认为0
size
否
Integer
获取行数,从start开始.默认为10
orderAscendingColumn
否
String
对结果行进行排序的字段,正序
orderDescendingColumn
否
String
对结果行进行排序的字段,倒序
响应码
描述
200
表示表存在,并返回行数据
404
表示表不存在
{
"total" : 3 ,
"start" : 0 ,
"sort" : null ,
"order" : null ,
"size" : 3 ,
"data" : [
{
"TASK_ID_" : "2" ,
"NAME_" : "var1" ,
"REV_" : 1 ,
"TEXT_" : "123" ,
"LONG_" : 123 ,
"ID_" : "3" ,
"TYPE_" : "integer"
} ,
...
]
}
引擎
获得引擎属性
GET management/properties
返回引擎内部使用的只读属性
{
"next.dbid" : "101" ,
"schema.history" : "create(5.14)" ,
"schema.version" : "5.14"
}
获得引擎信息
GET management/engine
{
"name" : "default" ,
"version" : "5.14" ,
"resourceUrl" : "file://activiti/activiti.cfg.xml" ,
"exception" : null
}
运行过程
接收信号事件
POST runtime/signals
提醒引擎,接收了一个信号事件,不会特别针对某个流程
{
"signalName" : "My Signal" ,
"tenantId" : "execute" ,
"async" : true ,
"variables" : [
{ "name" : "testVar" , "value" : "This is a string" } ,
...
]
}
参数
描述
signalName
signal的名称
tenantId
信号事件应该执行的tenantId
async
如果为true,处理信号应该是异步的.返回码为 202-Accepted, 表示请求已接受,但尚未执行.如果为false, 会立即处理信号,结果为200-OK, 会在成功完成后返回.如果忽略,默认为false
响应码
描述
200
表示已经处理了信号,没有发生错误
202
表示信号处理已经进入一个异步作业的队列,准备执行
400
信号没有处理.缺少信号名,或同时使用变量和异步,这是不允许的.响应体包含错误的详细信息
作业
获得一个作业
GET management/jobs/{jobId}
参数
是否必须
类型
描述
jobId
是
String
获取的作业Id
响应码
描述
200
表示作业存在,并成功返回
404
表示作业不存在
删除作业
DELETE management/jobs/{jobId}
参数
是否必须
类型
描述
jobId
是
String
需要删除的作业Id
响应码
描述
204
表示找到了作业,并成功删除.响应体为空
404
表示找不到作业
执行作业
POST management/jobs/{jobId}
{
"action" : "execute"
}
参数
是否必须
类型
描述
action
是
只支持execute
执行的操作
响应码
描述
204
表示成功执行了操作.响应体为空
404
表示找不到作业
500
表示执行作业时出现异常,状态描述包含错误的详细信息.如果需要可以后续获取错误堆栈
获得作业异常堆栈
GET management/jobs/{jobId}/exception-stracktrace
参数
是否必须
类型
描述
jobId
是
String
获得堆栈的作业Id
响应码
描述
200
表示找到了作业,并返回堆栈.响应包含原始堆栈 ,Content-Type 永远是text/plain
获得作业列表
GET management/jobs
参数
是否必须
类型
描述
id
否
String
只返回指定Id的作业
processInstanceId
否
String
只返回指定流程实例Id一部分的作业
executionId
否
String
只返回指定分支Id一部分的作业
processDefinitionId
否
String
只返回指定流程定义Id的作业
WithRetriesLeft
否
Boolean
如果为true, 只返回尝试剩下的.如果为false, 会忽略此参数
executable
否
Boolean
如果为true, 只返回可执行的作业.如果为false, 会忽略此参数
timersOnly
否
Boolean
如果为true, 只返回类型为定时器的作业.如果为false, 会忽略此参数.不能与messagesOnly 一起使用
messagesOnly
否
Boolean
如果为true, 只返回类型为消息的作业.如果为false, 会忽略此参数.不能与timersOnly 一起使用
withException
否
Boolean
如果为true, 只返回执行时出现异常的作业.如果为false, 会忽略此参数
dueBefore
否
Date
只返回在指定时间前到期的作业.如果使用这个参数,就不会返回没有设置持续时间的作业
dueAfter
否
Date
只返回在指定时间后到期的作业.如果使用这个参数,就不会返回没有设置持续时间的作业
exceptionMessage
否
String
只返回有异常信息的作业
tenantId
否
String
只返回指定tenantId的作业
tenantIdLike
否
String
只返回与指定tenantId匹配相似的作业
withoutTenantId
否
Boolean
如果为true, 只返回未设置tenantId 的作业.如果为false, 会忽略withoutTenantId 参数
sort
否
String
对结果进行排序的字段.可以是id, dueDate, executionId,processInstanceId,retries 或tenantId 其中之一
可以使用通用的分页和排序查询参数
响应码
描述
200
表示返回了作业
400
表示在url 参数中使用了非法的值,或参数中同时使用了messagesOnly 和timersOnly. 状态描述包含错误的详细信息
用户
获得一个用户
GET identity/users/{userId}
参数
是否必须
类型
描述
userId
是
String
获得的用户Id
响应码
描述
200
表示用户存在,并成功返回
404
表示用户不存在
获得用户列表
GET identity/users
参数
是否必须
类型
描述
id
否
String
只返回指定Id的用户
firstName
否
String
只返回指定firstname的用户
lastName
否
String
只返回指定lastname的用户
email
否
String
只返回指定email的用户
firstNameLike
否
String
只返回与指定firstname匹配相似的用户.使用 % 通配符
lastNameLike
否
String
只返回与指定lastname匹配相似的用户.使用 % 通配符
emailLike
否
String
只返回与指定email匹配相似的用户.使用 % 通配符
memberOfGroup
否
String
只返回指定组成员的用户
potentialStarter
否
String
只返回指定流程定义Id的默认启动人
sort
否
String
结果排序的字段,应该是id,firstName,lastname 或email 其中之一
可以使用通用的分页和排序查询参数
{
"data" : [
{
"id" : "anotherUser" ,
"firstName" : "Tijs" ,
"lastName" : "Barrez" ,
"url" : "http://localhost:8182/identity/users/anotherUser" ,
"email" : "[email protected] "
} ,
{
"id" : "kermit" ,
"firstName" : "Kermit" ,
"lastName" : "the Frog" ,
"url" : "http://localhost:8182/identity/users/kermit" ,
"email" : null
} ,
{
"id" : "testuser" ,
"firstName" : "Fred" ,
"lastName" : "McDonald" ,
"url" : "http://localhost:8182/identity/users/testuser" ,
"email" : "[email protected] "
}
] ,
"total" : 3 ,
"start" : 0 ,
"sort" : "id" ,
"order" : "asc" ,
"size" : 3
}
更新用户
PUT identity/users/{userId}
{
"firstName" : "Tijs" ,
"lastName" : "Barrez" ,
"email" : "[email protected] " ,
"password" : "pass123"
}
所有请求值都是可选的:
可以在请求体JSON 对象中只包含firstName 属性,只更新用户的firstName, 其他值都不受影响
当包含的属性设置为null, 用户的属性会被更新为null:
{“firstName” : null} - 会清空用户的firstName
更新用户-响应码:
响应码
描述
200
表示成功更新用户
404
表示找不到用户
409
表示请求的用户已经更新了
{
"id" : "testuser" ,
"firstName" : "Fred" ,
"lastName" : "McDonald" ,
"url" : "http://localhost:8182/identity/users/testuser" ,
"email" : "[email protected] "
}
创建用户
POST identity/users
{
"id" : "tijs" ,
"firstName" : "Tijs" ,
"lastName" : "Barrez" ,
"email" : "[email protected] " ,
"password" : "pass123"
}
响应码
描述
201
表示成功创建用户
400
表示没有请求到用户的Id
{
"id" : "testuser" ,
"firstName" : "Fred" ,
"lastName" : "McDonald" ,
"url" : "http://localhost:8182/identity/users/testuser" ,
"email" : "[email protected] "
}
删除用户
DELETE identity/users/{userId}
参数
是否必须
类型
描述
userId
是
类型
需要删除的用户Id
响应码
描述
204
表示找到了用户,并成功删除.响应体为空
404
表示找不到用户
获得用户图片
GET identity/users/{userId}/picture
参数
是否必须
类型
描述
userId
是
String
需要获得图片的用户Id
响应码
描述
200
表示找到了用户和图片,图片在响应体中返回
404
表示找不到用户,或用户没有图片.状态描述包含错误的详细信息
成功响应体:
响应体包含演示图片数据,展示用户的图片
响应的Content-Type 对应着创建图片时设置的mimeType
更新用户图片
PUT identity/users/{userId}/picture
参数
是否必须
类型
描述
userId
是
String
更新图片对应的用户Id
请求JSON体:
请求应该是multipart/form-data 类型.应该只有一个文件区域,包含源码的二进制内容.需要提供表单域:
mimeType: 上传的图片的mime-type. 如果省略,默认会使用image/jpeg 作为图片的mime-type
更新用户图片-响应码:
响应码
描述
200
表示找到了用户,并更新图片.响应体为空
404
表示找不到用户
获得用户列表信息
GET identity/users/{userId}/info
参数
是否必须
类型
描述
userId
是
String
获得列表信息的用户Id
响应码
描述
200
表示找到了用户,并返回信息列表 :key 和url
404
表示找不到用户
[
{
"key" : "key1" ,
"url" : "http://localhost:8182/identity/users/testuser/info/key1"
} ,
{
"key" : "key2" ,
"url" : "http://localhost:8182/identity/users/testuser/info/key2"
}
]
获得用户信息
GET identity/users/{userId}/info/{key}
参数
是否必须
类型
描述
userId
是
String
获得的信息用户Id
key
是
String
需要获得的用户信息的key
响应码
描述
200
表示找到了用户和指定key的用户信息
404
表示找不到用户,并且用户没有指定key的信息.状态描述中包含错误相关的详细信息
{
"key" : "key1" ,
"value" : "Value 1" ,
"url" : "http://localhost:8182/identity/users/testuser/info/key1"
}
更新用户信息
PUT identity/users/{userId}/info/{key}
参数
是否必须
类型
描述
userId
是
String
需要更新的信息对应的用户Id
key
是
String
需要更新的用户信息的key
{
"value" : "The updated value"
}
响应码
描述
200
表示找到了用户,并更新信息
400
表示缺少请求体中数据
404
表示找不到用户,或找不到指定key的用户信息.状态描述中包含错误详细信息
{
"key" : "key1" ,
"value" : "The updated value" ,
"url" : "http://localhost:8182/identity/users/testuser/info/key1"
}
创建用户信息条目
POST identity/users/{userId}/info
参数
是否必须
类型
描述
userId
是
String
需要创建信息条目的用户Id
{
"key" : "key1" ,
"value" : "The value"
}
响应码
描述
201
表示找到了用户,并创建信息
400
表示请求体中缺少key 或value. 状态描述中包含错误详细信息
{
"key" : "key1" ,
"value" : "The value" ,
"url" : "http://localhost:8182/identity/users/testuser/info/key1"
}
删除用户信息条目
DELETE identity/users/{userId}/info/{key}
参数
是否必须
类型
描述
userId
是
String
需要删除信息条目的用户Id
key
是
String
需要删除的用户信息条目的key
响应码
描述
204
表示找到了用户和信息,并删除指定key的条目.响应体为空
404
表示找不到用户,或用户不包含指定key的信息.状态描述中包含错误的详细信息
群组
获得群组
GET identity/groups/{groupId}
参数
是否必须
类型
描述
groupId
是
String
需要获得的群组Id
响应码
描述
200
表示群组存在,并成功返回
404
表示群组不存在
{
"id" : "testgroup" ,
"url" : "http://localhost:8182/identity/groups/testgroup" ,
"name" : "Test group" ,
"type" : "Test type"
}
获得群组列表
GET identity/groups
参数列表
是否必须
类型
描述
id
否
String
只返回指定id的群组
name
否
String
只返回指定名称的群组
type
否
String
只返回指定类型的群组
nameLike
否
String
只返回与指定名称匹配相似的群组,使用 % 作为通配符
member
否
String
只返回成员与指定用户相同的群组
potentialStarter
否
String
只返回成员作为指定流程定义Id的潜在启动者的群组
sort
否
String
结果排序的字段.应该是id,name 或type 其中之一
可以使用通用的分页和排序查询参数
更新群组
PUT identity/groups/{groupId}
{
"name" : "Test group" ,
"type" : "Test type"
}
所有请求值都是可选的:
可以在请求体JSON 对象中只包含name 属性,只更新群组的名称,其他属性都不会受到影响
如果想要把一个属性设为空,可以设置为null, 群组的数据就会更新为null
更新群组-响应码:
响应码
描述
200
表示成功更新群组
404
表示找不到请求的群组
409
表示请求的群组已经被更新
{
"id" : "testgroup" ,
"url" : "http://localhost:8182/identity/groups/testgroup" ,
"name" : "Test group" ,
"type" : "Test type"
}
创建群组
POST identity/groups
{
"id" : "testgroup" ,
"name" : "Test group" ,
"type" : "Test type"
}
响应码
描述
201
表示创建了群组
400
表示未找到群组Id
{
"id" : "testgroup" ,
"url" : "http://localhost:8182/identity/groups/testgroup" ,
"name" : "Test group" ,
"type" : "Test type"
}
删除群组
DELETE identity/groups/{groupId}
参数
是否必须
类型
描述
groupId
是
String
需要删除的群组Id
响应码
描述
204
表示找到了群组,并成功删除.响应体为空
404
表示找不到请求的群组
获得群组成员
identity/groups/members 不允许使用GET
使用identity/users?memberOfGroup=sales 的URL 来获得某个群组下的所有成员
创建群组一个成员
POST identity/groups/{groupId}/members
参数
是否必须
类型
描述
groupId
是
String
需要添加成员的群组Id
{
"userId" : "kermit"
}
响应码
描述
201
表示找到了群组,并添加成员
400
表示请求体中没有userId
404
表示找不到请求的群组
409
表示请求的用户已经是群组的一员
{
"userId" : "kermit" ,
"groupId" : "sales" ,
"url" : "http://localhost:8182/identity/groups/sales/members/kermit"
}
删除群组成员
DELETE identity/groups/{groupId}/members/{userId}
参数
是否必须
类型
描述
groupId
是
String
需要删除成员的群组Id
userId
是
String
期望删除的用户Id
响应码
描述
204
表示找到了群组,并删除成员.响应体为空
404
表示找不到请求的群组,或用户不是群组的成员.状态描述中包含错误详细信息
{
"userId" : "kermit" ,
"groupId" : "sales" ,
"url" : "http://localhost:8182/identity/groups/sales/members/kermit"
}