Bootstrapping Data in Alfresco

In various huge alfresco implementations generally we need to change lots out of box things in order to make it suitable for client’s environment. For instance each and every client wants to have their own directory structure which is based on some organizational hierarchy. So, we end up have so many onetime configuration which we needs to repeat each time we create new Alfresco instance. Each time we needs to create same folder structure, same set of rules after creating new instance which is tedious job. For large development project this needs to be replicated in every developer’s machine as well within development instance.

Recently I came to know about nice feature where alfresco take care of all this things itself during bootstrap. So, all we need to do is follow few simple steps to do it.

Step1:

Create one master instance with all onetime setup done properly.

Step2:

Export all that data inform of xml or ACP (For import export of data from Alfresco you can refer this post)

You can add your information in one of two ways:

1)      In XML file which points to files explicitly,

2)      ACP file The ACP packages an XML file that points to the files to be included, and is easier to generate through the space export feature.

For instance we have exported everything in to Setup.acp file.

Step3:

Download setup.acp file and add it into the package com/mycomp/test/bootstrap.

Step4:

Create bootstrap-context.xml in context subdirectory of your module, that is config/alfresco/module/module_id/context/

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.

In the file, add a bean for bootstrapping, and point it to the ACP file:

Configure ImporterModuleComponent bean which is responsible for this job

<bean id="amp-main.bootstrap"
      parent="module.baseComponent">

    <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/mycomp/test/bootstrap/setup.acp</prop>
            </props>
        </list>
    </property>
</bean>

In this case, setup.acp will be exploded to Company Home (/${spaces.company_home.childname}) space in Alfresco. You can find the complete list of childnames in repository.properties in Alfresco source. Since Alfresco parses XPath expressions the correct path to the CompanyHome folder you can have other locations mentioned there. It is possible to derive the correct XPath expression for any alfresco content by using the Node Browser.

References:

http://docs.alfresco.com/4.2/index.jsp?topic=%2Fcom.alfresco.enterprise.doc%2Fconcepts%2Fdev-extensions-modules-bootstrapping-files-spaces-xml.html

http://www.codinginahurry.com/2011/01/24/bootstraping-data-with-alfresco/

Looking for quality Alfresco Web Hosting ? Look no further than Arvixe Web Hosting !

Tags: , , , , , , | Posted under Alfresco | RSS 2.0

Author Spotlight

mitpatoliya

mitpatoliya

I love opensource technologies working with those technologies from the time I have stepped in to the Software Industry. Alfresco CMS is my area of expertise. I have worked on various complex implementations which involved integration of Alfresco with other technologies, extensively worked with JBPM workflows and Webscripts.

Leave a Reply

Your email address will not be published. Required fields are marked *


− 3 = 6

You may use these HTML tags and attributes: <a href="" title="" rel=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>