使用Alfresco 4.1 Web脚本查找站点中的所有文件

编程入门 行业动态 更新时间:2024-10-12 03:23:15
本文介绍了使用Alfresco 4.1 Web脚本查找站点中的所有文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

Alfresco Share无法跟踪在其界面之外修改的内容,这使得最近修改的RSS / Dashlet毫无用处。我正在创建一个RSS,我可以在网站上使用它来提取最近修改过的项目的列表。

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.

现在,我只是在获取列表的列表。文件,由于我对Webscript不太熟悉,所以我有点绊脚石。我已经获得了这段代码,它将检索站点的内容,然后构建文件数组,我遇到的问题是我可能有很多子文件夹,而且我不确定如何正确遍历它们。 / p>

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 = companyhome.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 = companyhome.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 :)

推荐答案

我将编写一个递归函数来遍历文件夹层次结构,像这样:

I would write a recursive function to traverse the folder hiarchy, something like this:

var documentLibrary = companyhome.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"]); } } }

更多推荐

使用Alfresco 4.1 Web脚本查找站点中的所有文件

本文发布于:2023-11-28 14:38:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1642814.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:脚本   站点   文件   Alfresco   Web

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!