⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 post.java

📁 java论坛
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
      String title = StringUtils.trimToEmpty(postForm.getTitle());
      String detail = StringUtils.trimToEmpty(postForm.getDetail());
      if (StringUtils.isBlank(title) || BBSCSUtil.getSysCharsetStrLength(title) > 90) {
        messages.add("error.post.titletoolong", new ActionMessage("error.post.titletoolong"));
        this.saveErrors(request, messages);
        return mapping.findForward(this.FORWARD_ERROR);
      }
      title = this.getSysConfig().bestrowScreen(title);
      if (StringUtils.isBlank(detail)) {
        messages.add("error.post.nodetail", new ActionMessage("error.post.nodetail"));
        this.saveErrors(request, messages);
        return mapping.findForward(this.FORWARD_ERROR);
      }

      if (BBSCSUtil.getSysCharsetStrLength(detail) < this.getSysConfig().getPostMinSize() ||
          BBSCSUtil.getSysCharsetStrLength(detail) > this.getSysConfig().getPostMaxSize()) {
        messages.add("error.post.texttoolong",
                     new ActionMessage("error.post.texttoolong",
                                       String.valueOf(this.getSysConfig().getPostMinSize()),
                                       String.valueOf(this.getSysConfig().getPostMaxSize())));
        this.saveErrors(request, messages);
        return mapping.findForward(this.FORWARD_ERROR);
      }
      detail = this.getSysConfig().bestrowScreen(detail);

      Forum mainForum = this.getForumService().findForumByID(postForm.getMainID(), bid);
      if (mainForum == null) {
        messages.add("error.post.getpost", new ActionMessage("error.post.getpost"));
        this.saveErrors(request, messages);
        return mapping.findForward(this.FORWARD_ERROR);
      }
      if (mainForum.getIsLock() == 1) {
        messages.add("error.post.islock", new ActionMessage("error.post.islock"));
        this.saveErrors(request, messages);
        return mapping.findForward(this.FORWARD_ERROR);
      }

      long nowtime = System.currentTimeMillis();
      Forum f = new Forum();
      f.setAgree(0);
      f.setAmend("");
      f.setArtSize(BBSCSUtil.getSysCharsetStrLength(detail));
      f.setAttachFileName(new ArrayList());
      f.setAuditing(board.getAuditPost());
      //f.setAuditingAttachFile(board.getAuditAttach());
      f.setAuditingAttachFile(0);
      f.setBeAgainst(0);
      f.setBoardID(bid);
      f.setBoardName(board.getBoardName());
      f.setCanNotDel(0);
      f.setCanNotRe(0);
      f.setClick(0);
      f.setCommend(0);
      f.setDelIP("");
      f.setDelSign(0);
      f.setDelTime(0);
      f.setDelUserID("");
      f.setDelUserName("");
      f.setDetail(detail);
      f.setDoEliteName("");
      f.setDoEliteTime(0);
      f.setEditType(postForm.getEditType());
      f.setElite(0);
      f.setEliteID(0);
      f.setFace(postForm.getFace());
      f.setHaveAttachFile(0);
      f.setIpAddress(request.getRemoteAddr());
      f.setIsHidden(postForm.getIsHidden());
      if (postForm.getIsHidden() == 2) {
        f.setIsHiddenValue(postForm.getUseCoin());
      }
      else if (postForm.getIsHidden() == 3) {
        f.setIsHiddenValue(postForm.getNeedArtNum());
      }
      else {
        f.setIsHiddenValue(0);
      }
      f.setIsLock(0);
      f.setIsNew(0);
      f.setIsTop(0);
      f.setIsVote(0);
      f.setLastPostNickName("---");
      f.setLastPostTitle("");
      f.setLastPostUserName("---");
      f.setLastTime(nowtime);
      f.setMainID(postForm.getMainID());
      f.setNickName(us.getNickName());
      f.setParentID(postForm.getParentID());
      f.setPostTime(nowtime);
      f.setPostType(postForm.getPostType());
      f.setQuoteText("");
      f.setReNum(0);
      if (postForm.getSign() == -1) {
        f.setSign("");
      }
      else {
        f.setSign(us.getSignDetail()[postForm.getSign()]);
      }
      f.setTitle(title);
      f.setTitleColor(postForm.getTitleColor());
      f.setUserID(us.getId());
      f.setUserName(us.getUserName());
      f.setEmailInform(postForm.getEmailInform());
      f.setMsgInform(postForm.getMsgInform());
      f.setUserBlog(0);
      if (board.getAuditPost() == 0) {
        f.setIndexStatus(Constant.INDEX_STATUS_NO_INDEX);
      }
      else {
        f.setIndexStatus(Constant.INDEX_STATUS_AUDIT);
      }

      int userPostPerNum = this.getUserPostPerNum(uc.getPostPerNum(),
                                                  this.getSysConfig().getPostPerPage());
      int inpages = (int) Math.ceil( (postForm.getTotalnum() + 1) + userPostPerNum - 1) /
          userPostPerNum;
      if (mainForum.getIsHidden() == 1) {
        inpages = 1;
      }

      try {
        UserInfo ui = this.getUserService().findUserInfoById(us.getId());
        if (ui == null) {
          messages.add("error.post.guest", new ActionMessage("error.post.guest"));
          this.saveErrors(request, messages);
          return mapping.findForward(this.FORWARD_ERROR);
        }

        f = this.getForumService().createReForum(f, mainForum, board, ui, null, false);
        uc.addLastPostTime();
        if (board.getAuditPost() == 0) {
          return new ActionForward(BBSCSUtil.getActionMappingURL("/read?action=topic&id=" +
              postForm.getMainID() + "&bid=" + bid + "&fcpage=" + postForm.getFcpage() +
              "&inpages=" +
              inpages), true);
        }
        else {
          return mapping.findForward("");
        }
      }
      catch (BbscsException ex1) {
        messages.add("error.post.add", new ActionMessage("error.post.add"));
        this.saveErrors(request, messages);
        return mapping.findForward(this.FORWARD_ERROR);
      }
    }

    if (postForm.getAction().equalsIgnoreCase("addre") ||
        postForm.getAction().equalsIgnoreCase("addrequote")) {
      boolean isQuote = false;
      if (postForm.getAction().equalsIgnoreCase("addrequote")) {
        isQuote = true;
      }
      String title = StringUtils.trimToEmpty(postForm.getTitle());
      String detail = StringUtils.trimToEmpty(postForm.getDetail());
      if (StringUtils.isBlank(title) || BBSCSUtil.getSysCharsetStrLength(title) > 90) {
        messages.add("error.post.titletoolong", new ActionMessage("error.post.titletoolong"));
        this.saveErrors(request, messages);
        this.setNeedsAttributeRe(request, us);
        return mapping.getInputForward();
      }
      title = this.getSysConfig().bestrowScreen(title);
      if (StringUtils.isBlank(detail)) {
        messages.add("error.post.nodetail", new ActionMessage("error.post.nodetail"));
        this.saveErrors(request, messages);
        this.setNeedsAttributeRe(request, us);
        return mapping.getInputForward();
      }

      if (BBSCSUtil.getSysCharsetStrLength(detail) < this.getSysConfig().getPostMinSize() ||
          BBSCSUtil.getSysCharsetStrLength(detail) > this.getSysConfig().getPostMaxSize()) {
        messages.add("error.post.texttoolong",
                     new ActionMessage("error.post.texttoolong",
                                       String.valueOf(this.getSysConfig().getPostMinSize()),
                                       String.valueOf(this.getSysConfig().getPostMaxSize())));
        this.saveErrors(request, messages);
        this.setNeedsAttributeRe(request, us);
        return mapping.getInputForward();
      }
      detail = this.getSysConfig().bestrowScreen(detail);
      UploadFile uploadFile = null;
      if (postForm.getUpdateFile() != null &&
          StringUtils.isNotBlank(postForm.getUpdateFile().getFileName()) &&
          postForm.getUpdateFile().getFileSize() > 0) {
        if (!this.getSysConfig().isAllowAttachFileType(postForm.getUpdateFile().getFileName().
            toLowerCase()) || postForm.getUpdateFile().getFileSize() >
            (this.getSysConfig().getAttachFileSize() * 1024)) {
          messages.add("post.upnotice",
                       new ActionMessage("post.upnotice",
                                         String.valueOf(this.getSysConfig().getAttachFileSize()),
                                         this.getSysConfig().getAttachFileType()));
          this.saveErrors(request, messages);
          this.setNeedsAttributeRe(request, us);
          return mapping.getInputForward();
        }
        try {
          uploadFile = new UploadFile();
          uploadFile.setFileName(postForm.getUpdateFile().getFileName().toLowerCase());
          uploadFile.setInputStream(postForm.getUpdateFile().getInputStream());
        }
        catch (FileNotFoundException ex2) {
          uploadFile = null;
        }
        catch (IOException ex2) {
          uploadFile = null;
        }
      }

      Forum mainForum = this.getForumService().findForumByID(postForm.getMainID(), bid);
      if (mainForum == null) {
        messages.add("error.post.getpost", new ActionMessage("error.post.getpost"));
        this.saveErrors(request, messages);
        this.setNeedsAttributeRe(request, us);
        return mapping.getInputForward();
      }
      if (mainForum.getIsLock() == 1) {
        messages.add("error.post.islock", new ActionMessage("error.post.islock"));
        this.saveErrors(request, messages);
        this.setNeedsAttributeRe(request, us);
        return mapping.getInputForward();
      }

      long nowtime = System.currentTimeMillis();
      Forum f = new Forum();
      f.setAgree(0);
      f.setAmend("");
      f.setArtSize(BBSCSUtil.getSysCharsetStrLength(detail));
      f.setAttachFileName(new ArrayList());
      f.setAuditing(board.getAuditPost());
      //f.setAuditingAttachFile(board.getAuditAttach());
      if (board.getAuditAttach() == 1 && uploadFile != null) {
        f.setAuditingAttachFile(board.getAuditAttach());
      }
      else {
        f.setAuditingAttachFile(0);
      }
      f.setBeAgainst(0);
      f.setBoardID(bid);
      f.setBoardName(board.getBoardName());
      f.setCanNotDel(0);
      f.setCanNotRe(0);
      f.setClick(0);
      f.setCommend(0);
      f.setDelIP("");
      f.setDelSign(0);
      f.setDelTime(0);
      f.setDelUserID("");
      f.setDelUserName("");
      f.setDetail(detail);
      f.setDoEliteName("");
      f.setDoEliteTime(0);
      f.setEditType(postForm.getEditType());
      f.setElite(0);
      f.setEliteID(0);
      f.setFace(postForm.getFace());
      f.setHaveAttachFile(0);
      f.setIpAddress(request.getRemoteAddr());
      f.setIsHidden(postForm.getIsHidden());
      if (postForm.getIsHidden() == 2) {
        f.setIsHiddenValue(postForm.getUseCoin());
      }
      else if (postForm.getIsHidden() == 3) {
        f.setIsHiddenValue(postForm.getNeedArtNum());
      }
      else {
        f.setIsHiddenValue(0);
      }
      f.setIsLock(0);
      f.setIsNew(0);
      f.setIsTop(0);
      f.setIsVote(0);
      f.setLastPostNickName("---");
      f.setLastPostTitle("");
      f.setLastPostUserName("---");
      f.setLastTime(nowtime);
      f.setMainID(postForm.getMainID());
      f.setNickName(us.getNickName());
      f.setParentID(postForm.getParentID());
      f.setPostTime(nowtime);
      f.setPostType(postForm.getPostType());
      /*
             if (postForm.getAction().equalsIgnoreCase("addrequote")) {
        f.setQuoteEditType(mainForum.getEditType());
        if (this.getSysConfig().getQuoteMaxSize() > 0) {
          f.setQuoteText(BBSCSUtil.getSpeShortString(mainForum.getDetail(),
              this.getSysConfig().getQuoteMaxSize(), "..."));
        }
        else {
          f.setQuoteText(mainForum.getDetail());
        }
             }
             else {
        f.setQuoteText("");
             }*/
      f.setQuoteText("");
      f.setReNum(0);
      if (postForm.getSign() == -1) {
        f.setSign("");
      }
      else {
        f.setSign(us.getSignDetail()[postForm.getSign()]);
      }
      f.setTitle(title);
      f.setTitleColor(postForm.getTitleColor());
      f.setUserID(us.getId());
      f.setUserName(us.getUserName());
      f.setEmailInform(postForm.getEmailInform());
      f.setMsgInform(postForm.getMsgInform());
      f.setUserBlog(postForm.getUserBlog());
      if (board.getAuditPost() == 0) {
        f.setIndexStatus(Constant.INDEX_STATUS_NO_INDEX);
      }
      else {
        f.setIndexStatus(Constant.INDEX_STATUS_AUDIT);
      }

      int userPostPerNum = this.getUserPostPerNum(uc.getPostPerNum(),
                                                  this.getSysConfig().getPostPerPage());
      int inpages = (int) Math.ceil( (postForm.getTotalnum() + 1) + userPostPerNum - 1) /
          userPostPerNum;
      if (mainForum.getIsHidden() == 1) {
        inpages = 1;
      }

      try {
        UserInfo ui = this.getUserService().findUserInfoById(us.getId());
        if (ui == null) {
          messages.add("error.post.guest", new ActionMessage("error.post.guest"));
          this.saveErrors(request, messages);
          this.setNeedsAttributeRe(request, us);
          return mapping.getInputForward();
        }

        f = this.getForumService().createReForum(f, mainForum, board, ui, uploadFile, isQuote);
        uc.addLastPostTime();
        if (board.getAuditPost() == 0) {
          return new ActionForward(BBSCSUtil.getActionMappingURL("/read?action=topic&id=" +
              postForm.getMainID() + "&bid=" + bid + "&fcpage=" + postForm.getFcpage() + "&fcaction=index" +
              "&inpages=" + inpages), true);
        }
        else {
          return new ActionForward(BBSCSUtil.getActionMappingURL("/postWaitAudit?bid=" + bid), true);
        }
      }
      catch (BbscsException ex1) {
        messages.add("error.post.add", new ActionMessage("error.post.add"));
        this.saveErrors(request, messages);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -