protected ActionForward doPublishTopic(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
BBSTopicForm log = (BBSTopicForm) form;
super.validateClientId(request, log);
ActionMessages msgs = new ActionMessages();
UserBean loginUser = super.getLoginUser(request, response);
while (true) {
if (loginUser == null) {
msgs.add("topic", new ActionMessage("error.user_not_login"));
break;
}
if (loginUser.getStatus() != UserBean.STATUS_NORMAL) {
msgs.add("topic", new ActionMessage("error.user_not_available"));
break;
}
if (StringUtils.isEmpty(log.getTitle())) {
msgs.add("title", new ActionMessage("error.empty_not_allowed"));
break;
}
if (StringUtils.isEmpty(log.getContent())) {
msgs.add("content",
new ActionMessage("error.empty_not_allowed"));
break;
}
SiteBean site = super.getSiteByID(log.getSid());
if (site == null) {
msgs.add("topic", new ActionMessage("error.site_not_available"));
break;
}
//��������
if(isUserInBlackList(site, loginUser)){
msgs.add("topic", new ActionMessage("error.user_in_blacklist"));
break;
}
ForumBean forum = BBSForumDAO.getForumByID(log.getForum());
if (forum == null || forum.getSite().getId() != site.getId()
|| !forum.canCreateOrUpdateTopic(loginUser)) {
msgs.add("topic", new ActionMessage("error.forum_not_available",
new Integer(log.getForum())));
break;
}
// ����TopicBean
TopicBean topic = new TopicBean();
topic.setUser(loginUser);
topic.setUsername(loginUser.getName());
topic.setSite(site);
// �Է����ı����Լ������Զ����������ִʹ���
topic.setTitle(super.autoFiltrate(site, log.getTitle()));
String content = StringUtils.abbreviate(super.autoFiltrate(null,
log.getContent()), MAX_TOPIC_LENGTH);
topic.setContent(super.filterScriptAndStyle(content));
// FIXME: �����ؼ���̫���������ݿ�д��ʧ�ܵ�����
topic.setKeyword(DLOGSecurityManager.IllegalGlossary
.deleteIllegalWord(log.getSearchKey()));
topic.setClient(new ClientInfo(request, log.getClientType()));
topic.setCreateTime(new Date());
topic.setForum(forum);
topic.setStatus(TopicBean.STATUS_NORMAL);
if(site.getOwner().getId()==loginUser.getId()){
if (log.getTop() == 1)
topic.setTop(true);
if (log.getElite() == 1)
topic.setElite(true);
}
BBSTopicDAO.create(topic, (log.getBookmark() == 1));
// �����ϴ�����Ϣ
pickupUploadFileItems(request, response, loginUser.getId(), site, topic
.getId(), TopicBean.TYPE_BBS);
break;
}
if (!msgs.isEmpty()) {
saveMessages(request, msgs);
return mapping.findForward("new_topic");
}
return makeForward(mapping.findForward("forum"), log.getSid(), "fid",
log.getForum());