*
*/
private void update(HttpServletRequest request, ModelAndView next, WikiPageInfo pageInfo) throws Exception {
WikiUserDetails userDetails = ServletUtil.currentUserDetails();
if (userDetails.hasRole(RoleImpl.ROLE_ANONYMOUS)) {
throw new WikiException(new WikiMessage("watchlist.error.loginrequired"));
}
String topicName = WikiUtil.getTopicFromRequest(request);
String virtualWiki = pageInfo.getVirtualWikiName();
Watchlist watchlist = ServletUtil.currentWatchlist(request, virtualWiki);
WikiUser user = ServletUtil.currentWikiUser();
WikiBase.getDataHandler().writeWatchlistEntry(watchlist, virtualWiki, topicName, user.getUserId());
String article = WikiUtil.extractTopicLink(topicName);
if (watchlist.containsTopic(topicName)) {
// added to watchlist
next.addObject("message", new WikiMessage("watchlist.caption.added", article));
} else {
// removed from watchlist
next.addObject("message", new WikiMessage("watchlist.caption.removed", article));
}
this.view(request, next, pageInfo);
}