You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@chemistry.apache.org by Alexander Haag <al...@alfresco.com> on 2013/10/16 13:58:53 UTC

Paging with OpenCMIS

Hello Community,

we are introducing the paging capability into our app, and run into a
behavior which is not very clear to us:

ItemIterable<CmisObject> children = ((Folder) obj).getChildren();
int count = 0;
for (CmisObject o : children)
{
count++;
}
int count2 = 0;
for (CmisObject o : children)
{
count2++;
}
assertEquals(count, count2);

And that simple test is failing since count2 will always be 0, that leads
to the assumption that ItemIterable is stateful. Reading the documentation
didn't bring any information to our conclusion.

One of the developers found following place:
org.apache.chemistry.opencmis.client.runtime.util.AbstractIterable.getIterator()
which is creating the stateful behavior.

Could someone clarify the behavior?
Comparing to the java-Iterable implementation it looks like a bug, but
maybe there is a reason for the behavior in OpenCMIS framework.

Kind Regards,
Alex

Re: Paging with OpenCMIS

Posted by Florian Müller <fm...@apache.org>.
 Hi Alex,

 You are right; the ItemIterable can only be used once and therefore 
 behaves a bit different than other Iterables.
 There is no specific reason for that, except that the implementation of 
 a reusable ItemIterable is more complicated. The current implementation 
 also allows easy access to numItems, totalNumItems, and the hasMoreItems 
 flag that depend on the underlying iterator. We'll improve the JavaDoc.


 Florian


> Hello Community,
>
> we are introducing the paging capability into our app, and run into a
> behavior which is not very clear to us:
>
> ItemIterable<CmisObject> children = ((Folder) obj).getChildren();
> int count = 0;
> for (CmisObject o : children)
> {
> count++;
> }
> int count2 = 0;
> for (CmisObject o : children)
> {
> count2++;
> }
> assertEquals(count, count2);
>
> And that simple test is failing since count2 will always be 0, that 
> leads
> to the assumption that ItemIterable is stateful. Reading the 
> documentation
> didn't bring any information to our conclusion.
>
> One of the developers found following place:
> 
> org.apache.chemistry.opencmis.client.runtime.util.AbstractIterable.getIterator()
> which is creating the stateful behavior.
>
> Could someone clarify the behavior?
> Comparing to the java-Iterable implementation it looks like a bug, 
> but
> maybe there is a reason for the behavior in OpenCMIS framework.
>
> Kind Regards,
> Alex