AnsweredAssumed Answered

How to properly bootstrap folder in Company Home?

Question asked by patrykl on Jul 4, 2013
Latest reply on Jul 9, 2013 by patrykl
Hi.
I'm using Alfresco Community Edition 4.2.c. As I'm starting my journey with Alfresco I want to achieve something simple. I want to bootstrap new folder called MyFolder in Company Home space. I'm following this tutorial: http://wiki.alfresco.com/wiki/Bootstrap_Data

I have simple module with following module-context.xml file:

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>

<beans>
   <bean id="customSpacesBootstrap" parent="spacesStoreImporter"
      singleton="true">
      <property name="useExistingStore">
         <value>false</value>
      </property>
      <property name="bootstrapViews">
         <list>
            <props>
               <prop key="path">/${spaces.company_home.childname}</prop>
               <prop key="location">alfresco/module/myModule/bootstrap.xml</prop>
            </props>
         </list>
      </property>
   </bean>
</beans>


And my bootstrap.xml is also very simple:

<view:view xmlns:view="http://www.alfresco.org/view/repository/1.0"
   xmlns:cm="http://www.alfresco.org/model/content/1.0" xmlns:app="http://www.alfresco.org/model/application/1.0"
   xmlns:emailserver="http://www.alfresco.org/model/emailserver/1.0"
   xmlns:sys="http://www.alfresco.org/model/system/1.0">

   <cm:folder view:childName="cm:MyFolder">
      <app:uifacets />
      <cm:name>MyFolder</cm:name>
      <app:icon>space-icon-default</app:icon>
      <cm:title>MyFolder</cm:title>
      <cm:description>MyFolder</cm:description>
   </cm:folder>
</view:view>


And the problem is that it isn't creating MyFolder. I have tried to redeploy Alfresco with this module many times, including tests with wiping up Alfresco data repository folder and its database. I'm using default Tomcat with Postgres and Jetty + H2 - both behave the same. To make it work I have to change 'useExistingStore' to true. After that change and redeploy MyFolder is being created. But it creates another problem: when I redeploy again, Alfresco throws Exception during Spring context spin up, complaining about duplicate node name (MyFolder) and deeper about unique constraint violation from DB. So I have to change useExistingStore to false again. This is very inconvenient for final production environment.

From what I have read about useExistingStore, when set to false, it should behave exactly how I would like: create folder once and then skip any changes and touching it when it exists.

I have also read Alfresco spaces.xml and import-export-context.xml file. I can easily reproduce the problem in these files as well. For example in spaces.xml top level Company Home folder is created. When I add another top level folder besides it, lets call it CompanyHome2 and redeploy Alfresco - CompanyHome2 won't be created (but it does not exist so should be). But when I wipe out Alfresco data and redeploy then it will be created.

What am I doing wrong?

Outcomes