Content Importer module

Content management Bundled: Community edition

Edition CE

License

MLA, GPL

Issues

Maven site

Latest

2.0.0

The Content Importer module allows you to bootstrap content from the file system into the JCR. The module adds bootstrapping capabilities for light modules. You can import content during light module development, distribution, and deployment. For example, you can import sample content for a new template so authors can immediately see how the template works.

Magnolia monitors the bootstrap directory on the file system. When Magnolia detects a change, it sends a message to the Tasks app to the superuser account. The superuser can then import the content. This allows you to import content in a controlled way, ensuring that no existing content is overridden by accident.

Installing with Maven

Maven is the easiest way to install the module. Add the following to your bundle:

<dependency>
  <groupId>info.magnolia.content</groupId>
  <artifactId>magnolia-content-importer</artifactId>
  <version>2.0.0</version> (1)
</dependency>
1 Should you need to specify the module version, do it using <version>.

How content import works

To demonstrate how content import works, we bootstrap a cruise-manager page into the /travel/about/careers section in the Pages app.

To create a bootstrap file for testing, create a page in the Pages app, export it, and save it to a temporary location on your computer. Next, delete the page in the Pages app and add the file to your bootstrap directory on the file system. See Importing and exporting JCR data for bootstrapping for more.

Here’s how bootstrapping files from the file system works in the UI:

  1. An XML file is added to the bootstrap directory.

    Example: Add website.travel.about.careers.cruise-manager.xml to /magnoliaAuthor/data.

    └─<magnoliaAuthor>
     └─data
         └─website.travel.about.careers.cruise-manager.xml
  2. A message is logged to the user:

    2024-03-28 14:27:06,676 INFO gnolia.content.observer.TaskCreatorWatcherCallback: File change detected at '/magnoliaAuthor/data/website.travel.about.careers.cruise-manager.xml', pulse task has been sent.
  3. A task is sent to the Tasks app.

    Example: Import request task and Import action for cruise-manager page in the Tasks app.

    Import request task and Import action for cruise-manager page in the Tasks app

  4. superuser assigns himself the task and clicks Import to import the content into the corresponding workspace in the repository. He can also Reject or Abort the import.

    Content Import Request tab

  5. The bootstrapped content is available in the relevant app. The bootstrap directory is monitored, and a new task is sent to the Tasks app when a change in the XML is detected.

    Example: Cruise Manager page in the Pages app

    • Directory view

    • Edit view

    Cruise Manager page in the Pages app

    Cruise Manager in edit mode.

  • Observation only occurs if the bootstrap directory is set in the magnolia.properties file.

  • Deletions aren’t removed automatically. To remove content, delete it in the JCR and the bootstrap directory.

Bootstrapping settings

You can use the Server configuration page in the About app to check the current bootstrapping settings.

Bootstrap directory

To set the bootstrap directory, add the magnolia.content.bootstrap.dir property in the magnolia.properties file. The bootstrap directory can reside anywhere on the file system and be named anything.

Example: Setting the bootstrap directory as a subdirectory of the resources directory.

# The directory to expose file system resources from
magnolia.resources.dir=${magnolia.home}/modules
......
# The directory to import file system content files from
 magnolia.content.bootstrap.dir=${magnolia.resources.dir}/data

Subdirectories of the bootstrap directory are also monitored. You can structure your bootstrap files within the bootstrap directory.

Filename pattern

Use the magnolia.content.bootstrap.pattern property to specify which filenames will be imported and observed in the content bootstrap directory.

Example: magnolia.content.bootstrap.pattern=*.{yaml,xml}

Bootstrapping strategy

You can use two properties to configure a content bootstrapping strategy: magnolia.content.bootstrap.onlyImportAtInstall and magnolia.content.bootstrap.createTasks.

  • onlyImportAtInstall=true and createTasks=always: the most restrictive strategy. Content is bootstrapped only at installation, not at every instance startup. No content is bootstrapped automatically.

  • createTasks=onchange: the most permissive strategy. Content is bootstrapped automatically if the path does not exist in JCR. If the path exists, a task is created.

  • createTasks=never: content is bootstrapped at every startup and after every change.

The default configuration is onlyImportAtInstall=false and createTasks=always.

Possible values for createTasks are always, onchange and never.

Configuration

The module is configured in /modules/content-importer.

No configuration changes are required unless you customize the implementation.

Content Import Request task

The Content Import Request task is displayed in the Tasks app.

This task is configured in /modules/content-importer/tasks.

The Content Import Request task configuration

Property Description

tasks

optional

Tasks folder.

     content

required

Task name.

         users

optional

Users who can view and assign tasks.

Please note that you should define at least one user or group (see the following property) to display bootstrap messages. The default configuration comes with superuser.

         groups

optional

User groups who can view and assign tasks.

         viewMapping

optional

Message view displayed in detail view.

         taskView

required

content message view definition.

         title

optional

Task title.

Content Import Request message view

The Content Import Request message view is displayed to the user who opens a task. The view is mapped to the Content Import Request task in the taskView property (above).

The Import (approve) action uses a custom action implementation class for importing the bootstrap file into the JCR. With this exception, it is a standard message view definition.

The content message view is configured in /modules/content-importer/messageViews/content.

Content Import Request message view

Property Description

messageViews

optional

Message views folder.

     content

required

Message view name.

         form

required

Form definition node.

Text fields (read only):

  • content.repository: Target workspace.

  • content.path: File source path.

  • content.modificationDate: Modification date.

         actions

required

Actions definition node.

             <action definitions>

optional

Configured actions:

  • approve:

Property Description

availability

optional

Availability rules node.

class

required

Action definition class.

info.magnolia.ui.admincentral.shellapp.pulse.task.action.ResolveTaskActionDefinition: Action for resolving a task.

decision

required

Decision.

icon

optional

Action icon.

implementationClass

optional

Implementation class.

info.magnolia.content.action.BootstrapAction executes bootstrap import action and resolves task by delegating to ResolveTaskAction.
  • confirmRejection: Reject action definition. Opens the reject dialog (configured in the module dialogs folder) that allows the user to leave a comment.

  • retry: Retry import task action definition.

  • claim: Assign to me action definition.

  • archive: Remove from list action definition.

  • abort: Abort action definition.

         actionbar

required

Action bar definition.

Feedback

DX Core

×

Location

This widget lets you know where you are on the docs site.

You are currently perusing through the DX Core docs.

Main doc sections

DX Core Headless PaaS Legacy Cloud Incubator modules