use of org.apache.chemistry.opencmis.commons.data.ObjectInFolderContainer in project structr by structr.
the class CMISNavigationService method getFolderTree.
@Override
public List<ObjectInFolderContainer> getFolderTree(final String repositoryId, final String folderId, final BigInteger depth, final String filter, final Boolean includeAllowableActions, final IncludeRelationships includeRelationships, final String renditionFilter, final Boolean includePathSegment, final ExtensionsData extension) {
final PropertyKey<Folder> parentKey = StructrApp.key(AbstractFile.class, "parent");
final List<ObjectInFolderContainer> result = new LinkedList<>();
final App app = StructrApp.getInstance();
try (final Tx tx = app.tx()) {
int maxDepth = Integer.MAX_VALUE;
if (depth != null && depth.intValue() >= 0) {
maxDepth = depth.intValue();
}
if (CMISInfo.ROOT_FOLDER_ID.equals(folderId)) {
for (final Folder folder : app.nodeQuery(Folder.class).and(parentKey, null).sort(AbstractNode.name).getAsList()) {
recursivelyCollectFolderTree(result, folder, maxDepth, 1, includeAllowableActions);
}
} else {
final Folder folder = app.get(Folder.class, folderId);
if (folder != null) {
final List<Folder> children = Iterables.toList(folder.getFolders());
Collections.sort(children, new GraphObjectComparator(AbstractNode.name, false));
for (final Folder child : children) {
recursivelyCollectFolderTree(result, child, maxDepth, 1, includeAllowableActions);
}
} else {
throw new CmisObjectNotFoundException("Folder with ID " + folderId + " does not exist");
}
}
tx.success();
} catch (final FrameworkException fex) {
logger.warn("", fex);
}
return result;
}
Aggregations