* @throws Exception
*/
protected ActionForward doPublishReply(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
BBSReplyForm rform = (BBSReplyForm) form;
super.validateClientId(request, rform);
ActionMessages msgs = new ActionMessages();
while (true) {
if (StringUtils.isEmpty(rform.getTitle())) {
msgs.add("title", new ActionMessage("error.empty_not_allowed"));
break;
}
if (StringUtils.isEmpty(rform.getContent())) {
msgs.add("content", new ActionMessage("error.empty_not_allowed"));
break;
}
UserBean loginUser = super.getLoginUser(request, response);
if (loginUser == null) {
msgs.add("reply", new ActionMessage("error.user_not_login"));
break;
}
if (loginUser.getStatus() != UserBean.STATUS_NORMAL) {
msgs.add("reply", new ActionMessage("error.user_not_available"));
break;
}
SiteBean site = getSiteByID(rform.getSid());
if (site == null) {
msgs.add("reply", new ActionMessage("error.site_not_available"));
break;
}
//��������
if(isUserInBlackList(site, loginUser)){
msgs.add("reply", new ActionMessage("error.user_in_blacklist"));
break;
}
TopicOutlineBean topic = BBSTopicDAO.getTopicOutlineByID(rform.getTid());
if (topic == null
|| topic.getStatus() != TopicBean.STATUS_NORMAL
|| topic.getSite().getId() != site.getId()
|| !topic.getForum().canCreateOrUpdateTopic(loginUser)) {
msgs.add("log", new ActionMessage("error.topic_not_available",
new Integer(rform.getTid())));
break;
}
// ����TopicBean
TopicReplyBean reply = new TopicReplyBean();
reply.setClient(new ClientInfo(request, rform.getClientType()));
String content = StringUtils.abbreviate(super.autoFiltrate(null,
rform.getContent()), MAX_REPLY_LENGTH);
reply.setContent(super.filterScriptAndStyle(content));
reply.setReplyTime(new Date());
reply.setSite(site);
reply.setTitle(super.autoFiltrate(site, rform.getTitle()));
reply.setTopic(topic);
reply.setUser(loginUser);
BBSReplyDAO.create(reply);
break;
}
if (!msgs.isEmpty()) {
saveMessages(request, msgs);
return mapping.findForward("new_reply");
}
StringBuffer ext = new StringBuffer();
ext.append("fid=");
ext.append(rform.getFid());
ext.append("&tid=");
ext.append(rform.getTid());
return makeForward(mapping.findForward("topic"), rform.getSid(), ext
.toString());
}