Json response is preferred.
please include the url path for giving in xml also.
You can create a custom Javascript or java backed web-script to get the list of folders and subfolders.
Execute a search query from your custom webscript to list the folders and subfolders and write to a json object and return in response.
If you want to get all folders at any depth then, Search query would be something like this:
PATH:"/app:company_home/st:sites/cm:test-site/cm:documentLibrary//*" AND TYPE:"cm:folder"
Get the count from returned result set and to get the path for each returned nodeRefs use 'nodeService.getPath(nodeRef).toDisplayPath(nodeService, permissionService)'
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:
1 Pass: PATH:"/app:company_home/st:sites/cm:test-site/cm:documentLibrary/*" AND TYPE:"cm:folder"
2 Pass:
PATH:"/app:company_home/st:sites/cm:test-site/cm:documentLibrary/cm:MyFolder/*" AND TYPE:"cm:folder"
3 Pass:
PATH:"/app:company_home/st:sites/cm:test-site/cm:documentLibrary/cm:MyFolder/cm:MySubFolder/*" AND TYPE:"cm:folder"
And so on.. depending on levels of subfolders.
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.
Refer here on how to write custom webscripts: https://ecmarchitect.com/alfresco-developer-series-tutorials/webscripts/tutorial/tutorial.html
You can find sample source code here: https://github.com/jpotts/alfresco-developer-series/tree/master/webscripts/webscripts-tutorial
There is a question by someone else on the same lines, this may be helpful to you as well: https://community.alfresco.com/thread/233943-list-all-folder-subfolders-files-via-webscript
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.