我想知道Alfresco中“公司主页”目录下的所有文件夹名称,但收到错误。
代码 -
ItemIterable<QueryResult> results = session.query("SELECT * FROM cmis:folder where IN_TREE('/Company Home')", false);
try {
for (QueryResult result : results) {
folderId = result.getPropertyValueById(PropertyIds.OBJECT_ID);
Folder folder = (Folder) session.getObject(folderId);
System.out.println("Folder Name " + folder.getName());
}
} catch(Exception e) {
e.printStackTrace();
}
错误 -
org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException: 00270668 Request failed 500 /solr/alfresco/cmis?wt=json&fl=DBID%2Cscore&rows=100&df=TEXT&start=0&locale=en_US&fq=%7B%21afts%7DAUTHORITY_FILTER_FROM_JSON&fq=%7B%21afts%7DTENANT_FILTER_FROM_JSON
at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.convertStatusCode(AbstractAtomPubService.java:452)
at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.post(AbstractAtomPubService.java:570)
at org.apache.chemistry.opencmis.client.bindings.spi.atompub.DiscoveryServiceImpl.query(DiscoveryServiceImpl.java:142)
at org.apache.chemistry.opencmis.client.runtime.SessionImpl$3.fetchPage(SessionImpl.java:567)
at org.apache.chemistry.opencmis.client.runtime.util.AbstractIterator.getCurrentPage(AbstractIterator.java:132)
at org.apache.chemistry.opencmis.client.runtime.util.CollectionIterator.hasNext(CollectionIterator.java:48)
at main.java.org.apache.chemistry.opencmis.doc.QueryTest.folderName(QueryTest.java:180)
答案 0 :(得分:3)
IN_TREE获取对象id,而不是对象路径。如果您提供“Company Home”文件夹的ID,则此查询应该有效。
答案 1 :(得分:1)
Company Home是根文件夹,我建议您使用以下内容:
Session session = createSession();
Folder rootFolder = session.getRootFolder();
ItemIterable<CmisObject> children = rootFolder.getChildren();
for (CmisObject child : children) {
System.out.println(child.getName());
}