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.search;
04:
05: import fitnesse.html.*;
06: import fitnesse.components.SearchObserver;
07: import fitnesse.wiki.*;
08: import fitnesse.responders.*;
09: import fitnesse.authentication.*;
10:
11: public abstract class ResultResponder extends ChunkingResponder
12: implements SearchObserver, SecureResponder {
13: private int hits = 0;
14:
15: protected PageCrawler getPageCrawler() {
16: return root.getPageCrawler();
17: }
18:
19: protected void doSending() throws Exception {
20: HtmlPage page = context.htmlPageFactory.newPage();
21: String renderedPath = getRenderedPath();
22: page.title.use(getTitle() + ": " + renderedPath);
23: page.header.use(HtmlUtil.makeBreadCrumbsWithPageType(
24: renderedPath, getTitle()));
25: page.main.use(HtmlPage.BreakPoint);
26: page.divide();
27:
28: response.add(page.preDivision + "<ul>");
29: startSearching();
30: response.add("</ul>\n" + getPageFooterInfo(hits) + "\n"
31: + page.postDivision);
32: response.closeAll();
33: }
34:
35: public void hit(WikiPage page) throws Exception {
36: hits++;
37: String fullPathName = PathParser.render(getPageCrawler()
38: .getFullPath(page));
39: response.add("<li><a href=\"" + fullPathName + "\">"
40: + fullPathName + "</a>\n");
41: }
42:
43: protected abstract String getTitle() throws Exception;
44:
45: protected abstract String getPageFooterInfo(int hits)
46: throws Exception;
47:
48: protected abstract void startSearching() throws Exception;
49:
50: public SecureOperation getSecureOperation() {
51: return new SecureReadOperation();
52: }
53: }
|