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.components;
04:
05: import java.util.Collections;
06: import java.util.List;
07:
08: import fitnesse.wiki.PageData;
09:
10: /**
11: * WIthin STIQ, we don't want to use RecentChanges so make this do nothing.
12: * @author jbellegarde
13: *
14: */
15: public class RecentChanges {
16: // private static final String RECENT_CHANGES = "RecentChanges";
17: //
18: // private static SimpleDateFormat makeDateFormat() {
19: // // SimpleDateFormat is not thread safe, so we need to create each
20: // // instance independently.
21: // return new SimpleDateFormat("kk:mm:ss EEE, MMM dd, yyyy");
22: // }
23:
24: public static void updateRecentChanges(PageData pageData)
25: throws Exception {
26: //createRecentChangesIfNecessary(pageData);
27: //addCurrentPageToRecentChanges(pageData);
28: }
29:
30: public static List getRecentChangesLines(PageData recentChangesdata)
31: throws Exception {
32: return Collections.EMPTY_LIST;
33: // String content = recentChangesdata.getContent();
34: // BufferedReader reader = new BufferedReader(new StringReader(content));
35: // List lines = new ArrayList();
36: // String line = null;
37: // while ((line = reader.readLine()) != null)
38: // lines.add(line);
39: // return lines;
40: }
41:
42: // private static void addCurrentPageToRecentChanges(PageData data) throws Exception {
43: // WikiPage recentChanges = data.getWikiPage().getPageCrawler().getRoot(data.getWikiPage())
44: // .getChildPage(RECENT_CHANGES);
45: // String resource = resource(data);
46: // PageData recentChangesdata = recentChanges.getData();
47: // List lines = getRecentChangesLines(recentChangesdata);
48: // removeDuplicate(lines, resource);
49: // lines.add(0, makeRecentChangesLine(data));
50: // trimExtraLines(lines);
51: // String content = convertLinesToWikiText(lines);
52: // recentChangesdata.setContent(content);
53: // recentChanges.commit(recentChangesdata);
54: // }
55: //
56: // private static String resource(PageData data) throws Exception {
57: // WikiPagePath fullPath = data.getWikiPage().getPageCrawler().getFullPath(data.getWikiPage());
58: // String resource = PathParser.render(fullPath);
59: // return resource;
60: // }
61: //
62: // private static void createRecentChangesIfNecessary(PageData data) throws Exception {
63: // PageCrawler crawler = data.getWikiPage().getPageCrawler();
64: // WikiPage root = crawler.getRoot(data.getWikiPage());
65: // if (!root.hasChildPage(RECENT_CHANGES))
66: // crawler.addPage(root, PathParser.parse(RECENT_CHANGES), "");
67: // }
68: //
69: // private static String makeRecentChangesLine(PageData data) throws Exception {
70: // String user = data.getAttribute(WikiPage.LAST_MODIFYING_USER);
71: // if (user == null)
72: // user = "";
73: // return "|" + resource(data) + "|" + user + "|" + makeDateFormat().format(new Date()) + "|";
74: // }
75: //
76: // private static void removeDuplicate(List lines, String resource) {
77: // for (ListIterator iterator = lines.listIterator(); iterator.hasNext();) {
78: // String s = (String) iterator.next();
79: // if (s.startsWith("|" + resource + "|"))
80: // iterator.remove();
81: // }
82: // }
83: //
84: // private static String convertLinesToWikiText(List lines) {
85: // StringBuffer buffer = new StringBuffer();
86: // for (Iterator iterator = lines.iterator(); iterator.hasNext();) {
87: // String s = (String) iterator.next();
88: // buffer.append(s).append("\n");
89: // }
90: // return buffer.toString();
91: // }
92: //
93: // private static void trimExtraLines(List lines) {
94: // while (lines.size() > 100)
95: // lines.remove(100);
96: // }
97: }
|