Alfresco Migration Preprocessor is an incredibly long name for such a simple feature! This tool provides a marshaller object that is (currently) able to
- Unmarshal one or more XML sources and transform them into a FS file/folder structure
- Invoke the File Import (shipped with Alfresco 4.** versions) pointing to the previously created FS structure
- Post-process recorded peer associations and create them accordingly, as soon as the import have finished
The Migration preprocessor extends XStream - the famous XML (de)serializer library - providing an AlfrescoXStreamMarshaller object which accepts the following inputs:
- One or more Java Beans, containing
- XStream-based annotations (i.e. XStreamAlias, XStreamImplicit, ...)
- Alfresco-based annotations (i.e. NodeProperty, or NodeAspect)
- One or more XML Sources; check our test XML files
It also provides an XmlBulkImporter which executes the XML unmarshalling and later invokes the FileImport to populate an Alfresco repository.
You can see how to use it in our JUnit test
Still not convinced? Imagine that you want to import the following 3 entities (1 cm:folder
and 2 cm:content
) into Alfresco:
<folder>
<name>foldername</name>
<title>Folder Title</title>
<description>the most awesome folder ever</description>
<isVersionable>true</isVersionable>
<children>
<content>
<name>contentname1</name>
<title>Content Title 1</title>
<description>the most awesome content ever 1</description>
<isVersionable>true</isVersionable>
<contentUrl>http://www.scala-lang.org/docu/files/ScalaByExample.pdf</contentUrl>
</content>
<content>
<name>contentname2</name>
<title>Content Title 2</title>
<description>the most awesome content ever 2</description>
<isVersionable>true</isVersionable>
<contentUrl>http://www.tug.org/pracjourn/2005-4/mertz/mertz.pdf</contentUrl>
<referenceNames>
<string>contentname1</string>
</referenceNames>
</content>
</children>
</folder>
Now you can do it without writing one single line of code.
You have a different input XML? Define Java Beans with fields and annotations that map your XML structure and you're ready to go!
To run the test
mvn clean test -Ppurge
- Files are created in
alf_data_dev/xml
- XML files being imported are located in
src/test/resources