【问题标题】:Alfresco REST API露天 REST API
【发布时间】:2016-01-15 16:05:09
【问题描述】:

我正在尝试获取一个脚本(使用 requests 的 Python),该脚本使用本地安装的 Alfresco(Community v5.0.0(d r99759-b2)架构 8022)执行以下操作。可悲的是,Alfresco's REST API documentation 很稀疏,没有任何示例。

我想要的是:

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

这应该允许我获得一个文档的唯一 {noderef}。一旦我有了这个 {noderef},我应该能够获得一个 URL 来下载这个文档。

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

【问题讨论】:

  • 我认为您正在查看错误的文档集 - 如果您 review the Alfresco Public REST API docs 会发生什么 - 那些没有涵盖您需要的内容吗?
  • @Gagravarr:是的,我可能一直在看错误的设置...谢谢。

标签: python django rest alfresco


【解决方案1】:

每当我需要使用 Rest API 时,我都会转到 /alfresco/service/index.js。这显示了 Alfresco 部署的所有 webscripts,并提供了一些关于它们的元信息。您可以使用它来确定哪些端点可用、它们的参数是什么等。按 URI 浏览可能是一个很好的起点...

【讨论】:

【解决方案2】:

我认为您有不同的选择。超过我将描述的三个。我更喜欢前两个。

1) 实现自己的网页脚本

这样做的好处是您可以准确地决定要返回什么以及如何在文件夹结构中导航。做你需要的就是一个用 javascript 和免费标记模板编写的简单 webscript。或者,如果您愿意,也可以使用 Java。 Repository-tier web scripts

2) 使用 CMIS

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

3) 使用可用的 REST API

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

要获取所有孩子,您可以使用例如:

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

这会返回例如(仅响应的一个 sn-p):

{
    "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
            },
            .....
        ]
    }
}

此网页脚本还有其他有用的参数。如果您想在工作中查看它,可以打开“对象查找器”(例如尝试将文档附加到工作流程)。浏览存储库的弹出窗口将调用此 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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-02-20
    • 2018-04-22
    • 1970-01-01
    • 1970-01-01
    • 2018-09-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多