The 5.7 branch of Magnolia reached End-of-Life on December 31, 2023, as specified in our End-of-life policy. This means the 5.7 branch is no longer maintained or supported. Please upgrade to the latest Magnolia release. By upgrading, you will get the latest release of Magnolia featuring significant improvements to the author and developer experience. For a successful upgrade, please consult our Magnolia 6.2 documentation. If you need help, please contact info@magnolia-cms.com.

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 development, distribution and deployment of light modules. For example, 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 Pulse task 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

Maven is the easiest way to install the module. Add the following to your bundle. The parent POM of your webapp project should set the latest version of the module automatically. Should you need to use a specific module version, you can define it using the <version/> in the dependency.

<dependency>
  <groupId>info.magnolia.content</groupId>
  <artifactId>magnolia-content-importer</artifactId>
</dependency>

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 the file to a temporary location on your computer. Next, delete the page in the Pages app and then 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. See Setting the bootstrap directory.
    Example : Add  website.travel.about.careers.cruise-manager.xml to /webapps/magnoliaAuthor/modules/data.

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

    INFO   info.magnolia.content.observer.TaskCreatorWatcherCallback 01.11.2016 13:18:48 
    -- File change detected at 'C:\Users\Ruth\magnolia\magnolia-enterprise-5.5\apache-tomcat
    -8.5.5\webapps\magnoliaAuthor\modules\data\website.travel.about.careers.cruise-manager.xml', 
    pulse task has been sent.
  3. A task is sent to the Pulse.
    Example: Import request task and Import action for cruise-manager page in the Pulse.
     
  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.
       
  5. The bootstrapped content is available in the relevant app. 
    Example: Cruise Manager page in Pages app.
      
  6. The bootstrap directory is monitored and a new task sent to the Pulse when a change in the XML is detected. 
    Example: Changes to Cruise Manager page in XML and page editor.
       
  • Observation only occurs if the bootstrap directory is set in the magnolia.properties file.
  • Bootstrap files are only detected on a running instance. The directory is not observed on startup. Only add bootstraps after starting Magnolia.
  • Deletions are not removed automatically. To remove content, delete it in the JCR and the bootstrap directory.
  • Only XML files are observed. All other extensions are filtered out.

Setting the bootstrap directory

For content import to work the bootstrap directory MUST be set. Observation will not take place until the property is added.

The bootstrap directory is set in the magnolia.properties file.

The bootstrap directory can reside anywhere on the file system and can be named anything you like.

To set the bootstrap directory add the magnolia.content.bootstrap.dir property to magnolia.properties.

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 XML 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.

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 displays in the Tasks tab in the Pulse.

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

Node nameValue

 
content-importer


 
tasks


 
content


 
users


 
superuser

superuser

 
eric

eric

 
groups


 
travel-demo-editors

travel-demo-editors

 
viewMapping


 
taskView

content-importer:content

 
title

Content Import Request

Properties:

tasks

optional

Tasks folder.

content

required

Task name.

users

optional

Users who can view and assign tasks.

This property has been introduced with Magnolia 5.6.6. Until then only superuser could bootstrap content (hardcoded in the module).

(info) Please note that at least one user or one group (see the next property) should be defined for bootstrap messages to be displayed. 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 displays when the user opens a task.This view is mapped to the Content Import Request task in the taskView property (above).

The Import (approve) action uses a custom action implementation class that is responsible 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.

Node nameValue

 
content-importer


 
messageViews


 
content


 
form


 
actions


 
approve


 
availability


 
class

info.magnolia.ui.admincentral.shellapp.pulse.task.action.ResolveTaskActionDefinition

 
decision

approve

 
icon

icon-publish

 
implementationClass

info.magnolia.content.action.BootstrapAction

 
confirmRejection


 
retry


 
claim


 
archive


 
abort


 
actionbar


Properties:

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:
    Properties:

    availability optional
    Availability rules node.
    class

    required
    Action definition class.

    $webResourceManager.requireResource("info.magnolia.sys.confluence.artifact-info-plugin:javadoc-resource-macro-resources") ResolveTaskActionDefinition
    : Action for resolving a task.

    decision required
    Decision.
    icon optional
    Action icon.
    implementationClass
    optional
    Implementation class.
    $webResourceManager.requireResource("info.magnolia.sys.confluence.artifact-info-plugin:javadoc-resource-macro-resources") 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.