01: /**
02: * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, version 2.1, dated February 1999.
03: *
04: * This program is free software; you can redistribute it and/or modify
05: * it under the terms of the latest version of the GNU Lesser General
06: * Public License as published by the Free Software Foundation;
07: *
08: * This program is distributed in the hope that it will be useful,
09: * but WITHOUT ANY WARRANTY; without even the implied warranty of
10: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11: * GNU Lesser General Public License for more details.
12: *
13: * You should have received a copy of the GNU Lesser General Public License
14: * along with this program (LICENSE.txt); if not, write to the Free Software
15: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16: */package org.jamwiki.servlets;
17:
18: import java.util.Collection;
19: import javax.servlet.http.HttpServletRequest;
20: import javax.servlet.http.HttpServletResponse;
21: import org.jamwiki.WikiBase;
22: import org.jamwiki.WikiMessage;
23: import org.jamwiki.utils.Pagination;
24: import org.jamwiki.utils.WikiLogger;
25: import org.jamwiki.utils.WikiUtil;
26: import org.springframework.web.servlet.ModelAndView;
27:
28: /**
29: * Used to generate a list of all edits made by a user.
30: */
31: public class ContributionsServlet extends JAMWikiServlet {
32:
33: private static final WikiLogger logger = WikiLogger
34: .getLogger(ContributionsServlet.class.getName());
35: protected static final String JSP_CONTRIBUTIONS = "contributions.jsp";
36:
37: /**
38: *
39: */
40: protected ModelAndView handleJAMWikiRequest(
41: HttpServletRequest request, HttpServletResponse response,
42: ModelAndView next, WikiPageInfo pageInfo) throws Exception {
43: this .contributions(request, next, pageInfo);
44: return next;
45: }
46:
47: /**
48: *
49: */
50: private void contributions(HttpServletRequest request,
51: ModelAndView next, WikiPageInfo pageInfo) throws Exception {
52: String virtualWiki = WikiUtil.getVirtualWikiFromURI(request);
53: String userString = WikiUtil.getParameterFromRequest(request,
54: "contributor", false);
55: Pagination pagination = ServletUtil.loadPagination(request,
56: next);
57: Collection contributions = WikiBase.getDataHandler()
58: .getUserContributions(virtualWiki, userString,
59: pagination, true);
60: next.addObject("contributions", contributions);
61: next.addObject("numContributions", new Integer(contributions
62: .size()));
63: next.addObject("contributor", userString);
64: pageInfo.setPageTitle(new WikiMessage("contributions.title",
65: userString));
66: pageInfo.setContentJsp(JSP_CONTRIBUTIONS);
67: pageInfo.setSpecial(true);
68: }
69: }
|