コード例 #1
0
  /*
   *
   * (non-Javadoc)
   *
   * @see com.opensymphony.xwork.ActionSupport#execute()
   */
  public String execute() {
    List moduleList = null;
    ModulesSearchCondition modulesSearch = null;
    String searchName = "";
    try {

      /** 验证请求的属性是否完整,防止知道URL非法请求----开始 */
      String page = this.getRequest().getParameter("page");
      String name = this.getRequest().getParameter("name");
      String isNewSearch = this.getRequest().getParameter("isNew");
      if (page != null) {
        if (page.trim().length() > 0) {
          try {
            NumberUtils.parseNumber(page, Integer.class);
          } catch (Exception e) {
            /** 记录日志 */
            LogsApplication appLog = new LogsApplication();
            appLog.setOperator(this.getUserSessionInfo().getName());
            appLog.setLogDate(new Date());
            appLog.setEventType("搜索模块异常");
            appLog.setContent(
                "操作员["
                    + this.getUserSessionInfo().getName()
                    + "]"
                    + "搜索模块出现异常,异常信息:["
                    + e.getMessage()
                    + "]!");
            appLog.setPriority(LogsApplication.EXCEPTION);
            appLog.setIpAddress(this.getUserSessionInfo().getIpAddress());
            this.appLogManager.saveOrUpdateAppLog(appLog);

            /** 输出错误信息 */
            logger.error(e.getMessage());
            e.printStackTrace();
          }
        }
      }

      /** 构造搜索对象 */
      modulesSearch = new ModulesSearchCondition();
      if (StringUtils.hasText(name)) {
        searchName = name;
        modulesSearch.setName(StringUtils.trimWhitespace(name));
      }

      /** 验证请求的属性是否完整----结束 */

      /** 构造Page对象 */
      Page pageInfo = this.getModuleManager().searchModules(modulesSearch, this.getUserPageSize());

      /** 设置取的页数 */
      if (page != null) {
        if (page.trim().length() > 0) {
          try {
            pageInfo.setPage(
                (Integer) NumberUtils.parseNumber(StringUtils.trimWhitespace(page), Integer.class));
          } catch (Exception e) {
            /** 记录日志 */
            LogsApplication appLog = new LogsApplication();
            appLog.setOperator(this.getUserSessionInfo().getName());
            appLog.setLogDate(new Date());
            appLog.setEventType("搜索模块异常");
            appLog.setContent(
                "操作员["
                    + this.getUserSessionInfo().getName()
                    + "]"
                    + "搜索模块出现异常,异常信息:["
                    + e.getMessage()
                    + "]!");
            appLog.setPriority(LogsApplication.EXCEPTION);
            appLog.setIpAddress(this.getUserSessionInfo().getIpAddress());
            this.appLogManager.saveOrUpdateAppLog(appLog);

            /** 输出错误信息 */
            logger.error(e.getMessage());
            e.printStackTrace();
          }
        }
      }

      /** 如果是新搜索 */
      if (isNewSearch != null) {
        if (isNewSearch.trim().length() > 0) {
          if (isNewSearch.equalsIgnoreCase("true")) {
            pageInfo.setPage(1);
          }
        }
      }
      /** 获得分页集合 */
      moduleList = this.getModuleManager().searchModules(modulesSearch, pageInfo);

      /** 设置到属性中去 */
      this.getRequest().setAttribute("pageInfo", pageInfo);
      this.getRequest().setAttribute("moduleList", moduleList);
      this.getRequest().setAttribute("searchContent", modulesSearch);
      this.getRequest().setAttribute("name", searchName);

      this.getRequest()
          .setAttribute(
              "actionName",
              "searchModules."
                  + Global.ACTION_EXT
                  + "?name="
                  + StringUtils.trimWhitespace(searchName));

      /** 记录日志 */
      LogsApplication appLog = new LogsApplication();
      appLog.setOperator(this.getUserSessionInfo().getName());
      appLog.setLogDate(new Date());
      appLog.setEventType("搜索模块");
      appLog.setContent("操作员[" + this.getUserSessionInfo().getName() + "]" + "搜索模块!");
      appLog.setPriority(LogsApplication.NORMAL);
      appLog.setIpAddress(this.getUserSessionInfo().getIpAddress());
      this.appLogManager.saveOrUpdateAppLog(appLog);

      return SUCCESS;
    } catch (Exception e) {

      /** 记录日志 */
      LogsApplication appLog = new LogsApplication();
      appLog.setOperator(this.getUserSessionInfo().getName());
      appLog.setLogDate(new Date());
      appLog.setEventType("搜索模块异常");
      appLog.setContent(
          "操作员["
              + this.getUserSessionInfo().getName()
              + "]"
              + "搜索模块出现异常,异常信息:["
              + e.getMessage()
              + "]!");
      appLog.setPriority(LogsApplication.EXCEPTION);
      appLog.setIpAddress(this.getUserSessionInfo().getIpAddress());
      this.appLogManager.saveOrUpdateAppLog(appLog);

      /** 输出错误信息 */
      logger.error(e.getMessage());
      e.printStackTrace();

      return ERROR;
    }
  }
コード例 #2
0
  /*
   *
   * (non-Javadoc)
   *
   * @see com.opensymphony.xwork.ActionSupport#execute()
   */
  public String execute() {
    List loginLogList = null;
    LogsLoginSearchCondition logsSearch = null;
    String searchOperator = "";
    String searchEventType = "";
    String searchStartLogDate = "";
    String searchEndLogDate = "";
    try {

      /** 验证请求的属性是否完整,防止知道URL非法请求----开始 */
      String page = this.getRequest().getParameter("page");
      String operator = this.getRequest().getParameter("operator");
      String eventType = this.getRequest().getParameter("eventType");
      String startLogDate = this.getRequest().getParameter("startLogDate");
      String endLogDate = this.getRequest().getParameter("endLogDate");
      String isNewSearch = this.getRequest().getParameter("isNew");
      if (page != null) {
        if (page.trim().length() > 0) {
          try {
            NumberUtils.parseNumber(page, Integer.class);
          } catch (Exception e) {
            /** 记录日志 */
            LogsApplication appLog = new LogsApplication();
            appLog.setOperator(this.getUserSessionInfo().getName());
            appLog.setLogDate(new Date());
            appLog.setEventType("搜索登陆日志异常");
            appLog.setContent(
                "操作员["
                    + this.getUserSessionInfo().getName()
                    + "]"
                    + "搜索登陆日志出现异常,异常信息:["
                    + e.getMessage()
                    + "]!");
            appLog.setPriority(LogsApplication.EXCEPTION);
            appLog.setIpAddress(this.getUserSessionInfo().getIpAddress());
            this.appLogManager.saveOrUpdateAppLog(appLog);

            /** 输出错误信息 */
            logger.error(e.getMessage());
            e.printStackTrace();
          }
        }
      }

      /** 构造搜索对象 */
      logsSearch = new LogsLoginSearchCondition();
      if (StringUtils.hasText(operator)) {
        searchOperator = operator;
        logsSearch.setOperator(StringUtils.trimWhitespace(operator));
      }
      if (StringUtils.hasText(eventType)) {
        searchEventType = eventType;
        logsSearch.setEventType(StringUtils.trimWhitespace(eventType));
      }
      if (StringUtils.hasText(startLogDate)) {
        logsSearch.setStartLogDate(java.sql.Date.valueOf(startLogDate));
        searchStartLogDate =
            DateUtils.formatDateToString(
                logsSearch.getStartLogDate(), DateUtils.DATE_FORMAT_YYYY_MM_DD);
      }
      if (StringUtils.hasText(endLogDate)) {
        logsSearch.setEndLogDate(java.sql.Date.valueOf(endLogDate));
        searchEndLogDate =
            DateUtils.formatDateToString(
                logsSearch.getEndLogDate(), DateUtils.DATE_FORMAT_YYYY_MM_DD);
      }

      /** 验证请求的属性是否完整----结束 */

      /** 构造Page对象 */
      Page pageInfo = this.getLoginLogManager().searchLoginLogs(logsSearch, this.getUserPageSize());

      /** 设置取的页数 */
      if (page != null) {
        if (page.trim().length() > 0) {
          try {
            pageInfo.setPage(
                (Integer) NumberUtils.parseNumber(StringUtils.trimWhitespace(page), Integer.class));
          } catch (Exception e) {
            /** 记录日志 */
            LogsApplication appLog = new LogsApplication();
            appLog.setOperator(this.getUserSessionInfo().getName());
            appLog.setLogDate(new Date());
            appLog.setEventType("搜索登陆日志异常");
            appLog.setContent(
                "操作员["
                    + this.getUserSessionInfo().getName()
                    + "]"
                    + "搜索登陆日志出现异常,异常信息:["
                    + e.getMessage()
                    + "]!");
            appLog.setPriority(LogsApplication.EXCEPTION);
            appLog.setIpAddress(this.getUserSessionInfo().getIpAddress());
            this.appLogManager.saveOrUpdateAppLog(appLog);

            /** 输出错误信息 */
            logger.error(e.getMessage());
            e.printStackTrace();
          }
        }
      }

      /** 如果是新搜索 */
      if (isNewSearch != null) {
        if (isNewSearch.trim().length() > 0) {
          if (isNewSearch.equalsIgnoreCase("true")) {
            pageInfo.setPage(1);
          }
        }
      }
      /** 获得分页集合 */
      loginLogList = this.getLoginLogManager().searchLoginLogs(logsSearch, pageInfo);

      /** 设置到属性中去 */
      this.getRequest().setAttribute("pageInfo", pageInfo);
      this.getRequest().setAttribute("loginLogList", loginLogList);
      this.getRequest().setAttribute("searchContent", logsSearch);
      this.getRequest().setAttribute("operator", searchOperator);
      this.getRequest().setAttribute("eventType", searchEventType);
      this.getRequest().setAttribute("startLogDate", searchStartLogDate);
      this.getRequest().setAttribute("endLogDate", searchEndLogDate);

      this.getRequest()
          .setAttribute(
              "actionName",
              "searchLoginLogs."
                  + Global.ACTION_EXT
                  + "?operator="
                  + StringUtils.trimWhitespace(searchOperator)
                  + "&eventType="
                  + StringUtils.trimWhitespace(searchEventType)
                  + "&startLogDate="
                  + StringUtils.trimWhitespace(searchStartLogDate)
                  + "&endLogDate="
                  + StringUtils.trimWhitespace(searchEndLogDate));

      /** 记录日志 */
      LogsApplication appLog = new LogsApplication();
      appLog.setOperator(this.getUserSessionInfo().getName());
      appLog.setLogDate(new Date());
      appLog.setEventType("搜索登陆日志");
      appLog.setContent("操作员[" + this.getUserSessionInfo().getName() + "]" + "搜索登陆日志!");
      appLog.setPriority(LogsApplication.NORMAL);
      appLog.setIpAddress(this.getUserSessionInfo().getIpAddress());
      this.appLogManager.saveOrUpdateAppLog(appLog);

      return SUCCESS;
    } catch (Exception e) {

      /** 记录日志 */
      LogsApplication appLog = new LogsApplication();
      appLog.setOperator(this.getUserSessionInfo().getName());
      appLog.setLogDate(new Date());
      appLog.setEventType("搜索登陆日志异常");
      appLog.setContent(
          "操作员["
              + this.getUserSessionInfo().getName()
              + "]"
              + "搜索登陆日志出现异常,异常信息:["
              + e.getMessage()
              + "]!");
      appLog.setPriority(LogsApplication.EXCEPTION);
      appLog.setIpAddress(this.getUserSessionInfo().getIpAddress());
      this.appLogManager.saveOrUpdateAppLog(appLog);

      /** 输出错误信息 */
      logger.error(e.getMessage());
      e.printStackTrace();

      return ERROR;
    }
  }