ALF-11319 Work around the fact that Filtered Lucene Results don't support start/hasMore calls, so the new services using these for tag queries (links and discussion) need to handle that if the results were filtered

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@32158 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Nick Burch
2011-11-21 17:35:59 +00:00
parent eb8f85a4fd
commit 772056a903
2 changed files with 35 additions and 4 deletions

View File

@@ -435,14 +435,33 @@ public class LinksServiceImpl implements LinksService
@Override
public boolean hasMoreItems()
{
return finalLuceneResults.hasMore();
try
{
return finalLuceneResults.hasMore();
}
catch(UnsupportedOperationException e)
{
// Not all lucene results support paging
return false;
}
}
@Override
public Pair<Integer, Integer> getTotalResultCount()
{
int skipCount = finalLuceneResults.getStart();
int itemsRemainingAfterThisPage = finalLuceneResults.length();
int skipCount = 0;
int itemsRemainingAfterThisPage = 0;
try
{
skipCount = finalLuceneResults.getStart();
}
catch(UnsupportedOperationException e) {}
try
{
itemsRemainingAfterThisPage = finalLuceneResults.length();
}
catch(UnsupportedOperationException e) {}
final int totalItemsInUnpagedResultSet = skipCount + itemsRemainingAfterThisPage;
return new Pair<Integer, Integer>(totalItemsInUnpagedResultSet, totalItemsInUnpagedResultSet);
}