*/
private void edit(HttpServletRequest request, ModelAndView next,
WikiPageInfo pageInfo) throws Exception {
String topicName = WikiUtil.getTopicFromRequest(request);
String virtualWiki = pageInfo.getVirtualWikiName();
Topic topic = loadTopic(virtualWiki, topicName);
// topic name might be updated by loadTopic
topicName = topic.getName();
// Integer lastTopicVersionId = retrieveLastTopicVersionId(request, topic);
// next.addObject("lastTopicVersionId", lastTopicVersionId);
String contents = (String) request.getParameter("contents");
if (isPreview(request)) {
preview(request, next, pageInfo);
} else if (isShowChanges(request)) {
// showChanges(request, next, pageInfo, virtualWiki, topicName,
// lastTopicVersionId);
// } else if
// (!StringUtils.isBlank(request.getParameter("topicVersionId"))) {
// // editing an older version
// Integer topicVersionId =
// Integer.valueOf(request.getParameter("topicVersionId"));
// TopicVersion topicVersion =
// WikiBase.getDataHandler().lookupTopicVersion(topicVersionId);
// if (topicVersion == null) {
// throw new WikiException(new WikiMessage("common.exception.notopic"));
// }
// contents = topicVersion.getVersionContent();
// if (!lastTopicVersionId.equals(topicVersionId)) {
// next.addObject("topicVersionId", topicVersionId);
// }
} else if (!StringUtils.isBlank(request.getParameter("section"))) {
// editing a section of a topic
int section = Integer.valueOf(request.getParameter("section"));
String[] sliceResults = ParserUtil.parseSlice(request.getContextPath(),
request.getLocale(), virtualWiki, topicName, section);
contents = sliceResults[1];
String sectionName = sliceResults[0];
String editComment = "/* " + sectionName + " */ ";
next.addObject("editComment", editComment);
} else {
// editing a full new or existing topic
contents = (topic == null) ? "" : topic.getTopicContent();
}
this.loadEdit(request, next, pageInfo, contents, virtualWiki, topicName,
true);
}