<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<!--
  - Application context definition for Graffito.
	-->
<beans>
	<!-- Transaction manager for a single OJB PersistenceBroker (alternative to JTA) -->
	<bean id="transactionManager" class="org.springframework.orm.ojb.PersistenceBrokerTransactionManager" />
	<!-- Transaction manager that delegates to JTA (for a transactional JNDI DataSource) -->
	<!--
	<bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"/>
	-->
	<bean id="baseTransactionProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" 
		abstract="true">
		<property name="transactionManager">
			<ref bean="transactionManager"/>
		</property>
		<property name="transactionAttributes">
			<props>
				<prop key="*">PROPAGATION_REQUIRED, -ContentManagementException</prop>
			</props>
		</property>
	</bean>
	<!--  
		   Graffito MASTER STORE
              The graffito master store is the mandatory content store in graffito. It contains all other content store references and if needed some cms objects.
-->
	<!--The graffito Master Store -->
	<bean id="graffitoMasterStore" class="org.apache.portals.graffito.model.server.impl.GraffitoServerImpl" >
		<!-- Either Alias property has to match  datasource component & set into the OJB repository.xml  
	       OR Uses the other graffitoServerImpl attributes to init the connection -->
		<property name = "alias">
			<value>graffitoMasterStoreDB</value>
		</property>
		<property name = "description">
			<value>The Graffito Master Server contains information about all server references. It may also contains some CMS 
				content like documents or folder. </value>
		</property>
		<property name = "scope">
			<value>/graffitotest</value>
		</property>
		<property name = "title">
			<value>graffito Master Server</value>
		</property>
		<property name = "storeClassName">
			<value>org.apache.portals.graffito.store.impl.ojb.GraffitoOJBStore</value>
		</property>
	</bean>
	<!-- 
		   CORE Graffito SERVICES 
	   The main services used by the Graffito engine
   -->
    
    <bean id="org.apache.portals.graffito.security.CmsAccessController" class="org.apache.portals.graffito.security.impl.EmptyCmsAccessControllerImpl"   />  	   
    
	
	<!-- Cms Request Context manager -->
	<bean id="org.apache.portals.graffito.context.CmsRequestContextManager" 
		class="org.apache.portals.graffito.context.impl.CmsRequestContextManagerImpl" />
	<!--Ojb Factory : used to access to the OJB Persistence Broker  -->
	<bean id="org.apache.portals.graffito.store.impl.ojb.OjbFactory" 
		class="org.apache.portals.graffito.store.impl.ojb.SpringOjbFactory" />
	<!-- Store service : manage the content stores plugged into Graffito -->
	<bean id="org.apache.portals.graffito.persistence.impl.ContentStoreServiceImpl" 
		class="org.apache.portals.graffito.persistence.impl.ContentStoreServiceImpl" >
		<constructor-arg >
			<ref bean="org.apache.portals.graffito.security.CmsAccessController"/>
		</constructor-arg>
		<constructor-arg >
			<ref bean="org.apache.portals.graffito.store.impl.ojb.OjbFactory"/>
		</constructor-arg>
	</bean>
	<!-- Persistence Service -->
	<bean id="org.apache.portals.graffito.persistence.impl.ContentPersistenceServiceImpl" 
		class="org.apache.portals.graffito.persistence.impl.ContentPersistenceServiceImpl" >
		<constructor-arg >
			<ref bean="graffitoMasterStore"/>
		</constructor-arg>
		<constructor-arg >
			<ref bean="org.apache.portals.graffito.persistence.impl.ContentStoreServiceImpl"/>
		</constructor-arg>
	</bean>
	<!-- Content Version Service -->
	<bean id="org.apache.portals.graffito.services.core.impl.ContentVersionServiceImpl" 
		class="org.apache.portals.graffito.services.core.impl.ContentVersionServiceImpl" >
		<constructor-arg >
			<ref bean="org.apache.portals.graffito.persistence.impl.ContentPersistenceServiceImpl"/>
		</constructor-arg>
	</bean>
	<!-- Content Model Service -->
	<bean id="org.apache.portals.graffito.services.core.impl.ContentModelServiceImpl" 
		class="org.apache.portals.graffito.services.core.impl.ContentModelServiceImpl" >
		<constructor-arg >
			<ref bean="org.apache.portals.graffito.persistence.impl.ContentPersistenceServiceImpl"/>
		</constructor-arg>
		<constructor-arg >
			<ref bean="org.apache.portals.graffito.services.core.impl.ContentVersionServiceImpl"/>
		</constructor-arg>
	</bean>
	<!-- Document Model Service -->
	<bean id="org.apache.portals.graffito.services.dm.impl.DocumentModelServiceImpl" 
		class="org.apache.portals.graffito.services.dm.impl.DocumentModelServiceImpl" >
		<constructor-arg >
			<ref bean="org.apache.portals.graffito.persistence.impl.ContentPersistenceServiceImpl"/>
		</constructor-arg>
		<constructor-arg >
			<ref bean="org.apache.portals.graffito.services.core.impl.ContentVersionServiceImpl"/>
		</constructor-arg>
	</bean>
	<!-- Content Search Service -->
	<bean id="org.apache.portals.graffito.services.search.impl.ContentSearchServiceImpl" 
		class="org.apache.portals.graffito.services.search.impl.ContentSearchServiceImpl" >
		<constructor-arg >
			<ref bean="org.apache.portals.graffito.persistence.impl.ContentPersistenceServiceImpl"/>
		</constructor-arg>
		<constructor-arg>
			<value>./index</value>
		</constructor-arg>
	</bean>
	<!-- Content Server Service -->
	<bean id="org.apache.portals.graffito.services.core.impl.ContentServerServiceImpl" 
		class="org.apache.portals.graffito.services.core.impl.ContentServerServiceImpl" >
		<constructor-arg >
			<ref bean="org.apache.portals.graffito.persistence.impl.ContentPersistenceServiceImpl"/>
		</constructor-arg>
	</bean>
	<!--
	  SPRING TRANSACTIONNAL PROXIES
	  Thoses spring proxies contains the declarative transaction management setting
  -->
	<bean id="org.apache.portals.graffito.persistence.ContentPersistenceService" parent="baseTransactionProxy" 
		name="contentPersistence" abstract="false" singleton="true" lazy-init="default" autowire="default" 
		dependency-check="default">
		<property name="proxyInterfaces">
			<value>org.apache.portals.graffito.persistence.ContentPersistenceService</value>
		</property>
		<property name="target">
			<ref bean="org.apache.portals.graffito.persistence.impl.ContentPersistenceServiceImpl" />
		</property>
		<property name="transactionAttributes">
			<props>
				<prop key="*">PROPAGATION_REQUIRED</prop>
			</props>
		</property>
	</bean>
	<bean id="org.apache.portals.graffito.services.core.ContentVersionService" parent="baseTransactionProxy" 
		name="contentVersion" abstract="false" singleton="true" lazy-init="default" autowire="default" dependency-check="default">
		<property name="proxyInterfaces">
			<value>org.apache.portals.graffito.services.core.ContentVersionService</value>
		</property>
		<property name="target">
			<ref bean="org.apache.portals.graffito.services.core.impl.ContentVersionServiceImpl" />
		</property>
		<property name="transactionAttributes">
			<props>
				<prop key="*">PROPAGATION_REQUIRED</prop>
			</props>
		</property>
	</bean>
	<bean id="org.apache.portals.graffito.services.core.ContentModelService" parent="baseTransactionProxy" name="contentModel" 
		abstract="false" singleton="true" lazy-init="default" autowire="default" dependency-check="default">
		<property name="proxyInterfaces">
			<value>org.apache.portals.graffito.services.core.ContentModelService</value>
		</property>
		<property name="target">
			<ref bean="org.apache.portals.graffito.services.core.impl.ContentModelServiceImpl" />
		</property>
		<property name="transactionAttributes">
			<props>
				<prop key="*">PROPAGATION_REQUIRED</prop>
			</props>
		</property>
	</bean>
	<bean id="org.apache.portals.graffito.services.dm.DocumentModelService" parent="baseTransactionProxy" name="documentModel" 
		abstract="false" singleton="true" lazy-init="default" autowire="default" dependency-check="default">
		<property name="proxyInterfaces">
			<value>org.apache.portals.graffito.services.dm.DocumentModelService</value>
		</property>
		<property name="target">
			<ref bean="org.apache.portals.graffito.services.dm.impl.DocumentModelServiceImpl" />
		</property>
		<property name="transactionAttributes">
			<props>
				<prop key="*">PROPAGATION_REQUIRED</prop>
			</props>
		</property>
	</bean>
	<bean id="org.apache.portals.graffito.services.search.ContentSearchService" parent="baseTransactionProxy" name="contentSearch" 
		abstract="false" singleton="true" lazy-init="default" autowire="default" dependency-check="default">
		<property name="proxyInterfaces">
			<value>org.apache.portals.graffito.services.search.ContentSearchService</value>
		</property>
		<property name="target">
			<ref bean="org.apache.portals.graffito.services.search.impl.ContentSearchServiceImpl" />
		</property>
		<property name="transactionAttributes">
			<props>
				<prop key="*">PROPAGATION_REQUIRED</prop>
			</props>
		</property>
	</bean>
	<bean id="org.apache.portals.graffito.services.core.ContentServerService" parent="baseTransactionProxy" name="contentServer" 
		abstract="false" singleton="true" lazy-init="default" autowire="default" dependency-check="default">
		<property name="proxyInterfaces">
			<value>org.apache.portals.graffito.services.core.ContentServerService</value>
		</property>
		<property name="target">
			<ref bean="org.apache.portals.graffito.services.core.impl.ContentServerServiceImpl" />
		</property>
		<property name="transactionAttributes">
			<props>
				<prop key="*">PROPAGATION_REQUIRED</prop>
			</props>
		</property>
	</bean>
	<!-- USED ONLY FOR THE UNIT TEST / This bean is not necessary if Graffito is running in a Jetspeed 2 application -->
	<!-- Security: Permission Service -->
	<bean id="org.apache.portals.graffito.services.core.impl.ContentPermissionServiceImpl" 
		class="org.apache.portals.graffito.services.core.impl.ContentPermissionServiceImpl" />
	<bean id="org.apache.portals.graffito.services.core.ContentPermissionService" parent="baseTransactionProxy" 
		name="graffitoPermissionService" >
		<property name="proxyInterfaces">
			<value>org.apache.portals.graffito.services.core.ContentPermissionService</value>
		</property>
		<property name="target">
			<ref bean="org.apache.portals.graffito.services.core.impl.ContentPermissionServiceImpl"/>
		</property>
		<property name="transactionAttributes">
			<props>
				<prop key="remove*">PROPAGATION_REQUIRED</prop>
				<prop key="grant*">PROPAGATION_REQUIRED</prop>
				<prop key="revoke*">PROPAGATION_REQUIRED</prop>
				<prop key="grant*">PROPAGATION_REQUIRED</prop>
				<prop key="add*">PROPAGATION_REQUIRED</prop>
				<prop key="*">PROPAGATION_SUPPORTS</prop>
			</props>
		</property>
	</bean>
	
	<bean id="TestTransaction"  class="org.apache.portals.graffito.engine.TestTransactionImpl"   >  	   
         <constructor-arg ><ref bean="org.apache.portals.graffito.services.core.ContentModelService"/></constructor-arg>  	 
    </bean>
      
  
	<bean id="TxUnitTest" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
		<property name="transactionManager"><ref local="transactionManager"/></property>
		<property name="target"><ref local="TestTransaction"/></property>
		<property name="transactionAttributes">
			<props>
				<prop key="*">PROPAGATION_REQUIRED,-ContentManagementException</prop>
			</props>
		</property>
	</bean>	
</beans>
