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

📄 post.java

📁 java论坛
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
        this.setNeedsAttributeRe(request, us);
        return mapping.getInputForward();
      }
    }

    if (postForm.getAction().equalsIgnoreCase("upfiledo")) {
      MessageResources mr = this.getResources(request);
      Locale locale = this.getLocale(request);

      Forum f = this.getForumService().findForumByID(postForm.getId(), postForm.getBid());

      if (this.getSysConfig().getAttachmentNum() == 0) {
        if (f.getAttachFileName().size() >= 20) {
          request.setAttribute("codeid", "2");
          request.setAttribute("msg", mr.getMessage(locale, "error.post.upfile.num", "20"));
          request.setAttribute("pid", postForm.getId());
          request.setAttribute("bid", new Long(postForm.getBid()));
          return mapping.findForward("forumUpComponent");
        }
      }
      else if (this.getSysConfig().getAttachmentNum() > 0 &&
               f.getAttachFileName().size() >= this.getSysConfig().getAttachmentNum()) {
        request.setAttribute("codeid", "2");
        request.setAttribute("msg",
                             mr.getMessage(locale, "error.post.upfile.num",
                                           String.valueOf(this.getSysConfig().getAttachmentNum())));
        request.setAttribute("pid", postForm.getId());
        request.setAttribute("bid", new Long(postForm.getBid()));
        return mapping.findForward("forumUpComponent");
      }

      if (!us.getId().equals(f.getUserID())) {
        request.setAttribute("codeid", "4");
        request.setAttribute("msg", mr.getMessage(locale, "error.post.upfile.user"));
        request.setAttribute("pid", postForm.getId());
        request.setAttribute("bid", new Long(postForm.getBid()));
        return mapping.findForward("forumUpComponent");
      }

      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);
                     return mapping.findForward("error");*/

          request.setAttribute("codeid", "1");
          request.setAttribute("msg",
                               mr.getMessage(locale, "post.upnotice",
                                             String.valueOf(this.getSysConfig().getAttachFileSize()),
                                             this.getSysConfig().getAttachFileType()));
          request.setAttribute("pid", postForm.getId());
          request.setAttribute("bid", new Long(postForm.getBid()));
          return mapping.findForward("forumUpComponent");

        }
        try {
          uploadFile = new UploadFile();
          uploadFile.setFileName(postForm.getUpdateFile().getFileName().toLowerCase());
          uploadFile.setInputStream(postForm.getUpdateFile().getInputStream());
        }
        catch (FileNotFoundException ex2) {
          uploadFile = null;
          request.setAttribute("codeid", "3");
          request.setAttribute("msg", mr.getMessage(locale, "error.post.upfile.error"));
          request.setAttribute("pid", postForm.getId());
          request.setAttribute("bid", new Long(postForm.getBid()));
          return mapping.findForward("forumUpComponent");

        }
        catch (IOException ex2) {
          uploadFile = null;
          request.setAttribute("codeid", "3");
          request.setAttribute("msg", mr.getMessage(locale, "error.post.upfile.error"));
          request.setAttribute("pid", postForm.getId());
          request.setAttribute("bid", new Long(postForm.getBid()));
          return mapping.findForward("forumUpComponent");
        }
      }

      try {
        if (board.getAuditAttach() == 1) {
          f.setAuditingAttachFile(1);
        }
        f = this.getForumService().createForumUpFile(f, uploadFile);
        if (board.getAuditAttach() == 0) {
          request.setAttribute("codeid", "0");
          request.setAttribute("msg", mr.getMessage(locale, "post.upfile.upok"));
        }
        else {
          request.setAttribute("codeid", "99");
          request.setAttribute("msg", mr.getMessage(locale, "post.upfile.upok1"));
        }
        request.setAttribute("codeid", "0");
        request.setAttribute("msg", mr.getMessage(locale, "post.upfile.upok"));
        request.setAttribute("pid", postForm.getId());
        request.setAttribute("bid", new Long(postForm.getBid()));
        return mapping.findForward("forumUpComponent");
      }
      catch (BbscsException ex3) {
        request.setAttribute("codeid", "3");
        request.setAttribute("msg", mr.getMessage(locale, "error.post.upfile.error"));
        request.setAttribute("pid", postForm.getId());
        request.setAttribute("bid", new Long(postForm.getBid()));
        return mapping.findForward("forumUpComponent");
      }
    }

    if (postForm.getAction().equalsIgnoreCase("edit")) {

      Forum f = this.getForumService().findForumByID(postForm.getId(), postForm.getBid());
      if (f == null) {
        messages.add("error.post.getpost", new ActionMessage("error.post.getpost"));
        this.saveErrors(request, messages);
        return mapping.findForward(this.FORWARD_ERROR);
      }
      if (! (f.getUserID().equals(us.getId()) ||
             us.isHaveBoardSpecialPermission(Constant.SPERMISSION_CAN_EDITPOST))) {
        messages.add("error.noPermission", new ActionMessage("error.noPermission"));
        this.saveErrors(request, messages);
        return mapping.findForward(this.FORWARD_ERROR);
      }

      if (this.getSysConfig().getEditPostLimit() > 0) {
        if (! (us.isHaveBoardSpecialPermission(Constant.SPERMISSION_CAN_EDITPOST) ||
               (System.currentTimeMillis() - f.getPostTime()) <
               this.getSysConfig().getEditPostLimit() * 60000)) {
          messages.add("error.post.edit.timeout", new ActionMessage("error.post.edit.timeout"));
          this.saveErrors(request, messages);
          return mapping.findForward(this.FORWARD_ERROR);
        }
      }

      postForm.setAction("editdo");
      postForm.setTitle(f.getTitle());
      postForm.setDetail(f.getDetail());
      int canUseTitleColor = 0;
      if (f.getIsNew() == 1) {
        if (us.isHaveBoardSpecialPermission(Constant.SPERMISSION_CAN_USE_TITLECOLOR)) {
          canUseTitleColor = 1;
        }
      }
      request.setAttribute("titleColorOptions",
                           BBSCSUtil.getTitleColorOptions(canUseTitleColor, request.getLocale()));
      postForm.setTitleColor(f.getTitleColor());
      postForm.setPostType(f.getPostType());
      postForm.setFace(f.getFace());
      postForm.setEditType(f.getEditType());
      postForm.setSign(3);
      postForm.setEmailInform(f.getEmailInform());
      postForm.setMsgInform(f.getMsgInform());

      return mapping.findForward("post");
    }

    if (postForm.getAction().equalsIgnoreCase("editdo")) {
      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 f = this.getForumService().findForumByID(postForm.getId(), postForm.getBid());
      if (f == null) {
        messages.add("error.post.getpost", new ActionMessage("error.post.getpost"));
        this.saveErrors(request, messages);
        return mapping.findForward(this.FORWARD_ERROR);
      }
      if (! (f.getUserID().equals(us.getId()) ||
             us.isHaveBoardSpecialPermission(Constant.SPERMISSION_CAN_EDITPOST))) {
        messages.add("error.noPermission", new ActionMessage("error.noPermission"));
        this.saveErrors(request, messages);
        return mapping.findForward(this.FORWARD_ERROR);
      }

      MessageResources mr = this.getResources(request);
      Locale locale = this.getLocale(request);

      String IP = request.getRemoteAddr();
      IP = IP.substring(0, IP.lastIndexOf(".")) + ".*";
      f.setArtSize(BBSCSUtil.getSysCharsetStrLength(postForm.getDetail()));

      String amend = mr.getMessage(locale, "change.text", us.getUserName(),
                                   Util.formatDateTime(new Date()), IP);
      f.setAmend(amend);

      f.setEditType(postForm.getEditType());
      f.setFace(postForm.getFace());
      f.setPostType(postForm.getPostType());
      if (postForm.getSign() != 3) {
        if (postForm.getSign() == -1) {
          f.setSign("");
        }
        else {
          f.setSign(us.getSignDetail()[postForm.getSign()]);
        }
      }
      f.setTitle(title);
      f.setTitleColor(postForm.getTitleColor());
      f.setDetail(detail);
      if (f.getIndexStatus() == Constant.INDEX_STATUS_INDEXED) {
        f.setIndexStatus(Constant.INDEX_STATUS_NEED_UPDTAE);
      }

      try {
        f = this.getForumService().saveForum(f);
        return new ActionForward(BBSCSUtil.getActionMappingURL("/read?action=topic&id=" +
            postForm.getMainID() + "&bid=" + bid + "&fcpage=" + postForm.getFcpage() + "&inpages=" +
            postForm.getInpages()), true);

      }
      catch (BbscsException ex4) {
        messages.add("error.post.editdo", new ActionMessage("error.post.editdo"));
        this.saveErrors(request, messages);
        return mapping.findForward(this.FORWARD_ERROR);

      }
    }

    if (postForm.getAction().equalsIgnoreCase("showdelattachpage")) {
      Forum f = this.getForumService().findForumByID(postForm.getId(), postForm.getBid());
      if (f == null) {
        messages.add("error.post.getpost", new ActionMessage("error.post.getpost"));
        this.saveErrors(request, messages);
        return mapping.findForward(this.FORWARD_HTMLERROR);
      }
      if (f.getAttachFileName() == null || f.getAttachFileName().isEmpty()) {
        messages.add("error.post.upfile.notexist",
                     new ActionMessage("error.post.upfile.notexist", postForm.getId()));
        this.saveErrors(request, messages);
        return mapping.findForward(this.FORWARD_HTMLERROR);
      }
      if (! (us.getId().equals(f.getUserID()) ||
             us.isHaveBoardSpecialPermission(Constant.SPERMISSION_CAN_DELATTACH))) {
        messages.add("error.post.upfile.user2",
                     new ActionMessage("error.post.upfile.user2", postForm.getId()));
        this.saveErrors(request, messages);
        return mapping.findForward(this.FORWARD_HTMLERROR);
      }
      request.setAttribute("attachFiles", f.getAttachFileName());
      return mapping.findForward("attachFiles");
    }

    return mapping.getInputForward();
  }

  private int getUserPostPerNum(int userNum, int sysNum) {
    if (userNum == 0) {
      return sysNum;
    }
    else {
      return userNum;
    }
  }

  private void setNeedsAttribute(HttpServletRequest request, UserSession us) {
    request.setAttribute("postHiddenTypeMoney",
                         new Integer(this.getSysConfig().getPostHiddenTypeMoney()));
    request.setAttribute("postHiddenTypeRe", new Integer(this.getSysConfig().getPostHiddenTypeRe()));
    request.setAttribute("postHiddenTypeArtNum",
                         new Integer(this.getSysConfig().getPostHiddenTypeArtNum()));
    int canUseTitleColor = 0;
    if (us.isHaveBoardSpecialPermission(Constant.SPERMISSION_CAN_USE_TITLECOLOR)) {
      canUseTitleColor = 1;
    }
    //System.out.println(canUseTitleColor);
    request.setAttribute("titleColorOptions",
                         BBSCSUtil.getTitleColorOptions(canUseTitleColor, request.getLocale()));
    request.setAttribute("postPriceValues",
                         BBSCSUtil.getPostPriceValues(this.getSysConfig().getPostPriceLists()));
  }

  private void setNeedsAttributeRe(HttpServletRequest request, UserSession us) {
    request.setAttribute("postHiddenTypeMoney",
                         new Integer(this.getSysConfig().getPostHiddenTypeMoney()));
    request.setAttribute("postHiddenTypeRe", new Integer(this.getSysConfig().getPostHiddenTypeRe()));
    request.setAttribute("postHiddenTypeArtNum",
                         new Integer(this.getSysConfig().getPostHiddenTypeArtNum()));
    int canUseTitleColor = 0;
    request.setAttribute("titleColorOptions",
                         BBSCSUtil.getTitleColorOptions(canUseTitleColor, request.getLocale()));
    request.setAttribute("postPriceValues",
                         BBSCSUtil.getPostPriceValues(this.getSysConfig().getPostPriceLists()));
  }

  public BoardService getBoardService() {
    return boardService;
  }

  public ForumService getForumService() {
    return forumService;
  }

  public SysConfig getSysConfig() {
    return sysConfig;
  }

  public UserService getUserService() {
    return userService;
  }

  public void setBoardService(BoardService boardService) {
    this.boardService = boardService;
  }

  public void setForumService(ForumService forumService) {
    this.forumService = forumService;
  }

  public void setSysConfig(SysConfig sysConfig) {
    this.sysConfig = sysConfig;
  }

  public void setUserService(UserService userService) {
    this.userService = userService;
  }
}

⌨️ 快捷键说明

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