1 25 26 package net.killingar.forum.actions.area; 27 28 import net.killingar.forum.internal.Area; 29 import net.killingar.forum.internal.Message; 30 import webwork.action.ActionContext; 31 32 public class EditMessage extends ActionAreaSupport 33 { 34 public long messageID = -1; 36 public long replyMessageID = -1; 37 public String subject; 38 public String body; 39 public String command = ""; 40 public boolean bodyEmpty; 41 public MessageData preview; 42 public String postMode = "html"; 43 public Area area; 44 public long time = View.NOT_SET; 45 46 protected AreaCustomizer areaCustomizer; 47 48 50 public void setMessageID(long l) {messageID = l;} 52 public void setBody(String s) {body = s;} 53 public void setCommand(String s) {command = s;} 54 public void setSubject(String s) {subject = s;} 55 public void setPostMode(String s) {postMode = s;} 56 public void setTime(long in) {time = in;} 57 58 public MessageData getPreview() {return preview;} 60 public String getSubject() {return subject;} 61 public String getBody() {return body;} 62 public String getPostMode() {return postMode;} 63 public Area getArea() {return area;} 64 public long getTime() {return time;} 65 public long getAreaID() {return area.getId();} 66 public String getActionName() {return "area.EditMessage";} 67 public long getMessageID() {return messageID;} 68 public String getMessageView() {return areaCustomizer.getMessageView();} 69 public String getEditMessageView() {return areaCustomizer.getEditMessageView();} 70 public long getReplyMessageID() {return replyMessageID;} 71 72 protected String doExecute() 74 { 75 try 76 { 77 Message message = areamgr.getMessage(messageID); 78 if (message == null) 79 { 80 addErrorMessage("invalid message ID specified"); 81 return ERROR; 82 } 83 84 replyMessageID = message.getParentID(); 85 86 area = areamgr.getArea(message.areaID); 87 88 areaCustomizer = AbstractAreaCustomizer.getAreaCustomizer(area); 89 90 if (body == null) 91 body = message.body; 92 if (subject == null) 93 subject = message.subject; 94 95 if (postMode.equals("text")) 96 { 97 body = net.killingar.forum.internal.Utils.disableHTML(body); 98 subject = net.killingar.forum.internal.Utils.disableHTML(subject); 99 } 100 101 body = body.trim(); 102 subject = subject.trim(); 103 104 if (command.equals("post")) 105 { 106 if (!areaCustomizer.editMessagePreProccess(this)) 107 { 108 ActionContext.getValueStack().pushValue(areaCustomizer); 109 return INPUT; 110 } 111 112 message.body = body; 113 message.subject = subject; 114 115 if (subject.equals("")) 116 { 117 addErrorMessage("you must specify a summary"); 118 return INPUT; 119 } 120 121 areamgr.changeMessage(message); 122 123 return SUCCESS; 124 } 125 else 126 { 127 areaCustomizer.previewMessage(this); 128 ActionContext.getValueStack().pushValue(areaCustomizer); 129 130 message.body = body; 131 message.subject = subject; 132 preview = new MessageData(manager, message); 133 } 134 135 137 } 139 catch (Exception exception) 140 { 141 exception.printStackTrace(); 142 addErrorMessage("error getting area manager or area (" + exception.toString() + ")"); 143 return ERROR; 144 } 145 return INPUT; 146 } 147 148 protected void doValidation() 149 { 150 if (messageID == -1) 151 addErrorMessage("no message id specified"); 152 } 153 } | Popular Tags |