return p;
}
@Override
public List<Page> findPages(PageQuery query) {
Pagination pagination = query.getPagination();
Iterator<PageContext> iterator;
if (pagination == null) {
if (query.getSiteType() == null || query.getSiteName() == null)
throw new IllegalArgumentException("Pagination is required when site type or site name is null.");
SiteKey siteKey = Util.from(new SiteId(query.getSiteType(), query.getSiteName()));
if (pageService instanceof PageServiceImpl) {
iterator = ((PageServiceImpl) pageService).loadPages(siteKey).iterator();
} else if (pageService instanceof PageServiceWrapper) {
iterator = ((PageServiceWrapper) pageService).loadPages(siteKey).iterator();
} else {
throw new RuntimeException("Unable to retrieve all pages for " + siteKey);
}
} else {
QueryResult<PageContext> result = pageService.findPages(pagination.getOffset(), pagination.getLimit(),
Util.from(query.getSiteType()), query.getSiteName(), null, query.getDisplayName());
iterator = result.iterator();
}