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 javax.servlet.http.HttpServletRequest;
19: import javax.servlet.http.HttpServletResponse;
20: import org.jamwiki.WikiBase;
21: import org.jamwiki.WikiMessage;
22: import org.jamwiki.parser.ParserInput;
23: import org.jamwiki.parser.ParserUtil;
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 an index of all Special: pages on the wiki.
30: */
31: public class SpecialPagesServlet extends JAMWikiServlet {
32:
33: /** Logger for this class and subclasses. */
34: private static final WikiLogger logger = WikiLogger
35: .getLogger(SpecialPagesServlet.class.getName());
36: protected static final String JSP_SPECIAL_PAGES = "all-special-pages.jsp";
37:
38: /**
39: * This method handles the request after its parent class receives control. It gets the topic's name and the
40: * virtual wiki name from the uri, loads the topic and returns a view to the end user.
41: *
42: * @param request - Standard HttpServletRequest object.
43: * @param response - Standard HttpServletResponse object.
44: * @return A <code>ModelAndView</code> object to be handled by the rest of the Spring framework.
45: */
46: protected ModelAndView handleJAMWikiRequest(
47: HttpServletRequest request, HttpServletResponse response,
48: ModelAndView next, WikiPageInfo pageInfo) throws Exception {
49: specialPages(request, next, pageInfo);
50: return next;
51: }
52:
53: /**
54: *
55: */
56: private void specialPages(HttpServletRequest request,
57: ModelAndView next, WikiPageInfo pageInfo) throws Exception {
58: String virtualWiki = WikiUtil.getVirtualWikiFromURI(request);
59: String contents = WikiUtil.readSpecialPage(request.getLocale(),
60: WikiBase.SPECIAL_PAGE_SPECIAL_PAGES);
61: ParserInput parserInput = new ParserInput();
62: parserInput.setContext(request.getContextPath());
63: parserInput.setLocale(request.getLocale());
64: parserInput.setAllowSectionEdit(false);
65: // FIXME - hard coding
66: parserInput.setTopicName("Special:Specialpages");
67: parserInput.setVirtualWiki(virtualWiki);
68: String content = ParserUtil.parse(parserInput, null, contents);
69: next.addObject("pageContent", content);
70: pageInfo.setPageTitle(new WikiMessage("specialpages.title"));
71: pageInfo.setContentJsp(JSP_SPECIAL_PAGES);
72: pageInfo.setSpecial(true);
73: }
74: }
|