简体   繁体   English

在存储库中获取所有文件夹和文档Alfresco Restful

[英]Get All Folder and Documents in Repository Alfresco Restful

I'm learning Alfresco. 我正在学习露天电影。 I want get all folder and documents in Repository with Restful API. 我想使用Restful API获取存储库中的所有文件夹和文档。 How can I do this? 我怎样才能做到这一点?

We can create restfull services using webscript of alfresco.For understanding webscript you can follow below link. 我们可以使用alfresco的网页脚本创建restfull服务。要了解网页脚本,请点击以下链接。

https://wiki.alfresco.com/wiki/Web_Scripts https://wiki.alfresco.com/wiki/Web_Scripts

For creating webscript for listing folders below are the file which you will need to create. 要创建用于列出文件夹的网页脚本,以下是您需要创建的文件。

1.list-folders.get.desc.xml 1.list-folders.get.desc.xml

<webscript>
  <shortname>Folder Listing Utility</shortname>
  <description>Java-backed implementation of listing folder contents
  </description>
  <url>/javadir/{folderpath}?verbose={verbose?}</url>
  <authentication>user</authentication>
</webscript>

2.list-folders.get.html.ftl 2.list-folders.get.html.ftl

<html>
 <head>
  <title>Folder ${folder.displayPath}/${folder.name}</title>
  </head>
 <body>
   <p>Alfresco ${server.edition} Edition v${server.version} : dir</p>
  <p>Contents of folder ${folder.displayPath}/${folder.name}</p>
  <table>
   <#list folder.children as child>
   <tr>
   <td><#if child.isContainer>d</#if></td>
   <#if verbose>
     <td>${child.properties.modifier}</td>
     <td><#if child.isDocument>
       ${child.properties.content.size}</#if></td>
     <td>${child.properties.modified?date}</td>
   </#if>
   <td>${child.name}</td>
   </tr>
   </#list>
  </table>
 </body>
</html>

The web script description specifies a URI template containing the tokens {folderpath} and {verbose?}. Web脚本描述指定了一个包含令牌{folderpath}和{verbose?}的URI模板。 The folderpath token represents the folder to list and the verbose URI argument specifies whether a verbose listing is required or not. folderpath令牌表示要列出的文件夹,而verbose URI参数指定是否需要详细列出。 The HTML response template renders the contents of the specified folder, taking into account the verbose flag. HTML响应模板在考虑了详细标记的情况下呈现了指定文件夹的内容。 It does this by accessing the web script model values named folder and verbose. 它通过访问名为folder和verbose的Web脚本模型值来做到这一点。

You need to put above files inside below path. 您需要将上方文件放在路径下方。

Company Home > Data Dictionary > Web Scripts Extensions > org 公司主页>数据字典> Web脚本扩展> org

Webscripts are a nice way to build your own API but in this case you should be fine with the buildin API that Alfresco provides you OOTB. Web脚本是一种构建自己的API的好方法,但是在这种情况下,您可以使用Alfresco为您提供OOTB的内置API。

You can fetch all folders/documents using the REST APIs getDescendants call. 您可以使用REST API getDescendants调用获取所有文件夹/文档。 Please see the API spec for the exact details: 请参阅API规范以获取详细信息:

https://wiki.alfresco.com/wiki/Repository_RESTful_API_Reference#Retrieve_tree_of_descendants_.28getDescendants.29 https://wiki.alfresco.com/wiki/Repository_RESTful_API_Reference#Retrieve_tree_of_descendants_.28getDescendants.29

It returns a list of descendant objects of the specified folder for the defined number of levels in the tree. 它为树中定义的级别返回指定文件夹的后代对象列表。

GET /alfresco/service/api/node/{store_type}/{store_id}/{id}/descendants?types={types}&filter={filter?}&depth={depth?}

It starts at the folder identified with the ID param and applies the optional arguments to your call. 它从ID参数已标识的文件夹开始,并将可选参数应用于您的呼叫。 This means that you can eg filter by type (document, folder,etc) and define a depth to query. 这意味着您可以例如按类型(文档,文件夹等)过滤并定义要查询的深度。 Using -1 returns you all levels. 使用-1将返回所有级别。

List of documents and folders can be obtained using below endpoints. 可以使用以下端点获取文档和文件夹的列表。

GET /alfresco/service/slingshot/doclib/doclist/{type}/site/{site}/{container}

        type = documents or folders
        container = documentLibrary

Reference : 参考:

Browser available Webscripts here: 浏览器可用的Web脚本在这里:

http://server:port/alfresco/service/index/all

Document List Webscript 文件清单网页脚本

http://server:port/alfresco/service/script/org/alfresco/slingshot/documentlibrary/doclist.get

Alfresco Version : Community v5.0.0 Alfresco版本:社区v5.0.0

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM