<?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>

    <!-- 
    The Shutdown Backstop Bean is a special bean which is used to terminate Alfresco if its 
    normal shutdown does not complete in a reasonable time - it needs to go first so it can 
    terminate any of the following beans if they misbehave.
    -->
    <bean id="shutdownBackstop" class="org.alfresco.repo.shutdown.ShutdownBackstop">
       <property name="timeout">
            <value>${shutdown.backstop.timeout}</value>
       </property>
       <property name="enabled">
          <value>${shutdown.backstop.enabled}</value>
       </property>   
    </bean>  


    <!-- 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="dialect">
          <ref bean="dialect" />
       </property>
       <property name="maximumStringLength">
          <value>${system.maximumStringLength}</value>
       </property>
       <property name="hibernateMaxExecutions">
          <value>${system.hibernateMaxExecutions}</value>
       </property>
       <property name="updateSchema">
          <value>${db.schema.update}</value>
       </property>
       <property name="stopAfterSchemaBootstrap">
          <value>${db.schema.stopAfterSchemaBootstrap}</value>
       </property>
       <property name="schemaUpdateLockRetryCount">
          <value>${db.schema.update.lockRetryCount}</value>
       </property>
       <property name="schemaUpdateLockRetryWaitSeconds">
          <value>${db.schema.update.lockRetryWaitSeconds}</value>
       </property>
       <property name="preCreateScriptUrls">
          <list>
             <value>classpath:alfresco/dbscripts/create/3.3/${db.script.dialect}/AlfrescoCreate-3.3-RepoTables.sql</value>
          </list>
       </property>
       <property name="postCreateScriptUrls">
          <list>
             <value>classpath:alfresco/dbscripts/create/2.2/${db.script.dialect}/AlfrescoPostCreate-2.2-Extra.sql</value>
             <value>classpath:alfresco/dbscripts/create/2.2/${db.script.dialect}/post-create-indexes-04.sql</value>
             <value>classpath:alfresco/dbscripts/create/3.0/${db.script.dialect}/create-activities-extras.sql</value>
             <value>classpath:alfresco/dbscripts/create/3.2/${db.script.dialect}/AlfrescoPostCreate-3.2-LockTables.sql</value>
             <value>classpath:alfresco/dbscripts/create/3.2/${db.script.dialect}/AlfrescoPostCreate-3.2-ContentTables.sql</value>
             <value>classpath:alfresco/dbscripts/create/3.2/${db.script.dialect}/AlfrescoPostCreate-3.2-PropertyValueTables.sql</value>
             <value>classpath:alfresco/dbscripts/create/3.2/${db.script.dialect}/AlfrescoPostCreate-3.2-AuditTables.sql</value>
             <value>classpath:alfresco/dbscripts/create/3.2/${db.script.dialect}/AlfrescoPostCreate-3.2-AvmTables.sql</value>
             <value>classpath:alfresco/dbscripts/create/3.2/${db.script.dialect}/AlfrescoPostCreate-3.2-Indexes.sql</value>
             <value>classpath:alfresco/dbscripts/create/3.2/${db.script.dialect}/AlfrescoPostCreate-3.2-JBPM-Extra.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" />
             <ref bean="patch.db-V2.1-NotNullColumns" />
             <ref bean="patch.db-V2.2-ACL-From-2.1-A" />
             <ref bean="patch.db-V2.2-ACL" />
             <ref bean="patch.db-V2.2-CleanNodeStatuses" />
             <ref bean="patch.db-V2.2-0-CreateMissingTables" />
             <ref bean="patch.db-V2.2-Upgrade-From-2.1" />
             <ref bean="patch.db-V2.2-Upgrade-From-2.2SP1" />
             <ref bean="patch.db-V2.2-Person-3" />
             <ref bean="patch.db-V3.2-LockTables" />
             <ref bean="patch.db-V3.2-ContentTables" />
             <ref bean="patch.db-V3.2-ContentTables2" />
             <ref bean="patch.db-V3.2-PropertyValueTables" />
             <ref bean="patch.db-V3.2-AuditTables" />
             <ref bean="patch.db-V3.2-Child-Assoc-QName-CRC" />
          </list>
       </property>
       <property name="postUpdateScriptPatches">
          <list>
             <ref bean="patch.db-V1.4-TxnCommitTimeIndex" />
             <ref bean="patch.db-V2.0-ContentUrls" />
             <ref bean="patch.db-V2.1-JBPMData" />
             <ref bean="patch.db-V2.1-VersionColumns2" />
             <ref bean="patch.db-V2.1-JBPMProcessKey" />
             <ref bean="patch.db-V2.1-RemoveWcmSubmittedAspect" />
             <ref bean="patch.db-V2.1-AuditPathIndex" />
             <ref bean="patch.db-V3.0-0-CreateActivitiesExtras" />
             <ref bean="patch.db-V3.1-Allow-IPv6" />
             <ref bean="patch.db-V3.2-Remove-AVM-Issuer" />
             <ref bean="patch.db-V3.2-Modify-AVM-MimeType" />
             <ref bean="patch.db-V3.2-Upgrade-JBPM" />
             <ref bean="patch.db-V3.3-Remove-VersionCount" />
             <ref bean="patch.db-V3.3-Fix-Repo-Seqs_1" />
          </list>
       </property>
    </bean>

    <!-- Set up JGroups communication, if necessary -->
    <bean name="jgroupsChannelFactory" class="org.alfresco.repo.jgroups.AlfrescoJGroupsChannelFactory">
        <property name="clusterName">
            <value>${alfresco.cluster.name}</value>
        </property>
        <property name="configUrlsByAppRegion">
            <map>
                <entry key="DEFAULT">
                    <value>${alfresco.jgroups.configLocation}</value>
                </entry>
            </map>
        </property>
    </bean>

    <!-- Bootstrap the AVM -->
    <bean id="avmBootstrap" class="org.alfresco.repo.avm.AvmBootstrap" >
       <property name="avmLockingAwareService">
            <ref bean="avmLockingAwareService"/>
       </property>
       <property name="avmRepository">
         <ref bean="avmRepository"/>
       </property>
       <property name="permissionService">
         <ref bean="permissionService"/>
       </property>
       <property name="avmSyncService">
            <ref bean="avmSyncService"/>
       </property>
    </bean>

    <!-- Bootstrap AVM Locking Service. -->
    <bean id="avmLockingBootstrap" class="org.alfresco.repo.avm.locking.AVMLockingBootstrap">
       <property name="avmLockingService" ref="avmLockingService"/>
       <property name="transactionService" ref="transactionService"/>
    </bean>
    
    <!-- Load models -->
    <bean id="dictionaryRepositoryBootstrap" class="org.alfresco.repo.dictionary.DictionaryRepositoryBootstrap">

      <property name="dictionaryDAO" ref="dictionaryDAO"/>
      <property name="contentService" ref="ContentService"/>
      <property name="transactionService" ref="transactionService"/>
      <property name="namespaceService" ref="namespaceService"/>
      <property name="nodeService" ref="NodeService"/>
      <property name="messageService" ref="messageService"/>
      <property name="tenantAdminService" ref="tenantAdminService"/>
      
      <property name="repositoryModelsLocations">
         <list>
            <ref bean="customModelsRepositoryLocation" />
         </list>
      </property>
      
      <property name="repositoryMessagesLocations">
         <list>
            <ref bean="customMessagesRepositoryLocation" />
         </list>
      </property>
      
   </bean>

    <!-- Bootstrap Data: Concrete instances for the basic Alfresco bootstrap -->
    <bean id="systemInfoBootstrap" parent="systemInfoBootstrap-base" singleton="true" />
    <bean id="userBootstrap" parent="userBootstrap-base" singleton="true" />
    <bean id="systemBootstrap" parent="systemBootstrap-base" singleton="true" />
    <bean id="versionBootstrap" parent="versionBootstrap-base" singleton="true" />
    <bean id="version2Bootstrap" parent="version2Bootstrap-base" singleton="true" />
    <bean id="spacesArchiveBootstrap" parent="spacesArchiveBootstrap-base" singleton="true" />
    <!--
        NOOP for fresh bootstrap (will skip store creation) - provides ordering when performing a repo restore (bootstrap import)
    -->
    <bean id="spacesModelsBootstrap" parent="storeImporter" singleton="true" />
    <bean id="spacesBootstrap" parent="spacesBootstrap-base" singleton="true" />
    
    <bean id="siteAVMBootstrap" class="org.alfresco.repo.site.SiteAVMBootstrap">
        <property name="avmService" ref="AVMService" />
        <property name="permissionService" ref="PermissionService" />
        <property name="transactionService" ref="TransactionService" />
        <property name="storename">
            <value>sitestore</value>
        </property>
        <property name="rootdir">
            <value>alfresco</value>
        </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>
               <props>
                    <!-- WCM workflow definition -->
                    <prop key="engineId">jbpm</prop>
                    <prop key="location">alfresco/workflow/changerequest_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/submitdirect_processdefinition.xml</prop>
                    <prop key="mimetype">text/xml</prop>
                    <prop key="redeploy">false</prop>
                </props>
            
             <!-- Invitation service workflow definition -->
            <props>
               <prop key="engineId">jbpm</prop>
               <prop key="location">alfresco/workflow/invitation-nominated_processdefinition.xml</prop>
               <prop key="mimetype">text/xml</prop>
               <prop key="redeploy">false</prop>
            </props>
            
            <!-- Invitation service workflow definition -->
            <props>
               <prop key="engineId">jbpm</prop>
               <prop key="location">alfresco/workflow/invitation-moderated_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>
               <value>alfresco/workflow/invitation-nominated-workflow-model.xml</value>
               <value>alfresco/workflow/invitation-moderated-workflow-model.xml</value>
            </list>
        </property>
        <property name="labels">
            <list>
               <value>alfresco/workflow/workflow-messages</value>
               <value>alfresco/workflow/wcm-workflow-messages</value>
               <value>alfresco/workflow/invitation-nominated-workflow-messages</value>
               <value>alfresco/workflow/invitation-moderated-workflow-messages</value>
            </list>
        </property>
        <property name="repositoryWorkflowDefsLocations" ref="customWorkflowDefsRepositoryLocation"/>
    </bean>
    
    <!-- Bootstrap MT (multi-tenancy) if applicable -->
    <bean id="multiTenantBootstrap" class="org.alfresco.repo.tenant.MultiTenantBootstrap" >
        <property name="tenantAdminService" ref="tenantAdminService" />
    </bean>
       
    <!-- Bootstrap any extensions -->
   
    <import resource="classpath*:alfresco/extension/bootstrap/*-context.xml" />
    
    <!--  Start third party transformer Subsystem. -->
    <bean id="thirdparty" class="org.alfresco.repo.management.subsystems.ChildApplicationContextFactory" parent="abstractPropertyBackedBean">
        <property name="autoStart">
            <value>true</value>
        </property>
    </bean>

    <bean id="OOoDirect" class="org.alfresco.repo.management.subsystems.ChildApplicationContextFactory" parent="abstractPropertyBackedBean">
        <property name="autoStart">
            <value>true</value>
        </property>
    </bean>


    <!-- Bootstrap any enterprise contexts -->
    <!-- This is placed at this point because we need the enterprise OOoJodConverter subsystem started
         before reindexing begins. -->
    <import resource="classpath*:alfresco/enterprise/bootstrap/*-context.xml" />


    <!-- Perform index recovery before applying any patches -->
    <!-- rebuild the index if required - before we check that it is there -->
    
    <bean id="indexRecoveryBootstrap" class="org.alfresco.repo.node.index.IndexRecoveryBootstrapBean" >
       <property name="indexRecoveryComponent">
           <ref bean="indexRecoveryComponent"/>
       </property>
    </bean>
    
    <bean id="avmIndexRecoveryBootstrap" class="org.alfresco.repo.node.index.IndexRecoveryBootstrapBean" >
       <property name="indexRecoveryComponent">
          <ref bean="avmIndexRecoveryComponent"/>
       </property>
    </bean>

    <!-- Descriptor Service -->
    <bean id="descriptorComponent" class="org.alfresco.repo.descriptor.DescriptorServiceImpl">
       <property name="serverDescriptorDAO">
           <ref bean="serverDescriptorDAO"/>
       </property>
       <property name="currentRepoDescriptorDAO">
           <ref bean="currentRepoDescriptorDAO"/>
       </property>
       <property name="installedRepoDescriptorDAO">
           <ref bean="installedRepoDescriptorDAO"/>
       </property>
       <property name="transactionService">
           <ref bean="transactionService"/>
       </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="transactionService"/>
       </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>
       <property name="avmSnapShotTriggeredIndexingMethodInterceptor">
           <ref bean="avmSnapShotTriggeredIndexingMethodInterceptor"/>
        </property>
    </bean>


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

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

    <!-- Import other Alfresco bootstrap components -->
    <import resource="classpath*:alfresco/alfresco-*-bootstrap-context.xml" />

    <!-- Start module components -->

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

    <!--  System Administration Parameters -->
    <bean id="sysAdmin" class="org.alfresco.repo.management.subsystems.ChildApplicationContextFactory" parent="abstractPropertyBackedBean"/>

    <!--  File Servers Subsystem -->
    <bean id="fileServers" class="org.alfresco.repo.management.subsystems.ChildApplicationContextFactory" parent="abstractPropertyBackedBean">
        <property name="autoStart">
            <value>true</value>
        </property>
        <property name="compositePropertyTypes">
            <map>
                <entry key="nfs.user.mappings">
                    <value>org.alfresco.filesys.auth.nfs.UserMapping</value>
                </entry>
                <entry key="filesystem.acl.global.domainAccessControls">
                    <value>org.alfresco.filesys.config.acl.DomainAccessControlBean</value>
                </entry>
                <entry key="filesystem.acl.global.protocolAccessControls">
                    <value>org.alfresco.filesys.config.acl.ProtocolAccessControlBean</value>
                </entry>
                <entry key="filesystem.acl.global.userAccessControls">
                    <value>org.alfresco.filesys.config.acl.UserAccessControlBean</value>
                </entry>
                <entry key="filesystem.domainMappings">
                    <value>org.alfresco.filesys.config.DomainMappingConfigBean</value>
                </entry>
            </map>
        </property>
    </bean>

   <bean id="fileServerConfiguration" class="org.alfresco.repo.management.subsystems.SubsystemProxyFactory">
      <property name="sourceApplicationContextFactory">
         <ref bean="fileServers" />
      </property>
      <property name="interfaces">
         <list>
            <!--  Allow authentication subsystem to see file server config at runtime -->
            <value>org.alfresco.filesys.ExtendedServerConfigurationAccessor</value>
            <!-- Allow export as MBean -->
            <value>org.alfresco.filesys.FileServerConfigMBean</value>
         </list>
      </property>
   </bean>

    <!-- IMAP Subsystem -->
    <bean id="imap" class="org.alfresco.repo.management.subsystems.ChildApplicationContextFactory" parent="abstractPropertyBackedBean">
        <property name="autoStart">
            <value>true</value>
        </property>
        <property name="compositePropertyTypes">
            <map>
               <entry key="imap.config.server.mountPoints">
                   <value>org.alfresco.repo.imap.config.ImapConfigMountPointsBean</value>
               </entry>
               <entry key="imap.config.ignore.extraction">
                   <value>org.alfresco.util.config.RepositoryFolderConfigBean</value>
               </entry>
            </map>
        </property>
    </bean>

    <!-- Outbound Email subsystem -->
    <bean id="OutboundSMTP" class="org.alfresco.repo.management.subsystems.ChildApplicationContextFactory" parent="abstractPropertyBackedBean">
        <property name="category">
            <value>email</value>
        </property>
        <property name="typeName">
            <value>OutboundSMTP</value>
        </property>
        <property name="instancePath">
            <list>
                <value>outbound</value>
            </list>
        </property>
        <property name="autoStart">
            <value>true</value>
        </property>
    </bean>

    <!-- Inbound Email subsystem -->
    <bean id="InboundSMTP" class="org.alfresco.repo.management.subsystems.ChildApplicationContextFactory" parent="abstractPropertyBackedBean">
        <property name="category">
            <value>email</value>
        </property>
        <property name="typeName">
            <value>InboundSMTP</value>
        </property>
        <property name="instancePath">
            <list>
                <value>inbound</value>
            </list>
        </property>
        <property name="autoStart">
            <value>true</value>
        </property>
    </bean>
    
    <!--  GoogleDocs subsystem -->
    <bean id="googledocs" class="org.alfresco.repo.management.subsystems.ChildApplicationContextFactory" parent="abstractPropertyBackedBean">
        <property name="autoStart">
            <value>true</value>
        </property>
    </bean>
    
    <!-- Start the quartz scheduler -->

    <bean id="schedulerStarter" class="org.alfresco.util.SchedulerStarterBean" >
       <property name="scheduler">
           <ref bean="schedulerFactory"/>
       </property>
    </bean>



    <!--  User usage tracking (requires a query across all users on startup) -->
    <bean id="userUsageTrackingComponent" class="org.alfresco.repo.usage.UserUsageTrackingComponent">
        <property name="transactionService">
            <ref bean="transactionService"/>
        </property>
        <property name="contentUsageImpl">
            <ref bean="contentUsageImpl"/>
        </property>
        <!-- The store in which people are persisted-->
        <property name="personStoreUrl">
           <value>${spaces.store}</value>
        </property>
        <property name="nodeService">
            <ref bean="nodeService"/>
        </property>
        <property name="nodeDaoService">
            <ref bean="nodeDaoService"/>
        </property>
        <property name="usageService">
            <ref bean="usageService"/>
        </property>
        <property name="tenantAdminService">
            <ref bean="tenantAdminService" />
        </property>
        <property name="tenantService">
            <ref bean="tenantService" />
        </property>
        <property name="clearBatchSize">
            <value>50</value>
        </property>
        <property name="updateBatchSize">
            <value>50</value>
        </property>
        <property name="enabled">
            <value>${system.usages.enabled}</value>
        </property>
    </bean>

    <!-- User registry synchronization jobs (e.g. LDAP) -->
    <bean id="Synchronization" class="org.alfresco.repo.management.subsystems.ChildApplicationContextFactory" parent="abstractPropertyBackedBean">
        <property name="autoStart">
            <value>true</value>
        </property>
    </bean>

    <!-- Workflow Scheduler -->
    <bean id="workflowScheduler" class="org.alfresco.repo.workflow.jbpm.JBPMScheduler">
       <property name="JBPMTemplate" ref="jbpm_template" />
    </bean>

    <!--  Start Auditing -->
    <bean id="Audit" class="org.alfresco.repo.audit.model.AuditModelRegistryImpl" parent="abstractPropertyBackedBean">
        <property name="searchPath">
            <list>
                <value>classpath*:alfresco/audit/*.xml</value>
                <value>classpath*:alfresco/enterprise/audit/*.xml</value>
                <value>classpath*:alfresco/module/*/audit/*.xml</value>
                <value>classpath*:alfresco/extension/audit/*.xml</value>
            </list>
        </property>
        <property name="transactionService" ref="transactionService" />
        <property name="auditDAO" ref="auditDAO" />
        <property name="dataExtractors" ref="auditModel.extractorRegistry" />
        <property name="dataGenerators" ref="auditModel.generatorRegistry" />
        <property name="autoStart">
            <value>true</value>
        </property>
    </bean>

   <!-- Repository helper class -->
   <bean id="repositoryHelper" class="org.alfresco.repo.model.Repository">
      <property name="transactionHelper" ref="retryingTransactionHelper" />
      <property name="namespaceService" ref="namespaceService" />
      <property name="nodeService" ref="nodeService" />
      <property name="personService" ref="personService" />
      <property name="fileFolderService" ref="fileFolderService" />
      <property name="searchService" ref="searchService" />
      <property name="tenantAdminService" ref="tenantAdminService" />
      <property name="avmService" ref="AVMService" />
      <property name="companyHomeStore"><value>${spaces.store}</value></property>
      <property name="companyHomePath"><value>/${spaces.company_home.childname}</value></property>
   </bean>

    <!-- Startup Message -->

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