/**
   * grant permission to the role
   *
   * @param roleData
   * @throws Exception
   */
  private void grantPermissionToRole(RoleData roleData) throws Exception {
    String permission = null;

    RegistryNode regNode = regResourceNode.getConnectionInfo();
    ResourceAdmin resourceAdmin = regNode.getResourceAdmin();
    if (roleData.isReadPerm()) {
      permission = BaseConstants.READ;
      resourceAdmin.setPermissionPerResource(
          regResourceNode.getRegistryResourcePath(), permission, roleData.role, "1");
    }

    if (roleData.isWritePerm()) {
      permission = BaseConstants.WRITE;
      resourceAdmin.setPermissionPerResource(
          regResourceNode.getRegistryResourcePath(), permission, roleData.role, "1");
    }

    if (roleData.isDeletePerm()) {
      permission = BaseConstants.DELETE;
      resourceAdmin.setPermissionPerResource(
          regResourceNode.getRegistryResourcePath(), permission, roleData.role, "1");
    }
    if (roleData.isAuthPerm()) {
      permission = BaseConstants.AUTHORIZE;
      resourceAdmin.setPermissionPerResource(
          regResourceNode.getRegistryResourcePath(), permission, roleData.role, "1");
    }
  }
  /**
   * load data for table
   *
   * @throws RemoteException
   * @throws Exception
   */
  public void loadData() throws RemoteException, Exception {
    ResourceAdmin rsAd = regResourceNode.getConnectionInfo().getResourceAdmin();
    ArrayList<Role> resourceInfo =
        rsAd.getPermissionPerResource(regResourceNode.getRegistryResourcePath());
    ArrayList<String> string = new ArrayList<String>();
    string.addAll(
        Arrays.asList(
            regResourceNode
                .getConnectionInfo()
                .getUserManagerContent()
                .getUserManager()
                .getRoles("*")));

    table.removeAll();
    Map<String, Role> rolePermissionMap = getRolePermissionMap(resourceInfo);
    for (String roleName : string) {
      if (roleName.equals("admin")) {
        continue;
      }
      TableItem tableItem = null;
      RoleData roleData = null;
      if (rolePermissionMap.containsKey(roleName)) {
        Role role = rolePermissionMap.get(roleName);
        ArrayList<String> permissionListPerRole = role.getAssignedPermission();
        roleData = getRoleData(role.getRole(), regResourceNode.getRegistryResourcePath());

        tableItem = new TableItem(table, SWT.NULL);
        for (int j = 0; j < permissionListPerRole.size(); j++) {
          if (permissionListPerRole.get(j).equals(BaseConstants.READ)) {
            roleData.setReadPerm(true);
          }
          if (permissionListPerRole.get(j).equals(BaseConstants.WRITE)) {
            roleData.setWritePerm(true);
          }
          if (permissionListPerRole.get(j).equals(BaseConstants.DELETE)) {
            roleData.setDeletePerm(true);
          }
          if (permissionListPerRole.get(j).equals(BaseConstants.AUTHORIZE)) {
            roleData.setAuthPerm(true);
          }
        }
      } else {
        roleData = getRoleData(roleName, regResourceNode.getRegistryResourcePath());
        tableItem = new TableItem(table, SWT.NULL);
      }
      tableItem.setText(roleData.role);
      createTable(tableItem, roleData);
    }
    //		for (int i = 0; i < resourceInfo.size(); i++) {
    //
    //			string.remove(resourceInfo.get(i).getRole());
    //
    //			ArrayList<String> permissionListPerRole = resourceInfo.get(i).getAssignedPermission();
    //			RoleData roleData = getRoleData(resourceInfo.get(i).getRole(),
    //											regResourceNode.getRegistryResourcePath());
    //
    //			TableItem tableItem = new TableItem(table, SWT.NULL);
    //			tableItem.setText(resourceInfo.get(i).getRole());
    //			for (int j = 0; j < permissionListPerRole.size(); j++) {
    //				if (permissionListPerRole.get(j).equals(BaseConstants.READ)) {
    //					roleData.setReadPerm(true);
    //				}
    //				if (permissionListPerRole.get(j).equals(BaseConstants.WRITE)) {
    //					roleData.setWritePerm(true);
    //				}
    //				if (permissionListPerRole.get(j).equals(BaseConstants.DELETE)) {
    //					roleData.setDeletePerm(true);
    //				}
    //				if (permissionListPerRole.get(j).equals(BaseConstants.AUTHORIZE)) {
    //					roleData.setAuthPerm(true);
    //				}
    //
    //			}
    //			createTable(tableItem, roleData);
    //		}
    //
    //		for (Iterator iterator = string.iterator(); iterator.hasNext();) {
    //	        String string2 = (String) iterator.next();
    //	        RoleData roleData = getRoleData(string2,
    //											regResourceNode.getRegistryResourcePath());
    //	        TableItem tableItem = new TableItem(table, SWT.NULL);
    //			tableItem.setText(string2);
    //			createTable(tableItem, roleData);
    //        }
  }