Hi Nicolas, There was no OpenCMIS cookbook, but now there is one: [1] It's linked from the OpenCMIS welcome page and will be on [2] in about two hours.
Thanks for your contribution! - Florian [1] https://cwiki.apache.org/confluence/display/CMIS/OpenCMIS+Cookbook [2] http://incubator.apache.org/chemistry/ -----Original Message----- From: Nicolas Raoul [mailto:[email protected]] Sent: Freitag, 28. Mai 2010 04:05 To: [email protected] Subject: Re: OpenCMIS client: Using maxItemsPerPage for paging Thanks a lot, it works indeed! Is there a "cookbook" wiki where I could contribute this code sample? I was looking for it desperately before resorting to try and guess how to do by reading the OpenCMIS source code. I maintain such a cookbook for Alfresco's Java NodeRef client API: http://wiki.alfresco.com/wiki/NodeRef_cookbook Is there a similar place for OpenCMIS tricks and how-tos? Is this page appropriate? http://incubator.apache.org/chemistry/opencmis-client-api.html Thank you! Nicolas Raoul On Thu, May 27, 2010 at 10:30 PM, David Caruana <[email protected]> wrote: > It's subtle... > > Try replacing: > >> ItemIterable<CmisObject> itemIterable = children.getPage().skipTo(skipCount); > > with > >> ItemIterable<CmisObject> itemIterable = children.skipTo(skipCount).getPage(); > > > The skipTo() method always creates an iterable over the complete collection. > The getPage() method can then be used to create an iterable for just a page > worth of items, starting from the skipTo() point. > > Regards, > Dave > > > On 27 May 2010, at 10:23, Nicolas Raoul wrote: > >> Hello all, >> >> Context: CMIS browsing Java application, using OpenCMIS >> >> I am trying to use paging to show the files in a folder. >> Below is my attempt to show files 10~15 from a folder that contains 17 files. >> Somehow, it seems to ignore "maxItemsPerPage". >> Am I using the wrong iterator? >> >> ===== Code ===== >> int maxItemsPerPage = 5; >> int skipCount = 10; >> CmisObject object = session.getObject(new ObjectIdImpl(folderId)); >> Folder folder = (Folder)object; >> OperationContext operationContext = new OperationContextImpl(); >> operationContext.setMaxItemsPerPage(maxItemsPerPage); >> ItemIterable<CmisObject> children = folder.getChildren(operationContext); >> ItemIterable<CmisObject> itemIterable = children.getPage().skipTo(skipCount); >> Iterator<CmisObject> iterator = itemIterable.iterator(); >> int count = 0; >> while(iterator.hasNext()) { >> CmisObject child = iterator.next(); >> count++; >> } >> System.out.println(count); >> System.out.println(children.getPageNumItems()); >> System.out.println(children.getTotalNumItems()); >> >> ===== Output ===== >> 7 >> 5 >> 17 >> >> Thanks a lot for your time! >> Nicolas Raoul > >
