Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
开发团队
Flowable Engine
提交
95c0b213
F
Flowable Engine
项目概览
开发团队
/
Flowable Engine
通知
9
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
Flowable Engine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
95c0b213
编写于
5月 31, 2013
作者:
F
Frederik Heremans
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added management/tables to REST
上级
f2555d18
变更
19
隐藏空白更改
内联
并排
Showing
19 changed file
with
400 addition
and
36 deletion
+400
-36
modules/activiti-common-rest/src/main/java/org/activiti/rest/api/DataResponse.java
...est/src/main/java/org/activiti/rest/api/DataResponse.java
+1
-1
modules/activiti-engine/src/main/java/org/activiti/engine/ManagementService.java
.../src/main/java/org/activiti/engine/ManagementService.java
+0
-1
modules/activiti-rest/src/main/java/org/activiti/rest/api/RestResponseFactory.java
.../main/java/org/activiti/rest/api/RestResponseFactory.java
+9
-0
modules/activiti-rest/src/main/java/org/activiti/rest/api/RestUrls.java
...ti-rest/src/main/java/org/activiti/rest/api/RestUrls.java
+13
-1
modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/management/JobExecuteResource.java
...tiviti/rest/api/legacy/management/JobExecuteResource.java
+1
-1
modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/management/JobsExecuteResource.java
...iviti/rest/api/legacy/management/JobsExecuteResource.java
+1
-1
modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/management/JobsPaginateList.java
...activiti/rest/api/legacy/management/JobsPaginateList.java
+3
-3
modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/management/JobsResource.java
...org/activiti/rest/api/legacy/management/JobsResource.java
+1
-1
modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/management/LegacyJobResource.java
...ctiviti/rest/api/legacy/management/LegacyJobResource.java
+4
-4
modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/management/LegacyJobResponse.java
...ctiviti/rest/api/legacy/management/LegacyJobResponse.java
+3
-3
modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/management/LegacyTableDataResource.java
...i/rest/api/legacy/management/LegacyTableDataResource.java
+2
-2
modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/management/LegacyTableResource.java
...iviti/rest/api/legacy/management/LegacyTableResource.java
+37
-0
modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/management/TablesResource.java
...g/activiti/rest/api/legacy/management/TablesResource.java
+1
-1
modules/activiti-rest/src/main/java/org/activiti/rest/api/management/TableCollectionResource.java
...activiti/rest/api/management/TableCollectionResource.java
+47
-0
modules/activiti-rest/src/main/java/org/activiti/rest/api/management/TableResource.java
.../java/org/activiti/rest/api/management/TableResource.java
+27
-8
modules/activiti-rest/src/main/java/org/activiti/rest/api/management/TableResponse.java
.../java/org/activiti/rest/api/management/TableResponse.java
+49
-0
modules/activiti-rest/src/main/java/org/activiti/rest/application/RestServicesInit.java
.../java/org/activiti/rest/application/RestServicesInit.java
+14
-9
modules/activiti-rest/src/test/java/org/activiti/rest/api/management/TableResourceTest.java
...a/org/activiti/rest/api/management/TableResourceTest.java
+78
-0
userguide/src/en/chapters/ch14-REST.xml
userguide/src/en/chapters/ch14-REST.xml
+109
-0
未找到文件。
modules/activiti-common-rest/src/main/java/org/activiti/rest/api/DataResponse.java
浏览文件 @
95c0b213
...
@@ -23,7 +23,7 @@ public class DataResponse {
...
@@ -23,7 +23,7 @@ public class DataResponse {
int
start
;
int
start
;
String
sort
;
String
sort
;
String
order
;
String
order
;
int
size
;
int
size
=
Integer
.
MAX_VALUE
;
public
Object
getData
()
{
public
Object
getData
()
{
return
data
;
return
data
;
...
...
modules/activiti-engine/src/main/java/org/activiti/engine/ManagementService.java
浏览文件 @
95c0b213
...
@@ -19,7 +19,6 @@ import org.activiti.engine.management.TableMetaData;
...
@@ -19,7 +19,6 @@ import org.activiti.engine.management.TableMetaData;
import
org.activiti.engine.management.TablePage
;
import
org.activiti.engine.management.TablePage
;
import
org.activiti.engine.management.TablePageQuery
;
import
org.activiti.engine.management.TablePageQuery
;
import
org.activiti.engine.runtime.JobQuery
;
import
org.activiti.engine.runtime.JobQuery
;
import
org.activiti.engine.task.Task
;
...
...
modules/activiti-rest/src/main/java/org/activiti/rest/api/RestResponseFactory.java
浏览文件 @
95c0b213
...
@@ -45,6 +45,7 @@ import org.activiti.rest.api.engine.variable.RestVariableConverter;
...
@@ -45,6 +45,7 @@ import org.activiti.rest.api.engine.variable.RestVariableConverter;
import
org.activiti.rest.api.engine.variable.ShortRestVariableConverter
;
import
org.activiti.rest.api.engine.variable.ShortRestVariableConverter
;
import
org.activiti.rest.api.engine.variable.StringRestVariableConverter
;
import
org.activiti.rest.api.engine.variable.StringRestVariableConverter
;
import
org.activiti.rest.api.identity.RestIdentityLink
;
import
org.activiti.rest.api.identity.RestIdentityLink
;
import
org.activiti.rest.api.management.TableResponse
;
import
org.activiti.rest.api.process.ExecutionResponse
;
import
org.activiti.rest.api.process.ExecutionResponse
;
import
org.activiti.rest.api.process.ProcessInstanceResponse
;
import
org.activiti.rest.api.process.ProcessInstanceResponse
;
import
org.activiti.rest.api.repository.DeploymentResourceResponse
;
import
org.activiti.rest.api.repository.DeploymentResourceResponse
;
...
@@ -382,6 +383,14 @@ public class RestResponseFactory {
...
@@ -382,6 +383,14 @@ public class RestResponseFactory {
return
result
;
return
result
;
}
}
public
TableResponse
createTableResponse
(
SecuredResource
securedResource
,
String
name
,
Long
count
)
{
TableResponse
result
=
new
TableResponse
();
result
.
setName
(
name
);
result
.
setCount
(
count
);
result
.
setUrl
(
securedResource
.
createFullResourceUrl
(
RestUrls
.
URL_TABLE
,
name
));
return
result
;
}
/**
/**
* Called once when the converters need to be initialized. Override of custom conversion
* Called once when the converters need to be initialized. Override of custom conversion
...
...
modules/activiti-rest/src/main/java/org/activiti/rest/api/RestUrls.java
浏览文件 @
95c0b213
...
@@ -27,6 +27,7 @@ public final class RestUrls {
...
@@ -27,6 +27,7 @@ public final class RestUrls {
*/
*/
public
static
final
String
SEGMENT_REPOSITORY_RESOURCES
=
"repository"
;
public
static
final
String
SEGMENT_REPOSITORY_RESOURCES
=
"repository"
;
public
static
final
String
SEGMENT_RUNTIME_RESOURCES
=
"runtime"
;
public
static
final
String
SEGMENT_RUNTIME_RESOURCES
=
"runtime"
;
public
static
final
String
SEGMENT_MANAGEMENT_RESOURCES
=
"management"
;
public
static
final
String
SEGMENT_QUERY_RESOURCES
=
"query"
;
public
static
final
String
SEGMENT_QUERY_RESOURCES
=
"query"
;
public
static
final
String
SEGMENT_DEPLOYMENT_RESOURCE
=
"deployments"
;
public
static
final
String
SEGMENT_DEPLOYMENT_RESOURCE
=
"deployments"
;
...
@@ -46,6 +47,7 @@ public final class RestUrls {
...
@@ -46,6 +47,7 @@ public final class RestUrls {
public
static
final
String
SEGMENT_IDENTITYLINKS_FAMILY_GROUPS
=
"groups"
;
public
static
final
String
SEGMENT_IDENTITYLINKS_FAMILY_GROUPS
=
"groups"
;
public
static
final
String
SEGMENT_IDENTITYLINKS_FAMILY_USERS
=
"users"
;
public
static
final
String
SEGMENT_IDENTITYLINKS_FAMILY_USERS
=
"users"
;
public
static
final
String
SEGMENT_VARIABLE_DATA
=
"data"
;
public
static
final
String
SEGMENT_VARIABLE_DATA
=
"data"
;
public
static
final
String
SEGMENT_TABLES
=
"tables"
;
/**
/**
* URL template for the deployment collection: <i>repository/deployments</i>
* URL template for the deployment collection: <i>repository/deployments</i>
...
@@ -201,7 +203,6 @@ public final class RestUrls {
...
@@ -201,7 +203,6 @@ public final class RestUrls {
*/
*/
public
static
final
String
[]
URL_PROCESS_INSTANCE_QUERY
=
{
SEGMENT_QUERY_RESOURCES
,
SEGMENT_PROCESS_INSTANCE_RESOURCE
};
public
static
final
String
[]
URL_PROCESS_INSTANCE_QUERY
=
{
SEGMENT_QUERY_RESOURCES
,
SEGMENT_PROCESS_INSTANCE_RESOURCE
};
/**
/**
* URL template for a single process instance: <i>runtime/process-instances/{0:processInstanceId}</i>
* URL template for a single process instance: <i>runtime/process-instances/{0:processInstanceId}</i>
*/
*/
...
@@ -227,6 +228,17 @@ public final class RestUrls {
...
@@ -227,6 +228,17 @@ public final class RestUrls {
*/
*/
public
static
final
String
[]
URL_PROCESS_INSTANCE_COMMENT
=
{
SEGMENT_RUNTIME_RESOURCES
,
SEGMENT_PROCESS_INSTANCE_RESOURCE
,
"{0}"
,
SEGMENT_COMMENTS
,
"{1}"
};
public
static
final
String
[]
URL_PROCESS_INSTANCE_COMMENT
=
{
SEGMENT_RUNTIME_RESOURCES
,
SEGMENT_PROCESS_INSTANCE_RESOURCE
,
"{0}"
,
SEGMENT_COMMENTS
,
"{1}"
};
/**
* URL template for the collection of tables: <i>management/tables</i>
*/
public
static
final
String
[]
URL_TABLES_COLLECTION
=
{
SEGMENT_MANAGEMENT_RESOURCES
,
SEGMENT_TABLES
};
/**
* URL template for a single table: <i>management/tables/{0:tableName}</i>
*/
public
static
final
String
[]
URL_TABLE
=
{
SEGMENT_MANAGEMENT_RESOURCES
,
SEGMENT_TABLES
,
"{0}"
};
/**
/**
* Creates an url based on the passed fragments and replaces any placeholders with the given arguments. The
* Creates an url based on the passed fragments and replaces any placeholders with the given arguments. The
...
...
modules/activiti-rest/src/main/java/org/activiti/rest/api/management/JobExecuteResource.java
→
modules/activiti-rest/src/main/java/org/activiti/rest/api/
legacy/
management/JobExecuteResource.java
浏览文件 @
95c0b213
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
* limitations under the License.
* limitations under the License.
*/
*/
package
org.activiti.rest.api.management
;
package
org.activiti.rest.api.
legacy.
management
;
import
org.activiti.rest.api.ActivitiUtil
;
import
org.activiti.rest.api.ActivitiUtil
;
import
org.activiti.rest.api.SecuredResource
;
import
org.activiti.rest.api.SecuredResource
;
...
...
modules/activiti-rest/src/main/java/org/activiti/rest/api/management/JobsExecuteResource.java
→
modules/activiti-rest/src/main/java/org/activiti/rest/api/
legacy/
management/JobsExecuteResource.java
浏览文件 @
95c0b213
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
* limitations under the License.
* limitations under the License.
*/
*/
package
org.activiti.rest.api.management
;
package
org.activiti.rest.api.
legacy.
management
;
import
org.activiti.engine.ActivitiException
;
import
org.activiti.engine.ActivitiException
;
import
org.activiti.rest.api.ActivitiUtil
;
import
org.activiti.rest.api.ActivitiUtil
;
...
...
modules/activiti-rest/src/main/java/org/activiti/rest/api/management/JobsPaginateList.java
→
modules/activiti-rest/src/main/java/org/activiti/rest/api/
legacy/
management/JobsPaginateList.java
浏览文件 @
95c0b213
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
* limitations under the License.
* limitations under the License.
*/
*/
package
org.activiti.rest.api.management
;
package
org.activiti.rest.api.
legacy.
management
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
...
@@ -27,9 +27,9 @@ public class JobsPaginateList extends AbstractPaginateList {
...
@@ -27,9 +27,9 @@ public class JobsPaginateList extends AbstractPaginateList {
@SuppressWarnings
(
"rawtypes"
)
@SuppressWarnings
(
"rawtypes"
)
@Override
@Override
protected
List
processList
(
List
list
)
{
protected
List
processList
(
List
list
)
{
List
<
JobResponse
>
responseList
=
new
ArrayList
<
JobResponse
>();
List
<
LegacyJobResponse
>
responseList
=
new
ArrayList
<
Legacy
JobResponse
>();
for
(
Object
job
:
list
)
{
for
(
Object
job
:
list
)
{
responseList
.
add
(
new
JobResponse
((
Job
)
job
));
responseList
.
add
(
new
Legacy
JobResponse
((
Job
)
job
));
}
}
return
responseList
;
return
responseList
;
}
}
...
...
modules/activiti-rest/src/main/java/org/activiti/rest/api/management/JobsResource.java
→
modules/activiti-rest/src/main/java/org/activiti/rest/api/
legacy/
management/JobsResource.java
浏览文件 @
95c0b213
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
* limitations under the License.
* limitations under the License.
*/
*/
package
org.activiti.rest.api.management
;
package
org.activiti.rest.api.
legacy.
management
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.HashMap
;
...
...
modules/activiti-rest/src/main/java/org/activiti/rest/api/
management/
JobResource.java
→
modules/activiti-rest/src/main/java/org/activiti/rest/api/
legacy/management/Legacy
JobResource.java
浏览文件 @
95c0b213
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
* limitations under the License.
* limitations under the License.
*/
*/
package
org.activiti.rest.api.management
;
package
org.activiti.rest.api.
legacy.
management
;
import
org.activiti.engine.runtime.Job
;
import
org.activiti.engine.runtime.Job
;
import
org.activiti.rest.api.ActivitiUtil
;
import
org.activiti.rest.api.ActivitiUtil
;
...
@@ -21,16 +21,16 @@ import org.restlet.resource.Get;
...
@@ -21,16 +21,16 @@ import org.restlet.resource.Get;
/**
/**
* @author Tijs Rademakers
* @author Tijs Rademakers
*/
*/
public
class
JobResource
extends
SecuredResource
{
public
class
Legacy
JobResource
extends
SecuredResource
{
@Get
@Get
public
JobResponse
getJob
()
{
public
Legacy
JobResponse
getJob
()
{
if
(
authenticate
(
SecuredResource
.
ADMIN
)
==
false
)
return
null
;
if
(
authenticate
(
SecuredResource
.
ADMIN
)
==
false
)
return
null
;
String
jobId
=
(
String
)
getRequest
().
getAttributes
().
get
(
"jobId"
);
String
jobId
=
(
String
)
getRequest
().
getAttributes
().
get
(
"jobId"
);
Job
job
=
ActivitiUtil
.
getManagementService
().
createJobQuery
().
jobId
(
jobId
).
singleResult
();
Job
job
=
ActivitiUtil
.
getManagementService
().
createJobQuery
().
jobId
(
jobId
).
singleResult
();
String
stacktrace
=
ActivitiUtil
.
getManagementService
().
getJobExceptionStacktrace
(
jobId
);
String
stacktrace
=
ActivitiUtil
.
getManagementService
().
getJobExceptionStacktrace
(
jobId
);
JobResponse
response
=
new
JobResponse
(
job
);
LegacyJobResponse
response
=
new
Legacy
JobResponse
(
job
);
response
.
setStacktrace
(
stacktrace
);
response
.
setStacktrace
(
stacktrace
);
return
response
;
return
response
;
}
}
...
...
modules/activiti-rest/src/main/java/org/activiti/rest/api/
management/
JobResponse.java
→
modules/activiti-rest/src/main/java/org/activiti/rest/api/
legacy/management/Legacy
JobResponse.java
浏览文件 @
95c0b213
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
* limitations under the License.
* limitations under the License.
*/
*/
package
org.activiti.rest.api.management
;
package
org.activiti.rest.api.
legacy.
management
;
import
org.activiti.engine.runtime.Job
;
import
org.activiti.engine.runtime.Job
;
import
org.activiti.rest.api.RequestUtil
;
import
org.activiti.rest.api.RequestUtil
;
...
@@ -19,7 +19,7 @@ import org.activiti.rest.api.RequestUtil;
...
@@ -19,7 +19,7 @@ import org.activiti.rest.api.RequestUtil;
/**
/**
* @author Tijs Rademakers
* @author Tijs Rademakers
*/
*/
public
class
JobResponse
{
public
class
Legacy
JobResponse
{
String
id
;
String
id
;
String
executionId
;
String
executionId
;
...
@@ -29,7 +29,7 @@ public class JobResponse {
...
@@ -29,7 +29,7 @@ public class JobResponse {
String
exceptionMessage
;
String
exceptionMessage
;
String
stacktrace
;
String
stacktrace
;
public
JobResponse
(
Job
job
)
{
public
Legacy
JobResponse
(
Job
job
)
{
setId
(
job
.
getId
());
setId
(
job
.
getId
());
setExecutionId
(
job
.
getExecutionId
());
setExecutionId
(
job
.
getExecutionId
());
setProcessInstanceId
(
job
.
getProcessInstanceId
());
setProcessInstanceId
(
job
.
getProcessInstanceId
());
...
...
modules/activiti-rest/src/main/java/org/activiti/rest/api/
management/
TableDataResource.java
→
modules/activiti-rest/src/main/java/org/activiti/rest/api/
legacy/management/Legacy
TableDataResource.java
浏览文件 @
95c0b213
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
* limitations under the License.
* limitations under the License.
*/
*/
package
org.activiti.rest.api.management
;
package
org.activiti.rest.api.
legacy.
management
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
...
@@ -31,7 +31,7 @@ import org.restlet.resource.Get;
...
@@ -31,7 +31,7 @@ import org.restlet.resource.Get;
/**
/**
* @author Tijs Rademakers
* @author Tijs Rademakers
*/
*/
public
class
TableDataResource
extends
SecuredResource
{
public
class
Legacy
TableDataResource
extends
SecuredResource
{
@Get
@Get
public
ObjectNode
getTableData
()
{
public
ObjectNode
getTableData
()
{
...
...
modules/activiti-rest/src/main/java/org/activiti/rest/api/legacy/management/LegacyTableResource.java
0 → 100644
浏览文件 @
95c0b213
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.activiti.rest.api.legacy.management
;
import
org.activiti.engine.ActivitiIllegalArgumentException
;
import
org.activiti.engine.management.TableMetaData
;
import
org.activiti.rest.api.ActivitiUtil
;
import
org.activiti.rest.api.SecuredResource
;
import
org.restlet.resource.Get
;
/**
* @author Tijs Rademakers
*/
public
class
LegacyTableResource
extends
SecuredResource
{
@Get
public
TableMetaData
getTableMetaData
()
{
if
(
authenticate
(
SecuredResource
.
ADMIN
)
==
false
)
return
null
;
String
tableName
=
(
String
)
getRequest
().
getAttributes
().
get
(
"tableName"
);
if
(
tableName
==
null
)
{
throw
new
ActivitiIllegalArgumentException
(
"table name is required"
);
}
return
ActivitiUtil
.
getManagementService
().
getTableMetaData
(
tableName
);
}
}
modules/activiti-rest/src/main/java/org/activiti/rest/api/management/TablesResource.java
→
modules/activiti-rest/src/main/java/org/activiti/rest/api/
legacy/
management/TablesResource.java
浏览文件 @
95c0b213
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
* limitations under the License.
* limitations under the License.
*/
*/
package
org.activiti.rest.api.management
;
package
org.activiti.rest.api.
legacy.
management
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Collections
;
...
...
modules/activiti-rest/src/main/java/org/activiti/rest/api/management/TableCollectionResource.java
0 → 100644
浏览文件 @
95c0b213
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.activiti.rest.api.management
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map.Entry
;
import
org.activiti.rest.api.ActivitiUtil
;
import
org.activiti.rest.api.RestResponseFactory
;
import
org.activiti.rest.api.SecuredResource
;
import
org.activiti.rest.application.ActivitiRestServicesApplication
;
import
org.restlet.resource.Get
;
/**
* @author Frederik Heremans
*/
public
class
TableCollectionResource
extends
SecuredResource
{
@Get
public
List
<
TableResponse
>
getTables
()
{
if
(
authenticate
()
==
false
)
return
null
;
List
<
TableResponse
>
tables
=
new
ArrayList
<
TableResponse
>();
Map
<
String
,
Long
>
tableCounts
=
ActivitiUtil
.
getManagementService
().
getTableCount
();
RestResponseFactory
factory
=
getApplication
(
ActivitiRestServicesApplication
.
class
).
getRestResponseFactory
();
for
(
Entry
<
String
,
Long
>
entry
:
tableCounts
.
entrySet
())
{
tables
.
add
(
factory
.
createTableResponse
(
this
,
entry
.
getKey
(),
entry
.
getValue
()));
}
return
tables
;
}
}
modules/activiti-rest/src/main/java/org/activiti/rest/api/management/TableResource.java
浏览文件 @
95c0b213
...
@@ -13,25 +13,44 @@
...
@@ -13,25 +13,44 @@
package
org.activiti.rest.api.management
;
package
org.activiti.rest.api.management
;
import
java.util.Map
;
import
java.util.Map.Entry
;
import
org.activiti.engine.ActivitiIllegalArgumentException
;
import
org.activiti.engine.ActivitiIllegalArgumentException
;
import
org.activiti.engine.
management.TableMetaData
;
import
org.activiti.engine.
ActivitiObjectNotFoundException
;
import
org.activiti.rest.api.ActivitiUtil
;
import
org.activiti.rest.api.ActivitiUtil
;
import
org.activiti.rest.api.SecuredResource
;
import
org.activiti.rest.api.SecuredResource
;
import
org.activiti.rest.application.ActivitiRestServicesApplication
;
import
org.restlet.resource.Get
;
import
org.restlet.resource.Get
;
/**
/**
* @author
Tijs Rademaker
s
* @author
Frederik Hereman
s
*/
*/
public
class
TableResource
extends
SecuredResource
{
public
class
TableResource
extends
SecuredResource
{
@Get
@Get
public
Table
MetaData
getTableMetaData
()
{
public
Table
Response
getTable
()
{
if
(
authenticate
(
SecuredResource
.
ADMIN
)
==
false
)
return
null
;
if
(
authenticate
()
==
false
)
return
null
;
String
tableName
=
(
String
)
getRequest
().
getAttributes
().
get
(
"tableName"
);
String
tableName
=
getAttribute
(
"tableName"
);
if
(
tableName
==
null
)
{
if
(
tableName
==
null
)
{
throw
new
ActivitiIllegalArgumentException
(
"
table name is required
"
);
throw
new
ActivitiIllegalArgumentException
(
"
The tableName cannot be null
"
);
}
}
return
ActivitiUtil
.
getManagementService
().
getTableMetaData
(
tableName
);
Map
<
String
,
Long
>
tableCounts
=
ActivitiUtil
.
getManagementService
().
getTableCount
();
TableResponse
response
=
null
;
for
(
Entry
<
String
,
Long
>
entry
:
tableCounts
.
entrySet
())
{
if
(
entry
.
getKey
().
equals
(
tableName
))
{
response
=
getApplication
(
ActivitiRestServicesApplication
.
class
).
getRestResponseFactory
()
.
createTableResponse
(
this
,
entry
.
getKey
(),
entry
.
getValue
());
break
;
}
}
if
(
response
==
null
)
{
throw
new
ActivitiObjectNotFoundException
(
"Could not find a table with name '"
+
tableName
+
"'."
,
String
.
class
);
}
return
response
;
}
}
}
}
modules/activiti-rest/src/main/java/org/activiti/rest/api/management/TableResponse.java
0 → 100644
浏览文件 @
95c0b213
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.activiti.rest.api.management
;
/**
* @author Frederik Heremans
*/
public
class
TableResponse
{
protected
String
name
;
protected
String
url
;
protected
Long
count
;
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getUrl
()
{
return
url
;
}
public
void
setUrl
(
String
url
)
{
this
.
url
=
url
;
}
public
Long
getCount
()
{
return
count
;
}
public
void
setCount
(
Long
count
)
{
this
.
count
=
count
;
}
}
modules/activiti-rest/src/main/java/org/activiti/rest/application/RestServicesInit.java
浏览文件 @
95c0b213
...
@@ -28,17 +28,19 @@ import org.activiti.rest.api.legacy.deployment.DeploymentDeleteResource;
...
@@ -28,17 +28,19 @@ import org.activiti.rest.api.legacy.deployment.DeploymentDeleteResource;
import
org.activiti.rest.api.legacy.deployment.DeploymentUploadResource
;
import
org.activiti.rest.api.legacy.deployment.DeploymentUploadResource
;
import
org.activiti.rest.api.legacy.deployment.DeploymentsDeleteResource
;
import
org.activiti.rest.api.legacy.deployment.DeploymentsDeleteResource
;
import
org.activiti.rest.api.legacy.deployment.DeploymentsResource
;
import
org.activiti.rest.api.legacy.deployment.DeploymentsResource
;
import
org.activiti.rest.api.legacy.management.JobExecuteResource
;
import
org.activiti.rest.api.legacy.management.JobsExecuteResource
;
import
org.activiti.rest.api.legacy.management.JobsResource
;
import
org.activiti.rest.api.legacy.management.LegacyJobResource
;
import
org.activiti.rest.api.legacy.management.LegacyTableDataResource
;
import
org.activiti.rest.api.legacy.management.LegacyTableResource
;
import
org.activiti.rest.api.legacy.management.TablesResource
;
import
org.activiti.rest.api.legacy.process.LegacyProcessInstanceResource
;
import
org.activiti.rest.api.legacy.process.LegacyProcessInstanceResource
;
import
org.activiti.rest.api.legacy.process.LegacyProcessInstancesResource
;
import
org.activiti.rest.api.legacy.process.LegacyProcessInstancesResource
;
import
org.activiti.rest.api.legacy.process.ProcessDefinitionsResource
;
import
org.activiti.rest.api.legacy.process.ProcessDefinitionsResource
;
import
org.activiti.rest.api.legacy.task.LegacyTaskResource
;
import
org.activiti.rest.api.legacy.task.LegacyTaskResource
;
import
org.activiti.rest.api.management.JobExecuteResource
;
import
org.activiti.rest.api.management.TableCollectionResource
;
import
org.activiti.rest.api.management.JobResource
;
import
org.activiti.rest.api.management.JobsExecuteResource
;
import
org.activiti.rest.api.management.JobsResource
;
import
org.activiti.rest.api.management.TableDataResource
;
import
org.activiti.rest.api.management.TableResource
;
import
org.activiti.rest.api.management.TableResource
;
import
org.activiti.rest.api.management.TablesResource
;
import
org.activiti.rest.api.process.ExecutionCollectionResource
;
import
org.activiti.rest.api.process.ExecutionCollectionResource
;
import
org.activiti.rest.api.process.ExecutionQueryResource
;
import
org.activiti.rest.api.process.ExecutionQueryResource
;
import
org.activiti.rest.api.process.ExecutionResource
;
import
org.activiti.rest.api.process.ExecutionResource
;
...
@@ -128,6 +130,9 @@ public class RestServicesInit {
...
@@ -128,6 +130,9 @@ public class RestServicesInit {
router
.
attach
(
"/runtime/executions/{executionId}/variables/{variableName}"
,
ExecutionVariableResource
.
class
);
router
.
attach
(
"/runtime/executions/{executionId}/variables/{variableName}"
,
ExecutionVariableResource
.
class
);
router
.
attach
(
"/runtime/executions/{executionId}/variables/{variableName}/data"
,
ExecutionVariableDataResource
.
class
);
router
.
attach
(
"/runtime/executions/{executionId}/variables/{variableName}/data"
,
ExecutionVariableDataResource
.
class
);
router
.
attach
(
"/management/tables"
,
TableCollectionResource
.
class
);
router
.
attach
(
"/management/tables/{tableName}"
,
TableResource
.
class
);
router
.
attach
(
"/query/tasks"
,
TaskQueryResource
.
class
);
router
.
attach
(
"/query/tasks"
,
TaskQueryResource
.
class
);
router
.
attach
(
"/query/process-instances"
,
ProcessInstanceQueryResource
.
class
);
router
.
attach
(
"/query/process-instances"
,
ProcessInstanceQueryResource
.
class
);
router
.
attach
(
"/query/executions"
,
ExecutionQueryResource
.
class
);
router
.
attach
(
"/query/executions"
,
ExecutionQueryResource
.
class
);
...
@@ -185,13 +190,13 @@ public class RestServicesInit {
...
@@ -185,13 +190,13 @@ public class RestServicesInit {
router
.
attach
(
"/deployment/{deploymentId}/resource/{resourceName}"
,
DeploymentArtifactResource
.
class
);
router
.
attach
(
"/deployment/{deploymentId}/resource/{resourceName}"
,
DeploymentArtifactResource
.
class
);
router
.
attach
(
"/management/jobs"
,
JobsResource
.
class
);
router
.
attach
(
"/management/jobs"
,
JobsResource
.
class
);
router
.
attach
(
"/management/job/{jobId}"
,
JobResource
.
class
);
router
.
attach
(
"/management/job/{jobId}"
,
Legacy
JobResource
.
class
);
router
.
attach
(
"/management/job/{jobId}/execute"
,
JobExecuteResource
.
class
);
router
.
attach
(
"/management/job/{jobId}/execute"
,
JobExecuteResource
.
class
);
router
.
attach
(
"/management/jobs/execute"
,
JobsExecuteResource
.
class
);
router
.
attach
(
"/management/jobs/execute"
,
JobsExecuteResource
.
class
);
router
.
attach
(
"/management/tables"
,
TablesResource
.
class
);
router
.
attach
(
"/management/tables"
,
TablesResource
.
class
);
router
.
attach
(
"/management/table/{tableName}"
,
TableResource
.
class
);
router
.
attach
(
"/management/table/{tableName}"
,
Legacy
TableResource
.
class
);
router
.
attach
(
"/management/table/{tableName}/data"
,
TableDataResource
.
class
);
router
.
attach
(
"/management/table/{tableName}/data"
,
Legacy
TableDataResource
.
class
);
router
.
attach
(
"/simple-workflow"
,
SimpleWorkflowResource
.
class
);
router
.
attach
(
"/simple-workflow"
,
SimpleWorkflowResource
.
class
);
...
...
modules/activiti-rest/src/test/java/org/activiti/rest/api/management/TableResourceTest.java
0 → 100644
浏览文件 @
95c0b213
package
org.activiti.rest.api.management
;
import
java.util.Map
;
import
org.activiti.rest.BaseRestTestCase
;
import
org.activiti.rest.api.RestUrls
;
import
org.codehaus.jackson.JsonNode
;
import
org.codehaus.jackson.node.ObjectNode
;
import
org.restlet.data.Status
;
import
org.restlet.representation.Representation
;
import
org.restlet.resource.ClientResource
;
import
org.restlet.resource.ResourceException
;
/**
* Test for all REST-operations related to the Table collection and a single
* table resource.
*
* @author Frederik Heremans
*/
public
class
TableResourceTest
extends
BaseRestTestCase
{
/**
* Test getting tables. GET management/tables
*/
public
void
testGetTables
()
throws
Exception
{
Map
<
String
,
Long
>
tableCounts
=
managementService
.
getTableCount
();
ClientResource
client
=
getAuthenticatedClient
(
RestUrls
.
createRelativeResourceUrl
(
RestUrls
.
URL_TABLES_COLLECTION
));
Representation
response
=
client
.
get
();
assertEquals
(
Status
.
SUCCESS_OK
,
client
.
getResponse
().
getStatus
());
// Check table array
JsonNode
responseNode
=
objectMapper
.
readTree
(
response
.
getStream
());
assertNotNull
(
responseNode
);
assertTrue
(
responseNode
.
isArray
());
assertEquals
(
tableCounts
.
size
(),
responseNode
.
size
());
for
(
int
i
=
0
;
i
<
responseNode
.
size
();
i
++)
{
ObjectNode
table
=
(
ObjectNode
)
responseNode
.
get
(
i
);
assertNotNull
(
table
.
get
(
"name"
).
getTextValue
());
assertNotNull
(
table
.
get
(
"count"
).
getLongValue
());
assertTrue
(
table
.
get
(
"url"
).
getTextValue
().
endsWith
(
RestUrls
.
createRelativeResourceUrl
(
RestUrls
.
URL_TABLE
,
table
.
get
(
"name"
).
getTextValue
())));
assertEquals
(((
Long
)
tableCounts
.
get
(
table
.
get
(
"name"
).
getTextValue
())).
longValue
(),
table
.
get
(
"count"
).
getLongValue
());
}
}
/**
* Test getting a single table. GET management/tables/{tableName}
*/
public
void
testGetTable
()
throws
Exception
{
Map
<
String
,
Long
>
tableCounts
=
managementService
.
getTableCount
();
String
tableNameToGet
=
tableCounts
.
keySet
().
iterator
().
next
();
ClientResource
client
=
getAuthenticatedClient
(
RestUrls
.
createRelativeResourceUrl
(
RestUrls
.
URL_TABLE
,
tableNameToGet
));
Representation
response
=
client
.
get
();
assertEquals
(
Status
.
SUCCESS_OK
,
client
.
getResponse
().
getStatus
());
// Check table
JsonNode
responseNode
=
objectMapper
.
readTree
(
response
.
getStream
());
assertNotNull
(
responseNode
);
assertEquals
(
tableNameToGet
,
responseNode
.
get
(
"name"
).
getTextValue
());
assertEquals
(((
Long
)
tableCounts
.
get
(
responseNode
.
get
(
"name"
).
getTextValue
())).
longValue
(),
responseNode
.
get
(
"count"
).
getLongValue
());
assertTrue
(
responseNode
.
get
(
"url"
).
getTextValue
().
endsWith
(
RestUrls
.
createRelativeResourceUrl
(
RestUrls
.
URL_TABLE
,
tableNameToGet
)));
}
public
void
testGetUnexistingTable
()
throws
Exception
{
ClientResource
client
=
getAuthenticatedClient
(
RestUrls
.
createRelativeResourceUrl
(
RestUrls
.
URL_TABLE
,
"unexisting"
));
try
{
client
.
get
();
fail
(
"404 expected, but was: "
+
client
.
getResponse
().
getStatus
());
}
catch
(
ResourceException
expected
)
{
assertEquals
(
Status
.
CLIENT_ERROR_NOT_FOUND
,
client
.
getResponse
().
getStatus
());
assertEquals
(
"Could not find a table with name 'unexisting'."
,
client
.
getResponse
().
getStatus
().
getDescription
());
}
}
}
\ No newline at end of file
userguide/src/en/chapters/ch14-REST.xml
浏览文件 @
95c0b213
...
@@ -3709,6 +3709,115 @@ Only the attachment name is required to create a new attachment.
...
@@ -3709,6 +3709,115 @@ Only the attachment name is required to create a new attachment.
</table>
</table>
</section>
</section>
</section>
</section>
<section>
<title>
Database tables
</title>
<section>
<title>
List of tables
</title>
<para>
<programlisting>
GET management/tables
</programlisting>
</para>
<para>
<table>
<title>
Response codes
</title>
<tgroup
cols=
'2'
>
<thead>
<row>
<entry>
Response code
</entry>
<entry>
Description
</entry>
</row>
</thead>
<tbody>
<row>
<entry>
200
</entry>
<entry>
Indicates the request was successful.
</entry>
</row>
</tbody>
</tgroup>
</table>
</para>
<para>
<emphasis
role=
"bold"
>
Success response body:
</emphasis>
<programlisting>
[
{
"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
},
...
]
</programlisting>
</para>
</section>
<section>
<title>
Get a single table
</title>
<para>
<programlisting>
GET management/tables/{tableName}
</programlisting>
</para>
<para>
<table>
<title>
URL parameters
</title>
<tgroup
cols=
'3'
>
<thead>
<row>
<entry>
Parameter
</entry>
<entry>
Required
</entry>
<entry>
Value
</entry>
<entry>
Description
</entry>
</row>
</thead>
<tbody>
<row>
<entry>
tableName
</entry>
<entry>
Yes
</entry>
<entry>
String
</entry>
<entry>
The name of the table to get.
</entry>
</row>
</tbody>
</tgroup>
</table>
</para>
<para>
<emphasis
role=
"bold"
>
Success response body:
</emphasis>
<programlisting>
{
"name":"ACT_RE_PROCDEF",
"url":"http://localhost:8182/management/tables/ACT_RE_PROCDEF",
"count":60
}
</programlisting>
<table>
<title>
Response codes
</title>
<tgroup
cols=
'2'
>
<thead>
<row>
<entry>
Response code
</entry>
<entry>
Description
</entry>
</row>
</thead>
<tbody>
<row>
<entry>
200
</entry>
<entry>
Indicates the table exists and the table count is returned.
</entry>
</row>
<row>
<entry>
404
</entry>
<entry>
Indicates the requested table does not exist.
</entry>
</row>
</tbody>
</tgroup>
</table>
</para>
</section>
</section>
<!-- Legacy -->
<!-- Legacy -->
<section>
<section>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录