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: import fitnesse.wikitext.widgets.*;
07: import fitnesse.wikitext.*;
08:
09: public class VirtualWikiDeprecationUpdate extends PageTraversingUpdate {
10: public static WidgetBuilder virtualWidgetBuilder = new WidgetBuilder(
11: new Class[] { VirtualWikiWidget.class });
12:
13: public VirtualWikiDeprecationUpdate(Updater updater) {
14: super (updater);
15: }
16:
17: public String getMessage() {
18: return "Updating pages with !virtualwiki widgets";
19: }
20:
21: public String getName() {
22: return "VirtualWikiDeprecationUpdate";
23: }
24:
25: public void processPage(WikiPage page) throws Exception {
26: PageData data = page.getData();
27: WidgetRoot widgetRoot = new WidgetRoot(data.getContent(), page,
28: virtualWidgetBuilder);
29: while (widgetRoot.hasNextChild()) {
30: WikiWidget widget = widgetRoot.nextChild();
31: if (widget instanceof VirtualWikiWidget) {
32: VirtualWikiWidget vWidget = (VirtualWikiWidget) widget;
33: String url = vWidget.getRemoteUrl();
34: data.setAttribute(
35: WikiPageProperties.VIRTUAL_WIKI_ATTRIBUTE, url);
36: page.commit(data);
37: break;
38: }
39: }
40: }
41: }
|