public String showAllComments( String siteId, int docId, long channelId, HttpServletRequest request, HttpServletResponse response) throws Exception { Container container = new ContainerImpl(); container.initWithSiteid(siteId, request, request.getSession(false), response); TransactionManager tm = new TransactionManager(); try { tm.begin(tm.RW_TRANSACTION); // 获得该文档所在的频道评论开关 int channelCommentSwitch = docCommentManager.getDocCommentSwitch(String.valueOf(docId), "chnl"); if (channelCommentSwitch != 0) { // 首先判断频道的评论开关 request.setAttribute("commentSwitch", channelCommentSwitch); } else { int documentCommentSwitch = docCommentManager.getDocCommentSwitch(String.valueOf(docId), "doc"); request.setAttribute("commentSwitch", documentCommentSwitch); } // 获得该文档所在频道的评论审核开关 Integer aduitSwitchFlag = docCommentManager.getChannelCommentAduitSwitch((int) channelId); if (aduitSwitchFlag != null) { request.setAttribute("aduitSwitchFlag", aduitSwitchFlag); } else { request.setAttribute("aduitSwitchFlag", 1); } Document doc = CMSUtil.getCMSDriverConfiguration() .getCMSService() .getDocumentManager() .getPartDocInfoById(docId + ""); String docurl = container.getPublishedDocumentUrl(doc); request.setAttribute("docId", docId); request.setAttribute("channelId", channelId); request.setAttribute("docurl", docurl); request.setAttribute("docTitle", doc.getTitle()); request.setAttribute("doc", doc); return "path:showAllComments"; } finally { tm.releasenolog(); } }
/** * 查询站点前n条评论和评论总数 * * @param sortKey 排序关键字 * @param desc 排序方式 * @param docId 文档ID * @param HttpServletRequest request * @return String * @throws Exception Exception */ public @ResponseBody(datatype = "jsonp") NComentList getSiteCommentNList( String site, int n, HttpServletRequest request, HttpServletResponse response) { try { Container container = new ContainerImpl(); // NComentList docCommentList = docCommentManager.getSiteCommnetList(n); container.init(site, request, request.getSession(), response); if (!CollectionUtils.isEmpty(docCommentList.getComments())) { for (DocComment docComment : docCommentList.getComments()) { String documentUrl = container.getPublishedDocumentUrl(new Integer(docComment.getDocId()).toString()); docComment.setDocUrl(documentUrl); } } return docCommentList; } catch (Exception e) { return null; } }