Easily illustrated bug, the getTotalNumItems() returns ONLY the results returned up to the current page. I saw a link that said the issue was fixed in Enterprise...has anyone fixed (or know how to fix) Community 4.2.f? If so, could you please share the fix? I believe this is the same issue: https://issues.alfresco.com/jira/browse/MNT-2839 (marked fixed in Enterprise).
import org.apache.chemistry.opencmis.commons.*
import org.apache.chemistry.opencmis.commons.data.*
import org.apache.chemistry.opencmis.commons.enums.*
import org.apache.chemistry.opencmis.client.api.*
String cql = "SELECT cmis:name FROM cmis:folder"
int maxItemsPerPage = 10;
OperationContext context = session.createOperationContext();
context.setIncludeAcls(false);
context.setIncludePolicies(false);
context.setMaxItemsPerPage(maxItemsPerPage);
int reqPageNum = 0;
ItemIterable results = session.query(cql, false, context).skipTo(reqPageNum * maxItemsPerPage).getPage(maxItemsPerPage);
long total = results.getTotalNumItems();
println("========== total: "+total); // will be WRONG and return 10
reqPageNum = 1;
results = session.query(cql, false, context).skipTo(reqPageNum * maxItemsPerPage).getPage(maxItemsPerPage);
total = results.getTotalNumItems();
println("========== total: "+total); // will be WRONG and return 20