// Finally Load the pages
pages = repository.find(query);
}
boolean found = false;
PageSearchResultItem item = null;
Page page = null;
WebUrl url = null;
// Look for the next header
while (!found && index < pages.getItems().length) {
SearchResultItem candidateItem = pages.getItems()[index];
if (!(candidateItem instanceof PageSearchResultItem)) {
index++;
continue;
}
item = (PageSearchResultItem) candidateItem;
// Store the important properties
url = item.getUrl();
page = item.getPage();
// TODO security check
found = true;
}