📄 document.java
字号:
logger.error(e.getMessage()); } finally { if (conn != null) { conn.close(); conn = null; } } return re; } public synchronized boolean UpdateSummary(ServletContext application, CMSMultiFileUploadBean mfu) throws ErrMsgException { String isuploadfile = StrUtil.getNullString(mfu.getFieldValue( "isuploadfile")); if (isuploadfile.equals("false")) return UpdateSummaryWithoutFile(application, mfu); String FilePath = StrUtil.getNullString(mfu.getFieldValue("filepath")); String tempAttachFilePath = application.getRealPath("/") + FilePath + "/"; mfu.setSavePath(tempAttachFilePath); File f = new File(tempAttachFilePath); if (!f.isDirectory()) { f.mkdirs(); } boolean re = false; ResultSet rs = null; Conn conn = new Conn(connname); try { String sql = "select path from flow_cms_images where mainkey=" + id + " and kind='document' and subkey=" + 0 + ""; rs = conn.executeQuery(sql); if (rs != null) { String fpath = ""; while (rs.next()) { fpath = rs.getString(1); if (fpath != null) { File virtualFile = new File(fpath); virtualFile.delete(); } } } if (rs != null) { rs.close(); rs = null; } sql = "delete from flow_cms_images where mainkey=" + id + " and kind='document' and subkey=" + 0 + ""; conn.executeUpdate(sql); int ret = mfu.getRet(); if (ret == 1) { mfu.writeFile(false); Vector files = mfu.getFiles(); java.util.Enumeration e = files.elements(); String filepath = ""; sql = ""; while (e.hasMoreElements()) { FileInfo fi = (FileInfo) e.nextElement(); filepath = mfu.getSavePath() + fi.getName(); sql = "insert into flow_cms_images (path,mainkey,kind,subkey) values (" + StrUtil.sqlstr(filepath) + "," + id + ",'document'," + 0 + ")"; conn.executeUpdate(sql); } } else throw new ErrMsgException("上传失败!ret=" + ret); if (rs != null) { try { rs.close(); } catch (Exception e) {} rs = null; } re = UpdateSummaryWithoutFile(application, mfu); } catch (Exception e) { logger.error("UpdateSummary:" + e.getMessage()); } finally { if (conn != null) { conn.close(); conn = null; } } return re; } public synchronized boolean updateTemplateId() { String sql = "update flow_document set template_id=? where id=?"; Conn conn = new Conn(connname); boolean re = false; try { PreparedStatement pstmt = conn.prepareStatement(sql); pstmt.setInt(1, templateId); pstmt.setInt(2, id); re = conn.executePreUpdate()==1?true:false; if (re) { DocCacheMgr dcm = new DocCacheMgr(); dcm.refreshUpdate(id); } } catch (SQLException e) { logger.error(e.getMessage()); } finally { if (conn!=null) { conn.close(); conn = null; } } return re; } public synchronized boolean Update(ServletContext application, CMSMultiFileUploadBean mfu) throws ErrMsgException { String isuploadfile = StrUtil.getNullString(mfu.getFieldValue( "isuploadfile")); if (isuploadfile.equals("false")) return UpdateWithoutFile(application, mfu); String dir_code = StrUtil.getNullStr(mfu.getFieldValue("dir_code")); author = StrUtil.getNullString(mfu.getFieldValue("author")); title = StrUtil.getNullString(mfu.getFieldValue("title")); 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); 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; } String strisnew = StrUtil.getNullStr(mfu.getFieldValue("isNew")); if (StrUtil.isNumeric(strisnew)) isNew = Integer.parseInt(strisnew); else isNew = 0; String strCanComment = StrUtil.getNullStr(mfu.getFieldValue( "canComment")); if (strCanComment.equals("")) canComment = false; else if (strCanComment.equals("1")) canComment = true; flowTypeCode = StrUtil.getNullStr(mfu.getFieldValue("flowTypeCode")); Conn conn = new Conn(connname); ResultSet rs = null; 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.setInt(12, id); conn.executePreUpdate(); DocCacheMgr dcm = new DocCacheMgr(); if (oldexamine==examine) { dcm.refreshUpdate(id); } else { dcm.refreshUpdate(id, class1, parentCode); } if (!dir_code.equals(class1)) { dcm.refreshChangeDirCode(class1, dir_code); } DocContent dc = new DocContent(); dc = dc.getDocContent(id, 1); dc.save(application, mfu); } catch (SQLException e) { logger.error("update:" + e.getMessage()); throw new ErrMsgException("服务器内部错!"); } finally { if (rs != null) { try { rs.close(); } catch (Exception e) {} rs = null; } if (conn != null) { conn.close(); conn = null; } } return true; } public boolean create(ServletContext application, CMSMultiFileUploadBean mfu, String nick) throws ErrMsgException { String isuploadfile = StrUtil.getNullString(mfu.getFieldValue( "isuploadfile")); author = StrUtil.getNullString(mfu.getFieldValue("author")); title = StrUtil.getNullString(mfu.getFieldValue("title")); content = StrUtil.getNullString(mfu.getFieldValue("htmlcode")); String dir_code = StrUtil.getNullStr(mfu.getFieldValue("dir_code")); 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; } String strexamine = StrUtil.getNullStr(mfu.getFieldValue("examine")); if (StrUtil.isNumeric(strexamine)) { examine = Integer.parseInt(strexamine); } else examine = 0; String strisnew = StrUtil.getNullStr(mfu.getFieldValue("isNew")); if (StrUtil.isNumeric(strisnew)) isNew = Integer.parseInt(strisnew); else isNew = 0; flowTypeCode = StrUtil.getNullStr(mfu.getFieldValue("flowTypeCode")); Directory dir = new Directory(); Leaf lf = dir.getLeaf(dir_code); if (lf==null || !lf.isLoaded()) { throw new ErrMsgException("节点:" + dir_code + "不存在!"); } if (lf.getType() == 0) throw new ErrMsgException("对不起,该目录不包含具体内容,请选择正确的目录项!"); if (lf.getType() == 1) { if (getFirstIDByCode(dir_code) != -1) throw new ErrMsgException("该目录节点为文章节点,且文章已经被创建!"); } String strCanComment = StrUtil.getNullStr(mfu.getFieldValue( "canComment")); if (strCanComment.equals("")) canComment = false; else if (strCanComment.equals("1")) canComment = true; String strtid = StrUtil.getNullStr(mfu.getFieldValue("templateId")); if (StrUtil.isNumeric(strtid)) templateId = Integer.parseInt(strtid); String isvote = mfu.getFieldValue("isvote"); String[] voptions = null; type = 0; String voteresult = "", votestr = ""; if (isvote != null && isvote.equals("1")) { type = 1; String voteoption = mfu.getFieldValue("vote").trim(); if (!voteoption.equals("")) { voptions = voteoption.split("\\r\\n"); } if (voteoption.indexOf("|") != -1) throw new ErrMsgException("投票选项中不能包含|"); int len = voptions.length; for (int k = 0; k < len; k++) { if (voteresult.equals("")) { voteresult = "0"; votestr = voptions[k]; } else { voteresult += "|" + "0"; votestr += "|" + voptions[k]; } } } DocCacheMgr dcm = new DocCacheMgr(); dcm.refreshCreate(dir_code, lf.getParentCode()); if (isuploadfile.equals("false")) return create(dir_code, title, content, type, votestr, voteresult, nick, templateId, author); this.id = (int) SequenceManager.nextID(SequenceManager.OA_DOCUMENT_FLOW); Conn conn = new Conn(connname); PreparedStatement pstmt = null; try { parentCode = lf.getParentCode(); pstmt = conn.prepareStatement(INSERT_DOCUMENT); pstmt.setInt(1, id); pstmt.setString(2, title); pstmt.setString(3, dir_code); pstmt.setInt(4, type); pstmt.setString(5, votestr); pstmt.setString(6, voteresult); pstmt.setString(7, nick); pstmt.setString(8, keywords); pstmt.setInt(9, intisRelateShow); pstmt.setInt(10, canComment?1:0); pstmt.setInt(11, templateId); pstmt.setString(12, parentCode); pstmt.setInt(13, examine); pstmt.setInt(14, isNew); pstmt.setString(15, author); pstmt.setString(16, flowTypeCode); conn.executePreUpdate(); pstmt.close(); pstmt = null; DocContent dc = new DocContent(); dc.create(application, mfu, id, content, 1); } catch (SQLException e) { logger.error("create:" + e.getMessage()); throw new ErrMsgException("服务器内部错!"); } finally { if (conn != null) { conn.close(); conn = null; } } return true; } public boolean create(String code_class1, String title, String content, int type, String voteoption, String voteresult, String nick, int templateId, String author) { Leaf lf = new Leaf(); lf = lf.getLeaf(code_class1); parentCode = lf.getParentCode(); Conn conn = new Conn(connname); this.id = (int) SequenceManager.nextID(SequenceManager.OA_DOCUMENT_FLOW); try { PreparedStatement pstmt = conn.prepareStatement(INSERT_DOCUMENT); pstmt.setInt(1, id); pstmt.setString(2, title); pstmt.setString(3, code_class1); pstmt.setInt(4, type); pstmt.setString(5, voteoption); pstmt.setString(6, voteresult); pstmt.setString(7, nick); pstmt.setString(8, ""); pstmt.setInt(9, 1); pstmt.setInt(10, canComment?1:0); pstmt.setInt(11, templateId); pstmt.setString(12, parentCode); pstmt.setInt(13, examine); pstmt.setInt(14, isNew); pstmt.setString(15, author); pstmt.setString(16, flowTypeCode); conn.executePreUpdate(); DocContent dc = new DocContent(); dc.create(id, content); } catch (SQLException e) { logger.error(e.getMessage()); } finally { if (conn != null) { conn.close(); conn = null; } } return true; } public String get(String field) { if (field.equals("title")) return getTitle();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -