\r
RepositoryJavaClientImpl nuxeoRepoClient = (RepositoryJavaClientImpl) repoClient;\r
try {\r
+ // Ignore any provided page size and number query parameters in\r
+ // the following call, as they pertain to the list of authority\r
+ // references to be returned, not to the list of documents to be\r
+ // scanned for those references.\r
DocumentModelList docList = findAuthorityRefDocs(ctx, repoClient, repoSession,\r
serviceTypes, refName, refPropName, queriedServiceBindings, authRefFieldsByService,\r
- filter.getWhereClause(), null, pageSize, pageNum, computeTotal);\r
+ filter.getWhereClause(), null, 0 /* pageSize */, 0 /* pageNum */, computeTotal);\r
\r
if (docList == null) { // found no authRef fields - nothing to process\r
return wrapperList;\r
// Slice the list to return only the specified page of items\r
// in the list results.\r
//\r
- // FIXME: There may well be a pattern-based way to do this in our framework.\r
+ // FIXME: There may well be a pattern-based way to do this\r
+ // in our framework.\r
int startIndex = 0;\r
int endIndex = 0;\r
- // Return all results if pageSize is 0\r
+ // Return all results if pageSize is 0.\r
if (pageSize == 0) {\r
startIndex = 0;\r
endIndex = list.size();\r
} else {\r
startIndex = pageNum * pageSize;\r
- int pageEndIndex = ((startIndex + pageSize) - 1);\r
- endIndex = (pageEndIndex > list.size()) ? list.size() : pageEndIndex;\r
}\r
- // Adjust for the second argument to List.subList() being exclusive\r
- // of the last item in the slice\r
- endIndex++;\r
- list = new ArrayList<AuthorityRefDocList.AuthorityRefDocItem>\r
- (list.subList(startIndex, endIndex));\r
- commonList.setItemsInPage(list.size());\r
+ \r
+ // Return an empty list if the start of the requested page is\r
+ // beyond the last item in the list.\r
+ if (startIndex > list.size()) {\r
+ wrapperList = null;\r
+ return wrapperList;\r
+ }\r
+\r
+ // Otherwise, return a list of items from the start of the specified\r
+ // page through the last item on that page, or otherwise through the last\r
+ // item in the entire list, if it occurs prior to the end of that page.\r
+ if (endIndex == 0) {\r
+ int pageEndIndex = ((startIndex + pageSize));\r
+ endIndex = (pageEndIndex > list.size()) ? list.size() : pageEndIndex;\r
+ }\r
+ \r
+ // Slice the list to return only the specified page.\r
+ // Note: the second argument to List.subList() is exclusive of the\r
+ // item at its index position, reflecting the zero-index nature of\r
+ // the list.\r
+ List<AuthorityRefDocList.AuthorityRefDocItem> currentPageList = list.subList(startIndex, endIndex);\r
+ wrapperList.getAuthorityRefDocItem().clear();\r
+ wrapperList.getAuthorityRefDocItem().addAll(currentPageList);\r
+ commonList.setItemsInPage(currentPageList.size());\r
\r
if (logger.isDebugEnabled() && (nRefsFound < docList.size())) {\r
logger.debug("Internal curiosity: got fewer matches of refs than # docs matched..."); // We found a ref to ourself and have excluded it.\r
}\r
} catch (Exception e) {\r
- logger.error("Could not retrieve the Nuxeo repository", e);\r
+ logger.error("Could not retrieve a list of documents referring to the specified authority item", e);\r
wrapperList = null;\r
}\r
\r