protected void diff(HttpServletRequest request, ModelAndView next, WikiPageInfo pageInfo) throws Exception { String topicName = Utilities.getTopicFromRequest(request); String diffType = request.getParameter("type"); if (diffType != null && diffType.equals("arbitrary")) { // FIXME - used with history.jsp, this is ugly int firstVersion = -1; int secondVersion = -1; Enumeration e = request.getParameterNames(); while (e.hasMoreElements()) { String name = (String) e.nextElement(); if (name.startsWith("diff:")) { int version = Integer.parseInt(name.substring(name.indexOf(':') + 1)); if (firstVersion >= 0) { secondVersion = version; } else { firstVersion = version; } } } if (firstVersion == -1 || secondVersion == -1) { next.addObject("badinput", "true"); } else { Collection diffs = WikiBase.getDataHandler() .diff( topicName, Math.max(firstVersion, secondVersion), Math.min(firstVersion, secondVersion)); next.addObject("diffs", diffs); } } else { int topicVersionId1 = 0; if (StringUtils.hasText(request.getParameter("version1"))) { topicVersionId1 = new Integer(request.getParameter("version1")).intValue(); } int topicVersionId2 = 0; if (StringUtils.hasText(request.getParameter("version2"))) { topicVersionId2 = new Integer(request.getParameter("version2")).intValue(); } Collection diffs = WikiBase.getDataHandler().diff(topicName, topicVersionId1, topicVersionId2); next.addObject("diffs", diffs); } pageInfo.setPageTitle(new WikiMessage("diff.title", topicName)); pageInfo.setTopicName(topicName); pageInfo.setContentJsp(JSP_DIFF); }
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); }