Content Importer

The content importer is a tool that can be used to import content JSON, i.e. content data expressed as JSON on file. Content JSON is the cornerstone for configuring types, variants, callbacks and other configurations in ACE.

The importer is part of the ACE Maven Plugin.

Setup

To facilitate the usage of the importer plugin you should add the plugin group com.atex.plugins to Maven's settings.xml.

Update maven settings.xml
  <pluginGroups>
    ...
    <pluginGroup>com.atex.plugins</pluginGroup>
  </pluginGroups>

Running the importer

To run the importer just run mvn ace:import from the top of your project directory. The importer will traverse all submodules and try to import all files in the respective src/main/content folders. Files in src/main/content/**/contentfiles/** will be ignored unless referenced by a content.

For a complete reference on the ACE Maven Plugin please see there.

Generate content jar automatically

To automatically generate a content jar when you build the project, add this to the project pom.xml

<build>
...
<pluginManagement>
  <plugins>
    ...
    <plugin>
      <groupId>com.atex.plugins</groupId>
      <artifactId>ace-maven-plugin</artifactId>
      <version>0.9.3-SNAPSHOT</version>
    </plugin>
    ...
  </plugins>
</pluginManagement>
<plugins>
 <plugin>
    ...
    <groupId>com.atex.plugins</groupId>
    <artifactId>ace-maven-plugin</artifactId>
    <version>0.9.3-SNAPSHOT</version>
    <executions>
      <execution>
        <id>package-jar</id>
        <goals>
          <goal>package</goal>
        </goals>
      </execution>
    </executions>
  </plugin>
  ...
</plugins>
...
</build>

You can also do this manually by running mvn ace:package

Importer metadata

The importer's file format is mostly the same as the web service's document format, but to deal with things that would normally go in e.g. the URL, there is an additional importerMetadata object that can be included. There are two things you can do with this field: specify an alias, so you can update the content if it already exists rather than try to create a new content, and specify the updateMode (see Update modes in the web service documentation for details). The importerMetadata object is optional, but in practice an alias should almost always be used because most files will be imported more than once.

This example creates or updates the content with alias person/john_doe, and sets its name field to John Doe without overwriting any other fields. For an update the contentType field is not strictly required and for a create the updateMode field has no effect.

{
  "importerMetadata": {
    "alias": "person/john_doe",
    "updateMode": "merge"
  },
  "system": {
    "contentType": "myContentType"
  },
  "aspects": {
    "doc_example": {
      "name": "John Doe"
    }
  }
}
Importing content with file aspects

If the content JSON to be imported has got an aceFiles aspect with fileUris that begin with file:, the importer will first import those files (that are placed in the same directory as the current content JSON file), and replace the URIs with the URI returned by the file service.

{
   "importerMetadata" : {
      "alias" : "example/content.with.file"
   },
  "system": {
    "contentType": "myContentType"
  },
   "aspects" : {
      "aceFiles" : {
         "files" : {
            "my_file" : {
               "fileUri" : "file:images/filename_on_disk.jpg",
               "filePath" : "file.jpg"
            }
         },
         "_type" : "aceFiles"
      },
      ...
   }
}