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.updates;
04:
05: import java.util.*;
06: import fitnesse.wiki.*;
07: import fitnesse.components.*;
08:
09: public abstract class PageTraversingUpdate implements
10: FitNesseTraversalListener, Update {
11: private Properties properties;
12:
13: private WikiPage root;
14:
15: public PageTraversingUpdate(Updater updater) {
16: properties = updater.getProperties();
17: root = updater.getRoot();
18: }
19:
20: public void doUpdate() throws Exception {
21: root.getPageCrawler().traverse(root, this );
22: properties.setProperty(getName(), "applied");
23: }
24:
25: public abstract void processPage(WikiPage currentPage)
26: throws Exception;
27:
28: public boolean shouldBeApplied() throws Exception {
29: boolean usesFileSystem = root instanceof FileSystemPage;
30: boolean hasBeenApplied = properties.getProperty(getName()) != null;
31:
32: return usesFileSystem && !hasBeenApplied;
33: }
34:
35: public String getSearchPattern() throws Exception {
36: return ".*";
37: }
38: }
|