03-28-2017 01:26 AM
How can i get all childs of a node?
Must i do a Recursive call to .getChildAssocs(nodeRef) ?
I want the deep listing!
For example i have a folder who have 5 sub-folders and some files. That 5 sub-folders have sub-folders, and files; and so on!
NodeService dont have methods who give the deep listing, for what i could see in the Api.
Thanks in advance
03-28-2017 01:59 AM
you could use a path query ( PATH:"yourPath//." ) the //. searches recursive for all nodes, including yourPath. //* would search recursively excluding yourPath.
But the path has to be a qName (app:company_home/....)
Second possibility: recurse through the path with javascript .getChildAsssocs or .children - could take long and is resource hungry.
03-28-2017 05:24 AM
Yes, a PATH query with the double forward slash + asterisk will give you any children in any depth. But it will not be transactionally consistent as it relies on the search index which is asynchronously updated after changes occur. Also, a PATH query is traditionally one of the less performant selectors. An alternative is to use the ANCESTOR selector, which only requires the NodeRef of the folder for which you want to get all descendants. E.g. ANCESTOR:"workspace://SpacesStore/12345678". This avoids having to construct the path in the first place (which can be somewhat expensive depending on the depth of the root Folder, and avoid the reevaluation of the path by the index (path is fragmented and evaluated in various ways - front-to-back and back-to-front).
03-30-2017 04:36 AM
Thanks for your reply,I want to know how to implement it by rest api?can you give me the code example?and the search is with the user permission?
04-01-2017 07:03 AM
For examples about the ReST APIs please look at Alfresco 5.2. REST APIs. All operations will include permission checks as long as you do not explicitly disable them. ReST APIs typically do not support disabling permission checks via their parameters (unless you implement a custom API endpoint yourself with that feature).
04-01-2017 08:12 AM
You can use Alfresco Content Services REST API Explorer to experiment with the REST apis.
04-04-2017 02:15 PM
I totally forgot about GitHub - ciber/alfresco-js-batch-executer: Alfresco easy bulk processing with JavaScript
this gives you a new root scope object which enables you to write a serverside JavaScript that iterates over the elements without the common problems like runtime, memory consumption, transaction size...
See the example from batch-executers page:
batchExecuter.processFolderRecursively({
root: companyhome,
onNode: function(node) {
if (node.isDocument) {
node.properties['cm:author'] = "Ciber NL";
node.save();
}
}
});
Explore our Alfresco products with the links below. Use labels to filter content by product module.