Ejemplo n.º 1
0
  public static long[] filterVocabularyIds(
      PermissionChecker permissionChecker, long[] vocabularyIds) throws PortalException {

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

    for (long vocabularyId : vocabularyIds) {
      if (AssetVocabularyPermission.contains(permissionChecker, vocabularyId, ActionKeys.VIEW)) {

        viewableVocabularyIds.add(vocabularyId);
      }
    }

    return ArrayUtil.toArray(viewableVocabularyIds.toArray(new Long[viewableVocabularyIds.size()]));
  }
  /** @deprecated As of 7.0.0, with no direct replacement */
  @Deprecated
  protected List<AssetVocabulary> filterVocabularies(List<AssetVocabulary> vocabularies)
      throws PortalException {

    PermissionChecker permissionChecker = getPermissionChecker();

    vocabularies = ListUtil.copy(vocabularies);

    Iterator<AssetVocabulary> itr = vocabularies.iterator();

    while (itr.hasNext()) {
      AssetVocabulary vocabulary = itr.next();

      if (!AssetVocabularyPermission.contains(permissionChecker, vocabulary, ActionKeys.VIEW)) {

        itr.remove();
      }
    }

    return vocabularies;
  }