在java组件xwiki中获取子页面
我正在尝试使用以下方法获取将当前文档列为perant的所有文档:在java组件xwiki中获取子页面,java,xwiki,Java,Xwiki,我正在尝试使用以下方法获取将当前文档列为perant的所有文档: List<DocumentReference> childDocs = doc.getChildrenReferences(xcontext); 而提交人将要访问AAA.BBB.Webhome或AAA.BBB.CCC.Webhome这是哪个XWiki版本?我尝试了7.3,但无法复制。(还有一些随机想法:页面BBB是否标记为隐藏?)另一个想法是:doc.isNew()产生了什么?如果访问不存在的文档,则不会生成nu
List<DocumentReference> childDocs = doc.getChildrenReferences(xcontext);
而提交人将要访问AAA.BBB.Webhome或AAA.BBB.CCC.Webhome这是哪个XWiki版本?我尝试了7.3,但无法复制。(还有一些随机想法:页面
BBB
是否标记为隐藏?)另一个想法是:doc.isNew()产生了什么?如果访问不存在的文档,则不会生成null
,而是动态创建一个文档,isNew()
将为该文档返回true
。这种“尚未存在”的文件当然没有子文件。发生在我身上是因为我在错误的上下文中解析了路径…问题是由页面创建组件导致的,该组件在创建时未设置页面父级。因此,从未设置子引用。当为所有文档设置父级时,该函数工作正常。
public void RECdeleteSpace(XWikiDocument doc, XWikiContext xcontext,boolean toTrash){
XWiki xwiki = xcontext.getWiki();
List<DocumentReference> childDocs;
try {
childDocs = doc.getChildrenReferences(xcontext);
System.out.println("REC " + doc.getFullName());
System.out.println("CHLD " + childDocs.toString());
System.out.println("----- ");
Iterator<DocumentReference> docit = childDocs.iterator();
while (docit.hasNext()) {
DocumentReference chdocref = docit.next();
XWikiDocument chdoc = xwiki.getDocument(chdocref, xcontext);
System.out.println("DOC: "+chdoc.getFullName());
RECdeleteSpace(chdoc,xcontext,toTrash);
}
xwiki.deleteDocument(doc, toTrash, xcontext);
} catch (XWikiException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
INIT WebHome
REC AAA.WebHome
CHLD []
-----