01: // Copyright (C) 2003,2004,2005 by Object Mentor, Inc. All rights reserved.
02: // Released under the terms of the GNU General Public License version 2 or later.
03: package fitnesse.responders;
04:
05: import fitnesse.*;
06: import fitnesse.wiki.*;
07: import fitnesse.http.*;
08:
09: // TODO This class could just be "WikiPageResponder" (already exists)
10: public abstract class BasicWikiPageResponder extends BasicResponder {
11: public Response makeResponse(FitNesseContext context,
12: Request request) throws Exception {
13: WikiPage requestedPage = getRequestedPage(request, context);
14:
15: Response response;
16: if (requestedPage == null)
17: response = pageNotFoundResponse(context, request);
18: else
19: response = responseWith(contentFrom(requestedPage));
20:
21: return response;
22: }
23:
24: private WikiPage getRequestedPage(Request request,
25: FitNesseContext context) throws Exception {
26: WikiPagePath path = PathParser.parse(request.getResource());
27: WikiPage requestedPage = context.root.getPageCrawler().getPage(
28: context.root, path);
29: return requestedPage;
30: }
31:
32: protected abstract String contentFrom(WikiPage requestedPage)
33: throws Exception;
34: }
|