/* * * (non-Javadoc) * * @see com.opensymphony.xwork.ActionSupport#execute() */ public String execute() { User userVO = null; String[] items = null; try { /** 验证请求的属性是否完整,防止知道URL非法请求----开始 */ items = this.getRequest().getParameterValues("items"); if (items == null) { /** 记录日志 */ 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; } else { if (items.length <= 0) { /** 每个属性都有内容表示正常 */ /** 记录日志 */ 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; } } /** 验证请求的属性是否完整----结束 */ Integer[] temp = null; temp = new Integer[items.length]; for (int i = 0; i < items.length; i++) { /** 获取用户对象 */ userVO = this.getUserManager() .getUserById( NumberUtils.parseNumber(StringUtils.trimWhitespace(items[i]), Integer.class)); if (userVO == null) { return "emptyUser"; } if (userVO.getId() == 1) { return "noDelUser"; } temp[i] = (Integer) NumberUtils.parseNumber(StringUtils.trimWhitespace(items[i]), Integer.class); } /** 删除一组用户 */ this.getUserManager().removeUserByIds(temp); /** 记录日志 */ 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; } }