Need a js based alfresco webscript to get the list of all folders and files recursively alond with their size.
-
Won't that be horribly horribly slow on big installs?Gagravarr– Gagravarr2016-11-24 22:27:47 +00:00Commented Nov 24, 2016 at 22:27
-
yes i am sure it would be, but we need it for one time analysisuser3331349– user33313492016-11-26 12:03:13 +00:00Commented Nov 26, 2016 at 12:03
Add a comment
|
2 Answers
CMIS Query:
select cmis:objectId, cmis:name, cmis:contentStreamLength
from cmis:document
where cmis:contentStreamLength>0
order by cmis:contentStreamLength desc
HTTP GET:
http://localhost:8080/alfresco/api/-default-/public/cmis/versions/1.1/browser/ ?cmisselector=query &succinct=true &q=select cmis:objectId, cmis:name, cmis:contentStreamLength from cmis:document where cmis:contentStreamLength>0 order by cmis:contentStreamLength descJavaScript:
Use search root object:
search - org.alfresco.repo.jscript.Search - Root object providing access to the various Alfresco search interfaces such as FTS-Alfresco, Lucene, XPath, and Saved Search results
var rs=search.query({ query:"select * from cmis:document where cmis:contentStreamLength>0 order by cmis:contentStreamLength desc", language:"cmis-alfresco" }); for (var r in rs){ logger.log(rs[r].parent.nodeRef.id+"/"+rs[r].nodeRef.id+"\t"+rs[r].parent.name+"/"+rs[r].name+"\t"+rs[r].size); }
2 Comments
user3331349
Thanks for your answer :) but i am a beginner in alfresco webscripting and have no idea how to execute this. i have explored some tutorials on alfresco like docs.alfresco.com/4.1/concepts/ws-folderListing-intro.html which involve :- 1. a js file 2. a free marker template 3. a descriptor xml file we create and register these in alfresco and hit through url and get the things. Is it possible to have my question solved by such a solution ? Thanks
MonkeyDreamzzz
This query only gets the documents. Not the folders
Yes it is possible. you can get the all folders,subfolders,and all the files using repository javascript Please try this code give proper path values
var path="Data Dictionary/***";
var documentLibrary = companyhome.childByNamePath("path");
var children = documentLibrary.children;
traverse(children);
function traverse(nodes){
for each(var node in nodes) {
if (node.isContainer){
logger.log(node.name + " is a folder, traversing down");
traverse(node.children);
}else {
logger.log(node.name );
logger.log(node.size);
}
}
}