document.java
来自「cwbbs 云网论坛源码」· Java 代码 · 共 1,961 行 · 第 1/5 页
JAVA
1,961 行
} return result; } public Vector list(String sql, int count) { ResultSet rs = null; Vector result = new Vector(); Conn conn = new Conn(connname); try { conn.setMaxRows(count); rs = conn.executeQuery(sql); if (rs == null) { return result; } else { rs.setFetchSize(count); while (rs.next()) { int id = rs.getInt(1); Document doc = getDocument(id); result.addElement(doc); } } } catch (SQLException e) { logger.error("list: " + e.getMessage()); } finally { if (conn != null) { conn.close(); conn = null; } } return result; } public String RenderContent(HttpServletRequest request, int pageNum) { DocContent dc = new DocContent(); dc = dc.getDocContent(id, pageNum); if (dc != null) { Leaf lf = new Leaf(); lf = lf.getLeaf(class1); String pluginCode = lf.getPluginCode(); if (pluginCode != null && pluginCode.equals(PluginUnit.DEFAULT)) return dc.getContent(); else { PluginMgr pm = new PluginMgr(); PluginUnit pu = pm.getPluginUnit(pluginCode); IPluginRender ipr = pu.getUI(request).getRender(); return ipr.RenderContent(request, dc); } } else return null; } public DocContent getDocContent(int pageNum) { DocContent dc = new DocContent(); return dc.getDocContent(id, pageNum); } public boolean isCanComment() { return canComment; } public String getDirCode() { return class1; } public synchronized boolean UpdateWithoutFile(ServletContext application, CMSMultiFileUploadBean mfu) throws ErrMsgException { String dir_code = StrUtil.getNullStr(mfu.getFieldValue("dir_code")); author = StrUtil.getNullString(mfu.getFieldValue("author")); title = StrUtil.getNullString(mfu.getFieldValue("title")); String strCanComment = StrUtil.getNullStr(mfu.getFieldValue( "canComment")); if (strCanComment.equals("")) canComment = false; else if (strCanComment.equals("1")) canComment = true; String strIsHome = StrUtil.getNullString(mfu.getFieldValue("isHome")); if (strIsHome.equals("")) isHome = false; else if (strIsHome.equals("false")) isHome = false; else if (strIsHome.equals("true")) isHome = true; else isHome = false; String strexamine = mfu.getFieldValue("examine"); int oldexamine = examine; examine = Integer.parseInt(strexamine); String strisnew = StrUtil.getNullStr(mfu.getFieldValue("isNew")); if (StrUtil.isNumeric(strisnew)) isNew = Integer.parseInt(strisnew); else isNew = 0; keywords = StrUtil.getNullStr(mfu.getFieldValue("keywords")); String strisRelateShow = StrUtil.getNullStr(mfu.getFieldValue( "isRelateShow")); int intisRelateShow = 0; if (StrUtil.isNumeric(strisRelateShow)) { intisRelateShow = Integer.parseInt(strisRelateShow); if (intisRelateShow == 1) isRelateShow = true; } flowTypeCode = StrUtil.getNullString(mfu.getFieldValue("flowTypeCode")); color = StrUtil.getNullStr(mfu.getFieldValue("color")); bold = StrUtil.getNullStr(mfu.getFieldValue("isBold")).equals("true"); expireDate = DateUtil.parse(mfu.getFieldValue("expireDate"), "yyyy-MM-dd"); source = StrUtil.getNullStr(mfu.getFieldValue("source")); try { pageTemplateId = Integer.parseInt(mfu.getFieldValue( "pageTemplateId")); } catch (Exception e) { pageTemplateId = -1; } String docType = StrUtil.getNullStr(mfu.getFieldValue("docType")); if (!docType.equals("" + TYPE_VOTE)) { type = Integer.parseInt(docType); } if (!dir_code.equals(class1)) { Leaf lf = new Leaf(); lf = lf.getLeaf(dir_code); parentCode = lf.getParentCode(); } String subjects = StrUtil.getNullStr(mfu.getFieldValue("subjects")); String strPageType = StrUtil.getNullStr(mfu.getFieldValue("pageType")); pageType = StrUtil.toInt(strPageType, PAGE_TYPE_MANUAL); createDate = DateUtil.parse(mfu.getFieldValue("createDate"), "yyyy-MM-dd HH:mm:ss"); int oldlevel = level; level = StrUtil.toInt(StrUtil.getNullStr(mfu.getFieldValue("level")), 0); Conn conn = new Conn(connname); PreparedStatement pstmt = null; try { pstmt = conn.prepareStatement(SAVE_DOCUMENT); pstmt.setString(1, title); pstmt.setInt(2, canComment ? 1 : 0); pstmt.setBoolean(3, isHome); pstmt.setInt(4, examine); pstmt.setString(5, keywords); pstmt.setInt(6, intisRelateShow); pstmt.setInt(7, templateId); pstmt.setString(8, dir_code); pstmt.setInt(9, isNew); pstmt.setString(10, author); pstmt.setString(11, flowTypeCode); pstmt.setString(12, "" + System.currentTimeMillis()); pstmt.setString(13, parentCode); pstmt.setString(14, color); pstmt.setInt(15, bold ? 1 : 0); pstmt.setString(16, DateUtil.toLongString(expireDate)); pstmt.setString(17, source); pstmt.setInt(18, type); pstmt.setInt(19, pageTemplateId); pstmt.setInt(20, pageType); pstmt.setInt(21, level); pstmt.setInt(22, pageNo); pstmt.setString(23, DateUtil.toLongString(createDate)); pstmt.setInt(24, id); conn.executePreUpdate(); if (!subjects.equals("")) { String[] subjectAry = StrUtil.split(subjects, ","); SubjectListDb sld = new SubjectListDb(); sld.setDocBelongtoSubjects(new JdbcTemplate(), subjectAry, id); } DocCacheMgr dcm = new DocCacheMgr(); if (oldexamine == examine && oldlevel == level) { dcm.refreshUpdate(id); } else { dcm.refreshUpdate(id, class1, parentCode); SubjectListCache slc = new SubjectListCache(new SubjectListDb()); if (!subjects.equals("")) { String[] subjectAry = StrUtil.split(subjects, ","); int len = subjectAry.length; for (int i = 0; i < len; i++) { slc.refreshList(subjectAry[i]); } } } if (!dir_code.equals(class1)) { dcm.refreshChangeDirCode(class1, dir_code); class1 = dir_code; } DocContent dc = new DocContent(); dc = dc.getDocContent(id, 1); dc.saveWithoutFile(application, mfu); } catch (SQLException e) { logger.error(e.getMessage()); throw new ErrMsgException("DB operate error."); } catch (ResKeyException e) { throw new ErrMsgException(e.getMessage()); } finally { if (conn != null) { conn.close(); conn = null; } } return true; } public void clearDustbin() throws ErrMsgException { String sql = "select id from document where examine=?"; Conn conn = new Conn(connname); PreparedStatement pstmt = null; try { pstmt = conn.prepareStatement(sql); pstmt.setInt(1, EXAMINE_DUSTBIN); ResultSet rs = conn.executePreQuery(); while (rs.next()) { Document doc = getDocument(rs.getInt(1)); doc.del(); DocCacheMgr dcm = new DocCacheMgr(); dcm.refreshUpdate(doc.getId(), doc.getDirCode(), doc.getParentCode()); } } catch (SQLException e) { logger.error(e.getMessage()); throw new ErrMsgException("Err db."); } finally { if (conn != null) { conn.close(); conn = null; } } } public boolean UpdateLevel() throws ErrMsgException { String sql = "update document set doc_level=? where id=?"; Conn conn = new Conn(connname); PreparedStatement pstmt = null; try { pstmt = conn.prepareStatement(sql); pstmt.setInt(1, level); pstmt.setInt(2, id); conn.executePreUpdate(); DocCacheMgr dcm = new DocCacheMgr(); dcm.refreshUpdate(id, class1, parentCode); } catch (SQLException e) { logger.error(e.getMessage()); throw new ErrMsgException("Err db."); } finally { if (conn != null) { conn.close(); conn = null; } } return true; } public boolean UpdateExamine(int examine) throws ErrMsgException { String sql = "update document set examine=? where id=?"; Conn conn = new Conn(connname); PreparedStatement pstmt = null; try { pstmt = conn.prepareStatement(sql); pstmt.setInt(1, examine); pstmt.setInt(2, id); conn.executePreUpdate(); DocCacheMgr dcm = new DocCacheMgr(); dcm.refreshUpdate(id, class1, parentCode); } catch (SQLException e) { logger.error("UpdateExamine:" + e.getMessage()); throw new ErrMsgException("Err db."); } finally { if (conn != null) { conn.close(); conn = null; } } return true; } public boolean UpdateIsHome(boolean isHome) throws ErrMsgException { String sql = "update document set isHome=? where id=?"; Conn conn = new Conn(connname); PreparedStatement pstmt = null; try { pstmt = conn.prepareStatement(sql); pstmt.setInt(1, isHome ? 1 : 0); pstmt.setInt(2, id); conn.executePreUpdate(); DocCacheMgr dcm = new DocCacheMgr(); dcm.refreshUpdate(id, class1, parentCode); } catch (SQLException e) { logger.error(e.getMessage()); throw new ErrMsgException("Err db."); } finally { if (conn != null) { conn.close(); conn = null; } } return true; } public boolean increaseHit() throws ErrMsgException { hit++; Conn conn = new Conn(connname); PreparedStatement pstmt = null; try { pstmt = conn.prepareStatement(SAVE_HIT); pstmt.setInt(1, hit); pstmt.setInt(2, id); conn.executePreUpdate(); DocCacheMgr dcm = new DocCacheMgr(); dcm.refreshUpdate(id); } catch (SQLException e) { logger.error(e.getMessage()); throw new ErrMsgException("DB operate error."); } finally { if (conn != null) { conn.close(); conn = null; } } return true; } public synchronized boolean UpdateSummaryWithoutFile(ServletContext application, CMSMultiFileUploadBean mfu) throws ResKeyException { Conn conn = new Conn(connname); boolean re = true; try { String idstr = StrUtil.getNullString(mfu.getFieldValue("id")); if (!StrUtil.isNumeric(idstr)) throw new ResKeyException(SkinUtil.ERR_ID); id = Integer.parseInt(idstr); summary = StrUtil.getNullString(mfu.getFieldValue("htmlcode")); PreparedStatement pstmt = null; pstmt = conn.prepareStatement(SAVE_SUMMARY); pstmt.setString(1, summary); pstmt.setInt(2, id); re = conn.executePreUpdate() == 1 ? true : false; DocCacheMgr dcm = new DocCacheMgr(); dcm.refreshUpdate(id); } catch (SQLException e) { re = false; logger.error(e.getMessage()); } finally { if (conn != null) { conn.close(); conn = null; } } return re; } public synchronized boolean UpdateSummary(ServletContext application, CMSMultiFileUploadBean mfu) throws ResKeyException {
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?