Get All Folder and Documents in Repository Alfresco Restful

亡梦爱人 提交于 2019-12-12 21:38:51

问题


I'm learning Alfresco. I want get all folder and documents in Repository with Restful API. How can I do this?


回答1:


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.

You can fetch all folders/documents using the REST APIs getDescendants call. Please see the API spec for the exact details:

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. This means that you can e.g. filter by type (document, folder,etc) and define a depth to query. Using -1 returns you all levels.




回答2:


We can create restfull services using webscript of alfresco.For understanding webscript you can follow below link.

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

<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

<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?}. The folderpath token represents the folder to list and the verbose URI argument specifies whether a verbose listing is required or not. The HTML response template renders the contents of the specified folder, taking into account the verbose flag. It does this by accessing the web script model values named folder and verbose.

You need to put above files inside below path.

Company Home > Data Dictionary > Web Scripts Extensions > org




回答3:


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:

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



来源:https://stackoverflow.com/questions/28206322/get-all-folder-and-documents-in-repository-alfresco-restful

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!