HttpServletRequest request, HttpServletResponse response)
throws Exception {
ActionMessages msgs = new ActionMessages();
DiaryForm log = (DiaryForm) form;
//super.validateClientId(request, log);
UserBean loginUser = super.getLoginUser(request, response);
while (true) {
if (loginUser == null) {
msgs.add("log", new ActionMessage("error.user_not_login"));
break;
}
if (loginUser.getStatus() != UserBean.STATUS_NORMAL) {
msgs.add("log", new ActionMessage("error.user_not_available"));
break;
}
SiteBean site = super.getSiteByID(log.getSid());
if (site == null) {
msgs.add("log", new ActionMessage("error.site_not_available"));
break;
}
boolean catalog_can_access = false;
CatalogBean catalog = null;
// վ�����Է���վ�ڵ��κη���
if (site.isOwner(loginUser)) {
catalog = CatalogDAO.getCatalogByID(log.getCatalogId());
if (catalog.getSite().getId() == site.getId())
catalog_can_access = true;
} else {
// �г��û��ڸ�վ��ɷ��ʵ��ռǷ���
List catalogs = CatalogDAO.listCatalogs(site, loginUser, true);
for (int i = 0; catalogs != null && i < catalogs.size(); i++) {
CatalogBean t_catalog = (CatalogBean) catalogs.get(i);
if (t_catalog.getId() == log.getCatalogId()
&& t_catalog.getSite().getId() == site.getId()) {
catalog = t_catalog;
catalog_can_access = true;
break;
}
}
}
//�û����������ռǷ��������
if(!catalog_can_access){
msgs.add("log", new ActionMessage("error.catalog_deny",
new Integer(log.getCatalogId())));
break;
}
// ����ռDZ����ֵ
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;
}
if (StringUtils.isEmpty(log.getWeather()))
log.setWeather(DEFAULT_WEATHER);
if (StringUtils.isEmpty(log.getAuthor()))
log.setAuthor(loginUser.getNickname());
if (StringUtils.isEmpty(log.getTags()))
log.setTags(null);
if (StringUtils.isEmpty(log.getAuthorUrl()))
log.setAuthorUrl(null);
if (StringUtils.isEmpty(log.getRefUrl()))
log.setRefUrl(null);
// ����JournalBean
DiaryBean journal = new DiaryBean();
journal.setOwner(loginUser);
journal.setSite(site);
journal.setAuthor(super.autoFiltrate(site,log.getAuthor()));
journal.setAuthorUrl(log.getAuthorUrl());
journal.setCatalog(catalog);
journal.setClient(new ClientInfo(request, log
.getClientType()));
journal.setContent(super.autoFiltrate(site,log.getContent()));
journal.setMoodLevel(log.getMoodLevel());
journal.setRefUrl(log.getRefUrl());
journal.setReplyNotify(log.getNotify());
journal.setStatus(DiaryBean.STATUS_DRAFT);
journal.setKeyword(super.autoFiltrate(site,log.getTags()));
journal.setTitle(super.autoFiltrate(site,log.getTitle()));
journal.setWeather(log.getWeather());
journal.setWriteTime(DateUtils.mergeDateTime(log.getWriteDate(), log.getWriteTime()).getTime());
Date curTime = new Date();
if(journal.getWriteTime()==null || journal.getWriteTime().after(curTime))
journal.setWriteTime(curTime);
DiaryDAO.create(journal, false);
//�����ϴ�����Ϣ
super.pickupUploadFileItems(request, response, loginUser
.getId(), site, journal.getId(), DiaryBean.TYPE_DIARY);
break;
}
if (!msgs.isEmpty()) {