Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

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

Abierto Apto para principiantes
#38,353 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 2 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
75/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
java
Área
backend

Línea de trabajo

Empieza en dotCMS/src/main/java/com/dotmarketing/portlets/categories/business/CategoryAPIImpl.java, en removeAllChildren, alrededor de la línea 794; después, sigue las llamadas desde CategoriesResource y CategoryAjax. Revisa las pruebas de integración de la API de categorías y añade cobertura para un hijo que el usuario no pueda eliminar; se considera terminado cuando ese hijo se devuelve como omitido, se procesan los hijos restantes y la importación de reemplazo y el comportamiento de eliminación heredado cumplen los criterios de aceptación.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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

Lenguaje dominante
Java
Estrellas
972
Forks
489
Merge medio
2 d 15 h
PR fusionados (30 d)
199

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de dotCMS/core

Todos los issues de dotCMS/core

Issues similares

Más issues de Java

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.