Repository navigation
Description
Description
Content Drive has no way to import content from a CSV. Today users have to go to the legacy Content Search portlet (the ImportContentletsAction Struts flow) to do it. This ticket brings that import flow into Content Drive, keeping every option and every piece of feedback the legacy screens show.
The backend is mostly already there. POST /api/v1/content/_import (ContentImportResource) runs the import as a background job and already powers the legacy preview: ImportResultConverter.toLegacyFormat builds the legacy "View Conflicts" lists from the same ImportResult the REST job returns. The work here is the Drive UI, plus one small backend endpoint for the CSV sample file.
Entry point
The Upload control in the Drive toolbar gets an Import option that opens the import form in a dialog, the same way the folder form opens. This is the only way to start an import. Dropping a .csv onto Drive keeps uploading it as a file, as it does today (see Out of scope).
The form (same fields as the legacy one)
| Field | Source |
|---|---|
| Content Type to Import (required) | Content type list |
| Language to Import (required) | Languages, plus a multilingual option where each row's language comes from its languageCode / countryCode columns (sent as language: "-1") |
| Key Fields | Fields of the selected content type. Fields that are not indexed are shown disabled, as in legacy (import_contentlets.jsp, fieldIndexed) |
| Workflow Action (required) | GET /api/v1/workflow/initialactions/contenttype/{id}, the same endpoint the legacy form uses |
| CSV File to Import (required) | A file picked in the form |
| Download a CSV sample file | New REST endpoint (see below) |
Flow
- Go To Preview calls
POST /api/v1/content/_import/_validate, waits for the job (GET /{jobId}/monitoror pollingGET /{jobId}), and shows the preview. - The preview shows the same three sections as the legacy "View Conflicts" screen:
- Summary: header match count, relationship fields found, import statistics, lines of data read, key fields selected
- Warnings and Errors, each prefixed with
Line #N:when the message has a line number - Some summary lines are not in the REST result as text. The legacy converter builds them from counts and Language.properties keys (
headers-match-these-will-be-imported,lines-of-data-were-read,input-lines-had-errors,Fields-selected-as-key). The UI rebuilds them with the same keys so translations carry over.
- Import Content calls
POST /api/v1/content/_importwith the same file and form. The new API does not keep the file between validate and import, so the UI holds on to it. Cancel discards the preview. - While the import runs, the dialog shows progress. Closing the dialog does not stop the job. When it finishes, a toast reports the created, updated and failed counts (
data.summary/data.processedon the job result).
Backend work in scope
- A REST endpoint that returns the CSV sample file for a content type, replacing the legacy
downloadCSVTemplatecommand inImportContentletsAction. - Correct the
languagedescription in the import endpoint's OpenAPI docs (ContentImportDocs). It currently says omittinglanguagemeans the default language. In the code, omitting it (or sending-1) turns on multilingual mode (ImportContentletsProcessor.findLanguage).
Out of scope
- Drag and drop import. An import places each row by the folder in its CSV, not where the file was dropped, so dropping a CSV into a folder and seeing the content land somewhere else would be confusing. Import starts only from the Upload control for now.
- Folder targeting. Where each row lands is decided by the CSV's host/folder column, as in legacy. Rows without one go to the site root. The form tells the user this, because importing from inside a folder does not put content in that folder.
- Missing folders. When a row's site exists but its folder path does not,
ImportUtil.getSiteAndFolderFromIdOrNamequietly places the row at the site root with no error. This will be tracked in a separate ticket. - Export from Content Drive: Content Drive: Add content export #37900
Acceptance Criteria
Entry points
- The Drive toolbar's Upload control offers an Import option, which opens the import form in a dialog
- The Import option is disabled whenever Upload is disabled, i.e. when the user lacks Can Add Children on the current folder
- Dropping a
.csvfile onto Drive uploads it as a file exactly as Drive does today, with no import prompt
Form
- The form shows Content Type, Language, Key Fields, Workflow Action, CSV File and a sample file link
- Selecting a content type lists its fields as key field checkboxes, with non-indexed fields disabled
- Selecting a content type lists only the workflow actions returned by
initialactions/contenttype/{id}for that type - The Language list includes a multilingual option; choosing it sends
language: "-1" - Go To Preview stays disabled until Content Type, Language, Workflow Action and a file are all set
- Selecting a file that does not end in
.csvshows an inline error and does not start a job - The form states that rows are placed by the CSV's host/folder column, and rows without one go to the site root
- Clicking the sample file link downloads a CSV whose header row lists the selected content type's importable fields
Preview
- Go To Preview starts a validate job and shows a loading state until the job finishes
- The preview lists the Summary, Warnings and Errors sections with the same information as the legacy View Conflicts screen for the same CSV and options
- Each warning and error that has a line number is shown as
Line #N: <message> - Summary lines built from counts use the Language.properties keys, so they appear translated in the user's language
- A validate job that fails (for example, a content type or language not found) shows the job's error message and keeps the form editable
- Cancel closes the preview and creates no content
Import
- Import Content starts the import job with the same file and options used in the preview
- The dialog shows import progress until the job finishes
- Closing the dialog while the import runs leaves the job running
- When the job finishes, a toast shows the number of created, updated and failed rows, whether or not the dialog is still open
- After a successful import, the Drive listing refreshes to show any new content in the current folder
- Content is imported into the site Drive is browsing. The endpoint reads the site from the server session (
ContentImportHelper), so this needs checking when Drive's site differs from the session's site.
Backend
- A new REST endpoint returns the CSV sample file for a given content type, matching the legacy
downloadCSVTemplateoutput - The endpoint rejects a user who cannot read the content type
- The OpenAPI description of
languagestates that omitting it, or sending-1, means multilingual mode, andopenapi.yamlis regenerated
Priority
Medium
Additional Context
- Import endpoint:
dotCMS/src/main/java/com/dotcms/rest/api/v1/content/dotimport/ContentImportResource.java(/_validate,/,/{jobId},/{jobId}/monitor,/{jobId}/cancel) - Request body: multipart
file(a CSV) plusformJSON:contentType,workflowActionId,language,fields(key fields),stopOnError(defaultfalse),commitGranularity(default100) - Result model:
com/dotmarketing/util/importer/model/AbstractImportResult(info/warning/error messages withlineNumber,code,field,invalidValue;fileInfo.headerInfo;data.processed;data.summary) - How legacy builds its preview text:
com/dotmarketing/util/importer/ImportResultConverter.java - Permissions are checked per row as the requesting user (workflow action permission and step, Can Add Children on the target folder or site), so problems show up as row errors in the preview
- Related security gap, to be filed separately: the job endpoints (
GET /{jobId},/cancel,/monitorand the job lists) do not check that the caller owns the job, so any backend user can see or cancel another user's import
Metadata
Metadata
Assignees
Type
Projects
- StatusShow more project fieldsIn Review
Activity
[-]Add CSV content import to Content Drive[/-][+]Content Drive: Add CSV content import[/+]github-actions commentedon Oct 12, 2026
PRs linked to this issue
docs(spec): apply PR review to the Content Drive CSV import spec (#37896
docs(spec): apply second-round review to the Content Drive CSV import…
docs(spec): correct row placement and site scope in the CSV import sp…
docs(spec): apply the UI review to the Content Drive CSV import spec (#…
20 remaining items
feat(content-drive): list importable content types through the conten…
docs(spec): document GET /api/v1/contenttype/_writable (#37896)
fix(jobs): wake an idle worker when a job is created (#37896)
refactor(content-import): drop the synchronous /_preview endpoint (#3…
feat(content-drive): preview the CSV through /_validate (#37896)
docs(spec): the preview goes through /_validate again (#37896)
feat(content-drive): lock the CSV while previewing and reuse an uncha…
fix(content-drive): report a job whose completion outruns its answer (#…
test(e2e): hold the folder delete run for the reload check (#37896)
fix(content-drive): address the CSV import review after merging main (#…
fix(content-drive): import message levels and a clearer import dialog (…
style(content-drive): use the standard form layout in the import dial…