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
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.
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).
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?
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).
You can use Alfresco Content Services REST API Explorer to experiment with the REST apis.
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();
}
}
});
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.