1 25 26 package net.killingar.actions.wiki; 27 28 import com.portalwizard.silo.Version; 29 import com.portalwizard.util.ReadException; 30 31 public class Edit extends WikiAction 32 { 33 String mode; 34 String submit; 35 36 String content; 37 String title; 38 String author = "none"; 39 String mimetype = "text/wiki"; 40 41 public void setSubmit(String submit) { this.submit = submit; } 42 public void setMode(String mode) { this.mode = mode; } 43 public void setContent(String content){ this.content = content; } 44 public void setMimetype(String mimetype){ this.mimetype = mimetype; } 45 public void setAuthor(String author) { this.author = author; } 46 public void setTitle(String in) { title = in; } 47 48 public String getSubmit() { return submit; } 49 public String getMode() { return mode; } 50 public String getContent() { return content; } 51 public String getMimetype() { return mimetype; } 52 public String getAuthor() { return author; } 53 public String getTitle() { return title; } 54 55 protected String doExecute() throws Exception 56 { 57 if (getSubmit() != null) 58 { 59 Version ov = null; 61 62 try { ov = vm.get(getContext(), getWiki()); } catch (ReadException e){} 63 64 if (ov != null && ov.getContent().equals(getContent())) 65 { 66 addErrorMessage("document unaltered"); 67 return INPUT; 68 } 69 70 Version nv = new Version(getContext(), getWiki()); 71 nv.setContent(getContent()); 72 nv.setMimetype(getMimetype()); 73 nv.setAuthor(getAuthor()); 74 if (getTitle() != null && !"".equals(getTitle())) 75 nv.setTitle(getTitle()); 76 else 77 nv.setTitle(getWiki()); 78 vm.store(nv); 79 80 return SUCCESS; 81 } 82 else 83 { 84 if (getMode() == null || !getMode().equals("preview")) 85 { 86 try 87 { 88 Version v = vm.get(getContext(), getWiki()); 89 content = v.getContent(); 90 author = v.getAuthor(); 91 mimetype = v.getMimetype(); 92 title = v.getTitle(); 93 } 94 catch (Exception e){} 95 } 96 } 97 98 return INPUT; 99 } 100 } 101 | Popular Tags |