Let's assume that you followed this Blog and you know that it is possible to set up a repository project by using the AMP archetype which is provided via Maven. Then you already have the source folder which is 'config' which contains a subfolder which is named 'context''. Here the steps:
- Create a new folder 'bootsrap' inside the 'context' folder
- Create a new xml file named bootstrap-context inside the context folder and add the following to it:
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <bean id="${groupId}.${artifactId}.myBootstrap" class="org.alfresco.repo.module.ImporterModuleComponent" parent="module.baseComponent"> <!-- Module Details --> <property name="moduleId" value="${pom.artifactId}" /> <property name="name" value="myBootstrap" /> <property name="description" value="For bootstrapping purposes" /> <property name="sinceVersion" value="1.0" /> <property name="appliesFromVersion" value="1.0" /> <!-- Data --> <property name="importer" ref="spacesBootstrap"/> <property name="bootstrapViews"> <list> <!-- Bootstrap the categories --> <props> <prop key="path">/cm:categoryRoot/cm:generalclassifiable</prop> <prop key="location">alfresco/module/${artifactId}/bootstrap/my_categories.xml</prop> </props> </list> </property> </bean> </beans>
- Now import the this context by adding the following line to the file 'config/module-context.xml':
<import resource="classpath:alfresco/module/${artifactId}/context/bootstrap-context.xml"/>
- Finally create an XML file named 'my_categories.xml which contains your category names like this:
<view:view xmlns:view="http://www.alfresco.org/view/repository/1.0" xmlns:sys="http://www.alfresco.org/model/system/1.0" xmlns:cm="http://www.alfresco.org/model/content/1.0"> <cm:category> <cm:name>My Categories</cm:name> <cm:subcategories> <cm:category> <cm:name>My first category</cm:name> <cm:subcategories> <cm:category> <cm:name>My second category</cm:name> </cm:category> <cm:category> <cm:name>My third category</cm:name> </cm:category> <cm:category> <cm:name>My last category</cm:name> </cm:category> </cm:subcategories> </cm:category> </cm:subcategories> </cm:category> </view:view>
You can also bootstrap complete folders by referencing an A(lfresco)C(ontent)P(ackage) instead the XML file.
ReplyDelete