コード例 #1
0
  public static boolean contains(
      PermissionChecker permissionChecker, WikiPage page, String actionId) {

    if (actionId.equals(ActionKeys.VIEW)) {
      WikiPage redirectPage = page.getRedirectPage();

      if (redirectPage != null) {
        page = redirectPage;
      }
    }

    if (page.isPending()) {
      Boolean hasPermission =
          WorkflowPermissionUtil.hasPermission(
              permissionChecker,
              page.getGroupId(),
              WikiPage.class.getName(),
              page.getResourcePrimKey(),
              actionId);

      if (hasPermission != null) {
        return hasPermission.booleanValue();
      }
    }

    if (page.isDraft()
        && actionId.equals(ActionKeys.DELETE)
        && (page.getStatusByUserId() == permissionChecker.getUserId())) {

      return true;
    }

    if (permissionChecker.hasOwnerPermission(
        page.getCompanyId(),
        WikiPage.class.getName(),
        page.getResourcePrimKey(),
        page.getUserId(),
        actionId)) {

      return true;
    }

    if (PropsValues.PERMISSIONS_VIEW_DYNAMIC_INHERITANCE) {
      WikiPage parentPage = page.getParentPage();

      if ((parentPage != null) && !contains(permissionChecker, parentPage, ActionKeys.VIEW)) {

        return false;
      }
    }

    return permissionChecker.hasPermission(
        page.getGroupId(), WikiPage.class.getName(), page.getResourcePrimKey(), actionId);
  }
コード例 #2
0
  public static boolean contains(
      PermissionChecker permissionChecker, WikiPage page, String actionId) {

    Boolean hasPermission =
        StagingPermissionUtil.hasPermission(
            permissionChecker,
            page.getGroupId(),
            WikiPage.class.getName(),
            page.getPageId(),
            PortletKeys.WIKI,
            actionId);

    if (hasPermission != null) {
      return hasPermission.booleanValue();
    }

    if (page.isDraft()) {
      if (actionId.equals(ActionKeys.VIEW)
          && !contains(permissionChecker, page, ActionKeys.UPDATE)) {

        return false;
      }

      if (actionId.equals(ActionKeys.DELETE)
          && (page.getStatusByUserId() == permissionChecker.getUserId())) {

        return true;
      }
    } else if (page.isPending()) {
      hasPermission =
          WorkflowPermissionUtil.hasPermission(
              permissionChecker,
              page.getGroupId(),
              WikiPage.class.getName(),
              page.getResourcePrimKey(),
              actionId);

      if ((hasPermission != null) && hasPermission.booleanValue()) {
        return true;
      }
    } else if (page.isScheduled()) {
      if (actionId.equals(ActionKeys.VIEW)
          && !contains(permissionChecker, page, ActionKeys.UPDATE)) {

        return false;
      }
    }

    if (actionId.equals(ActionKeys.VIEW)) {
      WikiPage redirectPage = page.fetchRedirectPage();

      if (redirectPage != null) {
        page = redirectPage;
      }

      if (PropsValues.PERMISSIONS_VIEW_DYNAMIC_INHERITANCE) {
        WikiNode node = page.getNode();

        if (!WikiNodePermission.contains(permissionChecker, node, actionId)) {

          return false;
        }

        while (page != null) {
          if (!_hasPermission(permissionChecker, page, actionId)) {
            return false;
          }

          page = page.fetchParentPage();
        }

        return true;
      }
    }

    return _hasPermission(permissionChecker, page, actionId);
  }