Skip to content

Content Drive: Add CSV content import #37896

Description

@zJaaal

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

  1. Go To Preview calls POST /api/v1/content/_import/_validate, waits for the job (GET /{jobId}/monitor or polling GET /{jobId}), and shows the preview.
  2. 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.
  3. Import Content calls POST /api/v1/content/_import with 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.
  4. 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.processed on the job result).

Backend work in scope

  • A REST endpoint that returns the CSV sample file for a content type, replacing the legacy downloadCSVTemplate command in ImportContentletsAction.
  • Correct the language description in the import endpoint's OpenAPI docs (ContentImportDocs). It currently says omitting language means 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.getSiteAndFolderFromIdOrName quietly 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 .csv file 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 .csv shows 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 downloadCSVTemplate output
  • The endpoint rejects a user who cannot read the content type
  • The OpenAPI description of language states that omitting it, or sending -1, means multilingual mode, and openapi.yaml is 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) plus form JSON: contentType, workflowActionId, language, fields (key fields), stopOnError (default false), commitGranularity (default 100)
  • Result model: com/dotmarketing/util/importer/model/AbstractImportResult (info/warning/error messages with lineNumber, 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, /monitor and the job lists) do not check that the caller owns the job, so any backend user can see or cancel another user's import

Activity

  1. added theissue type on Oct 5, 2026
  2. changed the title [-]Add CSV content import to Content Drive[/-] [+]Content Drive: Add CSV content import[/+] on Oct 7, 2026
  3. github-actions commented on Oct 12, 2026

    @github-actions
    Contributor
  4. 20 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