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

<!-- Beans pertinent to node persistence and services --> 
<beans>
   
   <bean id="mlPropertyInterceptor" class="org.alfresco.repo.node.MLPropertyInterceptor">
      <property name="directNodeService">
         <ref bean="mlAwareNodeService"></ref>
      </property>
      <property name="dictionaryService">
         <ref bean="dictionaryService" />
      </property>
   </bean>
   
   <bean id="nodeService" class="org.springframework.aop.framework.ProxyFactoryBean" >
      <property name="targetName">
         <value>mlAwareNodeService</value>
      </property>
      <property name="proxyInterfaces">
         <list>
            <value>org.alfresco.service.cmr.repository.NodeService</value>
         </list>
      </property>
      <property name="interceptorNames">
         <list>
            <value>mlPropertyInterceptor</value>
         </list>
      </property>
   </bean>
   
   <bean id="mlAwareNodeService" class="org.alfresco.repo.service.StoreRedirectorProxyFactory">
      <property name="proxyInterface">
         <value>org.alfresco.service.cmr.repository.NodeService</value>
      </property>
      <property name="defaultBinding">
         <ref bean="dbNodeService"></ref>
      </property>
      <property name="redirectedProtocolBindings">
         <map>
            <entry key="workspace"><ref bean="dbNodeService"></ref></entry>
            <entry key="versionStore"><ref bean="versionNodeService"></ref></entry>
            <entry key="avm"><ref bean="avmNodeService"/></entry>
         </map>
      </property>
   </bean>
   
   <!-- Map stores to archive stores -->
   <bean id="storeArchiveMap" class="org.alfresco.repo.node.StoreArchiveMap">
      <property name="archiveMap">
         <map>
            <entry key="workspace://SpacesStore"><value>archive://SpacesStore</value></entry>
         </map>
      </property>
   </bean>
   
   <!-- Wrapper component to handle restore and purge of archived nodes -->
   <bean id="nodeArchiveService" class="org.alfresco.repo.node.archive.NodeArchiveServiceImpl" >
      <property name="nodeService">
         <ref bean="NodeService"/>
      </property>
      <property name="searchService">
         <ref bean="SearchService"/>
      </property>
      <property name="transactionService">
         <ref bean="transactionComponent"/>
      </property>
   </bean>

   <!-- The raw NodeService, implemented to persist to the database -->
   <bean id="dbNodeService" class="org.alfresco.repo.node.db.DbNodeServiceImpl" init-method="init" >
      <property name="dictionaryService">
         <ref bean="dictionaryService" />
      </property>
      <property name="nodeDaoService">
         <ref bean="nodeDaoService" />
      </property>
      <property name="policyComponent">
         <ref bean="policyComponent"/>
      </property>
      <property name="storeArchiveMap">
         <ref bean="storeArchiveMap"/>
      </property>
      <property name="avmNodeService">
         <ref bean="avmNodeService"/>
      </property>
   </bean>
   
   <!-- AVMNodeService -->
   <bean id="avmNodeService" class="org.alfresco.repo.avm.AVMNodeService" init-method="init">
		<property name="dictionaryService">
			<ref bean="dictionaryService"/>
		</property>
		<property name="avmService">
			<ref bean="avmService"/>
		</property>
		<property name="policyComponent">
			<ref bean="policyComponent"/>
		</property>
	</bean>
		
   <!-- Handles policy callbacks to ensure that node hierarchy gets indexed -->
   <bean id="nodeIndexer" class="org.alfresco.repo.node.index.NodeIndexer" init-method="init">
      <property name="policyComponent">
         <ref bean="policyComponent" />
      </property>
      <property name="indexer">
         <ref bean="indexerComponent" />
      </property>
   </bean>

   <!-- ensures model-compliance of node structures -->   
   <bean id="integrityChecker" class="org.alfresco.repo.node.integrity.IntegrityChecker" init-method="init">
      <property name="policyComponent">
         <ref bean="policyComponent"/>
      </property>
      <property name="dictionaryService">
         <ref bean="dictionaryService" />
      </property>
      <property name="nodeService">
         <ref bean="nodeService" />
      </property>
      <property name="enabled">
         <value>true</value>  <!-- on/off switch -->
      </property>
      <property name="traceOn">
         <value>false</value>  <!-- use only to trace problems -->
      </property>
      <property name="failOnViolation" >
         <value>true</value>
      </property>
      <property name="maxErrorsPerTransaction" >
         <value>5</value>  <!-- limit output (exception and log) to the first N violation messages -->
      </property>
   </bean>

   <!-- tags nodes that are incomplete w.r.t. properties-->   
   <bean id="incompleteNodeTagger" class="org.alfresco.repo.node.integrity.IncompleteNodeTagger" init-method="init">
      <property name="policyComponent">
         <ref bean="policyComponent"/>
      </property>
      <property name="dictionaryService">
         <ref bean="dictionaryService" />
      </property>
      <property name="nodeService">
         <ref bean="nodeService" />
      </property>
   </bean>
   
</beans>
