admin管理员组文章数量:1391960
Alfresco Share doesn't keep track of content modified outside it's interface which makes the recently modified RSS/Dashlet useless. I'm working on creating an RSS that I can use within sites to pull a list of recently modified items.
Right now I'm just working on getting the list of files and I'm stumbling a little bit as I'm not very familiar with Webscripts. I've got this piece of code that will retrieve the contents of a site then build an array of the files, the problem I'm running into is I could have many subfolders and I'm not sure how to properly traverse them.
var folder = panyhome.childByNamePath("/Sites/foo/documentLibrary");
var docs = new Array();
print(folder);
print("iterating...");
var children = folder.children;
for (i=0; i<children.length; i++)
{
var c = children[i];
if (c.isContainer)
{
print(c.name + " is a folder, traversing...");
var subfolder = panyhome.childByNamePath("/Sites/foo/documentLibrary/" + c.name.toString());
var subchildren = subfolder.children;
for (j=0; j<subchildren.length; j++)
{
var d = subchildren[j];
if (d.isDocument) docs.push(d);
}
}
if (c.isDocument) docs.push(c);
}
print(docs);
In the end I'll sort by modified time then chop it for presentation, I'm operating under the assumption that getting the content is the hard part :)
Alfresco Share doesn't keep track of content modified outside it's interface which makes the recently modified RSS/Dashlet useless. I'm working on creating an RSS that I can use within sites to pull a list of recently modified items.
Right now I'm just working on getting the list of files and I'm stumbling a little bit as I'm not very familiar with Webscripts. I've got this piece of code that will retrieve the contents of a site then build an array of the files, the problem I'm running into is I could have many subfolders and I'm not sure how to properly traverse them.
var folder = panyhome.childByNamePath("/Sites/foo/documentLibrary");
var docs = new Array();
print(folder);
print("iterating...");
var children = folder.children;
for (i=0; i<children.length; i++)
{
var c = children[i];
if (c.isContainer)
{
print(c.name + " is a folder, traversing...");
var subfolder = panyhome.childByNamePath("/Sites/foo/documentLibrary/" + c.name.toString());
var subchildren = subfolder.children;
for (j=0; j<subchildren.length; j++)
{
var d = subchildren[j];
if (d.isDocument) docs.push(d);
}
}
if (c.isDocument) docs.push(c);
}
print(docs);
In the end I'll sort by modified time then chop it for presentation, I'm operating under the assumption that getting the content is the hard part :)
Share Improve this question asked Jun 5, 2013 at 0:53 AshexAshex 5435 silver badges11 bronze badges 3- Wouldn't you be better off running a search, rather than doing a full recursion? – Gagravarr Commented Jun 5, 2013 at 11:54
- Probably, I was trying to use the search api but I was having issues building a query. – Ashex Commented Jun 5, 2013 at 16:02
- You might want to ask a fresh question then - someone here will I'm sure be able to help you work out what that should be – Gagravarr Commented Jun 5, 2013 at 21:50
2 Answers
Reset to default 6I would write a recursive function to traverse the folder hiarchy, something like this:
var documentLibrary = panyhome.childByNamePath("sites/foo/documentLibrary");
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 + "is a document, modified: " + node.properties["cm:modified"]);
}
}
}
It's quite simple actually. If you look in the code of the docsummary dashlet/js file (Recently Modified Dashlet), you'll see that it's firing:
slingshot/doclib/doclist/documents/site/" + Alfresco.constants.SITE + "/documentLibrary?max=50
So you only need is a list of sites available and good for you that there is a service for it listSites(nameFilter, sitePresetFilter) .
You can just use listSites(null, null), which will return all sites. So just loop through the sites and fire the webscript.
本文标签: javascriptFind all files in a site with Alfresco 41 webscriptsStack Overflow
版权声明:本文标题:javascript - Find all files in a site with Alfresco 4.1 webscripts - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744669181a2618719.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论