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 fitnesse.wiki.*;
06:
07: public class AttributeAdderUpdate extends PageTraversingUpdate {
08: private String attributeName;
09:
10: public AttributeAdderUpdate(Updater updater, String attributeName) {
11: super (updater);
12: this .attributeName = attributeName;
13: }
14:
15: public String getName() {
16: return attributeName + "AttributeUpdate";
17: }
18:
19: public String getMessage() {
20: return "Adding '" + attributeName + "' attribute to all pages";
21: }
22:
23: public void processPage(WikiPage page) throws Exception {
24: try {
25: PageData data = page.getData();
26: data.setAttribute(attributeName, "true");
27: page.commit(data);
28: } catch (Exception e) {
29: String fullPathName = PathParser.render(page
30: .getPageCrawler().getFullPath(page));
31: System.out.println("Failed to add attribute "
32: + attributeName + " to " + fullPathName);
33: throw e;
34: }
35: }
36:
37: public String getSearchPattern() {
38: return ".*";
39: }
40: }
|