public AssetCategory moveCategory(
      long categoryId, long parentCategoryId, long vocabularyId, ServiceContext serviceContext)
      throws PortalException, SystemException {

    AssetCategoryPermission.check(getPermissionChecker(), categoryId, ActionKeys.UPDATE);

    return assetCategoryLocalService.moveCategory(
        categoryId, parentCategoryId, vocabularyId, serviceContext);
  }
  @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);
  }
  public void deleteCategories(long[] categoryIds) throws PortalException, SystemException {

    PermissionChecker permissionChecker = getPermissionChecker();

    for (long categoryId : categoryIds) {
      AssetCategory category = assetCategoryPersistence.fetchByPrimaryKey(categoryId);

      if (category == null) {
        continue;
      }

      AssetCategoryPermission.check(permissionChecker, categoryId, ActionKeys.DELETE);

      assetCategoryLocalService.deleteCategory(category);
    }
  }
示例#4
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;
  }
  public AssetCategory updateCategory(
      long categoryId,
      long parentCategoryId,
      Map<Locale, String> titleMap,
      Map<Locale, String> descriptionMap,
      long vocabularyId,
      String[] categoryProperties,
      ServiceContext serviceContext)
      throws PortalException, SystemException {

    AssetCategoryPermission.check(getPermissionChecker(), categoryId, ActionKeys.UPDATE);

    return assetCategoryLocalService.updateCategory(
        getUserId(),
        categoryId,
        parentCategoryId,
        titleMap,
        descriptionMap,
        vocabularyId,
        categoryProperties,
        serviceContext);
  }
  public AssetCategory addCategory(
      long parentCategoryId,
      Map<Locale, String> titleMap,
      Map<Locale, String> descriptionMap,
      long vocabularyId,
      String[] categoryProperties,
      ServiceContext serviceContext)
      throws PortalException, SystemException {

    AssetCategoryPermission.check(
        getPermissionChecker(),
        serviceContext.getScopeGroupId(),
        parentCategoryId,
        ActionKeys.ADD_CATEGORY);

    return assetCategoryLocalService.addCategory(
        getUserId(),
        parentCategoryId,
        titleMap,
        descriptionMap,
        vocabularyId,
        categoryProperties,
        serviceContext);
  }
  public void deleteCategory(long categoryId) throws PortalException, SystemException {

    AssetCategoryPermission.check(getPermissionChecker(), categoryId, ActionKeys.DELETE);

    assetCategoryLocalService.deleteCategory(categoryId);
  }
  public AssetCategory getCategory(long categoryId) throws PortalException, SystemException {

    AssetCategoryPermission.check(getPermissionChecker(), categoryId, ActionKeys.VIEW);

    return assetCategoryLocalService.getCategory(categoryId);
  }