/** * 修改帖子 * * @param topic */ public static void update(TopicBean topic, boolean updateTags) { try { beginTransaction(); if (updateTags) { TagDAO.deleteTagByRefId(topic.getId(), DiaryBean.TYPE_BBS); List tags = topic.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(topic.getSite()); tag.setRefId(topic.getId()); tag.setRefType(DiaryBean.TYPE_BBS); tag.setName((String) tags.get(i)); topic.getTags().add(tag); tag_count++; } } } commit(); } catch (HibernateException e) { rollback(); throw e; } }