@Override
  public boolean hasPermission(
      PermissionChecker permissionChecker,
      String entryClassName,
      long entryClassPK,
      String actionId)
      throws Exception {

    AssetCategory category = AssetCategoryLocalServiceUtil.getCategory(entryClassPK);

    return AssetCategoryPermission.contains(permissionChecker, category, ActionKeys.VIEW);
  }
Пример #2
0
  public static long[] filterCategoryIds(PermissionChecker permissionChecker, long[] categoryIds)
      throws PortalException {

    List<Long> viewableCategoryIds = new ArrayList<>();

    for (long categoryId : categoryIds) {
      AssetCategory category = AssetCategoryLocalServiceUtil.fetchCategory(categoryId);

      if ((category != null)
          && AssetCategoryPermission.contains(permissionChecker, categoryId, ActionKeys.VIEW)) {

        viewableCategoryIds.add(categoryId);
      }
    }

    return ArrayUtil.toArray(viewableCategoryIds.toArray(new Long[viewableCategoryIds.size()]));
  }
  protected List<AssetCategory> filterCategories(List<AssetCategory> categories)
      throws PortalException {

    PermissionChecker permissionChecker = getPermissionChecker();

    categories = ListUtil.copy(categories);

    Iterator<AssetCategory> itr = categories.iterator();

    while (itr.hasNext()) {
      AssetCategory category = itr.next();

      if (!AssetCategoryPermission.contains(permissionChecker, category, ActionKeys.VIEW)) {

        itr.remove();
      }
    }

    return categories;
  }