SearchPageProvider doesn't fulfil the Java iterator contract
------------------------------------------------------------
Key: NXP-1573
URL: http://jira.nuxeo.org/browse/NXP-1573
Project: Nuxeo Enterprise Platform 5
Issue Type: Improvement
Components: Query / Search
Affects Versions: 5.1.0.GA
Reporter: Bogdan Stefanescu
Assignee: Georges Racinet
When having as a search result a single page this code is not working:
DocumentModelList page = null;
DocumentModelList list = new DocumentModelListImpl();
while (provider.isNextPageAvailable()) {
page = provider.getNextPage();
for ( DocumentModel doc : page) {
list.add(session.getDocument(doc.getRef()));
}
}
return list;
But this one is working:
DocumentModelList page = null;
DocumentModelList list = new DocumentModelListImpl();
page = provider.getCurrentPage();
if (page == null) {
return list;
}
for ( DocumentModel doc : page) {
list.add(session.getDocument(doc.getRef()));
}
while (provider.isNextPageAvailable()) {
page = provider.getNextPage();
for ( DocumentModel doc : page) {
list.add(session.getDocument(doc.getRef()));
}
}
return list;
The first code is the natural way to use iterators.
Iterators must return the first available item when first time calling the
getNext method
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.nuxeo.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
_______________________________________________
ECM-tickets mailing list
[email protected]
http://lists.nuxeo.com/mailman/listinfo/ecm-tickets