户外休息 API

Alfresco REST API

我正在尝试获取脚本(Python 使用 requests) working to do the following with Alfresco (Community v5.0.0 (d r99759-b2) schema 8022) installed locally. Sadly Alfresco's REST API documentation 是稀疏的,不包含任何示例。

我想要的是:

  1. 列出站点文档存储库中任意点的所有目录。
  2. 对于每个目录,我需要其中的所有文件和所有可能的版本。 (file_name, version, {noderef}) 的列表会很棒,但只要信息在那里,我不在乎它看起来像什么。

这应该能让我获得文档的唯一 {noderef}。一旦我有了这个 {noderef},我应该可以得到一个 URL 来下载这个文档。

我该怎么做这些(简单的?)事情?

每当我需要与其他 API 一起工作时,我都会去 /alfresco/service/index。这显示了 Alfresco 部署的所有网络脚本,并提供了一些关于它们的元信息。您可以使用它来确定可用的端点、它们的参数是什么等。通过 URI 浏览可能是一个很好的起点...

我认为你有不同的选择。不仅仅是我要描述的三个。我比较喜欢前两个。

1) 实现您自己的网络脚本

这样做的好处是您可以准确地决定要 return 的内容以及如何在文件夹结构中导航。做你需要的是用 javascript 和免费标记模板编写的简单网页脚本。或者,如果您愿意,可以使用 Java。 Repository-tier web scripts

2) 使用 CMIS

如果您不想编写您的网络脚本,因为没有 OOTB REST API 可以完全满足您的需要,使用 CMIS 可能更容易。 您需要做的事情可以通过 cmis 查询轻松实现。 作为起点:CMIS tutorials and CMIS Documentation

3) 使用可用的 REST API

有几个 API 可供您使用。找到它们的最简单方法是按照已经建议的方式访问 /alfresco/service/index。 Wiki - Alfresco API

要获得所有 children,您可以使用例如:

http://<your-alfresco-server>/alfresco/service/api/forms/picker/node/workspace/SpacesStore/62ccab8f-20bc-4039-9b59-70e4192fbeb6/doclib

例如 returns(只是响应的一个片段):

{
    "data":
    {
       "parent":
       {
           "type": "cm:folder",
           "isContainer": true,
           "name": "Company Home",
           "title": "Company Home",
           "description": "The company root space",
           "modified": "2015-11-24T01:13:48.132Z",
           "modifier": "System",
           "displayPath": "",
           "nodeRef": "workspace://SpacesStore/3e49a3f3-54e8-427c-a7e6-33eedf3cb479"
       },
        "items":
        [
            {
                "type": "cm:folder",
                "parentType": "cm:cmobject",
                "isContainer": true,
                "name": "Container Bank",
                "title": "Container Bank",
                "description": "Bank of Deal Container Folders",


                "modified": "2015-11-24T01:13:44.827Z",
                "modifier": "System",

                "displayPath": "\/Company Home",
                "nodeRef": "workspace://SpacesStore/09b3072a-e76d-427c-8465-e18a009279c8",
                "selectable" : true
            },
            {
                "type": "cm:folder",
                "parentType": "cm:cmobject",
                "isContainer": true,
                "name": "Data Dictionary",
                "title": "Data Dictionary",
                "description": "User managed definitions",


                "modified": "2015-11-26T22:40:27.078Z",
                "modifier": "System",

                "displayPath": "\/Company Home",
                "nodeRef": "workspace://SpacesStore/b6653365-0c1c-4fa7-a604-0ac302d2374a",
                "selectable" : true
            },
            .....
        ]
    }
}

此网络脚本还有其他有用的参数。如果你想在工作中看到它,你可以打开一个 "object finder"(例如尝试将文档附加到工作流)。浏览存储库的弹出 window 将调用此 webscript。例如,在我的例子中,它执行了以下调用:

curl "http://192.168.64.150:8080/share/proxy/alfresco/api/forms/picker/node/workspace/SpacesStore/66704925-4b32-4c4c-953b-42c6f0f047ec/children?selectableType=cm:content&searchTerm=&size=1000&filterStatusGroups=null" -H "Cookie: JSESSIONID=D9D08EC75879F4807AFF0FF115702E07; alfLogin=1452880051; alfUsername3=admin" -H "Accept-Encoding: gzip, deflate, sdch" -H "Accept-Language: en-US,en;q=0.8,it;q=0.6,en-GB;q=0.4" -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36" -H "Accept: */*" -H "Referer: http://192.168.64.150:8080/share/page/site/evergreeen-entertainment-ltd/start-workflow" -H "X-Requested-With: application/x-www-form-urlencoded" -H "Connection: keep-alive" --compressed

要获取节点的所有版本,您可以使用以下示例:

http://192.168.64.150:8080/alfresco/service/api/node/workspace/SpacesStore/687858da-c713-4739-8a3c-f322251ce00e/versions