*/
protected static void viewTopic(HttpServletRequest request, ModelAndView next, WikiPageInfo pageInfo, WikiMessage pageTitle,
Topic topic, boolean sectionEdit, boolean allowRedirect) throws WikiException {
// FIXME - what should the default be for topics that don't exist?
if (topic == null) {
throw new WikiException(new WikiMessage("common.exception.notopic"));
}
// WikiUtil.validateTopicName(topic.getName());
// if (allowRedirect
// && topic.getTopicType() == Topic.TYPE_REDIRECT
// && (request.getParameter("redirect") == null || !request.getParameter(
// "redirect").equalsIgnoreCase("no"))) {
// Topic child = null;
// try {
// child = WikiUtil.findRedirectedTopic(topic, 0);
// } catch (DataAccessException e) {
// throw new WikiException(
// new WikiMessage("error.unknown", e.getMessage()), e);
// }
// if (!child.getName().equals(topic.getName())) {
// String redirectUrl = null;
// try {
// redirectUrl = LinkUtil.buildTopicUrl(request.getContextPath(), topic
// .getVirtualWiki(), topic.getName(), true);
// } catch (DataAccessException e) {
// throw new WikiException(new WikiMessage("error.unknown", e
// .getMessage()), e);
// }
// // FIXME - hard coding
// redirectUrl += LinkUtil.appendQueryParam("", "redirect", "no");
// String redirectName = topic.getName();
// pageInfo.setRedirectInfo(redirectUrl, redirectName);
// pageTitle = new WikiMessage("topic.title", child.getName());
// topic = child;
// // update the page info's virtual wiki in case this redirect is to
// // another virtual wiki
// pageInfo.setVirtualWikiName(topic.getVirtualWiki());
// }
// }
String virtualWiki = topic.getVirtualWiki();
String topicName = topic.getName();
// WikiUserDetails userDetails = ServletUtil.currentUserDetails();
// if (sectionEdit
// && !ServletUtil.isEditable(virtualWiki, topicName, userDetails)) {
// sectionEdit = false;
// }
WikiUser user = ServletUtil.currentWikiUser();
ParserInput parserInput = new ParserInput();
parserInput.setContext(request.getContextPath());
parserInput.setLocale(request.getLocale());
parserInput.setWikiUser(user);
parserInput.setTopicName(topicName);
parserInput.setUserDisplay(ServletUtil.getIpAddress(request));
parserInput.setVirtualWiki(virtualWiki);
parserInput.setAllowSectionEdit(sectionEdit);
ParserOutput parserOutput = new ParserOutput();
String content = null;
try {
content = ParserUtil.parse(parserInput, parserOutput, topic.getTopicContent());
} catch (ParserException e) {
throw new WikiException(new WikiMessage("error.unknown", e.getMessage()), e);
}
if (parserOutput.getCategories().size() > 0) {
LinkedHashMap<String, String> categories = new LinkedHashMap<String, String>();
for (String key : parserOutput.getCategories().keySet()) {
String value = key.substring(NamespaceHandler.NAMESPACE_CATEGORY.length() + NamespaceHandler.NAMESPACE_SEPARATOR.length());