AbstractCommonList commonList = (AbstractCommonList) wrapperList;\r
int pageNum = filter.getStartPage();\r
int pageSize = filter.getPageSize();\r
- commonList.setPageNum(pageNum);\r
- commonList.setPageSize(pageSize);\r
+ \r
List<AuthorityRefDocList.AuthorityRefDocItem> list =\r
wrapperList.getAuthorityRefDocItem();\r
\r
if (docList == null) { // found no authRef fields - nothing to process\r
return wrapperList;\r
}\r
- // Set num of items in list. this is useful to our testing framework.\r
- commonList.setItemsInPage(docList.size());\r
- // set the total result size\r
- commonList.setTotalItems(docList.totalSize());\r
+\r
// set the fieldsReturned list. Even though this is a fixed schema, app layer treats\r
// this like other abstract common lists\r
/*\r
String fieldList = "docType|docId|docNumber|docName|sourceField|uri|updatedAt|workflowState";\r
commonList.setFieldsReturned(fieldList);\r
\r
+ // As a side-effect, the method called below modifies the value of\r
+ // the 'list' variable, which holds the list of references to\r
+ // an authority item.\r
+ //\r
+ // There can be more than one reference to a particular authority\r
+ // item within any individual document scanned, so the number of\r
+ // authority references may potentially exceed the total number\r
+ // of documents scanned.\r
int nRefsFound = processRefObjsDocList(docList, refName, queriedServiceBindings, authRefFieldsByService, // the actual list size needs to be updated to the size of "list"\r
list, null);\r
+\r
+ commonList.setPageSize(pageSize);\r
+ \r
+ // Values returned in the pagination block above the list items\r
+ // need to reflect the number of references to authority items\r
+ // returned, rather than the number of documents originally scanned\r
+ // to find such references.\r
+ commonList.setPageNum(pageNum);\r
+ commonList.setTotalItems(list.size());\r
+\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
+ int startIndex = 0;\r
+ int endIndex = 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
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
DocumentModelList docList;\r
boolean morePages = true;\r
while (morePages) {\r
- \r
+\r
docList = findAuthorityRefDocs(ctx, repoClient, repoSession,\r
getRefNameServiceTypes(), oldRefName, refPropName,\r
queriedServiceBindings, authRefFieldsByService, WHERE_CLAUSE_ADDITIONS_VALUE, ORDER_BY_VALUE, pageSize, currentPage, false);\r
- \r
+\r
if (docList == null) {\r
logger.debug("updateAuthorityRefDocs: no documents could be found that referenced the old refName");\r
break;\r
((RepositoryJavaClientImpl) repoClient).saveDocListWithoutHandlerProcessing(ctx, repoSession, docList, true);\r
nRefsFound += nRefsFoundThisPage;\r
}\r
- \r
+\r
// FIXME: Per REM, set a limit of num objects - something like\r
// 1000K objects - and also add a log Warning after some threshold\r
docsScanned += docsInCurrentPage;\r
// Additional qualifications, like workflow state\r
if (Tools.notBlank(whereClauseAdditions)) {\r
query += " AND " + whereClauseAdditions;\r
- } \r
+ }\r
// Now we have to issue the search\r
RepositoryJavaClientImpl nuxeoRepoClient = (RepositoryJavaClientImpl) repoClient;\r
DocumentWrapper<DocumentModelList> docListWrapper = nuxeoRepoClient.findDocs(ctx, repoSession,\r