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());
}