Repository navigation
Export content to CSV in Content Drive - #38043
dario-daza wants to merge 33 commits into
Conversation
…st, then selection (#37900) Filter mode brings the Content Search export to Drive: with the listing filtered to exactly one content type, export every result of its location and filters as one CSV. Selection mode is new: up to 60 folders and contentlets of any types, exported as a zip with one CSV per type. Both reuse the Content Search CSV writer and file names, and refuse exports over 100,000 rows instead of truncating them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Claude finished @dario-daza's task in 1m 2s —— View job SDK Compatibility Check — complete
Result: No SDK breaking change detected. This PR adds Content Drive's new CSV/zip export feature end-to-end: a new None of the changed files touch an SDK-reachable surface:
A grep of the diff stat for |
…port scope (#37900) The Input line still carried the open points from the first analysis, including the undefined <name> in the zip file name, which the issue has since settled as <SiteName>_export_<M_d_yyyy>.zip. It now summarizes the agreed scope, and the refinement-history block is folded into it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fabrizzio-dotCMS
left a comment
There was a problem hiding this comment.
Solid, well-scoped spec. Three changes I'd ask for before approval, plus a few suggestions.
Changes
-
Pin the exported version: one row per identifier + language, working version. FR-017 only forbids repeating an inode. A published contentlet edited afterwards has a live and a working inode in the same language, so selection mode could emit both, giving two rows with the same
Identifier/languageCodeand breaking the clean re-import (SC-004). Working is the right choice: it is what Content Search exports (+working:trueinContentletAjax), drafts and archived content have no live version (and FR-008 requires archived), and re-importing live values would overwrite unpublished edits. -
Filter mode should depend on a completeness contract, not on how the listing pages today. Require that filter mode gets the complete set of readable results for the same query the Drive listing uses, through an operation that guarantees completeness and does not expose paging, cursors or scan budgets. Today walking to the end relies on
BrowserAPIImpl.getContentByChunksinternals: e.g.BROWSER_DB_MAX_SCAN_ROWS(50,000) is compared against the absolutedbOffset, so past that row nearly every page comes back short withhasMore = true; an exporter that stops on a short page would silently drop rows. If permissions move into SQL tomorrow, those details change. The plan picks the shape (e.g. aBrowserAPImethod that returns everything and hides the chunking); note the existingmaxRows <= 0fetch-all path only covers the non-text-filter branch. I'd also drop the "pages of 2,000 behind cursors" wording from Assumptions. -
Unknown or unreadable content type in filter mode.
ContentDriveHelper.driveSearchresolves types withTry.of(() -> find(...)).getOrNull()and drops nulls, so a missing type or one the user can't read silently disappears; if it was the only one, the listing applies no type filter and returns every type. If FR-004 validates the request rather than the resolved type, the export would dump all types through a single-type writer. Please specify: validate the resolved type before querying, and reject missing and unreadable alike with the same 400 message.
Suggestions
- Skip, don't fail, if permissions change between resolution and writing.
downloadToExcelre-loads each contentlet withconAPI.find(inode, user, ...)and only catchesDotDataException; aDotSecurityExceptionthere becomes a 500. Skip the row and computeX-Export-Contentletsfrom what was actually written (FR-026). - Keep the pre-write resolution light: identifiers + content type, batch permission filtering (
filterCollection), no loading/formatting. The real cost is the legacy per-row writer. - Don't reveal folder existence: FR-014 (403 for an unreadable folder) vs FR-028 (400 for an unresolvable path) lets a limited user probe which folders exist. Same response for both.
- Cross-site folders:
//site/path/carries the site, so a hand-built request could name folders from another site while the zip is named after the browsed site. Say whether that is rejected.
Verified and fine: the import already parses //site/path/ for the host/folder column (ImportUtil.getHostNameAndPath), and Drive's language filter doesn't add default-language fallback (showDefaultLangItems is never set).
…s and the full row range (#37900) A contentlet selected on its own is exported in the language version that was selected, while a selected folder still brings every language version and archived content below it. In filter mode the Export button is disabled when the listing shows nothing. Every export of 1 to 100,000 rows is complete, and exported CSVs must still import back unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…leteness and leaks (#37900) Export only the working version, one row per identifier and language, so a published contentlet edited afterwards cannot produce two rows. Filter mode must read a complete result for the listing's query instead of walking the listing's screen pages, which come back short past the database scan budget. The content type is validated after it is resolved, so a missing or unreadable type is refused instead of falling through to every type. Rows that become unreadable mid-export are skipped and not counted. An unreadable folder and a missing one get the same 404, and selections are limited to the browsed site and System Host. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… shared writer silent (#37900) Refusing an export over 100,000 rows no longer needs the exact total, so counting can stop at 100,001 instead of resolving and permission-checking a content type with millions of contentlets just to reject it. The message says the export has more than 100,000 rows. The writer moved out of downloadToExcel must not push websocket messages itself: Content Search keeps sending them from its caller, Drive does not. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fabrizzio-dotCMS
left a comment
There was a problem hiding this comment.
Solid spec. Both modes, the 60-item cap, refusing exports over 100,000 rows instead of truncating them, and the permission rules all look right to me. One change is blocking; the rest is small.
Blocking: FR-022, host/folder column format (inline comment). If root content is written as //site/, re-import silently moves it to System Host: findFolderByPath("/") returns the system folder, and the importer takes that folder's host. SC-004 would still pass, because it only checks for row errors. Proposal, without touching the importer: write //site/path/ for folders, the bare hostname for site-root content, and SYSTEM_HOST for System Host content. Add one re-import test per form that asserts the contentlet ends up on the same site and folder.
Before approval: FR-020, writer extraction (inline comment). downloadToExcel swallows whole-file failures, streams straight to the response, and lets a DotSecurityException abort the export. That conflicts with FR-029, FR-031 and FR-026a. The spec should say that the shared writer propagates failures and skips rows that are no longer readable.
Sign-off: FR-024, relationship identifiers (inline comment). No behavior change. I'd just like a product owner to accept the identifier exposure explicitly.
For the plan: FR-017a says rows are the working version "as Content Search does", but downloadToExcel exports whatever inodes searchContentletsByUser returns. Please confirm this with a contentlet that was published and then edited.
…arden the shared writer (#37900) Written as //site/, content at a site root is moved to System Host on re-import, because the import resolves the path / to the system folder. The host/folder column now uses the form the import already resolves for each case: //site/path/ in a folder, the bare hostname at a site root, and SYSTEM_HOST for System Host. Re-import tests must check the location, not only the absence of row errors. The writer moved out of downloadToExcel propagates whole-file failures, skips rows that are no longer readable, writes to a given output instead of the response, and reports how many rows it wrote. The working-version rule cites the Content Search query it mirrors and must be proven with a contentlet published and then edited. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nd its follow-up (#37900) The relationship column keeps listing every related identifier, as the Content Search export does today. That is now recorded as an explicit feature-parity decision from the spec review rather than inherited behavior, with filtering by read permission and protecting hidden relationships on re-import tracked in #38055. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fabrizzio-dotCMS
left a comment
There was a problem hiding this comment.
Nit: the PR description still says the host/folder column is written as //site/path/. After e63e59c it's //site/path/ for content in a folder, the bare hostname for content at a site root, and SYSTEM_HOST for System Host content. Worth updating so reviewers who only read the description get the right rule.
… by identifier and language (#37900) A selected contentlet that does not exist, cannot be read, or sits outside the browsed site is now skipped the same way in all three cases, so the response no longer tells a limited user that an identifier exists or which site it belongs to, and a stale entry never fails the whole export. Selection entries name an identifier and a language and resolve to the working version at export time; duplicates are removed by identifier and language, so a contentlet edited after it was selected cannot produce two rows. Filter mode gains a scenario that scans past the database scan budget with a text filter, and the timing measurement near 100,000 rows now decides whether the limit fits the proxy idle timeout. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…export Tests written and approved before the implementation (TDD Red) for exporting everything the Content Drive listing shows for one content type (#37900): BrowserAPI#getContentForExport against the listing paged to the end, the POST /api/v1/drive/export endpoint in filter mode, the Postman "Export" folder, the export service and Export button specs, and a Playwright test. The endpoint answers 501 and the new API, helper, service and button are stubs until the implementation lands. Refs #37900 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
…ent type Adds POST /api/v1/drive/export in filter mode (#37900): with nothing selected and the Drive listing filtered to one content type, Export downloads one CSV with every readable contentlet the listing's query matches, across all pages. - BrowserAPI#getContentForExport reuses the listing's SQL predicates with an export projection, pages by (identifier, language) keyset, narrows each chunk through the index when the query needs it, filters readable rows, and stops past CONTENT_DRIVE_EXPORT_MAX_ROWS. The listing SQL is unchanged. - The endpoint is documented in OpenAPI under the new "Content Drive" tag, answers 204 when nothing matches, and returns errors as ResponseEntityView. - The toolbar shows an Export button next to Upload / Add New. Refs #37900 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Tests approved before the implementation for the Content Drive export outcomes (#37900): 204 when nothing readable matches, a generic 500 that leaks no cause and leaves no temp file when writing fails, and one 404 for a missing or unreadable site or folder. The frontend specs cover reading the server's error message from the blob body and the empty and error toasts. Adds the seams the failure test needs to inject a failing CSV writer. Refs #37900 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When an export has nothing readable to write, the Drive shows a warning toast; when it fails, an error toast with the server's message, read from the JSON error body the endpoint returns as a blob (#37900). Neither downloads anything, and the button leaves its loading state in every case. Refs #37900 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Tests for refusing a Content Drive export over CONTENT_DRIVE_EXPORT_MAX_ROWS (#37900): one row over the limit is a 400 with the limit in the message and leaves no file, the limit itself is allowed, only readable rows count, the default limit is written as 100,000, and resolving rows stops at the chunk that passes the limit. The chunk reader becomes a package-visible instance method so the test can count chunks, and the message builder is public. Refs #37900 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Covers what a limited user's filter-mode export shows (#37900): content they cannot read is absent, the response carries only the contract's headers so nothing reveals how many rows were skipped, and a row that becomes unreadable between resolving and writing is skipped and not counted. Splits the filter-mode export into a resolve step and a write step so that last case can be tested. Refs #37900 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Round-trip test for the Content Drive filter-mode export (#37900): content in a folder, at a site root and in System Host is exported, edited and imported with the identifier as the key, with no row errors, every value updated and nothing moved. Also checks the Drive CSV equals the Content Search CSV column by column except host/folder. Refs #37900 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Tests approved before the implementation for selection-mode export of contentlets (#37900): one CSV per content type in a zip named after the site, each contentlet in its selected language, archived and System Host content included, the selection winning over the listing's filters, repeated or edited entries exported once, unexportable entries dropped without a trace, distinct and safe entry names, the 60-item limit and the site 404. Postman, button, toolbar, action center and Playwright tests cover the same flow. Refs #37900 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With contentlets selected in Content Drive, Export downloads a zip named after the site with one CSV per content type (#37900). Each contentlet is exported in the language it was selected in, as its working version, and only if the user can read it; missing, other-site, Form and Host entries are dropped silently. The selection wins over the listing's filters. The button sits next to the workflow actions and is disabled above 60 selected items. Refs #37900 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Tests approved before the implementation for selecting folders in a Content Drive export (#37900): every contentlet below a folder at any depth, in every language and archived, each once even when nested folders and their content are selected together; assets and pages in their own CSVs; Form content skipped; 400 for an unparseable path or a site root and one 404 for a missing path, a file or another site's folder, leaving no file. The button spec covers sending folders and counting them toward the 60-item limit. Refs #37900 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Selected folders now export every contentlet below them, at any depth, in every language, archived included, skipping subfolders the user cannot read (#37900). Folders are validated before any content is read: an unparseable path or a site root is a 400, and a missing path, a file, another site's folder or an unreadable one is the same 404. The button sends the selected folders as site-qualified paths. Refs #37900 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Extends the Content Drive export tests to selections (#37900): unreadable subfolders and rows are left out while a readable contentlet selected inside an unreadable folder is exported; unreadable, missing and other-site folders give identical 404s and dropped contentlets leave no trace; folder rows count toward the row limit while a folder counts as one selected item; a selection zip imports back in place; and an empty selection result is a 204 with the empty toast. Refs #37900 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…export' into 37900-content-drive-add-content-export Brings in the main merge pushed to the remote branch, on top of the local Content Drive export commits. No conflicts; openapi.yaml regenerated by the build matches the merged file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DriveExportRequestForm is generated by Immutables in the same round as DriveRequestForm, so on a clean build the imported simple name was not resolved yet and the generated class referred to it without an import, failing `just build-no-cache` (#37900). The query attribute now declares the type fully qualified. Refs #37900 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… helpers downloadToExcel takes its writer in a try-with-resources, after setting the headers as before, and drops the branch that printed through a null writer; empty input still writes nothing (#37900). Adds the missing Javadoc to the new private helpers of the CSV writer and the selection resolver. The Content Search characterization tests still pass. Refs #37900 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Tests approved before the fixes (#37900): a search text too complex for the index is the same 400 as the listing gives, a file built before a failure is deleted at once, error bodies carry a null entity as the contract shows, and an export started from one Export button blocks the other one that appears when the selection changes. Refs #37900 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A filter-mode export whose search text the index rejects as too complex now answers the listing's 400 instead of a generic 500; the endpoint deletes a file it built before failing; error bodies carry `entity: null`; and both Export buttons share whether an export is running, so changing the selection mid-export cannot start a second one (#37900). Refs #37900 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…w actions For two contentlets of different types the workflow actions component has no shared action and renders hidden, so the wait for it timed out before the Export click (#37900). The wait only located the button; the test still checks the button is enabled with a selection and the zip download name. Refs #37900 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Three changes to the approved spec for #37900, decided after checking the implementation by hand: - A selection whose rows are all of one content type exports that single CSV, named as in filter mode, instead of a zip holding it (FR-016, US2). - The Export button sits in the same place in both modes: last in the toolbar (FR-035, US2). - The selection limit becomes configurable, CONTENT_DRIVE_EXPORT_MAX_SELECTED_ITEMS (default 60), selection mode only; the UI reads the same value. The 100,000-row limit is unchanged and applies in both modes (FR-004a, FR-028, SC-002, US2). Refs #37900 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Spec update after the manual check While checking the implementation by hand we made three changes to the spec, in commit b59a8a6 (spec.md only):
|
|
|
Semgrep found 18
🟡 Medium severity issue identified in your code: The method identified is susceptible to injection. The input should be validated and properly If this is a critical or high severity finding, please also link this issue in the #security channel in Slack. |
Spec-Kit specification for Content Drive content export (#37900). This is phase 1: spec review only. The PR carries
specs/37900-content-drive-export/spec.mdand no code.Content Drive cannot export content today. The only CSV export lives in the legacy Content Search portlet, which exports every result of its filters for exactly one content type and silently stops at 100,000 rows. The team asked for feature parity first: whatever Content Search can export, Drive must export too. Exporting a selection is new capability on top of that.
What the spec settles
The export goes through one new endpoint and has two modes, delivered in this order:
<ContentType>_contents_<M_d_yyyy>.csv<SiteName>_export_<M_d_yyyy>.zipwith one CSV per content typeRules for both modes:
EditContentletAction.downloadToExcelinto a reusable piece that both portlets call, so the columns, values and file name are the same and each file can be imported back. The shared writer sends no websocket messages, propagates whole-file failures, and skips rows that are no longer readable. Content Search's own export does not change.//site/path/for content in a folder, the bare hostname for content at a site root, andSYSTEM_HOSTfor System Host content. It is deliberately not uniform, because//site/would move root content to System Host on re-import.404. A selected contentlet that is missing, unreadable or outside the browsed site is skipped the same way in all three cases.400saying it has more than 100,000 rows, instead of being cut silently. Counting stops at 100,001.Worth a reviewer's attention
BROWSER_DB_MAX_SCAN_ROWS, 50,000 by default) those pages come back short while still reporting more results, and the existing fetch-everything path does not cover text-filtered searches. The plan must pick an operation that returns the complete set. A scenario covers a text-filtered export that scans past the budget.Proposed Changes
specs/37900-content-drive-export/spec.md. It has seven user stories: filter mode, selected contentlets, whole folders, permissions, the 100,000-row refusal, re-import, and empty or failed exports. It also has 43 functional requirements, success criteria, edge cases, legacy considerations and assumptions.Checklist
/speckit-plan) once the spec is approved. The spec requires integration tests with a limited user in both modes, registered in a MainSuite, plus re-import tests that check content stays on the same site and folder.🤖 Generated with Claude Code
This PR fixes: #37900