AnsweredAssumed Answered

Pagination CMIS query results

Question asked by agz on May 30, 2013
Latest reply on Sep 4, 2014 by chayiadp
Hi all,
I'm working with Alfresco Community 4.0.e through CMIS.

In a Java class I have a query that find all documents in a specified folder:

FROM cmis:document
WHERE IN_FOLDER('workspace://SpacesStore/d588e663-7dc4-48b2-be8e-b6044584f769')

this query give mi 28 results and I want to have pagination every 25 results.
In my Java class I have:

ItemIterable<QueryResult> risultati = <SOMETHING>.getSession(Security.connectedUser()).query(query,false);

At this point I try to have pagination of my results but I have tried in different ways but with no result.

I introduced in the code the OperationContext because I have tried this approach <a></a>
<em>(the code below is extracted from above topic and adapted)</em>

Session session = cmisClient.getSession();
      OperationContext operationContext = new OperationContextImpl();
      String queryString = <MYQUERY>;
      ItemIterable<QueryResult> results = session.query(queryString, false,operationContext);
                int pageNumber = 0;
      boolean finished = false;
      int count = 0;
      while (!finished) {
         ItemIterable<QueryResult> currentPage = results.skipTo(count).getPage();
         for (QueryResult qResult : currentPage) {
                        <SOME LOGIC>   
           if (!currentPage.getHasMoreItems())
               finished = true;

but in
ItemIterable<QueryResult> currentPage = results.skipTo(count).getPage();
after first 25 results I have a CmisRuntimeException because currentaPage have no data

…but where are 3 records after 25???

Thanks in advance.