#36939: feat(roles): add DELETE /v1/roles/{roleId} for role deletion - #37042
#36939: feat(roles): add DELETE /v1/roles/{roleId} for role deletion#37042hassandotcms wants to merge 4 commits into
Conversation
…eparent * New v1 REST endpoint replacing DWR RoleAjax#updateRole for the Angular Roles & Tools portlet (epic #36909): updates name, key, description, can-grant flags and parent; null parentRoleId reparents to root (DWR parity) * Guards: 404 missing role/parent, 403 system/locked roles, 400 invalid name and reparent cycles (net-new corruption guard), 409 duplicate key/name * Auth: backend user + roles portlet + CMS admin, shared gate extracted and reused by POST /v1/roles (behavior unchanged, regression-tested) * RoleHelper promoted to @ApplicationScoped CDI with the update logic under @WrapInTransaction; response reuses RoleView/ResponseEntityRoleDetailView (same shape as GET /v1/roles/{roleid}) * 15 integration tests (TDD red->green), registered in MainSuite3a * Regenerated openapi.yaml
…th a test * OpenAPI description now spells out that PUT overwrites every field: omitted booleans reset to false, omitted roleKey/description are cleared, omitted parentRoleId reparents to root (DWR parity) * New IT testUpdateRole_fullReplace_omittedFieldsAreReset pins the contract so drift to merge/PATCH semantics is a deliberate, test-breaking change * Addresses claude[bot] review finding on PR #37012
Cascading delete (legacy RoleAPIImpl.delete parity): removes the role from all users, strips its permissions, detaches its layouts. Blocks only where legacy blocks: children (409), workflow-action Assign To references (409, pre-checked because delete() re-wraps the check into a generic failure), system/locked roles (403). Response reports usersAffected as the cascade blast radius via a new typed RoleDeletionView.
|
Claude finished @hassandotcms's task in 2m 38s —— View job Code Review — DELETE /v1/roles/{roleId}Reviewed the delete path end-to-end: This is a clean, well-tested change. Cascade parity is correctly preserved, the auth gate is appropriately tightened, exception→HTTP mapping is all in place ( New Issues
Notes (non-issues, for confirmation)
No blocking issues. The two Medium items are worth a look but do not block merge. • |
Adds
DELETE /v1/roles/{roleId}, replacing DWRRoleAjax#deleteRolefor the Angular portlet rewrite (#36909).Delete cascades, same as legacy
RoleAPIImpl.delete: role removed from all users, permissions deleted, layouts detached. Cascading (rather than the 409-on-users the issue suggested) keeps legacy behavior intact; the blast radius is returned asusersAffected(direct assignments) so the FE can warn before calling (#36930). Returns{deleted, roleId, usersAffected}.Blocks: children → 409, workflow-action Assign To reference → 409 (pre-checked; inside
delete()it degrades to a generic error), system/locked → 403. Auth: backend user + roles portlet + CMS admin (legacy gated on users-portlet only; tightened since this is destructive and token-scriptable — DWR path untouched until Dojo removal).Testing
10 new ITs in
RoleResourceIntegrationTest, 26/26 green: happy path, cascade pinned (user/permission/layout rows verified gone), both 409s, 403 system/locked, 404, 401, both auth 403s.resolved #36939