簡體   English   中英

在存儲庫中獲取所有文件夾和文檔Alfresco Restful

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

我正在學習露天電影。 我想使用Restful API獲取存儲庫中的所有文件夾和文檔。 我怎樣才能做到這一點?

我們可以使用alfresco的網頁腳本創建restfull服務。要了解網頁腳本,請點擊以下鏈接。

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

要創建用於列出文件夾的網頁腳本,以下是您需要創建的文件。

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>

Web腳本描述指定了一個包含令牌{folderpath}和{verbose?}的URI模板。 folderpath令牌表示要列出的文件夾,而verbose URI參數指定是否需要詳細列出。 HTML響應模板在考慮了詳細標記的情況下呈現了指定文件夾的內容。 它通過訪問名為folder和verbose的Web腳本模型值來做到這一點。

您需要將上方文件放在路徑下方。

公司主頁>數據字典> Web腳本擴展> org

Web腳本是一種構建自己的API的好方法,但是在這種情況下,您可以使用Alfresco為您提供OOTB的內置API。

您可以使用REST API getDescendants調用獲取所有文件夾/文檔。 請參閱API規范以獲取詳細信息:

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

它為樹中定義的級別返回指定文件夾的后代對象列表。

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

它從ID參數已標識的文件夾開始,並將可選參數應用於您的呼叫。 這意味着您可以例如按類型(文檔,文件夾等)過濾並定義要查詢的深度。 使用-1將返回所有級別。

可以使用以下端點獲取文檔和文件夾的列表。

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

        type = documents or folders
        container = documentLibrary

參考:

瀏覽器可用的Web腳本在這里:

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

文件清單網頁腳本

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

Alfresco版本:社區v5.0.0

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM