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: private WikiPage root;
13:
14: public PageTraversingUpdate(Updater updater) {
15: properties = updater.getProperties();
16: root = updater.getRoot();
17: }
18:
19: public void doUpdate() throws Exception {
20: root.getPageCrawler().traverse(root, this );
21: properties.setProperty(getName(), "applied");
22: }
23:
24: public abstract void processPage(WikiPage currentPage)
25: throws Exception;
26:
27: public boolean shouldBeApplied() throws Exception {
28: boolean usesFileSystem = root instanceof FileSystemPage;
29: boolean hasBeenApplied = properties.getProperty(getName()) != null;
30:
31: return usesFileSystem && !hasBeenApplied;
32: }
33:
34: public String getSearchPattern() throws Exception {
35: return ".*";
36: }
37: }
|