获取ticket
描述:
- 获取ticket
ticket使用说明:
在请求接口URL后增加参数:alf_ticket={ticket}
ticket默认失效时间为1小时内未调用,可在alfresco-global.properties中修改配置
以下是默认配置:
# Do authentication tickets expire or live for ever?
authentication.ticket.ticketsExpire=true
# If ticketsEpire is true then how they should expire?
# Valid values are: AFTER_INACTIVITY, AFTER_FIXED_TIME, DO_NOT_EXPIRE
# The default is AFTER_FIXED_TIME
authentication.ticket.expiryMode=AFTER_INACTIVITY
# If authentication.ticket.ticketsExpire is true and
# authentication.ticket.expiryMode is AFTER_FIXED_TIME or AFTER_INACTIVITY,
# this controls the minimum period for which tickets are valid.
# The default is PT1H for one hour.
authentication.ticket.validDuration=PT1H
请求URL:
http://{ipaddress}:{port}/alfresco/service/api/login?u={userName}&pw={password}&format=json
{ipaddress}:系统IP地址或域名
{port}:端口号
{userName}:用户名,视接口所需的权限,可以使用admin账号
{password}:密码
请求方式:
- GET
请求头:
参数名 | 是否必须 | 类型 | 值/说明 |
---|---|---|---|
dataType | 是 | string | json |
请求参数:
参数名 | 是否必须 | 类型 | 值/说明 |
---|---|---|---|
u | 是 | string | 用户名,详见请求URL |
pw | 是 | string | 密码,详见请求URL |
返回示例:
正确时返回:
{
"data": {
"ticket": "TICKET_9635ea426423207b132842b4cb1506118b6d27e3"
}
}
错误时返回:
{
"status" : {
"code" : 403,
"name" : "Forbidden",
"description" : "Server understood the request but refused to fulfill it."
},
"message" : "00020085 Login failed",
"exception" : "",
"callstack" : [],
"server" : "Community v5.2.0 (re21f2be5-b22) schema 10,057",
"time" : "2019-1-1 00:00:00"
}
返回参数说明:
参数名 | 类型 | 说明 |
---|---|---|
data.ticket | string | ticket值 |
创建目录
描述:
- 创建目录
请求URL:
http://{ipaddress}:{port}/alfresco/service/idoc/common/node/savenode
{ipaddress}:系统IP地址或域名
{port}:端口号
请求方式:
- POST
请求头:
参数名 | 是否必须 | 类型 | 值/说明 |
---|---|---|---|
Content-Type | 是 | string | application/json |
dataType | 是 | string | json |
请求参数:
参数名 | 是否必须 | 类型 | 值/说明 |
---|---|---|---|
saveRef | 是 | string | 父节点ID,站点下建根目录,填站点ID;父文件夹下建子目录,填父文件夹nodeRef |
name | 是 | string | 文件夹名称 |
nodeType | 是 | string | 节点类型,固定为:folder |
返回示例:
正确时返回:
{
"nodeRef": "workspace://SpacesStore/ae768f1e-00fd-40a6-97fa-5bca65859f87"
}
错误时返回:
{
"status": {
"code": 400,
"name": "Bad Request",
"description": "Request sent by the client was syntactically incorrect."
},
"message": "error.existed",
"exception": "",
"callstack": [
],
"server": "Community v5.2.0 (re21f2be5-b22) schema 10,057",
"time": "2019-1-1 00:00:00"
}
返回参数说明:
参数名 | 类型 | 说明 |
---|---|---|
nodeRef | string | 所创建目录的nodeRef |
创建文档
描述:
- 创建文档
请求URL:
http://{ipaddress}:{port}/alfresco/service/idoc/common/node/upload/{destination}
{ipaddress}:系统IP地址或域名
{port}:端口号
{destination}:文档父文件夹的nodeRef
请求方式:
- POST(构造form提交)
请求头:
参数名 | 是否必须 | 类型 | 值/说明 |
---|---|---|---|
Content-Type | 是 | string | multipart/form-data |
请求参数:
参数名 | 是否必须 | 类型 | 值/说明 |
---|---|---|---|
files[] | 是 | 二进制 | 文档二进制数据 |
fileName | 否 | string | 单独指定文件名 |
返回示例:
正确时返回:
{
"nodeRef": "workspace://SpacesStore/dd406225-e0e5-4fb3-9ab3-03394b2dd4e1",
"fileName": "Wps\u6587\u6863\u6d4b\u8bd5.wps",
"result": "success",
"errMsg": ""
}
返回参数说明:
参数名 | 类型 | 说明 |
---|---|---|
nodeRef | string | 所创建文档的nodeRef |
fileName | string | 文档名称 |
result | string | 处理结果 |
errMsg | string | 错误信息 |
更新文档
描述:
- 更新文档
请求URL:
http://{ipaddress}:{port}/alfresco/service/api/upload?format=json
{ipaddress}:系统IP地址或域名
{port}:端口号
请求方式:
- POST(构造form提交)
请求头:
参数名 | 是否必须 | 类型 | 值/说明 |
---|---|---|---|
Content-Type | 是 | string | multipart/form-data |
请求参数:
参数名 | 是否必须 | 类型 | 值/说明 |
---|---|---|---|
updateNodeRef | 是 | string | 更新文档的nodeRef |
filedata | 是 | 二进制 | 文档二进制数据 |
majorVersion | 否 | boolean | 是否大版本更新,默认false |
description | 否 | string | 版本描述 |
updatenameandmimetype | 否 | boolean | 是否更新文档名称和mimetype,默认false |
返回示例:
正确时返回:
{
"nodeRef": "workspace://SpacesStore/3820fc4f-6567-4e6a-9a55-576a4bf68287",
"fileName": "word document.docx",
"status":
{
"code": 200,
"name": "OK",
"description": "File uploaded successfully"
}
}
返回参数说明:
参数名 | 类型 | 说明 |
---|---|---|
nodeRef | string | 所创建文档的nodeRef |
fileName | string | 文档名称 |
status | json | 处理结果 |
删除文档
描述:
- 删除文档
请求URL:
http://{ipaddress}:{port}/alfresco/service/idoc/common/node/deletenode
{ipaddress}:系统IP地址或域名
{port}:端口号
请求方式:
- POST
请求头:
参数名 | 是否必须 | 类型 | 值/说明 |
---|---|---|---|
Content-Type | 是 | string | application/json |
dataType | 是 | string | json |
请求参数:
参数名 | 是否必须 | 类型 | 值/说明 |
---|---|---|---|
nodeArray | 是 | string[] | 要删除文档的nodeRef数组 |
返回示例:
正确时返回:
{
"fail": 0,
"success": 2,
"detail": [
{
"msg": "",
"nodeRef": "workspace://SpacesStore/c427ea08-a706-4389-b8d8-076026cf9a77",
"success": "true",
"name": "Spreadsheet.xlsx",
"type": "file"
},
{
"msg": "",
"nodeRef": "workspace://SpacesStore/3820fc4f-6567-4e6a-9a55-576a4bf68287",
"success": "true",
"name": "word document.docx",
"type": "file"
}
]
}
返回参数说明:
参数名 | 类型 | 说明 |
---|---|---|
fail | number | 失败数 |
success | number | 成功数 |
detail | json | 具体处理结果 |
查询文档列表
描述:
- 查询文档列表
请求URL:
http://{ipaddress}:{port}/alfresco/service/idoc/common/node/searchnode
{ipaddress}:系统IP地址或域名
{port}:端口号
请求方式:
- POST
请求头:
参数名 | 是否必须 | 类型 | 值/说明 |
---|---|---|---|
Content-Type | 是 | string | application/json |
dataType | 是 | string | json |
请求参数:
参数名 | 是否必须 | 类型 | 值/说明 |
---|---|---|---|
key | 否 | string | 搜索关键词 |
nodeRef | 否 | string | 指定目录的nodeRef或站点ID |
nodeRefs | 否 | string[] | 指定目录的nodeRef或站点ID的数组,需要同时在多个目录下搜索时使用 |
query | 否 | string | 检索文,搜索文档的情况固定为: EXACTTYPE:’cm:content’ |
page | 否 | number | 页码。默认1 |
rows | 否 | number | 每页条数,默认200 |
sidx | 否 | string | 排序列,默认cm_name |
sord | 否 | string | 升序asc/降序desc,默认asc |
返回示例:
正确时返回:
{
"total": 1,
"records": 4,
"page": 1,
"rows": [
{
"notModify": "false",
"isiso": false,
"cm_modifier": "演示账号1",
"isAdmin": "true",
"downloadlimit": false,
"type": "item",
"isfav": false,
"version": "2.0",
"isEditor": "true",
"parentid": "ecdec37a-a387-4161-a81d-c88621069eb8",
"cm_size": 9409,
"path": "knowledge:企业知识库/00.安全宣传",
"cm_modified": "2023-04-18 16:16:58",
"orgpath": "/Company Home/Sites/knowledge/documentLibrary/00.安全宣传",
"nodeRef": "workspace://SpacesStore/7ad76ba9-fe4b-4e5f-b919-238d27291e09",
"cm_name": "test1.xlsx",
"mimetype": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"cm_creator": "管理员"
}
]
}
返回参数说明:
参数名 | 类型 | 说明 |
---|---|---|
total | number | 总共有多少页 |
records | number | 总共有多少条数据 |
page | number | 当前页码 |
rows | json[] | 具体数据 |
在线浏览文档
描述:
- 在线浏览文档
viewer浏览器可解决大部分文档浏览需求,office文档的情况会自动转为pdf在线浏览,这种情况要求excel文件有正确的分页设置,否则转为pdf可能会造成分页混乱。为解决这个问题,对于office文档可以使用Onlyoffice浏览器浏览。
注意:url上要加上alf_ticket参数
1、viewer在线浏览器
http://{ipaddress}:{port}/idoc/viewer?nodeRef={nodeRef}
{ipaddress}:系统IP地址或域名
{port}:端口号
{nodeRef}:文档的nodeRef
2、onlyoffice浏览器
http://{ipaddress}:{port}/idoc/edit?readonly=1&nodeRef={nodeRef}
{ipaddress}:系统IP地址或域名
{port}:端口号
{nodeRef}:文档的nodeRef
下载文档
描述:
- 下载文档
请求URL:
http://{ipaddress}:{port}/alfresco/service/slingshot/node/content/{shortNodeRef}/{filename}?a=true
{ipaddress}:系统IP地址或域名
{port}:端口号
{shortNodeRef}:nodeRef.replace(“://“, “/“)
{filename}:encodeURIComponent(文档名称)
请求方式:
- GET
获取目录清单
描述:
- 查询某个目录下的所有子目录
请求URL:
http://{ipaddress}:{port}/alfresco/service/idoc/common/node/treefolder?id={nodeRef}
{ipaddress}:系统IP地址或域名
{port}:端口号
{nodeRef}:站点ID或文件夹nodeRef
请求方式:
- GET
请求头:
参数名 | 是否必须 | 类型 | 值/说明 |
---|---|---|---|
dataType | 是 | string | json |
请求参数:
参数名 | 是否必须 | 类型 | 值/说明 |
---|---|---|---|
id | 是 | string | 站点ID或文件夹nodeRef |
返回示例:
正确时返回:
[
{
"additionalParameters": {
"path": "企业知识库/00.安全宣传/Documentation",
"children": true,
"mimetype": "application/octet-stream",
"id": "workspace://SpacesStore/e1d4f065-854d-4a2e-8e09-a9e87a6f3bfa"
},
"text": "Documentation",
"type": "folder"
}
]
统计文档数量
描述:
- 指定目录下文档数量,支持多个目录同时统计
需二次开发
修改目录名
描述:
- 修改目录名
请求URL:
http://{ipaddress}:{port}/alfresco/service/idoc/common/node/savenode
{ipaddress}:系统IP地址或域名
{port}:端口号
请求方式:
- POST
请求头:
参数名 | 是否必须 | 类型 | 值/说明 |
---|---|---|---|
Content-Type | 是 | string | application/json |
dataType | 是 | string | json |
请求参数:
参数名 | 是否必须 | 类型 | 值/说明 |
---|---|---|---|
nodeRef | 是 | string | 修改对象的nodeRef |
name | 是 | string | 新的名称 |
返回示例:
正确时返回:
{
"nodeRef": "workspace://SpacesStore/ae768f1e-00fd-40a6-97fa-5bca65859f87"
}
错误时返回:
{
"status": {
"code": 400,
"name": "Bad Request",
"description": "Request sent by the client was syntactically incorrect."
},
"message": "error.existed",
"exception": "",
"callstack": [
],
"server": "Community v5.2.0 (re21f2be5-b22) schema 10,057",
"time": "2019-1-1 00:00:00"
}
返回参数说明:
参数名 | 类型 | 说明 |
---|---|---|
nodeRef | string | 操作对象的nodeRef |
移动子目录
描述:
- 移动子目录(目录中的文件一起移动)
请求URL:
http://{ipaddress}:{port}/alfresco/service/idoc/common/node/movenode
{ipaddress}:系统IP地址或域名
{port}:端口号
请求方式:
- POST
请求头:
参数名 | 是否必须 | 类型 | 值/说明 |
---|---|---|---|
Content-Type | 是 | string | application/json |
dataType | 是 | string | json |
请求参数:
参数名 | 是否必须 | 类型 | 值/说明 |
---|---|---|---|
nodeArray | 是 | string[] | 移动对象的nodeRef数组 |
target | 是 | string | 移动到目录的nodeRef或站点ID |
返回示例:
正确时返回:
{
"fail": 0,
"success": 1,
"detail": [
{
"msg": "",
"nodeRef": "workspace://SpacesStore/1077ebb3-1b3f-4935-99df-970b2ea46287",
"success": "true",
"name": "test"
}
]
}
返回参数说明:
参数名 | 类型 | 说明 |
---|---|---|
fail | number | 失败数 |
success | number | 成功数 |
detail | json | 处理详细信息 |
删除子目录
描述:
- 删除子目录
此接口不判断目录中是否有文档,若要增加判断需二次开发
请求URL:
http://{ipaddress}:{port}/alfresco/service/idoc/common/node/deletenode
{ipaddress}:系统IP地址或域名
{port}:端口号
请求方式:
- POST
请求头:
参数名 | 是否必须 | 类型 | 值/说明 |
---|---|---|---|
Content-Type | 是 | string | application/json |
dataType | 是 | string | json |
请求参数:
参数名 | 是否必须 | 类型 | 值/说明 |
---|---|---|---|
nodeArray | 是 | string[] | 要删除文档的nodeRef数组 |
返回示例:
正确时返回:
{
"fail": 0,
"success": 2,
"detail": [
{
"msg": "",
"nodeRef": "workspace://SpacesStore/c427ea08-a706-4389-b8d8-076026cf9a77",
"success": "true",
"name": "Spreadsheet.xlsx",
"type": "file"
},
{
"msg": "",
"nodeRef": "workspace://SpacesStore/3820fc4f-6567-4e6a-9a55-576a4bf68287",
"success": "true",
"name": "word document.docx",
"type": "file"
}
]
}
返回参数说明:
参数名 | 类型 | 说明 |
---|---|---|
fail | number | 失败数 |
success | number | 成功数 |
detail | json | 具体处理结果 |