Skip to content

Workflow Center: add a Refresh quick action that reindexes the selection #36845

Description

@rjvelazco

Description

Add a Refresh action to the Action Center's Quick Actions that sends every selected contentlet to be reindexed.

Unlike the other quick actions, Refresh does not depend on content state. Publish only applies to items that are not live, Delete only to archived ones — Refresh applies to the whole selection regardless of live / archived / locked status, so it is always listed whenever the selection contains at least one contentlet.

What it does. Clears the contentlet cache and reindexes the item — the same effect as the existing single-item endpoint PUT /api/v1/content/_refresh/{identifierOrInode}, which performs CacheLocator.getContentletCache().remove(identifier) followed by contentletAPI.refresh(contentlet). Useful when content is correct in the database but stale or missing in search results.

There is no bulk endpoint. Two things it must not be confused with:

  • POST /api/v1/esindex/reindex rebuilds the entire index (optionally filtered by content type). It is not a per-selection operation and must not be used here.
  • Legacy does have a batch path, but not over REST: cmd=full_reindex_list → EditContentletAction._batchReindex, which loops the inodes on a background thread.

So this needs either N calls to _refresh from the client, or a new bulk endpoint. That decision should be made before building.

Permission question to settle

The legacy equivalent of this button is not shown to everyone. view_contentlets.jsp gates it:

final boolean canReindexContentlets =
    APILocator.getRoleAPI().doesUserHaveRole(user, loadRoleByKey(Role.CMS_POWER_USER))
    || APILocator.getRoleAPI().doesUserHaveRole(user, loadCMSAdminRole());

"Always available" in this issue means not gated by content state. Whether it is additionally gated by role is a separate decision, and reindexing is an expensive operation, so matching legacy (Power User or Admin) is the conservative default. This needs an explicit answer rather than being inherited by accident.

Acceptance Criteria

Updated to match what shipped in #37131. Original wording kept wherever it still describes the
behaviour; reworded only where the implementation went somewhere the AC did not anticipate.

  • Decide whether Refresh is role-gated — decided: yes, matching legacy (CMS Power User or CMS Administrator), enforced server-side in BulkRefreshHelper.canRefresh. Deliberately not mirrored in the client: the browser knows whether the user is an admin but cannot tell whether they are a Power User, so a client-side gate would hide Refresh from exactly the users the legacy button was written for. A visible action that answers 403 beats a capability silently withheld.
  • Refresh appears in Quick Actions whenever the selection contains at least one contentlet, regardless of live / archived / locked state
  • The count shown equals the number of selected contentlets, with folders excluded
  • Executing it reindexes every selected contentlet — every version of each, not just the working one — and reports the outcome in the same toast shape as the other quick actions
  • The operation is asynchronous and the user is told so twice: a toast at trigger saying it runs in the background, and a completion toast pushed over the websocket when the job finishes. The outcome also lands in the notification bell, so it survives the user navigating away.
  • Nothing in the UI or copy suggests this triggers a full index rebuild
  • The grid refreshes after the run so the user sees the reindexed state
  • Decide client-side loop vs new bulk endpoint — decided: new bulk endpoint, POST /api/v1/content/_bulkrefresh. Permission enforced server-side; 11 integration tests and 5 Postman requests cover it.
  • Unit tests cover the always-available listing behaviour and the execute path — 24 backend unit tests, plus Content Drive store and Action Center specs on the frontend

Added during implementation, not in the original list:

  • Indexing is synchronous per version (IndexPolicy.WAIT_FOR), so a job reporting SUCCESS means the content is genuinely searchable rather than merely queued
  • The contentlet cache is evicted by inode, not identifier — an identifier-keyed eviction leaves a stale cached version to be written straight back to the index, which is the exact failure this action exists to repair
  • The submission is capped (default 500, CONTENT_BULK_REFRESH_MAX_ITEMS)
  • Firing any action clears the grid selection — not Refresh-specific, but a general change this work pulled in

Known divergence, left open deliberately:

  • The completion toast counts identifiers, not selected rows. Selecting three language versions of one contentlet reports "1 item", because the job groups inodes by identifier and reindexes all versions of each together. Accurate to the work done, potentially confusing next to the count shown at trigger. Copy decision, not a behaviour bug.

Priority

Medium

Additional Context

Endpoints in play today:

Purpose Endpoint Scope
Refresh / reindex one contentlet PUT /api/v1/content/_refresh/{identifierOrInode} (optional ?language=) single
Full index rebuild POST /api/v1/esindex/reindex whole index — not for a selection
Reindex progress GET /api/v1/esindex/reindex whole index
Legacy batch reindex cmd=full_reindex_list (Struts, not REST) batch, loops server-side

This mirrors the Lock/Unlock situation closely: existing single-item REST endpoint, a legacy Struts command that loops server-side, and no bulk REST equivalent. If a _bulkrefresh endpoint is added it would be worth designing it alongside _bulklock / _bulkunlock so the three share one request/response shape rather than each inventing its own.

The legacy button carries the label "Refresh" (view_bulk_actions_inc.jsp), so the naming here is consistent with what existing users already know.

Activity

  1. added theissue type on Jul 31, 2026
  2. changed the title [-]Content Drive Action Center: add a Refresh quick action that reindexes the selection[/-] [+]Workflow Center: add a Refresh quick action that reindexes the selection[/+] on Aug 10, 2026
  3. self-assigned this
    on Aug 19, 2026
  4. moved this from New to On Hold in dotCMS - Product Planningon Aug 19, 2026
  5. moved this from On Hold to In Progress in dotCMS - Product Planningon Aug 19, 2026
  6. github-actions commented on Aug 20, 2026

    @github-actions
    Contributor
  7. rjvelazco commented on Aug 21, 2026

    @rjvelazco
    MemberAuthor

    Decision log

    Recording the calls made while building #37131, since several went beyond what the AC anticipated.
    The AC above has been updated to match; this is the reasoning behind it.

    Role gate: yes, matching legacy

    CMS Power User or CMS Administrator, enforced in BulkRefreshHelper.canRefresh on submit. "Always
    available" in the original issue means not gated by content state, and that still holds.

    The gate is not mirrored in the client. The browser knows whether the user is an admin but has no
    way to tell whether they are a Power User, so the only client-side gate available would hide Refresh
    from exactly the users the legacy button was written for. A visible action that answers 403 is a
    better failure than a capability silently withheld from people who have it.

    New bulk endpoint, not N client calls

    POST /api/v1/content/_bulkrefresh, answering 202 with a jobId. N client calls would have made
    the browser the coordinator of a minutes-long operation, with no server-side record if the tab closed
    and no cap on the fan-out.

    Job-backed and pushed, not synchronous — and why it cannot mimic _refresh

    This was the most-revisited decision, so it is worth writing down properly.

    PUT /api/v1/content/_refresh/{identifierOrInode} returns 200 immediately, and it is tempting to
    read that as "reindexed". It is not. It calls contentletAPI.refresh, which reaches
    addContentToIndex with the default policy — and the default is DEFER
    (INDEX_POLICY_SINGLE_CONTENT, IndexPolicyProvider:33). DEFER writes a row to
    dist_reindex_journal and returns; ReindexThread does the work later. The 200 means enqueued.

    The bulk workflow fire endpoints genuinely do block — distributeWorkAndProcess waits on
    future.get() — but their per-item work is a DB write plus a deferred index write, so a hundred items
    still settle in seconds.

    This endpoint deliberately uses IndexPolicy.WAIT_FOR instead, so that a job reporting SUCCESS means
    the content is actually searchable. WAIT_FOR blocks on an Elasticsearch refresh cycle (~1s by
    default) per bulk request, and the processor issues one per version, widened further when
    includeDependencies is set. A 500-item selection is therefore minutes of real waiting — past any
    proxy or load-balancer timeout, holding a servlet thread the whole way, with the run dying if the tab
    closes. Hence the job queue, the 202, and reporting by push.

    Honest trade: a synchronous mode for small selections is perfectly feasible (run inline under some
    threshold, 202 above it, which is roughly what view_bulk_actions_inc.jsp does). Not done, because
    one response shape is simpler than two and the background path has to exist for the large case anyway.

    Not modelled as a workflow action or SystemAction

    Bulk workflow fire resolves its target set by searching the index. That is circular for an
    operation whose entire purpose is to repair the index: content missing from the index cannot be found
    by an index search, so the items that most need this are exactly the ones such a path could never
    reach.

    Reporting: two toasts, no progress, no polling

    • A toast at trigger saying the reindex runs in the background.
    • A completion toast when the BULK_REFRESH_COMPLETED system event arrives over the websocket the
      admin UI already holds open, carrying success / skipped / failed counts.
    • A notification-bell record written server-side regardless of socket delivery, so the outcome
      survives the user navigating away.

    Things tried and removed along the way, all deliberately:

    Removed Why
    SSE endpoint Dropped after PO discussion. Node affinity, and it cannot attach to a job that already finished.
    GET /_bulkrefresh/{jobId} status endpoint The client polled it every 1.5s for up to five minutes. Push replaced it.
    Live progress counters Not wanted for a first cut; the endpoint reports no intermediate progress anyway.
    "Applying Refresh to N items…" indicator An indicator that cannot update, and an Action Center lock lasting minutes, are both wrong for a backgrounded job. The trigger toast is the honest substitute.
    POST /_bulkrefresh/{jobId}/cancel Never called — the UI has no cancel control. The processor stays Cancellable, so a stuck run is still killable through the generic POST /api/v1/jobs/{jobId}/cancel.
    Client-side five-minute completion deadline It existed only to un-wedge an in-flight guard, and reported a 504 about a run it had no information about. Both removed together; a second reindex is now simply allowed.

    Also changed, beyond Refresh

    Firing any action now clears the grid selection. Previously the boxes only cleared via the
    post-run loadItems, so they stayed ticked whenever a run failed, timed out, or hit an early return
    in loadItems — in that last case permanently.

    Deliberately not done

    • includeItemResults is hardcoded false. The per-item records are implemented and reachable
      through the generic GET /api/v1/jobs/{jobId}/status, but nothing requests them, so in practice
      they are never produced. Worth removing if no consumer appears.
    • versionsIndexed is produced but unused client-side. Harmless payload weight.
    • The completion toast counts identifiers, not rows — see the open AC item above.
    • Cross-node websocket delivery is unverified. Needs two nodes to test properly; the
      notification-bell record is the fallback either way.
    • One WAIT_FOR bulk request per version. Batching all versions of an identifier into a single
      request would cut the wall-clock several-fold. Left alone as an optimisation, not a fix.
  8. 3 remaining items

  9. added
    OKR : Core Features
    Area : Frontend
    on Aug 25, 2026
  10. rjvelazco commented on Aug 25, 2026

    @rjvelazco
    MemberAuthor

    Note for QA

    The refresh is an asynchronous job; once triggered, the UI will not be blocked. This is different from the regular bulk actions that block the UI while running.

    Videos

    video.mov
    video.mov
  11. self-assigned this
    on Aug 26, 2026
  12. zJaaal commented on Aug 26, 2026

    @zJaaal
    Member

    QA: POST /api/v1/content/_bulkrefresh

    Passes. Live trunk instance (classes dated 2026-08-26, so it carries #37131), tested over HTTP with direct Elasticsearch and Postgres inspection. 41 checks, 4 findings, none blocking.

    Endpoint only. @zJaaal covered the UI separately.

    The three tests that mattered

    The endpoint's whole claim is that SUCCESS means searchable, unlike the single-item _refresh, which only enqueues. Three tests were built to break that. None did.

    1. Missing index entry. Deleted the document from both indices, confirmed search went to zero, submitted one inode.

    search +identifier:e7ceee89…   0 results
    POST _bulkrefresh              202  jobId d71acb7a…
    job status                     SUCCESS  versionsIndexed 1
    search +identifier:e7ceee89…   1 result    working + live both back
    

    Searchable the moment the job reported success, no wait on ReindexThread. WAIT_FOR does what it says.

    2. Stale cache written back to the index. Warmed the contentlet cache, then changed the row in Postgres behind dotCMS's back.

                before                       after refresh
    database    STALE-REPAIR-MARKER          (unchanged)
    cache/API   QA bulkrefresh probe  stale  STALE-REPAIR-MARKER
    index       qa bulkrefresh probe  stale  stale-repair-marker
    

    The index took database truth, not the cached copy. The inode-keyed eviction earns its comment.

    3. Every version, not just the working one. Built a contentlet with working ≠ live, wiped both documents, submitted only the live inode → versionsIndexed: 2, correct inode restored in each index.

    Findings

    F1 · The AC says Power User or Admin. It is Admin only. select role_key from cms_role where role_key ilike '%power%' returns 0 rows, so loadRoleByKey answers null and that half of canRefresh is always false. Admin-only is the intended gate, so the behaviour is right — only the AC wording and test_bulkRefresh_powerUserIsAllowed, which creates the key itself, suggest otherwise. The client now gates on isAdmin to match (shipped in #37216). Left to do: reword the AC line.

    F2 · Anonymous callers get 400 with validation detail instead of 401. BulkRefreshForm calls checkValid() from its @JsonCreator, so validation runs before init(). Not platform-wide — /api/v1/categories answers 401 here — and it contradicts the endpoint's own @ApiResponse. Leaks only the endpoint's existence and field names.

    F3 · A run where every item failed still reports state: SUCCESS. The notification gets it right (ERROR level), but GET /api/v1/jobs/{id}/status is the only programmatic read, and a caller keying on state sees green. Worth a doc line: state is the job, the counters are the outcome.

    F4 · One 400 returns text/plain. A type mismatch ({"contentletIds":"abc"}) escapes as a raw Jackson message; every other 400 is application/json. The client always sends an array, so nothing ships broken.

    Noted, no action

    Trigger vs completion count behaves exactly as the open AC item documents: two language inodes of one contentlet give submitted: 2 and total: 1. Coverage is a superset of the selection, so nothing is missed.

    Throughput is ~1 item/sec. 50 real contentlets took 58.9s — the ~1s Elasticsearch refresh cycle per WAIT_FOR request, per version, as predicted. Extrapolated, the 500 cap is 8–10 minutes with no progress and no cancel control. Vindicates the job queue; worth the PO knowing the real number.

    All 41 checks (click to expand)

    Auth — anonymous with valid body 401 · wrong password 401 · anonymous with invalid body 400 (F2) · admin 202 · non-admin refused in UI

    Validation — no body, literal null, empty array, contentletIds: null, malformed JSON, unknown field all 400 · missing/wrong Content-Type 415 · GET 405 · 500 items 202 · 501 items 400

    Reindex — missing index doc repaired in both indices · stale cache loses to db truth · working ≠ live both indexed · two language inodes collapse to one identifier · one language submitted reindexes both · duplicate inodes collapse · bogus inode fails without rejecting the batch · bogus mixed with real leaves batch intact · folder / content type / template inodes each fail per item · archived, locked and unpublished all reindex · includeDependencies and includeItemResults honoured

    Lifecycle — cancel mid-run gives CANCELED with 1 succeeded / 49 skipped and skipReason · counters always sum to total · notification level correct for success, partial, cancelled and all-failed · two concurrent submissions get distinct job ids and both finish · Postman collection registered in CI · SystemEventType and Language.properties keys present

    Still open

    • Cross-node websocket delivery of BULK_REFRESH_COMPLETED needs two nodes. Already flagged in the decision log; the notification-bell record is the fallback.
    • The Postman collection has no 401 or 403 request — its four cases are all validation. Worth adding, since authorization is where the surprising behaviour lives.
    • BulkRefreshHelper's javadoc notes that GET /api/v1/jobs/{jobId}/status needs only a back-end user and returns the whole job, every submitted inode included. Pre-existing, not created here, and it needs a job UUID you would already have to know. Untested.

    Cleanup

    Test content created for this run was deleted afterwards. One demo contentlet had its Elasticsearch documents removed and restored by the endpoint under test. Nothing in the database was left modified.


    QA run and comment authored by Claude (Claude Code), posted from @zJaaal's account.

  13. zJaaal commented on Aug 26, 2026

    @zJaaal
    Member

    QA Passed

    Tested with admin and with limited user

    We are gating the refresh to admin only, preventing it to be fired with no permissions and with text explaining why on: #37216

    Screen.Recording.2026-08-26.at.6.06.47.PM-1.mov
  14. removed their assignment
    on Aug 26, 2026
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