1 25 26 package net.killingar.actions.wiki; 27 28 import com.portalwizard.silo.DocumentVersionMgr; 29 import com.portalwizard.silo.IDocumentVersionMgr; 30 import com.portalwizard.silo.IVersionMgr; 31 import com.portalwizard.silo.VersionMgr; 32 import net.killingar.actions.ActionSupport; 33 34 import java.util.Properties ; 35 36 public class WikiAction extends ActionSupport 37 { 38 long start; 39 40 String wiki; 41 String context; 42 static String defaultWiki; 43 static String defaultContext; 44 public IVersionMgr vm; 45 public IDocumentVersionMgr dvm; 46 47 public String getWiki() { return wiki; } 48 public void setWiki(String wiki) { this.wiki = wiki; } 49 public String getContext() { return context == null? getDefaultContext() : context; } 50 public void setContext(String in) { context = in; } 51 public String getTitle() { return wiki; } 52 53 public long getExecutionTime() { return System.currentTimeMillis()-start; } 54 55 public String getDefaultWiki() 56 { 57 if (defaultWiki == null) 58 { 59 Properties p = net.killingar.Utils.getProperties(); 60 defaultWiki = p.getProperty("net.killingar.actions.wiki.defaultDocument"); 61 defaultContext = p.getProperty("net.killingar.actions.wiki.defaultContext"); 62 } 63 64 if (defaultWiki == null) 65 throw new RuntimeException ("no default wiki set"); 66 67 if (defaultContext == null) 68 throw new RuntimeException ("no default context set"); 69 70 return defaultWiki; 71 } 72 73 public String getDefaultContext() 74 { 75 getDefaultWiki(); return defaultContext; 77 } 78 79 public WikiAction() 80 { 81 wiki = defaultWiki; 82 context = defaultContext; 83 } 84 85 public String execute() throws Exception 86 { 87 getDefaultWiki(); 88 89 start = System.currentTimeMillis(); 90 91 vm = VersionMgr.getInstance(); 92 dvm = DocumentVersionMgr.getInstance(); 93 94 if (getWiki() == null || "".equals(getWiki())) 95 setWiki(defaultWiki); 96 97 if (getContext() == null || "".equals(getContext())) 98 setContext(defaultContext); 99 100 if (wiki != null) 101 wiki = wiki.trim().toLowerCase(); 102 103 return super.execute(); 104 } 105 } | Popular Tags |