Exemple #1
0
  /**
   * 进入权限授予页面
   *
   * @return
   */
  public String grantPage() {
    List<Role> roles = roleManager.findAllByDf();
    if (partitionId != null && !"".equals(partitionId)) {
      String roleIdsByPartition = "";
      List<Role> rolesByPartition = roleManager.findAllByDf("partitionId", partitionId);
      for (Role r : rolesByPartition) {
        roleIdsByPartition += r.getId() + "|";
        getRequest().setAttribute("roleIdsByPartition", roleIdsByPartition);
      }
    }

    String roleEd = "";

    for (Role role : user.getRoles()) {
      if (role != null) {
        roleEd = roleEd + "," + role.getId();
      }
    }

    getRequest().setAttribute("roles", roles);
    getRequest().setAttribute("roleEd", roleEd);
    return GRANT_ROLE_PAGE;
  }
  // 设置管理员
  public String grantAdministrator() {
    if (this.selectedUserIds != null && !this.selectedUserIds.equals("")) {
      Set<User> users = new HashSet<User>(0);
      String[] ids = this.selectedUserIds.split(",");
      for (String id : ids) {
        User user = this.userManager.getById(id);

        users.add(user);

        // 给用户绑定分区管理员角色
        Role role = this.roleManager.findByDf("code", "Partition_admin");
        Set<Role> roles = user.getRoles();
        roles.add(role);
        user.setRoles(roles);
        this.userManager.update(user);
      }
      //			this.partition.setUsers(users);
    } else {
      //			this.partition.setUsers(null);
    }

    this.partitionManager.update(partition);
    return CLOSE_DIALOG;
  }