results.setMaskedPagination(itemsTotal, firstItemIndex,
lastItemIndex, currentPage, pagesTotal, pageURLMask);
// Look for any communities or collections in the mix
ReferenceSet referenceSet = null;
boolean resultsContainsBothContainersAndItems = false;
@SuppressWarnings("unchecked") // This cast is correct
java.util.List<String> containerHandles = queryResults.getHitHandles();
for (String handle : containerHandles)
{
DSpaceObject resultDSO = HandleManager.resolveToObject(
context, handle);
if (resultDSO instanceof Community
|| resultDSO instanceof Collection)
{
if (referenceSet == null) {
referenceSet = results.addReferenceSet("search-results-repository",
ReferenceSet.TYPE_SUMMARY_LIST,null,"repository-search-results");
// Set a heading showing that we will be listing containers that matched:
referenceSet.setHead(T_head2);
resultsContainsBothContainersAndItems = true;
}
referenceSet.addReference(resultDSO);
}
}
// Look for any items in the result set.
referenceSet = null;
@SuppressWarnings("unchecked") // This cast is correct
java.util.List<String> itemHandles = queryResults.getHitHandles();
for (String handle : itemHandles)
{
DSpaceObject resultDSO = HandleManager.resolveToObject(
context, handle);
if (resultDSO instanceof Item)
{
if (referenceSet == null) {
referenceSet = results.addReferenceSet("search-results-repository",
ReferenceSet.TYPE_SUMMARY_LIST,null,"repository-search-results");
// Only set a heading if there are both containers and items.
if (resultsContainsBothContainersAndItems)
referenceSet.setHead(T_head3);
}
referenceSet.addReference(resultDSO);
}
}
}
else