예제 #1
0
 private void update(HttpServletRequest request, ModelAndView next, WikiPageInfo pageInfo)
     throws Exception {
   WikiUser user = Utilities.currentUser();
   if (!user.hasRole(Role.ROLE_USER)) {
     throw new WikiException(new WikiMessage("watchlist.error.loginrequired"));
   }
   String topicName = Utilities.getTopicFromRequest(request);
   String virtualWiki = Utilities.getVirtualWikiFromURI(request);
   Watchlist watchlist = Utilities.currentWatchlist(request, virtualWiki);
   WikiBase.getDataHandler()
       .writeWatchlistEntry(watchlist, virtualWiki, topicName, user.getUserId(), null);
   String article = Utilities.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);
 }