Context
The Angular Roles and Tools portlet (FE task #36930) needs a Delete Role destructive action — surfaced in the Edit Role dialog per the design. The current REST surface has no endpoint for role deletion. The only path today is DWR RoleAjax#deleteRole (dotCMS/src/main/java/com/dotmarketing/business/ajax/RoleAjax.java, ~line 450), which the Angular portlet is dropping.
Add a DELETE /v1/roles/{roleId} endpoint that surfaces the "has dependencies" failure as a structured error the FE can present clearly.
Endpoint Spec
| Field |
Value |
| HTTP |
DELETE |
| Path |
/v1/roles/{roleId} |
| Class#method |
com.dotcms.rest.api.v1.system.role.RoleResource#deleteRole (new) |
| Path param |
roleId — role ID to delete |
| Request body |
None |
| Response |
ResponseEntityRoleOperationView — { deleted: true, roleId: '...' } on success |
| Auth gates |
requiredBackendUser=true, requiredPortlet("roles"), admin check |
| OpenAPI |
@Operation annotation required; regenerated openapi.yaml committed |
Behavior
- Load the role by
roleId; 404 if not found
- Reject with 403 if
role.isSystem() or role.isLocked()
- Delegate to
RoleAPI.delete(role) (or the existing deletion path used by RoleAjax#deleteRole)
- Surface deletion failures as structured errors:
- Has children → 409 with message
message.role.delete.failed.has.children and payload { children: <count> }
- Has users assigned → 409 with message
message.role.delete.failed.has.users and payload { userCount: <count> }
- Has layouts assigned → 409 with message
message.role.delete.failed.has.layouts
- Generic dependency failure → 409 with message
message.role.delete.failed.has.dependencies
- Do NOT force-delete or cascade — dependency cleanup is the caller's responsibility
Acceptance Criteria
References
Context
The Angular Roles and Tools portlet (FE task #36930) needs a Delete Role destructive action — surfaced in the Edit Role dialog per the design. The current REST surface has no endpoint for role deletion. The only path today is DWR
RoleAjax#deleteRole(dotCMS/src/main/java/com/dotmarketing/business/ajax/RoleAjax.java, ~line 450), which the Angular portlet is dropping.Add a
DELETE /v1/roles/{roleId}endpoint that surfaces the "has dependencies" failure as a structured error the FE can present clearly.Endpoint Spec
DELETE/v1/roles/{roleId}com.dotcms.rest.api.v1.system.role.RoleResource#deleteRole(new)roleId— role ID to deleteResponseEntityRoleOperationView—{ deleted: true, roleId: '...' }on successrequiredBackendUser=true,requiredPortlet("roles"), admin check@Operationannotation required; regeneratedopenapi.yamlcommittedBehavior
roleId; 404 if not foundrole.isSystem()orrole.isLocked()RoleAPI.delete(role)(or the existing deletion path used byRoleAjax#deleteRole)message.role.delete.failed.has.childrenand payload{ children: <count> }message.role.delete.failed.has.usersand payload{ userCount: <count> }message.role.delete.failed.has.layoutsmessage.role.delete.failed.has.dependenciesAcceptance Criteria
DELETE /v1/roles/{roleId}implemented with the spec above@OperationOpenAPI doc addedswagger-maven-pluginregeneratedopenapi.yamlcommitteddeleteRoleremains functionalReferences
RoleAjax#deleteRoleindotCMS/src/main/java/com/dotmarketing/business/ajax/RoleAjax.javamessage.role.delete.failed.has.dependencies(present inLanguage.properties; additional keys may need to be added)