示例#1
0
  /**
   * Do input verification and setup the role list
   *
   * @return status code from webwork
   * @throws Exception Exception
   */
  public String execute() throws Exception {

    if (userId == null) {
      addFieldError("userId", "userId is required");
      return INPUT;
    }

    this.userRoles = adminRolesService.getAllRoles(userId);

    return SUCCESS;
  }
示例#2
0
  /**
   * Assign the roles passed in through the form submit
   *
   * @return status code from webwork
   * @throws Exception
   */
  public String assignRoles() throws Exception {

    if (userId == null) {
      addFieldError("userId", "userId is required");
      return INPUT;
    }

    // Revoke all roles and then reassign them
    this.adminRolesService.revokeAllRoles(userId);

    if (this.roleIDs != null) {
      for (Long roleID : roleIDs) {
        this.adminRolesService.grantRole(userId, roleID);
      }
    }

    this.userRoles = adminRolesService.getAllRoles(userId);

    addActionMessage("Roles Updated Successfully");

    return SUCCESS;
  }