* @throws HibernateException
* @throws SQLException
*/
public static void create(DiaryBean journal, boolean add_bookmark){
try{
Session ssn = getSession();
beginTransaction();
if(journal.getStatus()==DiaryBean.STATUS_NORMAL){
journal.getCatalog().incArticleCount(1);
journal.getOwner().getCount().incArticleCount(1);
}
ssn.save(journal);
if(journal.getCatalog().getType()==CatalogBean.TYPE_GENERAL){
//ֻ�й��������е��ռDzſ������ñ�ǩ
List tags = journal.getKeywords();
if(tags!=null && tags.size()>0){
int tag_count = 0;
for(int i=0;i<tags.size();i++){
if(tag_count>=MAX_TAG_COUNT)
break;
String tag_name = (String)tags.get(i);
if(tag_name.getBytes().length > MAX_TAG_LENGTH)
continue;
TagBean tag = new TagBean();
tag.setSite(journal.getSite());
tag.setRefId(journal.getId());
tag.setRefType(DiaryBean.TYPE_DIARY);
tag.setName(tag_name);
ssn.save(tag);
tag_count ++;
}
}
}
if(add_bookmark){
BookmarkBean bmb = new BookmarkBean();
bmb.setOwner(journal.getOwner());
bmb.setSite(journal.getSite());
bmb.setCreateTime(new Date());
bmb.setParentId(journal.getId());
bmb.setParentType(_BeanBase.TYPE_DIARY);
bmb.setTitle(journal.getTitle());
journal.getOwner().getCount().incBookmarkCount(1);
ssn.save(bmb);
}
commit();
}catch(HibernateException e){
rollback();
throw e;