Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

CategoryAPIImpl.removeAllChildren throws UnsupportedOperationException when a child category can't be deleted

オープン 初心者向け
#38,353 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
75/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
java
領域
backend

調査の方向性

dotCMS/src/main/java/com/dotmarketing/portlets/categories/business/CategoryAPIImpl.javaの794行目付近にあるremoveAllChildrenから始め、次にCategoriesResourceとCategoryAjaxに記載された呼び出し元をたどってください。カテゴリAPIの統合テストを確認し、ユーザーが削除できない子のテストを追加してください。その子がスキップされたものとして返され、残りの子が処理され、置換インポートとレガシー削除動作が受け入れ基準を満たせば完了です。

索引モデルが issue の本文から書いたものです。

説明

OKR : Customer Support Team : Maintenance Type : Defect
Problem Statement

CategoryAPIImpl.removeAllChildren (dotCMS/src/main/java/com/dotmarketing/portlets/categories/business/CategoryAPIImpl.java, around line 794) is meant to delete every child of a category and return the ones it could not delete. The list it returns is created unmodifiable:

final List<Category> unableToDelete = Collections.unmodifiableList(new ArrayList<>());
...
} catch (final DotDataException | DotSecurityException e) {
    ...
    unableToDelete.add(category);   // throws UnsupportedOperationException
}

So as soon as one child cannot be deleted (for example, the user does not have EDIT on that child), add throws UnsupportedOperationException. The exception leaves the loop, the remaining children are not processed, and the caller gets an error instead of the list of skipped children.

Callers:

  • CategoriesResource import (POST /api/v1/categories/_import) with exportType=replace and a contextInode, used by the Categories portlet's import in "replace" mode inside a parent category. The import stops before addOrUpdateCategory runs, so the user can be left with some children deleted, the rest still there, and nothing imported (depending on whether the earlier deletes are rolled back; not verified).
  • CategoryAjax.deleteCategories(contextInode) and CategoryAjax import (legacy categories screen).

Impact: only when at least one child cannot be deleted by the current user. Nothing is deleted that the user is not allowed to delete; the operation just fails partway instead of reporting the skipped children.

Steps to Reproduce
  1. As admin, create category Parent with children A, B and C.
  2. Create a back-end user with EDIT on Parent, A and C, but only READ on B.
  3. As that user, open Settings > Categories, go into Parent, and import a CSV in "replace" mode.
  4. Actual: the request fails with a server error; the log shows UnsupportedOperationException from CategoryAPIImpl.removeAllChildren. Children after B in the loop are not deleted and the CSV is not imported.
  5. Expected: A and C are deleted, B is reported as not deleted, and the CSV is imported.
Acceptance Criteria
  • removeAllChildren returns the children it could not delete instead of throwing, and keeps processing the remaining children.
  • A "replace" import inside a parent category reports the children it could not delete and still imports the file.
  • CategoryAjax.deleteCategories(contextInode) returns SOME_CATEGORIES_DELETED in the same situation.
  • An integration test covers removeAllChildren with one child the user cannot delete.
dotCMS Version

Latest from main branch

Severity

Medium - Some functionality impacted

Links

NA

主要言語
Java
スター
972
フォーク
489
平均マージ
2日 15時間
マージ済み PR(30日)
199

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

dotCMS/core のほかの issue

dotCMS/core の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。