*
*/
private void viewOrphanedPages(HttpServletRequest request, ModelAndView next,
WikiPageInfo pageInfo) throws Exception {
String virtualWiki = pageInfo.getVirtualWikiName();
Pagination pagination = ServletUtil.loadPagination(request, next);
Set<String> allItems = new TreeSet<String>();
List<String> unlinkedTopics = WikiBase.getDataHandler().getAllTopicNames(
virtualWiki);
Topic topic;
List<SearchResultEntry> topicLinks = null;
ParserInput parserInput;
ParserOutput parserOutput;
for (String topicName : unlinkedTopics) {
topic = WikiBase.getDataHandler().lookupTopic(virtualWiki, topicName,
true, null);
if (topic == null) {
logger.warning("No topic found: " + virtualWiki + " / " + topicName);
continue;
}
if (topic.getTopicType() != Topic.TYPE_ARTICLE) {
continue;
}
// only mark them orphaned if there is neither category defined in it, nor
// a link to it!
// topicLinks = WikiBase.getSearchEngine().findLinkedTo(virtualWiki,
// topicName);
if (topicLinks == null || !topicLinks.isEmpty()) {
continue;
}
parserInput = new ParserInput();
parserInput.setContext(request.getContextPath());
parserInput.setLocale(request.getLocale());
parserInput.setWikiUser(ServletUtil.currentWikiUser());
parserInput.setTopicName(topicName);
parserInput.setUserDisplay(ServletUtil.getIpAddress(request));
parserInput.setVirtualWiki(virtualWiki);
parserInput.setAllowSectionEdit(false);
parserOutput = new ParserOutput();
ParserUtil.parse(parserInput, parserOutput, topic.getTopicContent());
if (parserOutput.getCategories().size() == 0) {
allItems.add(topic.getName());
}
}
// FIXME - this is a nasty hack until data can be retrieved properly for
// pagination
Set<String> items = new TreeSet<String>();
int count = 0;
for (String topicName : allItems) {
count++;
if (count < (pagination.getOffset() + 1)) {
continue;
}
if (count > (pagination.getOffset() + pagination.getNumResults())) {
break;
}
items.add(topicName);
}
next.addObject("itemCount", items.size());