Search code examples
alfrescoopencmis

How can I get both Folders and Documents with one Cmis query


By using Apache Cmis query, if I understand correctly, you can get either

  1. a List of Cmis Folders (SELECT * FROM cmis:folder WHERE...)
  2. a List of Cmis Documents (SELECT * FROM cmis:document WHERE...)

But what I need, is a List of cmisObjects. I need this abstraction, because I want to get all the children (Folder or Document) of the selected Parent Folder.

Using 2 queries (1 for each type) is not an option, as I also have to use paging (using OperationContext.setMaxItemsPerPage) over the query results

EDIT : Just to make sure I made myself clear, I need to

  1. Use the query Function, as I need to filter my results by using a specific custom aspect
  2. Use Pagination, because even after filtering, the results (Folder Children) can be up to hundreds

Solution

  • This one has hit me years ago (I gave up on CMIS at that time). As of CMIS 1.1, there is this optional cmis:item. Have a look at http://docs.oasis-open.org/cmis/CMIS/v1.1/CMIS-v1.1.html#x1-220002 . You may be lucky and find that working with Alfresco. It might be required to use the v.1.1 implementation of the spec.

    If that does not work, I guess your only option is to abondon CMIS for this query and either use another search service or roll your own.

    Good luck ! ;)