Skip to content

Content Drive: bulk folder delete, async job endpoint and frontend wiring #37063

Closed

Description

@zJaaal

Description

Bulk folder delete over a Content Drive multi-select, end to end: the asynchronous backend endpoint and the Content Drive wiring that drives it. One ticket, one operation, one deliverable — multi-select delete works in the product when this closes.

Re-split 2026-09-14. This ticket previously carried the frontend wiring for all three folder operations (move, copy, bulk delete), with their backends on #37062 and #37165. The three tickets are now one per operation, each carrying its own backend and frontend, so each can be handed to one developer and finished without waiting on a sibling. No design decision changed — bulk delete is still an async job for the reasons recorded below. Copy is now #37062, move is #37165.

Single-folder delete is already done and is not part of this ticket. It shipped on #35161 as a Delete Folder context menu item over POST /api/v1/assets/folders/_delete (WebAssetResource.java:314), which takes one assetPath (AbstractFolderDeletionRequestForm:24) and needed no backend work. That endpoint and its form are left exactly as they are. What this ticket adds is the multi-select path, as a sibling bulk endpoint — the precedent workflow already sets with .../bulk/fire beside the single fire.

Why this cannot be a synchronous REST call

Delete is a single unbounded transaction over a recursive walk:

Entry point What runs inside that one transaction
FolderAPIImpl.delete @WrapInTransaction (FolderAPIImpl.java:427) recursive delete of children at :472

Deleting a folder holding thousands of assets holds one long transaction and times out at the proxy, and a multi-select multiplies it by the size of the selection. An earlier version of this work proposed a synchronous endpoint and designed around the expected timeout. Designing around an expected timeout is an async design with none of the machinery, so it is built as one.

Per-folder child lists are also loaded whole rather than paged, so peak memory is bounded by the widest single folder, not by the subtree. That is survivable; the transaction is the part that is not.

The job-queue framework already exists

No new infrastructure. com.dotcms.jobs.business is complete and Postgres-backed: JobProcessor, @Queue, Cancellable, ProgressTracker, retry policies, PostgresJobQueue, AbandonedJobDetector, RealTimeJobMonitor.

JobQueueResource (/v1/jobs) already exposes everything the caller needs after submission:

  • GET /v1/jobs/{jobId}/status
  • POST /v1/jobs/{jobId}/cancel
  • GET /v1/jobs/{jobId}/monitor, an SSE EventOutput
  • paginated active / completed / successful / failed / canceled / abandoned

Closest precedents to copy: CleanAssetsJobProcessor and FixAssetsJobProcessor (@Queue + Cancellable + AtomicBoolean cancel flag + progress reported only when the rounded percentage changes + a summary in getResultMetadata). ImportContentletsProcessor is the older precedent.


Backend

Proposed contract

A domain endpoint that enqueues and returns immediately, following the _import precedent of a domain resource wrapping the job queue rather than making callers post to the generic /v1/jobs/{queueName}:

POST /api/v1/assets/folders/_bulkdelete   -> 202, queue "folderBulkDelete"
{ "assetPaths": ["//demo.dotcms.com/old-a/", "//demo.dotcms.com/old-b/"] }

Answers 202 with the job handle:

{ "entity": { "jobId": "e6d9bae8-657b-4e2f-8524-c0222db66355", "statusUrl": "/api/v1/jobs/e6d9bae8-.../status" } }

Validation that can be done at submission time still uses status codes: a malformed body is 400 before a job is created. Per-path outcomes are the job's business.

Pieces to build, all following patterns already in WebAssetResource:

Piece Follow
Immutable request form AbstractFolderDeletionRequestForm: @Value.Immutable, @JsonSerialize/@JsonDeserialize, @Schema with RequiredMode.REQUIRED and examples
Path to folder resolution folders/_delete (WebAssetResource.java:314) resolves a single assetPath; do the same per entry
Permission gate WebResource.InitBuilder as in deleteFolder
OpenAPI @Operation annotations, then regenerate openapi.yaml

Per-path results move into the job result, they do not disappear

JobProcessor.getResultMetadata(Job) returns Map<String, Object>, so the per-path contract survives verbatim, just relocated out of a synchronous response body:

{
  "successCount": 3,
  "failCount": 2,
  "results": [
    { "path": "//demo.dotcms.com/old-a/", "success": true },
    { "path": "//demo.dotcms.com/old-b/", "success": false, "error": "PERMISSION_DENIED", "message": "..." }
  ]
}

Each source folder is its own transaction, so one failure does not roll back the folders already deleted. This shape is shared with #37062 and #37165 — the three must not diverge.

The real work is chunking, not the endpoint

Wrapping this in a job does not by itself fix the transaction. A job holding one 40-minute transaction is still one 40-minute transaction; it just stops timing out at the proxy. Meaningful progress, working cancellation and bounded memory all require chunking inside the recursion, which means changing FolderFactoryImpl, not only adding a JobProcessor. Estimate this ticket on that, not on the endpoint.

Cancellation semantics, and why delete's differ from copy's

A partially deleted tree is unrecoverable. So unlike copy, cancellation is honoured only between top-level source folders, never mid-subtree: a cancelled bulk delete leaves each source either fully deleted or untouched. Two jobs deleting overlapping subtrees must not run concurrently; the second submission is rejected with a readable reason rather than queued.


Frontend

Content Drive's action center operates on contentlets. Folders are selectable in the table but cannot be deleted in bulk. This is the wiring.

The job-progress primitive comes from #37166

Nothing in core-web calls /v1/jobs today, so a reusable primitive has to be built. #37166 (bulk file upload) owns it, because #32356 asks for the richer version (per-file progress and per-file cancel) and a primitive that satisfies upload satisfies the folder actions too. This ticket consumes it. Whichever of #37062 / #37063 / #37165 / #37166 lands first builds it to #37166's stated requirements and the rest reuse it unchanged — do not build it four times.

The flow: submit and get a jobId, follow the job, render progress, handle the terminal state, then report the result and refresh.

Following the job has two options and the cheap one is available:

  • GET /v1/jobs/{jobId}/monitor is an SSE EventOutput, and because it is a GET, native EventSource works with no shim. Worth stating explicitly: dot-content-drive-action-center.component.ts:126 records that the legacy _bulkfire SSE path was skipped precisely because "native EventSource cannot POST a body". That objection does not apply here — submission is a normal POST returning a jobId, monitoring is a separate GET.
  • GET /v1/jobs/{jobId}/status polling is the fallback if SSE proves awkward behind the proxy.

Things the primitive has to get right, which are easy to miss:

  • A job outlives the component. Navigating away, or closing the dialog, does not cancel it. Either the outcome stays discoverable when the user comes back, or the UI must say plainly that it will not be. Do not silently lose a running job's result.
  • Cancellation is exposed over POST /v1/jobs/{jobId}/cancel, with delete's wording: cancelling leaves each source folder either fully deleted or untouched. This is a different promise from copy's, and the confirmation copy must match the action that is actually running.

Delete is recursive and permanent, and the confirmation has to say so

The confirmation is the last thing standing between a user and an unrecoverable operation. It has to state plainly that the selected folders and everything inside them are permanently deleted. Deleting a folder deletes its contents with it, with no workflow action fired on those contents.

Bulk means per-path results, not a boolean

The toast must report the server's counts, not the selection size — the same rule the existing quick actions follow. A per-folder failure has to name the folder and say why: permission, unresolvable path, in-use.

Acceptance Criteria

Submission

  • POST /api/v1/assets/folders/_bulkdelete accepts several assetPaths, enqueues a folderBulkDelete job and returns 202 with jobId and statusUrl
  • An immutable request form follows the AbstractFolderDeletionRequestForm pattern, with @Schema descriptions and examples on every property
  • The shipped single _delete endpoint and its form are untouched
  • A malformed body returns 400 before any job is created
  • A caller with no rights to enqueue gets 403 at submission

Job execution

  • The processor is @Queue-annotated, implements Cancellable, and reports progress through Job#progressTracker() only when the rounded percentage changes
  • Each source folder runs in its own transaction; a failure on one does not roll back sources already completed nor abort the remaining ones
  • The recursion is chunked so that a folder with tens of thousands of descendants does not run in a single transaction and does not hold the whole subtree in memory
  • getResultMetadata returns successCount, failCount and a per-path results array; every failure carries a machine-readable error and a human-readable message
  • A per-path permission failure is reported per path
  • An unresolvable path is a per-path failure, not a request-level error
  • Cancelling a bulk delete leaves each source folder either fully deleted or untouched, never partially deleted, and the job result records where it stopped
  • A submission overlapping an in-flight job's subtree is rejected with a readable reason rather than queued

Frontend

Docs and tests

  • The @Operation description states that the operation is asynchronous, that the delete is recursive and permanent, names the folderBulkDelete queue, and points at the /v1/jobs/{jobId} status, cancel and monitor endpoints
  • openapi.yaml regenerated from the annotations and committed alongside the Java changes
  • Integration tests cover: happy path over several folders, mixed partial failure, permission denied, unresolvable path, cancellation between sources, and a subtree large enough to exercise more than one chunk
  • Jest specs cover: progress updates, success, partial failure, job failure, cancellation, permission-denied, and teardown while a job is in flight

Priority

Medium

Additional Context

History of the decisions on this ticket, so they are not relitigated.

Add to bundle is not here. It moved to #35161, which covers the folder push publish family: push publish, add to bundle and push history, across the context menu and the Action Center. All of them resolve folder ids through PublisherAPIImpl.java:251-257 and enforce PERMISSION_PUBLISH the same way, so none of them need backend work.

Publish all was dropped as unsupported and is not being carried forward. Recording the analysis so nobody re-adds it on the strength of it:

  • the approach previously advocated was PUT /api/v1/workflow/contentlet/actions/bulk/fire with a Lucene query (+conFolder:<folderInode>) in place of contentletIds, since FireBulkActionsForm.java:18 accepts one
  • it also had a real gap: menu links are not contentlets and would not be covered by a query-based fire
  • the obvious alternative is worse. PublishFactory.publishAsset(Folder, ...) (PublishFactory.java:206) publishes contentlets directly and bypasses workflow schemes entirely

So the decision is not "too hard to implement", it is that folder-level publish-all is not a supported operation. Anything under a folder can still be published by selecting it and firing a workflow action, which is the path that respects schemes.

Related: #37062 (folder copy, end to end — same job-result contract), #37165 (folder move, end to end), #37166 (owns the job-progress primitive this ticket consumes), #35161 (single-folder delete, shipped; and the folder push publish family), #33468 (move/copy destination picker UX), #36448 (Add to Bundle toolbar action), #32302 (folder CRUD backend), #36046 (bulk delete/download endpoints for publishing), #33999 (parent epic).

Activity

  1. changed the title [-]Content Drive: folder-level actions — copy, move, publish all, add to bundle[/-] [+]Content Drive: folder-level actions (copy, move, publish all, add to bundle)[/+] on Aug 14, 2026
  2. added theissue type on Aug 14, 2026
  3. moved this from New to Current Sprint Backlog in dotCMS - Product Planningon Aug 14, 2026
  4. changed the title [-]Content Drive: folder-level actions (copy, move, publish all, add to bundle)[/-] [+][TASK] Content Drive: wire folder copy and move (blocked on #37062)[/+] on Aug 20, 2026
  5. changed the title [-][TASK] Content Drive: wire folder copy and move (blocked on #37062)[/-] [+]Content Drive: folder-level actions (copy and move)[/+] on Aug 20, 2026
  6. changed the title [-]Content Drive: folder-level actions (copy and move)[/-] [+]Content Drive: wire folder copy, move and delete[/+] on Aug 20, 2026
  7. changed the title [-]Content Drive: wire folder copy, move and delete[/-] [+]Content Drive: wire folder copy, move and bulk delete[/+] on Aug 20, 2026
  8. changed the title [-]Content Drive: wire folder copy, move and bulk delete[/-] [+]Content Drive: wire folder move, copy and bulk delete[/+] on Aug 24, 2026
  9. zJaaal commented on Aug 24, 2026

    @zJaaal
    MemberAuthor

    Retitled and rewritten (2026-08-24) to follow the backend restructure: move is now synchronous (#37165), copy and bulk delete are jobs (#37062). Adds the core-web job-progress primitive, which nothing in the repo has yet and which #37166 also needs.

    Analysis and edit by Claude (Claude Code), posted from @zJaaal's account.

  10. 75 remaining items

  11. dario-daza commented on Sep 28, 2026

    @dario-daza
    Member

    📝 QA note: testing bulk delete on a folder with locked content (IN_USE)

    A folder whose content is locked by another user must fail with IN_USE, and nothing
    in it may be deleted. Reproducing this needs specific users and permissions; with a
    typical admin QA account the lock is bypassed and the folder is deleted.

    The user who runs the delete must not be a CMS Administrator. dotCMS lets CMS
    Admins override any lock, so for an admin the lock check is skipped: the content is
    destroyed and the folder reports SUCCESS. That is existing dotCMS behavior, not a bug
    in this feature. The user holding the lock can be anyone other than the deleter.

    Setup

    1. Folder: create a test folder, e.g. //demo.dotcms.com/bulk-delete/, with one
      piece of content inside it (any type, e.g. Rich Text).
    2. Deleter: a Back-end User whose roles do not include CMS Administrator. Give
      its role:
      On Permissions Why
      The site View To resolve the folder path
      The folder View, Edit, Edit Permissions Deleting a folder requires both Edit and Edit Permissions on it (and on every subfolder)
      Content in the folder (inherited from the folder) View, Edit, Publish Destroying content requires Publish; the lock check requires Edit
    3. Locker: a different backend user with Edit on that content (the manual run used
      an existing Publisher user).
    4. As the locker, lock the content (open it in the editor and lock it, and leave it
      locked).

    Steps

    1. As the deleter, select the folder in Content Drive and delete it (or
      POST /api/v1/assets/folders/_bulkdelete with {"assetPaths": ["//demo.dotcms.com/bulk-delete/"]}).
    2. Wait for the job to finish and check the outcome.

    Expected result

    • The folder is reported FAILED with reason IN_USE and the message
      "Only the CMS Admin or the user who locked the contentlet can lock/unlock it".
    • The folder, the content and the lock are all still there.

    If you get something else

    Result Cause
    PERMISSION_DENIED, "does not have edit permissions on Folder" The deleter is missing Edit Permissions on the folder. The delete stops before the content (and its lock) is ever checked
    PERMISSION_DENIED, "does not have permission to destroy some or all of the contentlets" The deleter is missing Publish on the content
    SUCCESS, content deleted despite the lock The deleter is a CMS Administrator (see above)
    SUCCESS, content still exists The deleter cannot see the content: check it has the Back-end User role and View on the content. After changing permissions, reindex

    Verified manually on a local instance with this exact setup (result: IN_USE), and
    covered by FolderBulkDeleteProcessorIT.test_process_contentLockedByAnotherUser_recordedAsInUse.

  12. fabrizzio-dotCMS commented on Sep 28, 2026

    @fabrizzio-dotCMS
    Member

    QA results — bulk folder delete: ❌ Failed QA

    Caution

    Blocking: a failed bulk delete permanently loses files while reporting that nothing was deleted — #37782.

    If a folder delete fails part-way (for example, because a later subfolder lacks Edit Permissions, or because content deeper in the tree is locked), the database rolls back, but the binaries of every file the delete had already reached are gone from disk. The files keep showing in Content Drive and return 404 when opened, while the toast says the folder was not deleted. Neither the user nor the product can recover the files afterwards.

    Reproduce: use a back-end user without CMS Administrator. Create parent/a/ containing a file and parent/b/, and remove Edit Permissions on parent/b/ for that user. Then bulk-delete parent/ → the outcome is FAILED / PERMISSION_DENIED, the database is unchanged, and /parent/a/<file> returns 404.

    The root cause is in the shared FolderAPIImpl.delete (deleteBinaryFiles removes files immediately, outside the transaction), and the context-menu delete behaves the same way. But this ticket's own contract is that a failed folder is left untouched (FR-023), and the bulk delete makes this failure far more likely, since it runs over many folders at once and reports each failure as "nothing was deleted".

    Apart from that, the bulk delete works end to end and behaves as the spec describes. The copy and contract observations below are not blocking.

    Tested on dotcms/dotcms:trunk_0666682 (includes #37685 and #37688), with Postgres, Elasticsearch and a single node. Almost every case was run as a back-end user without CMS Administrator, because an admin bypasses both locks and permissions and would hide the outcomes.

    Results

    Area Case Result
    Normal delete Delete 3 folders, each with content and a file ✅ All deleted, binaries removed from disk. The toast count is the server's successCount, not the selection size. The outcome is also kept in the notifications bell
    Delete offered only when the user can delete ✅ Hidden for a folder the user can only view. With a folder + a contentlet selected, only the folder is deleted
    Single-folder context menu delete ✅ Unchanged. It shows no message on success, which is intentional since #37166
    Per-folder outcomes Mixed selection ✅ One success, one PERMISSION_DENIED, and a subfolder submitted together with its parent reported SKIPPED / COVERED_BY_PARENT. A failure never stops the other folders
    Path deleted from another tab first ✅ PATH_NOT_FOUND; the other folder is deleted
    Content locked by another user ✅ IN_USE; nothing deleted, lock kept
    Refusals Empty selection ✅ 400 EMPTY_SELECTION
    Over the maximum (API with default 50; UI with DOT_FOLDER_BULK_DELETE_MAX_PATHS=3) ✅ 400 OVER_MAX_PATHS; the UI shows "You selected more folders than one delete allows…"
    Overlapping an in-flight run (same folder or a subfolder) ✅ 409 OVERLAPPING_RUN; the message names the folder, never the other author
    Malformed body / unknown field ✅ 400
    No session / not a back-end user ⚠️ 401, not the documented 403 (see below)
    No job created on any refusal ✅
    Cancellation (API only; the UI does not expose it, per D-011) Cancel between folders ✅ The folder in progress finishes whole, later folders are SKIPPED with all content intact, and stoppedAt names the first one not reached
    Navigation and other users Navigate away and reload during a run ✅ The folder stays marked busy and the outcome arrives
    A second user watching ✅ Sees the busy marking in the grid and the tree, which clears at the end; receives no outcome
    One action at a time ✅ Workflow Center does not open while a run is in flight
    Partial permissions Content the user can see but not publish ✅ PERMISSION_DENIED, nothing deleted, binaries kept
    Content the user cannot see As specified (D-014): deleted without permission checks, and the folder reports success. The search document is left behind (#37599)
    Locked content the user cannot see As specified (D-014): deleted, ignoring the lock
    Hidden empty subfolder As specified: deleted without permission checks
    Hidden subfolder with content ⚠️ Fails and nothing is deleted, but with UNCLASSIFIED (see below)
    A later subfolder refuses the delete ❌ Data loss — #37782 (see the top of this comment)
    Volume 1k / 10k contentlets, flat and as a 20-subfolder tree ✅ ~13 ms per contentlet (10k in ~2 min), linear, structure makes no difference; no memory issues. 50k was not run
    Long run vs. abandonment (DOT_JOB_ABANDONMENT_THRESHOLD_MINUTES=2) ✅ 127 s and 135 s runs finished SUCCESS, no retries, never abandoned
    Lock at the end of a 2,000-item tree ✅ IN_USE after 26 s, full rollback
    Cancel during a 3,000-item folder ✅ The folder finishes whole; the cancel takes effect ~35 s later
    Progress indication on a single large folder Not recorded

    Findings

    1. Data loss when a delete fails part-way — #37782. See the top of this comment.

    2. The partial-result toast uses workflow wording. When a folder fails or is skipped, the counts line reads "N failed (you may not have permission, or the content is locked by another user), N skipped (this action is not on their workflow step)". For folders, "skipped" means cancelled or covered by its parent, never a workflow step, so after a cancellation the toast contradicts its own detail line ("Left untouched, because the delete was stopped before reaching them"). The folder delete result does not pass its own partialDetailKey (withActionExecution.ts:1001-1014), unlike refresh and upload.

    3. A cancelled run with nothing left to skip reads as a plain success. When the cancel lands during the last folder, the job ends CANCELED with every folder SUCCESS, and the toast is "Delete Folder ran on N item(s)", with no mention of the cancellation. FR-032 asks for a cancelled run to read differently. This is an edge case.

    4. A hidden subfolder with content fails as UNCLASSIFIED. Nothing is lost: the database trigger check_child_assets refuses to delete a folder identifier that still has children, and the whole folder rolls back. But the user only gets the generic "could not be deleted" message, with no way to tell that something they cannot see is blocking it. Note: FR-009b says the hidden subfolder is removed and its descendants are left behind. That does not happen: the trigger prevents it.

    5. The site root reports PERMISSION_DENIED instead of PROTECTED_FOLDER for a limited user. //site/ resolves to the System Folder with the user's permissions before the protected-folder check runs (FolderBulkDeleteProcessor.java:326-358). A user who cannot read the System Folder gets "does not have permission to read Folder /". An admin gets PROTECTED_FOLDER. Nothing is ever deleted either way.

    6. Not a back-end user returns 401, not 403. The acceptance criterion and @ApiResponse in FolderBulkDeleteResource document 403, but requiredBackendUser(true) answers 401 before the endpoint runs. The UI is unaffected, since Content Drive users are already back-end users.

    7. Minor UI notes. The max-paths limit is only enforced by the server: the UI asks for confirmation first, and the refusal toast does not say what the maximum is, although it is available as maxPaths in /api/v1/configuration. With a folder and a contentlet selected, "Delete Folder" deletes only the folder, and nothing tells the user that the contentlet is left out. Finally, the toast arrives ~10-30 s after confirming (queue pickup) and only in the tab that submitted the delete, while the bell always keeps the outcome.

    Side note for anyone reproducing this: content created through the REST API as admin can end up locked by admin, which makes every delete by another user fail with IN_USE. Unlock the test content first.

  13. removed their assignment
    on Sep 28, 2026
  14. zJaaal commented on Sep 28, 2026

    @zJaaal
    MemberAuthor

    @fabrizzio-dotCMS thanks for the thorough QA. Bulk folder duplicate (#37062) shares delete's toast and refusal handling in Content Drive, so three of your findings will be fixed for delete by the frontend changes going into the duplicate PR, #37761:

    • Finding 2, partial toast with workflow wording: the folder results will pass their own partialDetailKey, so "skipped" reads as covered by a selected parent folder, or not reached after a cancel, never as a workflow step. This is done for delete and duplicate together.
    • Finding 3, a cancelled run with nothing left to skip reads as a success: the toast will check the run's CANCELED state and say the run was cancelled even when every folder succeeded, as the bell notification already does.
    • Finding 7, the maximum is only enforced by the server: the UI will read maxPaths from the app configuration, refuse an oversized selection before asking for confirmation, and name the maximum in the refusal toast. The server's 400 OVER_MAX_PATHS stays the authority.

    The data loss (#37782) stays in its own ticket. The backend findings (the site root reporting PERMISSION_DENIED, the 401 documented as 403, and the hidden subfolder reported as UNCLASSIFIED) stay with this ticket.

    Reply written by Claude (Claude Code) on behalf of @zJaaal.

  15. fabrizzio-dotCMS commented on Sep 29, 2026

    @fabrizzio-dotCMS
    Member

    Closing in favor of #37782
    QA will be held in #37782

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions