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


<!--
    Repository Bootstrap Sequence.
    
    This file specifies the initialisation (and order of initialisation) to perform during Repository startup.
    
    The pattern for adding new initialisation to the bootstrap sequence is as follows:
    
    1) Develop a bean that implements the Spring interface ApplicationListener
    2) Place the initialisation logic in the method onApplicationEvent(ApplicationEvent event)...
    
       public void onApplicationEvent(ApplicationEvent event)
       {
          if (event instanceof ContextRefreshedEvent)
          {
             // initialisation logic here
          }
       }
       
    3) Add the bean definition to this file - Note: the beans are initialised in the order they are specified.
-->

<beans>

   <!-- ensure that the schema is bootstrapped -->
   <bean id="schemaBootstrap" class="org.alfresco.repo.domain.schema.SchemaBootstrap" >
      <property name="localSessionFactory">
         <ref bean="&amp;sessionFactory"></ref>  <!-- inject the actual factory, not a session -->
      </property>
      <property name="updateSchema">
         <value>${db.schema.update}</value>
      </property>
      <property name="postCreateScriptUrls">
         <list>
            <value>classpath:alfresco/dbscripts/create/2.0/${db.script.dialect}/AlfrescoPostCreate-2.0-FKIndexes.sql</value>
         </list>
      </property>
      <property name="validateUpdateScriptPatches">
         <list>
         </list>
      </property>
      <property name="preUpdateScriptPatches">
         <list>
            <ref bean="patch.schemaUpdateScript-V1.4-1" />
            <ref bean="patch.schemaUpdateScript-V1.4-2" />
         </list>
      </property>
      <property name="postUpdateScriptPatches">
         <list>
            <ref bean="patch.db-V2.0-ExplicitIndexes" />
            <ref bean="patch.db-V2.0-AVMFKIndexes" />
         </list>
      </property>
   </bean>
   
   <!-- Bootstrap the AVM -->
   <bean id="avmBootstrap" class="org.alfresco.repo.avm.AvmBootstrap" >
      <property name="issuers">
         <list>
            <ref bean="nodeIssuer" />
            <ref bean="layerIssuer" />
         </list>
      </property>
   </bean>

	<!-- Bootstrap Files -->

    <bean id="systemInfoBootstrap" parent="systemInfoImporter">
    </bean>

    <bean id="userBootstrap" parent="userStoreImporter">
        <property name="bootstrapViews">
            <list>
                <props>
                    <prop key="path">/</prop>
                    <prop key="location">alfresco/bootstrap/alfrescoUserStore.xml</prop>
                </props>
                <props>
                    <prop key="path">/${alfresco_user_store.system_container.childname}</prop>
                    <prop key="location">alfresco/bootstrap/alfrescoAuthorityStore.xml</prop>
                </props>
                <props>
                    <prop key="path">/${alfresco_user_store.system_container.childname}</prop>
                    <prop key="location">alfresco/bootstrap/alfrescoAuthorityStorePermission.xml</prop>
                </props>
            </list>
        </property>
    </bean>

    <bean id="systemBootstrap" parent="systemStoreImporter">
        <property name="bootstrapViews">
            <list>
                <props>
                    <prop key="path">/</prop>
                    <prop key="location">alfresco/bootstrap/descriptor.xml</prop>
                </props>
                <props>
                    <prop key="path">/</prop>
                    <prop key="location">alfresco/bootstrap/systemRegistry.xml</prop>
                </props>
            </list>
        </property>
    </bean>

    <bean id="versionBootstrap" parent="versionStoreImporter">
        <property name="bootstrapViews">
            <list>
                <props>
                    <prop key="path">/</prop>
                    <prop key="location">alfresco/bootstrap/lightWeightVersionStore.xml</prop>
                </props>
            </list>
        </property>
    </bean>

    <bean id="spacesArchiveBootstrap" parent="spacesArchiveStoreImporter">
        <property name="bootstrapViews">
            <list>
                <props>
                    <prop key="path">/</prop>
                    <prop key="location">alfresco/bootstrap/spacesArchive.xml</prop>
                </props>
            </list>
        </property>
    </bean>

    <bean id="spacesBootstrap" parent="spacesStoreImporter">
        <property name="bootstrapViews">
            <list>
                <props>
                    <prop key="path">/</prop>
                    <prop key="location">alfresco/bootstrap/spaces.xml</prop>
                    <prop key="messages">alfresco/messages/bootstrap-spaces</prop>
                </props>
                <props>
                    <prop key="path">/</prop>
                    <prop key="location">alfresco/bootstrap/system.xml</prop>
                </props>
                <props>
                    <prop key="path">/</prop>
                    <prop key="location">alfresco/bootstrap/categories.xml</prop>
                </props>
                <props>
                    <prop key="path">/</prop>
                    <prop key="location">alfresco/bootstrap/multilingualRoot.xml</prop>
                </props>
                <props>
                    <prop key="path">/${spaces.company_home.childname}/${spaces.guest_home.childname}</prop>
                    <prop key="location">alfresco/bootstrap/tutorial.xml</prop>
                    <prop key="messages">alfresco/messages/bootstrap-tutorial</prop>
                </props>
                <props>
                    <prop key="path">/${spaces.company_home.childname}/${spaces.dictionary.childname}/${spaces.templates.childname}</prop>
                    <prop key="location">alfresco/templates/software_engineering_project.xml</prop>
                    <prop key="messages">alfresco/messages/bootstrap-templates</prop>
                </props>
                <props>
                    <prop key="path">/${spaces.company_home.childname}/${spaces.dictionary.childname}/${spaces.templates.content.childname}</prop>
                    <prop key="location">alfresco/templates/content_template_examples.xml</prop>
                </props>
                <props>
                    <prop key="path">/${spaces.company_home.childname}/${spaces.dictionary.childname}/${spaces.templates.email.childname}</prop>
                    <prop key="location">alfresco/templates/email_templates.acp</prop>
                </props>
                <props>
                    <prop key="path">/${spaces.company_home.childname}/${spaces.dictionary.childname}/${spaces.templates.rss.childname}</prop>
                    <prop key="location">alfresco/templates/rss_templates.acp</prop>
                </props>
                <props>
                    <prop key="path">/${spaces.company_home.childname}/${spaces.dictionary.childname}/${spaces.scripts.childname}</prop>
                    <prop key="location">alfresco/bootstrap/example_javascripts.acp</prop>
                </props>
            </list>
        </property>
    </bean>

    <bean id="workflowBootstrap" parent="workflowDeployer">
		<property name="workflowDefinitions">
			<list>
				<props>
					<prop key="engineId">jbpm</prop>
					<prop key="location">alfresco/workflow/review_processdefinition.xml</prop>
					<prop key="mimetype">text/xml</prop>
					<prop key="redeploy">false</prop>
				</props>
				<props>
					<prop key="engineId">jbpm</prop>
					<prop key="location">alfresco/workflow/adhoc_processdefinition.xml</prop>
					<prop key="mimetype">text/xml</prop>
					<prop key="redeploy">false</prop>
				</props>
			    <props>
                    <!-- WCM workflow definition -->
			    	<prop key="engineId">jbpm</prop>
			    	<prop key="location">alfresco/workflow/submit_processdefinition.xml</prop>
			    	<prop key="mimetype">text/xml</prop>
			    	<prop key="redeploy">false</prop>
			    </props>
			</list>
		</property>
		<property name="models">
			<list>
               <value>alfresco/workflow/workflowModel.xml</value>
               <value>alfresco/workflow/wcmWorkflowModel.xml</value>
			</list>
		</property>
		<property name="labels">
			<list>
			   <value>alfresco/workflow/workflow-messages</value>
               <value>alfresco/workflow/wcm-workflow-messages</value>
			</list>
		</property>
	</bean>

    <!-- Bootstrap any extensions -->
    
    <import resource="classpath*:alfresco/extension/bootstrap/*-context.xml" />

    <!-- Descriptor Service -->

    <bean id="descriptorComponent" class="org.alfresco.repo.descriptor.DescriptorServiceImpl">
       <property name="descriptor">
	       <value>classpath:alfresco/version.properties</value>
       </property>
       <property name="systemBootstrap">
           <ref bean="systemBootstrap"/>
       </property>
       <property name="transactionService">
           <ref bean="transactionComponent"/>
       </property>
       <property name="namespaceService">
           <ref bean="namespaceService"/>
       </property>
       <property name="nodeService">
           <ref bean="nodeService"/>
       </property>
       <property name="searchService">
           <ref bean="searchService"/>
       </property>
    </bean>
    
    <!-- This component checks the interconnection between the metadata, indexes and content -->
    <bean id="configurationChecker" class="org.alfresco.repo.admin.ConfigurationChecker">
       <property name="strict">
           <value>${system.bootstrap.config_check.strict}</value>
       </property>
       <property name="dirRoot">
           <value>${dir.root}</value>
       </property>
       <property name="indexRecoveryMode">
           <value>${index.recovery.mode}</value>
       </property>
       <!-- helper beans -->
       <property name="transactionService">
           <ref bean="transactionComponent"/>
       </property>
       <property name="systemBootstrap">
           <ref bean="systemBootstrap"/>
       </property>
       <property name="namespaceService">
           <ref bean="namespaceService"/>
       </property>
       <property name="nodeService">
           <ref bean="nodeService"/>
       </property>
       <property name="searchService">
           <ref bean="searchService"/>
       </property>
       <property name="contentService">
           <ref bean="contentService"/>
       </property>
    </bean>

    <!-- This component ensures that patches get applied on startup -->

    <bean id="patchExecuter" class="org.alfresco.repo.admin.patch.PatchExecuter">
        <property name="patchService">
            <ref bean="PatchService" />
        </property>
    </bean>

    <!-- Start module components -->

    <bean id="moduleStarter" class="org.alfresco.repo.module.ModuleStarter">
        <property name="moduleService">
            <ref bean="ModuleService" />
        </property>
    </bean>

    <!-- CIFS Server -->

    <bean id="fileServerConfiguration" class="org.alfresco.filesys.server.config.ServerConfiguration" parent="fileServerConfigurationBase">
       <property name="configService">
           <ref bean="fileServersConfigService"/>
       </property>
    </bean>
    
    <bean id="cifsServer" class="org.alfresco.filesys.CIFSServer" destroy-method="stopServer">
        <constructor-arg>
           <ref local="fileServerConfiguration"/>
        </constructor-arg>
    </bean>
   
    <!-- FTP Server -->
    
    <bean id="ftpServer" class="org.alfresco.filesys.FTPServer" destroy-method="stopServer">
        <constructor-arg>
           <ref local="fileServerConfiguration"/>
        </constructor-arg>
    </bean>

    <!-- NFS Server -->
    
    <bean id="nfsServer" class="org.alfresco.filesys.NFSServer" destroy-method="stopServer">
        <constructor-arg>
           <ref local="fileServerConfiguration"/>
        </constructor-arg>
    </bean>

	<!-- Startup Message -->

    <bean id="startupLog" class="org.alfresco.repo.descriptor.DescriptorStartupLog">
       <property name="descriptorService">
	       	<ref local="descriptorComponent"/>
       </property>
	</bean>
	
</beans>
