<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Can anyone help me with custom webscript for finding the number of folders and sub-folders present in a given site? in Alfresco Forum</title>
    <link>https://connect.hyland.com/t5/alfresco-forum/can-anyone-help-me-with-custom-webscript-for-finding-the-number/m-p/86620#M26177</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Json response is preferred.&lt;/P&gt;&lt;P&gt;please include the url path for giving in xml also.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 25 Jul 2019 06:55:42 GMT</pubDate>
    <dc:creator>madhu_sudireddy</dc:creator>
    <dc:date>2019-07-25T06:55:42Z</dc:date>
    <item>
      <title>Can anyone help me with custom webscript for finding the number of folders and sub-folders present in a given site?</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/can-anyone-help-me-with-custom-webscript-for-finding-the-number/m-p/86620#M26177</link>
      <description>Json response is preferred.please include the url path for giving in xml also.</description>
      <pubDate>Thu, 25 Jul 2019 06:55:42 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/can-anyone-help-me-with-custom-webscript-for-finding-the-number/m-p/86620#M26177</guid>
      <dc:creator>madhu_sudireddy</dc:creator>
      <dc:date>2019-07-25T06:55:42Z</dc:date>
    </item>
    <item>
      <title>Re: Can anyone help me with custom webscript for finding the number of folders and sub-folders present in a given site?</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/can-anyone-help-me-with-custom-webscript-for-finding-the-number/m-p/86621#M26178</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can create a custom Javascript or java backed web-script to get the list of folders and subfolders.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Execute a search query from your custom webscript to list the folders and subfolders and write to a json object and return in response.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want to get all folders at any depth then, Search query would be something like this:&lt;/P&gt;&lt;P&gt;PATH:"/app:company_home/st:sites/cm:test-site/cm:documentLibrary//*" AND TYPE:"cm:folder"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Get the count from returned result set and to get the path for each returned nodeRefs use 'nodeService.getPath(nodeRef).toDisplayPath(nodeService, permissionService)'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want to get all folders at first level and then get subfolders for each folder then, Search query would be something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding: 0px;"&gt;1 Pass: PATH:"/app:company_home/st:sites/cm:test-site/cm:documentLibrary/*" AND TYPE:"cm:folder"&lt;/P&gt;&lt;P style="padding: 0px;"&gt;2 Pass:&amp;nbsp;&lt;/P&gt;&lt;P&gt;PATH:"/app:company_home/st:sites/cm:test-site/cm:documentLibrary/cm:MyFolder/*" AND TYPE:"cm:folder"&lt;/P&gt;&lt;P style="padding: 0px;"&gt;3 Pass:&amp;nbsp;&lt;/P&gt;&lt;P&gt;PATH:"/app:company_home/st:sites/cm:test-site/cm:documentLibrary/&lt;SPAN&gt;cm:MyFolder/cm:MySubFolder/*&lt;/SPAN&gt;" AND TYPE:"cm:folder"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And so on.. depending on levels of subfolders.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Get the folders and subfolders recursively and prepare a POJO having parent and child count including the display path and convert it to JSON at the end when all folders/sub-folders are iterated.&amp;nbsp;&lt;/P&gt;&lt;P style="padding: 0px;"&gt;&lt;/P&gt;&lt;P&gt;Refer here on how to write custom webscripts:&amp;nbsp;&lt;A href="https://ecmarchitect.com/alfresco-developer-series-tutorials/webscripts/tutorial/tutorial.html" rel="nofollow noopener noreferrer"&gt;https://ecmarchitect.com/alfresco-developer-series-tutorials/webscripts/tutorial/tutorial.html&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can find sample source code here:&amp;nbsp;&lt;A href="https://github.com/jpotts/alfresco-developer-series/tree/master/webscripts/webscripts-tutorial" rel="nofollow noopener noreferrer"&gt;https://github.com/jpotts/alfresco-developer-series/tree/master/webscripts/webscripts-tutorial&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There is a question by someone else on the same lines, this may be helpful to you as well:&amp;nbsp;&lt;A _jive_internal="true" href="https://community.alfresco.com/thread/233943-list-all-folder-subfolders-files-via-webscript" rel="nofollow noopener noreferrer"&gt;https://community.alfresco.com/thread/233943-list-all-folder-subfolders-files-via-webscript&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Jul 2019 15:15:19 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/can-anyone-help-me-with-custom-webscript-for-finding-the-number/m-p/86621#M26178</guid>
      <dc:creator>abhinavmishra14</dc:creator>
      <dc:date>2019-07-25T15:15:19Z</dc:date>
    </item>
  </channel>
</rss>

