//super.validateClientId(request, diaryForm);
UserBean loginUser = super.getLoginUser(request, response);
if (loginUser == null) {
msgs.add("editlog", new ActionMessage("error.user_not_login"));
} else {
DiaryBean diary = DiaryDAO.getDiaryByID(diaryForm.getId());
if (diary == null) {
msgs
.add("editlog", new ActionMessage(
"error.diary_not_exists"));
} else if (!DiaryDAO.canUserEditDiary(loginUser, diary)) {
msgs.add("editlog", new ActionMessage("error.access_deny"));
} else {
boolean catalog_can_access = false;
if (diary.getCatalog().getId() != diaryForm.getCatalogId()) {
SiteBean site = diary.getSite();
CatalogBean catalog = null;
// վ�����Է���վ�ڵ��κη���
if (site.isOwner(loginUser)) {
catalog = CatalogDAO.getCatalogByID(diaryForm
.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() == diaryForm.getCatalogId()) {
catalog = t_catalog;
catalog_can_access = true;
break;
}
}
}
// �����ռ���������
if (catalog != null) {
diary.getCatalog().incArticleCount(-1);
diary.setCatalog(catalog);
catalog.incArticleCount(1);
}
} else
catalog_can_access = true;
if (catalog_can_access) {
SiteBean site = diary.getSite();
// �����ռ�
boolean updateTags = false;
if (!StringUtils.equals(diary.getKeyword(), diaryForm
.getTags())) {
updateTags = true;
if (StringUtils.isNotEmpty(diaryForm.getTags()))
diary.setKeyword(super.autoFiltrate(site, diaryForm.getTags()));
else {
diary.setKeyword(null);
}
}
diary.setTitle(super.autoFiltrate(site,diaryForm.getTitle()));
if (!StringUtils.equals(diaryForm.getContent(), diary.getContent())) {
diary.setContent(super.autoFiltrate(site,diaryForm.getContent()));
diary.setSize(diaryForm.getContent().getBytes().length);
//�����ı�����(Winter Lau, 2006-5-12)
if(diary.getStatus() == DiaryBean.STATUS_NORMAL)
TextCacheManager.updateTextContent(DiaryBean.TYPE_DIARY, diary.getId(), diary.getContent());
}
diary.setAuthor(diaryForm.getAuthor());
if (StringUtils.isNotEmpty(diaryForm.getAuthorUrl()))
diary.setAuthorUrl(diaryForm.getAuthorUrl());
diary.setMoodLevel(diaryForm.getMoodLevel());
if (StringUtils.isNotEmpty(diaryForm.getRefUrl()))
diary.setRefUrl(diaryForm.getRefUrl());
diary.setReplyNotify(diaryForm.getNotify());
diary.setWeather(diaryForm.getWeather());
diary.setModifyTime(new Date());
if (diaryForm.getBgSound() != -1) {
// ��鱳�������Ƿ���Ч
MusicBean song = MusicDAO.getMusicByID(diaryForm.getBgSound());
if (song != null
&& song.getSite().getId() == diary.getSite().getId()) {
diary.setBgSound(song);
}
}
try {
// �����ϴ�����Ϣ
pickupUploadFileItems(request, response, loginUser
.getId(), diary.getSite(), diary.getId(), DiaryBean.TYPE_DIARY);
DiaryDAO.update(diary, updateTags);
} catch (Exception e) {
context().log("update diary failed.", e);
msgs.add("editlog", new ActionMessage("error.database",
e.getMessage()));