public List<QueryPageRow> build() {
validate();
int skipped = 0;
Integer pageSize = pageRequest.getPageSize();
int startRowIndex = pageRequest.getStartRowIndex();
RepositoryFilter filter = new AssetItemFilter(identity);
RepositoryFilter categoryFilter = new CategoryFilter(identity);
List<QueryPageRow> rowList = new ArrayList<QueryPageRow>();
while (iterator.hasNext() && (pageSize == null || rowList.size() < pageSize)) {
AssetItem assetItem = iterator.next();
// Filter surplus assets
if ( filter.accept( assetItem, RoleType.PACKAGE_READONLY.getName() )
|| checkCategoryPermissionHelper(categoryFilter, assetItem, RoleType.ANALYST_READ.getName())) {
// Cannot use AssetItemIterator.skip() as it skips non-filtered
// assets whereas startRowIndex is the index of the
// first displayed asset (i.e. filtered)