Bootstrap Data
From AlfrescoWiki
For many content models, it is useful to have some data populated when the model is loaded. This is done by bootstrapping some data. One good example is in the Records Management module.
Importing the data in an import XML file or an ACP file as part of your modules initialization can be easily done.
- First place your ACP or XML file somewhere in your module's class path. Often this will be in the config folder structure.
- Next add the following config to your module-context.xml file, specifying either the XML or ACP file by its location on the classpath.
<bean id="myModule.bootstrap"
class="org.alfresco.repo.module.ImporterModuleComponent"
parent="module.baseComponent">
<!-- Module Details -->
<property name="moduleId" value="myModule" />
<property name="name" value="myModuleBootstrap" />
<property name="description" value="My Modules initial data requirements" />
<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">alfresco/module/myModule-123/myACP.acp</prop>
</props>
</list>
</property>
</bean>
Property Values
- moduleId = the id of the module that this import component relates to.
- name = the name of the import component.
- description = a description of the import component.
- sinceVersion = the version of the module this import component was introduced.
- appliesFromVersion = the version of the module from which this import component applies from.
- importer = the importer to use when importing the data
BootstrapViews
A list of the ACP or XML files to be imported and the location in the destination repository where the data should be imported.
[edit] Procedure for Adding Bootstrapped Files
Where you put them in the amp structure does not matter at all. what does matter is how you bootstrap it. bootstrap code allows you to refer to an xml file which points to how nodes are supposed to be added.
You can add your information in oen of two ways - in an xml file that points to files explicitly, or an ACP file, (which also has an xml file that points to file, it's just easier to generate it through space export).
The easiest way to do this is:
1. Put your webscripts into the appropriate directory in data dictionary. 2. Delete ALL webscripts OTHER than yours. 3. Do an export of the contents of the directory. This will create an ACP file. Download the ACP file to your desktop and copy it to one of the module directories (e.g. bootstrap). 4. Create bootstrap-context.xml in context subdirectory of your module, i.e. config\alfresco\module\org.alfresco.module.yourmodule\context\ 5. In the file, add a bean for bootstrapping, and point it to the acp file:
<!-- Bootstrap -->
<bean id="org_alfresco_module_bootstrapSpaces" class="org.alfresco.repo.module.ImporterModuleComponent" parent="module.baseComponent">
<property name="moduleId" value="org.alfresco.module.yourmodule.project" />
<property name="name" value="org.alfresco.module.yourmodule.bootstrapSpaces" />
<property name="description" value="Initial data requirements" />
<property name="sinceVersion" value="0.4" />
<property name="appliesFromVersion" value="0.4" />
<!-- Data properties -->
<property name="importer" ref="spacesBootstrap"/>
<property name="bootstrapViews">
<list>
<props>
<prop key="path">/cm:categoryRoot/cm:generalclassifiable</prop>
<prop key="location">alfresco/module/org.alfresco.module.yourmodule/bootstrap/rm_categories.xml</prop>
</props>
<props>
<props>
<prop key="path">/${spaces.company_home.childname}/${spaces.dictionary.childname}/Web Scripts</prop>
<prop key="location">alfresco/bootstrap/web_scripts.acp</prop>
</props>
</list>
</property>
</bean>
In the snippet above, web_scripts.acp should get exploded to Web Scripts directory (i am not sure about the exact string you should be using there, so you might have to play around with that one).
After that, you can start testing. The bootstrap happens when you startup the first time after installing that AMP. There is no good way to uninstall AMP right now, so for testing purposes, you can delete your db and file store, and recreate it from scratch. There might be a better way, don't know.
[edit] Space Names Reference
The following are the substitution tokens that can be used for bootstrapping purposes. These tokens can be redefines in the configuration files if needed.
- spaces.store=workspace://SpacesStore
- spaces.company_home.childname=Company Home
- spaces.guest_home.childname=Guest Home
- spaces.dictionary.childname=Data Dictionary
- spaces.templates.childname=Templates
- spaces.templates.content.childname=Content Templates
- spaces.templates.email.childname=Email Templates
- spaces.templates.rss.childname=RSS Templates
- spaces.savedsearches.childname=Saved Searches
- spaces.scripts.childname=Scripts
- spaces.wcm.childname=WCM
- spaces.wcm_content_forms.childname=Web Forms
- spaces.content_forms.childname=Web Forms
- spaces.user_homes.childname=User Homes
- spaces.projects.childname=Space Templates

