Skip to content

Content Drive: Add content export #37900

In review
In review

Description

@zJaaal

Description

Content Drive has no way to export content. Today the only CSV export is in the legacy Content Search portlet: it exports every result of the current filters (site or folder, language, workflow, text, System Host) for exactly one content type, without paging, and silently stops at 100,000 rows.

This task brings that export to Content Drive through a new endpoint (POST /api/v1/drive/export), reusing the Content Search CSV logic (same columns, values and file name), so every CSV can be imported back. It has two modes, delivered in this order:

  1. Filter mode — feature parity with Content Search. With nothing selected and the listing filtered to exactly one content type, Export downloads one CSV with every contentlet the listing shows for the current location and filters, across all pages. The location works as Content Search's filters do: All Site Content covers the whole site, and a folder covers only what sits directly in it.
  2. Selection mode — new. The user selects up to 60 items (folders and contentlets, of any content types). A contentlet selected on its own is exported only in the language version that was selected. A selected folder brings every contentlet below it, at any depth, in every language version and including archived ones; folders themselves are never rows. The result is a zip with one CSV per content type. Drive's filters do not apply: what you select is what you export.

Rules for both modes

  • If there is a selection, the selection wins over the filter.
  • Only content the user can read is exported, and nothing tells the user how much was skipped.
  • At most 100,000 rows. A bigger export is refused with a clear message instead of being truncated.
  • Forms and Host content are never exported. Files and pages are content and get their own CSVs.
  • File names follow Content Search: each CSV is <ContentType>_contents_<M_d_yyyy>.csv, and the zip is <SiteName>_export_<M_d_yyyy>.zip.
  • The CSV format is the legacy one, with one change: the host/folder column is written as a readable location instead of an identifier (see Spec review adjustments for its three forms).
  • The Content Search export itself does not change.

UI: the Export button lives in the Drive toolbar, not in the Action Center. With nothing selected it appears when the listing is filtered to one content type, and it is disabled when the listing shows no contentlets. With a selection it appears beside the workflow actions, and it is disabled above 60 items. It shows a loading state while running, and a toast with the result.

Out of scope: filter mode with more than one content type, exporting across all sites at once, recursive filter mode inside a folder (select the folder instead), import (#37896), background-job exports, and exporting file contents (binary fields export as a download URL, as in legacy).

Acceptance Criteria

Filter mode (parity)

  • With nothing selected and the listing filtered to exactly one content type (not a Form), the Export button appears in every Drive view; with no type or more than one, it does not
  • When the listing shows no contentlets for the current filters, the Export button is disabled
  • The CSV holds exactly the contentlets the listing shows for that type and the active filters (language, workflow, status, text, Include System Host), across every page
  • In All Site Content the whole site is exported; inside a folder, only the contentlets directly in it
  • A single CSV named <ContentType>_contents_<M_d_yyyy>.csv downloads, not a zip
  • For the same type and filters, the Drive CSV matches the Content Search CSV, except the host/folder column

Selection mode

  • With items selected, the Export button appears beside the workflow actions; the Action Center has no Export row
  • With more than 60 items selected, the Export button is disabled and explains the limit; the endpoint rejects more than 60 entries with 400
  • A selected folder exports the contentlets in it and in all its subfolders at any depth; no folder is a row
  • Folders and contentlets of different types export together as one zip <SiteName>_export_<M_d_yyyy>.zip, with one CSV per content type and one header row each
  • Each contentlet version appears once, even when selected directly and inside a selected folder, or when nested folders are both selected
  • A contentlet selected on its own is exported only in the selected language version; its other language versions are exported only if they were selected too
  • A selected folder exports every language version and the archived contentlets below it, one row per version
  • Drive's filters do not change what a selection exports
  • With a selection and a single-type filter at the same time, the selection is exported

Both modes

  • Forms and Host content are never exported
  • From 1 to 100,000 rows, every row is exported, including exports of more than 10,000 rows; above 100,000 readable rows the export is refused with 400 and a message saying it has more than 100,000 rows and that 100,000 is the limit
  • A selection with nothing the user can read (for example a readable folder whose content is not readable) returns 204 and the toast says there is nothing to export; a refusal or failure shows the server's message; no file downloads in either case
  • While running, the button shows a loading state and cannot be clicked again; on success the toast reports the items and files exported
  • A successful response carries X-Export-Contentlets, X-Export-Files and Content-Length, and no temp file is left on the server, whether the export succeeded or failed
  • A CSV from either mode can be imported back (key field Identifier, no language) with no row errors, and every contentlet stays on the same site and in the same folder
  • The Content Search export keeps its current behavior

Permissions

  • A contentlet the user cannot read is never exported
  • Content in a subfolder the user cannot read is not exported, at any depth below it
  • A selected contentlet the user can read is exported even if its folder is not readable
  • Selecting a folder the user cannot read returns 404 (see Spec review adjustments)
  • Integration tests cover these cases with a limited user in both modes, registered in a MainSuite; the endpoint is documented and openapi.yaml is regenerated

Spec review adjustments

Added after the spec review on the spec PR (#38043):

  • Working version only. Every row is the working version of its contentlet in its language, in both modes, as Content Search exports it. A published contentlet edited afterwards has a live and a working version in the same language; only the working one is exported, so the file never holds two rows with the same Identifier and language.
  • Filter mode reads a complete result. It must get the full set of readable results for the same query the Drive listing uses, through an operation that guarantees completeness. It must not walk the listing's screen pages: past the database scan budget (BROWSER_DB_MAX_SCAN_ROWS, 50,000 by default) those pages come back short while still reporting more results, so rows could be dropped silently.
  • The content type is validated after it is resolved. The listing drops a content type that does not exist or that the user cannot read, and with no type left it returns every type. Filter mode rejects both cases with the same 400 and never falls through to an export without a type restriction.
  • Permissions that change mid-export. A contentlet that stops being readable after it was counted is skipped instead of failing the export, and the reported row count is the number of rows actually written.
  • Folder existence is not revealed. An unreadable folder and a folder that does not exist get the same 404.
  • Refusing a large export stays cheap. The over-limit message says the export has more than 100,000 rows instead of giving the exact total, so counting can stop at 100,001 rather than resolving and permission-checking millions of contentlets just to reject them.
  • The shared CSV writer sends no websocket messages. downloadToExcel pushes the "A total of N…" and error messages itself today; when it is extracted, those move to its caller, so Content Search keeps them and Drive does not.
  • The host/folder column keeps root content on its site. Written as //site/, content at a site root would be moved to System Host on re-import, because the import resolves the path / to the system folder, and no row error would show it. The column uses the form the existing import already resolves for each case: //site/path/ for content in a folder, the bare hostname (e.g. demo.dotcms.com) for content at a site root, and SYSTEM_HOST for System Host content. It is deliberately not uniform. The import is not changed.
  • The shared CSV writer stops swallowing failures. Besides sending no websocket messages, the writer moved out of downloadToExcel propagates whole-file failures instead of catching them and reporting success, writes to a given output instead of the HTTP response, skips rows that are no longer readable, and reports how many rows it wrote. A failure formatting a single field still leaves that cell empty, as today.
  • Selections stay within the browsed site. The request names the site being browsed. Folders must belong to it, and contentlets to it or to System Host; anything else gets the same 404.

Acceptance Criteria

  • Only the working version is exported, with at most one row per identifier and language, in both modes; a contentlet published and then edited exports one row with the edited values
  • Filter mode exports every readable result of the listing's query, including listings whose database scan goes past 50,000 rows and searches with a text filter
  • A filter-mode request naming a content type that does not exist, or one the user cannot read, returns the same 400, and no other content type is exported
  • A contentlet that becomes unreadable during the export is skipped, the export succeeds, and X-Export-Contentlets matches the rows written
  • An unreadable folder and a missing folder return the same 404 and message
  • A folder from another site, or a contentlet outside the browsed site and System Host, returns that same 404
  • Rejecting an export far above 100,000 rows does not resolve the whole set; the message says "more than 100,000"
  • A Drive export pushes no websocket system messages, and the Content Search export still pushes the ones it pushes today
  • The host/folder column is //site/path/ for content in a folder, the bare hostname for content at a site root, and SYSTEM_HOST for System Host content
  • Re-importing content from a folder, from a site root and from System Host leaves each contentlet on the same site and in the same folder
  • A failure of the whole file returns 500 and no file, never a truncated file or a success message

Priority

Medium

Additional Context

  • Import ticket: Content Drive: Add CSV content import #37896
  • Legacy export: EditContentletAction (cmd=export, downloadToExcel); legacy filters in ContentletAjax and view_contentlets_js_inc.jsp
  • Drive listing search: ContentDriveResource (/v1/drive/search), ContentDriveHelper.skipsFolderConstraint (a folder is never recursive in the listing)
  • Recursive folder walk: FolderAPIImpl.findSubFoldersRecursively; scroll reads: ContentletAPI.createScrollQuery
  • Frontend precedents: DotPublishingQueueService.generateBundle (blob download), getDownloadLink in @dotcms/utils, toFolderAssetPaths in the Drive utils/action-center.ts
  • Not yet reproduced with a limited user: a readable contentlet inside an unreadable folder being exported when selected directly. It comes from reading the code, which is why it is in the criteria.

Activity

  1. added theissue type on Oct 5, 2026
  2. changed the title [-]Add content export to Content Drive[/-] [+]Content Drive: Add content export[/+] on Oct 7, 2026
  3. self-assigned this
    on Oct 7, 2026
  4. moved this from In Progress to Spec In Progress in dotCMS - Product Planningon Oct 12, 2026
  5. github-actions commented on Oct 14, 2026

    @github-actions
    Contributor
  6. 9 remaining items

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

Metadata

Metadata

Assignees

Type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions