/*
   *
   * (non-Javadoc)
   *
   * @see com.opensymphony.xwork.ActionSupport#execute()
   */
  public String execute() {
    User userVO = null;
    try {

      /** 验证请求的属性是否完整,防止知道URL非法请求----开始 */
      String userId = this.getRequest().getParameter("userId");
      String name = this.getRequest().getParameter("name");
      String password = this.getRequest().getParameter("password");
      String mailAddress = this.getRequest().getParameter("mailAddress");
      String mobileNumber = this.getRequest().getParameter("mobileNumber");
      String pageSize = this.getRequest().getParameter("pageSize");

      if (StringUtils.hasText(userId)
          && StringUtils.hasText(name)
          && StringUtils.hasText(password)
          && StringUtils.hasText(mailAddress)
          && StringUtils.hasText(mobileNumber)
          && StringUtils.hasText(pageSize)) {
        try {
          NumberUtils.parseNumber(userId, Integer.class);
          NumberUtils.parseNumber(pageSize, 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();

          return INPUT;
        }
        /** 每个属性都有内容表示正常 */
      } else {
        /** 记录日志 */
        LogsApplication appLog = new LogsApplication();
        appLog.setOperator(this.getUserSessionInfo().getName());
        appLog.setLogDate(new Date());
        appLog.setEventType("修改用户自身信息异常");
        appLog.setContent(
            "操作员["
                + this.getUserSessionInfo().getName()
                + "]"
                + "修改用户自身信息出现异常,异常信息:["
                + "必填属性值有空值"
                + "]!");
        appLog.setPriority(LogsApplication.EXCEPTION);
        appLog.setIpAddress(this.getUserSessionInfo().getIpAddress());
        this.appLogManager.saveOrUpdateAppLog(appLog);

        /** 输出错误信息 */
        logger.error("必填属性值有空值");

        /** 有空值的属性,返回 */
        return INPUT;
      }

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

      // 通过identifier获得User对象。
      userVO =
          this.getUserManager()
              .getUserById(
                  NumberUtils.parseNumber(StringUtils.trimWhitespace(userId), Integer.class));
      if (userVO == null) {
        return "emptyUser";
      }

      /** 验证用户是否存在 */
      if (!StringUtils.trimWhitespace(userVO.getName()).equals(StringUtils.trimWhitespace(name))) {
        if (this.getUserManager().getUserByUserName(StringUtils.trimWhitespace(name)) != null) {
          return "existUser";
        }
      }

      // 设置属性。
      userVO.setName(name);
      userVO.setMailAddress(mailAddress);
      userVO.setMobileNumber(mobileNumber);
      userVO.setPageSize(new Integer(pageSize));
      userVO.setPassword(password);
      this.getUserManager().saveOrUpdateUser(userVO);

      /** 记录日志 */
      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;
    }
  }