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

📄 doboardsaction.java

📁 天乙代码src_531.rar 天乙代码src_531.rar 天乙代码src_531.rar 天乙代码src_531.rar
💻 JAVA
字号:
package com.laoer.bbscs.bbs.action;

import org.apache.struts.action.*;
import javax.servlet.http.*;
import com.laoer.bbscs.bbs.actionform.*;
import com.laoer.bbscs.bbs.business.*;
import com.laoer.bbscs.sysinfo.*;
import com.laoer.bbscs.util.*;
import com.laoer.bbscs.servlet.*;
import com.laoer.bbscs.db.*;
import java.util.*;

public class DoBoardsAction
    extends Action {

  public ActionForward execute(ActionMapping actionMapping,
                               ActionForm actionForm,
                               HttpServletRequest httpServletRequest,
                               HttpServletResponse httpServletResponse) {
    ActionErrors errors = new ActionErrors();
    BoardsActionForm form = (BoardsActionForm) actionForm;
    UserSessionCheck myUserSessionCheck = new UserSessionCheck(form.getSid(),
        httpServletRequest);
    if (!myUserSessionCheck.checkSession(form.getBid())) {
      errors.add("error.timeout", new ActionError("error.timeout"));
      saveErrors(httpServletRequest, errors);
      return actionMapping.findForward("error");
    }
    if (myUserSessionCheck.isGuest()) {
      errors.add("noguest", new ActionError("error.user.noguest"));
      saveErrors(httpServletRequest, errors);
      return actionMapping.findForward("error");
    }
    httpServletRequest.setAttribute("myUserSessionCheck", myUserSessionCheck);
    httpServletRequest.setAttribute("sid", form.getSid());
    httpServletRequest.setAttribute("bid", form.getBid());
    httpServletRequest.setAttribute("theBoards",
                                    myUserSessionCheck.getTheBoards());
    if (form.getAction().equals("changebull")) {
      BoardsInfo bsi = new BoardsInfo();
      bsi.setID(Long.parseLong(form.getBid()));
      //bsi.setBulletin(form.getBulletin());
      Boards aBoards = BoardsFactory.getInstance();
      aBoards.setBoardsInfo(bsi);
      if (aBoards.getBoards(null, "ID", true) != Sys.RESULT_RIGHT) {
        errors.add("error.baordsno", new ActionError("error.baordsno"));
        saveErrors(httpServletRequest, errors);
        return actionMapping.findForward("error");
      }
      bsi = aBoards.getBoardsInfo();
      bsi.setBulletin(form.getBulletin());
      aBoards.setBoardsInfo(bsi);
      aBoards.updateBoards(null, "Boards");
      bsi = null;
      aBoards = null;
      Boards initBoards = BoardsFactory.getInstance();
      initBoards.setBoardsList(null);
      initBoards = null;
      /*
             httpServletRequest.setAttribute("aForwardInfo",
                                      new ForwardInfo("",
          Sys.getURL() + "manageAction.do?sid=" + form.getSid() +
          "&bid=" + form.getBid() + "&action=h"));*/
      errors = null;
      //form = null;
      myUserSessionCheck = null;
      //return actionMapping.findForward("forwards");

      ActionForward f = new ActionForward("/manageAction.do?sid=" + form.getSid() +
                                          "&bid=" + form.getBid() + "&action=h", true);
      return f;

    }
    if (form.getAction().equals("addcaninuser")) {
      BoardsInfo bsi = new BoardsInfo();
      bsi.setID(Long.parseLong(form.getBid()));
      Boards aBoards = BoardsFactory.getInstance();
      aBoards.setBoardsInfo(bsi);
      if (aBoards.getBoards(null, "ID", true) != Sys.RESULT_RIGHT) {
        errors.add("error.baordsno", new ActionError("error.baordsno"));
        saveErrors(httpServletRequest, errors);
        return actionMapping.findForward("error");
      }
      bsi = aBoards.getBoardsInfo();
      UserInfo aui = new UserInfo();
      aui.setUserName(form.getUname());
      User au = UserFactory.getInstance();
      au.setUserInfo(aui);
      int result = au.getUser(null, "UserName", true);
      if (result != Sys.RESULT_RIGHT) {
        errors.add("error.user.nouser", new ActionError("error.user.nouser"));
        saveErrors(httpServletRequest, errors);
        return actionMapping.findForward("error");
      }
      aui = au.getUserInfo();
      result = aBoards.setUserCanIn(null, aui, 1);
      if (result == Sys.RESULT_OBJECTEXIST) {
        errors.add("error.reg.name1", new ActionError("error.reg.name1"));
        saveErrors(httpServletRequest, errors);
        return actionMapping.findForward("error");
      }
      if (result != Sys.RESULT_RIGHT) {
        errors.add("error.canuserin", new ActionError("error.canuserin"));
        saveErrors(httpServletRequest, errors);
        return actionMapping.findForward("error");
      }
      bsi = null;
      aBoards = null;
      Boards initBoards = BoardsFactory.getInstance();
      initBoards.setBoardsList(null);
      initBoards = null;
      /*
             httpServletRequest.setAttribute("aForwardInfo",
                                      new ForwardInfo("",
          Sys.getURL() + "manageAction.do?sid=" + form.getSid() +
          "&bid=" + form.getBid() + "&action=h"));*/
      errors = null;
      //form = null;
      myUserSessionCheck = null;
      aui = null;
      au = null;
      //return actionMapping.findForward("forwards");

      ActionForward f = new ActionForward("/manageAction.do?sid=" + form.getSid() +
                                          "&bid=" + form.getBid() + "&action=h", true);
      return f;

    }
    if (form.getAction().equals("delcaninuser")) {
      BoardsInfo bsi = new BoardsInfo();
      bsi.setID(Long.parseLong(form.getBid()));
      Boards aBoards = BoardsFactory.getInstance();
      aBoards.setBoardsInfo(bsi);
      if (aBoards.getBoards(null, "ID", true) != Sys.RESULT_RIGHT) {
        errors.add("error.baordsno", new ActionError("error.baordsno"));
        saveErrors(httpServletRequest, errors);
        return actionMapping.findForward("error");
      }
      bsi = aBoards.getBoardsInfo();
      UserInfo aui = new UserInfo();
      aui.setUserName(form.getUname());
      User au = UserFactory.getInstance();
      au.setUserInfo(aui);
      int result = au.getUser(null, "UserName", true);
      if (result != Sys.RESULT_RIGHT) {
        errors.add("error.user.nouser", new ActionError("error.user.nouser"));
        saveErrors(httpServletRequest, errors);
        return actionMapping.findForward("error");
      }
      aui = au.getUserInfo();
      result = aBoards.setUserCanIn(null, aui, 2);
      if (result != Sys.RESULT_RIGHT) {
        errors.add("error.canuserin", new ActionError("error.canuserin"));
        saveErrors(httpServletRequest, errors);
        return actionMapping.findForward("error");
      }
      bsi = null;
      aBoards = null;
      Boards initBoards = BoardsFactory.getInstance();
      initBoards.setBoardsList(null);
      initBoards = null;
      /*
             httpServletRequest.setAttribute("aForwardInfo",
                                      new ForwardInfo("",
          Sys.getURL() + "manageAction.do?sid=" + form.getSid() +
          "&bid=" + form.getBid() + "&action=h"));*/
      errors = null;
      form = null;
      myUserSessionCheck = null;
      aui = null;
      au = null;
      //return actionMapping.findForward("forwards");

      ActionForward f = new ActionForward("/manageAction.do?sid=" + form.getSid() +
                                          "&bid=" + form.getBid() + "&action=h", true);
      return f;

    }
    return actionMapping.findForward("error");
  }
}

⌨️ 快捷键说明

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