Importing data

WebCmsModule provides infrastructure for easy importing of data using YAML files. The data import services are also the ones used for the default data of WebCmsModule. See the default data section for the YAML version of the default types and assets.


The WebCmsDataImportService allows importing data from Map structures. The Map based data could for example be sourced from YAML, JSON or XML files.

When converting to the domain model, the WebCmsDataImportService will dispatch to WebCmsDataImporter beans for handling data items. The WebCmsDataConversionService is used to convert from raw values (for example String) to the actual data type (for example WebCmsPage).

Example importing from YAML file data
Yaml yaml = new Yaml();
Map<String, Object> data = (Map<String, Object>) yaml.load( inputStream );
dataImportService.importData( data );

Using an installer

The AbstractWebCmsDataInstaller is a base class for an installer that imports one or more YAML files using the WebCmsDataImportService. The files specified will be imported in registration order.

Example YAML data installer
@Installer(description = "Install some test data", phase = InstallerPhase.AfterContextBootstrap, version = 1)
public class TestDataInstaller extends AbstractWebCmsDataInstaller
	protected void registerResources( List<String> locations ) {
		locations.add( "classpath:installers/test-data/my-types.yml" );
		locations.add( "classpath:installers/test-data/my-assets.yml" );