Bootstraping Data with Alfresco

When you work with Alfresco, soon you realize that there lot’s of data/configuration that has to be done to run Alfresco properly. In the end developing with Alfresco means extending it;

  • Implementing a custom content model
  • Setting up a repository structure
  • Applying custom rules on spaces
  • Adding users/groups and configuring access rights
  • …

It means every time you install a new Alfresco instance, you also have to setup these prerequisites. However there is a much simpler way to do it, you don’t have to do it by hand. You can use ImporterBootstraps, in order to do so what you have to do is;

  • Define a org.alfresco.repo.module.ImporterModuleComponent for your module
  • Configure it accordingly to import all your data

A module component is a bean that is executed only when the module is being installed for the first time, so it will not run again when you restart Alfresco.

ImporterBootstrap supports two formats for data import; xml and acp. Both of them are Alfresco specific formats and you can generate these files using Alfresco web client by exporting your content. Initially you have to do it all by hand but then you can export everything as xml and amp and reuse it.

See the following sample configuration for importing an acp at the time of module installation.

<bean id="amp-main.bootstrap" class="org.alfresco.repo.module.ImporterModuleComponent"
      parent="module.baseComponent">

    <!-- Module Details -->
    <property name="moduleId" value="amp-main"/>
    <property name="name" value="amp-main.bootstrap"/>
    <property name="description" value="Imports bootstrap data required by this module."/>
    <property name="sinceVersion" value="1.0"/>
    <property name="appliesFromVersion" value="1.0"/>

    <!-- Data properties -->
    <property name="importer" ref="spacesBootstrap"/>
    <property name="bootstrapViews">
        <list>
            <props>
                <prop key="path">/${spaces.company_home.childname}</prop>
                <prop key="location">com/sony/forest/roots/extensions/config/data/repository.acp</prop>
            </props>
        </list>
    </property>
</bean>

All you have to do is define this bean and configure it accordingly. It basically imports repository.acp on the given classpath to Company Home (/${spaces.company_home.childname}) space in Alfresco. You can find the complete list of childnames in repository.properties in Alfresco source.

This example extends only spacesBootstrap bean for inserting content to space. There are also other pre-configured importers for importing different kinds of data. Please refer to spring configuration file repository/config/alfresco/import-export-context.xml in Alfresco source code for more information or see this page on Alfresco Wiki.

One final tiny detail, it cost me one hour to figure it out. You have to use your module’s id for the moduleId property of the component. Otherwise Alfresco cannot relate this ModuleComponent with your module and as a result of this it is not executed. And you should also set the versions properly. I don’t know why they need this much configuration, it is like launching a rocket, just run the damn importer.

Read More Post

STAY CONNECTED

Most Popular

Why Serviced Apartments Are the Perfect Choice for Long-Term Stays in Singapore – Everything You Need to Know
17 Dec

Why Serviced Apartments Are the Perfect Choice for Long-Term Stays in Singapore – Everything You Need to Know

If you’re heading to Singapore for a few weeks or many months, maybe for work or study or just to

Manifesting Your Dream Career: Finding Your Passion And Purpose
01 Aug

Manifesting Your Dream Career: Finding Your Passion And Purpose

Are you passionate about finding your dream career? Manifesting can help you align your career with your passions and purpose.

Revolutionizing Your Ride: Expert Auto Service At Carolina Auto Service
27 Feb

Revolutionizing Your Ride: Expert Auto Service At Carolina Auto Service

Finding a reliable auto service provider is paramount in the bustling world of vehicle maintenance and repair. That's where Carolina

Floratam: The Robust Grass Solution From Council Growers SOD
25 Jan

Floratam: The Robust Grass Solution From Council Growers SOD

Floratam grass, a popular St. Augustine variety, has become a go-to choice for homeowners and landscapers seeking a lush, durable

Carolina Mobile Autoservice: Your Go-To For Expert Brake Service Repair
25 Jan

Carolina Mobile Autoservice: Your Go-To For Expert Brake Service Repair

For vehicle owners, the braking system is among the most critical components for safety and performance. Carolina Mobile Autoservice, a

Safeguarding Your Property: Expert Water Damage Services By MBC Capital
24 Jan

Safeguarding Your Property: Expert Water Damage Services By MBC Capital

Water damage can significantly impact homes and businesses, often leaving a trail of destruction and disruption in its wake. Understanding