<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:flow="http://www.springframework.org/schema/webflow-config"
	xmlns:dwr="http://www.directwebremoting.org/schema/spring-dwr"
	xmlns:jee="http://www.springframework.org/schema/jee"
	xmlns:lang="http://www.springframework.org/schema/lang"
	xmlns:util="http://www.springframework.org/schema/util"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
		http://www.springframework.org/schema/webflow-config http://www.springframework.org/schema/webflow-config/spring-webflow-config-1.0.xsd
		http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.0.xsd
		http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.0.xsd
		http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd
		http://www.directwebremoting.org/schema/spring-dwr http://www.directwebremoting.org/schema/spring-dwr-2.0.xsd">


	<!-- the application context definition for the SiteWebSpring DispatcherServlet -->

	<bean
		class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
		<property name="mappings">
			<props>
				<prop key="/main.htm">MainController</prop>
				<prop key="/listArticle.htm">ListArticleController</prop>
				<prop key="/manageArticle.htm">ManageArticleController</prop>
				<prop key="/registerUser.htm">SUserRegistrationController</prop>
				<prop key="/submissionArticle.htm">SArticleController</prop>
				<prop key="/choosePreference.htm">ChoosePreferenceController</prop>
				<prop key="/dispatchArticleList.htm">DispatchArticleListController</prop>
				<prop key="/dispatchArticle.htm">DispatchArticleController</prop>
				<prop key="/addConference.htm">AddConferenceController</prop>
				<prop key="/reportConfCreate.htm">ReportConfCreateController</prop>
				<prop key="/evaluation.htm">EvaluationController</prop>
				<prop key="/createReport.htm">CreateReportController</prop>
				<prop key="/listConference.htm">ListConferenceController</prop>
				<prop key="/chooseConference.htm">ChooseConferenceController</prop>
				<prop key="/validateArticle.htm">ValidateArticleController</prop>
				<prop key="/validateOrReject.htm">ValidateOrRejectController</prop>
				<prop key="/login.htm">LogonController</prop>
				<prop key="/listEvaluation.htm">ListEvaluationController</prop>
				<prop key="/download.htm">ArticleDownloadController</prop>
				<prop key="/delete.htm">ArticleDeleteController</prop>
				<prop key="/listReport.htm">ListReportController</prop>
				<prop key="/forgotPassword.htm">ForgotPasswordController</prop>
				<prop key="/detailArticle.htm">DetailArticleController</prop>
				<prop key="/userBoard.htm">UserBoardController</prop>
				<prop key="/stateArticle.htm">StateArticleController</prop>
				<prop key="/admin.htm">AdminController</prop>
			</props>
		</property>
	</bean>

	<bean id="MainController"
		class="org.yacos.web.author.controller.MainController" />

	<bean id="ListArticleController"
		class="org.yacos.web.PCmember.controller.ListArticleController">
		<property name="articleManager" ref="articleManager" />
	</bean>
	
	<bean id="AdminController"
		class="org.yacos.web.admin.AdminController">
		<dwr:remote javascript="AdminController" />
		<property name="articleManager" ref="articleManager" />
		<property name="userManager" ref="userManager" />
		<property name="conferenceManager" ref="conferenceManager" />
		<property name="methodNameResolver">
			<bean name="AdminControllerMethodResolver" class="org.springframework.web.servlet.mvc.multiaction.ParameterMethodNameResolver">
				<property name="defaultMethodName">
					<value>show</value>
				</property>
				<property name="paramName" value="action"/>
				<property name="methodParamNames">
					<list>
						<value>show</value>
					</list>
				</property>
			</bean>
		</property>
	</bean>
	
	<bean id="ManageArticleController"
		class="org.yacos.web.author.controller.ManageArticleController">
		<property name="articleManager" ref="articleManager" />
	</bean>
	
	<bean id="ArticleDownloadController" class="org.yacos.web.system.controller.ArticleDownloadController">
		<property name="articleManager" ref="articleManager" />
		<property name="downloadDirPath" value="${download.dir.path}"/>
	</bean>
	
	<bean id="ArticleDeleteController" class="org.yacos.web.author.controller.ArticleDeleteController">
		<property name="articleManager" ref="articleManager" />
	</bean>

	<bean id="SUserRegistrationController"
		class="org.yacos.web.system.controller.SUserRegistrationController">
		<property name="sessionForm" value="true" />
		<property name="commandName" value="registerUser" />
		<property name="commandClass"
			value="org.yacos.web.system.form.FormUser" />
		<property name="formView" value="registerUser" />
		<property name="userManager" ref="userManager" />
		<property name="validator" ref="UserValidator"/>
	</bean>
	
	<bean id="UserValidator"
		class="org.yacos.web.system.validation.UserValidator">
	</bean>
	
	<bean id="ForgotPasswordController"
		class="org.yacos.web.system.controller.ForgotPasswordController">
		<property name="sessionForm" value="false" />
		<property name="commandName" value="forgotPassword" />
		<property name="commandClass"
			value="org.yacos.web.system.form.FormForgotPassword" />
		<property name="formView" value="forgotPassword" />
		<property name="successView" value="forgotPassword.htm" />
		<property name="userManager" ref="userManager" />
	</bean>

	<bean id="SArticleController"
		class="org.yacos.web.author.controller.SArticleController">
		<property name="sessionForm" value="true" />
		<property name="commandName" value="submissionArticle" />
		<property name="commandClass"
			value="org.yacos.web.author.form.FormSubmission" />
		<property name="formView" value="submissionArticle" />
		<property name="successView" value="manageArticle.htm" />
		<property name="articleManager" ref="articleManager" />
		<property name="validator" ref="submissionCheck" />
		<property name="downloadDirPath" value="${download.dir.path}"/>
	</bean>

	<bean id="submissionCheck"
		class="org.yacos.web.author.validator.ValidateSubmission">
	</bean>
	
	
	<bean id="UserBoardController"
		class="org.yacos.web.system.controller.UserBoardController">
		<property name="conferenceManager" ref="conferenceManager" />
		<property name="userManager" ref="userManager" />
		<property name="evaluationManager" ref="evaluationManager" />
		<property name="articleManager" ref="articleManager" />
	</bean>

	<bean id="ChoosePreferenceController"
		class="org.yacos.web.PCmember.controller.ChoosePreferenceController">
		<property name="sessionForm" value="true" />
		<property name="commandName" value="choosePreference" />
		<property name="commandClass"
			value="org.yacos.web.PCmember.form.FormPreference" />
		<property name="formView" value="choosePreference" />
		<property name="successView" value="choosePreference.htm" />
		<property name="articleManager" ref="articleManager" />
		<property name="userManager" ref="userManager" />
		<property name="conferenceManager" ref="conferenceManager" />
	</bean>

	<bean id="ValidateArticleController"
		class="org.yacos.web.PCmember.controller.ValidateArticleController">
		<property name="formView" value="validateArticle" />
		<property name="articleManager" ref="articleManager" />
	</bean>

	<bean id="ValidateOrRejectController"
		class="org.yacos.web.PCmember.controller.ValidateOrRejectController">
		<property name="articleManager" ref="articleManager" />
	</bean>

	 <bean id="DispatchArticleController"
		class="org.yacos.web.chairman.controller.DispatchArticleController">
		
		<property name="articleManager" ref="articleManager" />
		<property name="userManager" ref="userManager" />
		<property name="conferenceManager" ref="conferenceManager" />
	</bean>


	<bean id="DispatchArticleListController"
		class="org.yacos.web.chairman.controller.DispatchArticleListController">
		<dwr:remote javascript="DispatchArticlesJS" />
		<property name="articleManager" ref="articleManager" />
		<property name="userManager" ref="userManager" />
		<property name="conferenceManager" ref="conferenceManager" />
	</bean>
	
	<bean id="AddConferenceController"
		class="org.yacos.web.chairman.controller.AddConferenceController"
		scope="session">
		<dwr:remote javascript="AddCriteriaJS" />
		<property name="sessionForm" value="true" />
		<property name="commandName" value="formConference" />
		<property name="commandClass"
			value="org.yacos.web.chairman.form.FormConference" />
		<property name="conferenceManager" ref="conferenceManager" />
		<property name="userManager" ref="userManager" />
		<property name="evaluationManager" ref="evaluationManager" />
		<property name="validator" ref="ConferenceValidator" />
	</bean>
	<bean id="ReportConfCreateController"
		class="org.yacos.web.chairman.controller.ReportConfCreateController">
		<property name="conferenceManager" ref="conferenceManager" />
		<property name="evaluationManager" ref="evaluationManager" />
		<property name="userManager" ref="userManager" />
	</bean>

	<bean id="ConferenceValidator"
		class="org.yacos.web.chairman.validation.ConferenceValidator">
	</bean>

	<bean id="EvaluationController"
		class="org.yacos.web.PCmember.controller.EvaluationController">
		<property name="sessionForm" value="true" />
		<property name="commandName" value="evaluationForm" />
		<property name="commandClass"
			value="org.yacos.web.PCmember.form.FormEvaluation" />
		<property name="formView" value="evaluation" />
		<property name="successView" value="createReport.htm" />
		<property name="articleManager" ref="articleManager" />
		<property name="userManager" ref="userManager" />
		<property name="conferenceManager" ref="conferenceManager" />
		<property name="evaluationManager" ref="evaluationManager" />
	</bean>

	<bean id="CreateReportController"
		class="org.yacos.web.PCmember.controller.CreateReportController">
		<property name="articleManager" ref="articleManager" />
	</bean>

	<bean id="LogonController"
		class="org.yacos.web.system.controller.LogonController">
	</bean>

	<!-- List all conference -->
	<bean id="ListConferenceController"
		class="org.yacos.web.system.controller.ListConferenceController">
		<property name="conferenceManager" ref="conferenceManager" />
		<property name="userManager" ref="userManager" />
	</bean>

   
    <bean id="ListEvaluationController"
		class="org.yacos.web.PCmember.controller.ListEvaluationController">
		<property name="articleManager" ref="articleManager" />
   </bean>
   
    <bean id="StateArticleController"
		class="org.yacos.web.system.controller.StateArticleController">
		<property name="articleManager" ref="articleManager" />
   </bean>
   
   
    <bean id="ListReportController"
		class="org.yacos.web.PCmember.controller.ListReportController">
		<property name="evaluationManager" ref="evaluationManager" />
   </bean>
   
    <bean id="DetailArticleController"
		class="org.yacos.web.author.controller.DetailArticleController">
		<property name="articleManager" ref="articleManager" />
   </bean>
   
	<!-- Get chosen conference in session context -->
	<bean id="ChooseConferenceController"
		class="org.yacos.web.system.controller.ChooseConferenceController">
		<property name="conferenceManager" ref="conferenceManager" />
	</bean>

	<!-- dwr servlet -->
	 
	<bean id="dwrUrlMapping"
		class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
		<property name="alwaysUseFullPath" value="true" />
		<property name="mappings">
			<props>
				<prop key="/dwr/**/*">dwrController</prop>
			</props>
		</property>
	</bean>

	<dwr:controller id="dwrController" debug="true"></dwr:controller>
	<dwr:configuration>
		<dwr:convert type="bean"
			class="org.yacos.web.chairman.form.FormConference">
		</dwr:convert>

		<dwr:convert type="bean"
			class="org.yacos.web.chairman.controller.CriterionBean">
		</dwr:convert>

		<dwr:convert type="bean"
			class="org.yacos.web.chairman.controller.PersonBean">
		</dwr:convert>

		<dwr:convert type="bean"
			class="org.yacos.web.chairman.controller.PCMemberBean">
		</dwr:convert>

		<dwr:convert type="bean" class="java.lang.StackTraceElement"></dwr:convert>
		<dwr:convert type="exception" class="java.lang.exception"></dwr:convert>

	</dwr:configuration>

	
	<!-- View Resolver -->
	<bean id="viewResolver"
		class="org.springframework.web.servlet.view.InternalResourceViewResolver">
		<property name="viewClass"
			value="org.springframework.web.servlet.view.JstlView">
		</property>
		<property name="prefix" value="/WEB-INF/jsp/"></property>
		<property name="suffix" value=".jsp"></property>
	</bean>

	<bean id="multipartResolver"
		class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
		<property name="maxUploadSize" value="10000000" />
	</bean>
	
	<bean id="messageSource"
			class="org.springframework.context.support.ResourceBundleMessageSource">
		<property name="basename" value="messages" />
	</bean>

	<bean id="sessionService"
		class="org.yacos.web.system.session.SessionService">
		<property name="conferenceManager" ref="conferenceManager" />
		<property name="userManager" ref="userManager" />
	</bean>
	
	<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
		<property name="host" value="smtp.univ-lille1.fr"/>
	</bean>

	<bean id="mailSenderService"
		class="org.yacos.web.system.controller.MailSenderService" factory-method="getInstance">
		<property name="mailSender" ref="mailSender"/>
		<property name="fromEmail" value="${mailService.fromEmailAddress}" />
		<property name="replyTo" value="${mailService.replyToEmailAddress}" />
	</bean>

	<!-- EJB Services Linking -->
	<jee:jndi-lookup id="articleManager"
		jndi-name="ArticleManagerBean/remote" cache="true" />
	<jee:jndi-lookup id="userManager" jndi-name="UserManagerBean/remote"
		cache="true" />
	<jee:jndi-lookup id="conferenceManager"
		jndi-name="ConferenceManagerBean/remote" cache="true" />
	<jee:jndi-lookup id="evaluationManager"
		jndi-name="EvaluationManagerBean/remote" cache="true" />
	
<!--	Configuration Properties-->
	<bean id="configproperties"
			class="org.springframework.beans.factory.config.PropertiesFactoryBean">
		<property name="location" value="classpath:config.properties"/>
	</bean>
	
	<bean id="propertyConfigurer"
			class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
		<property name="properties" ref="configproperties"/>
	</bean>
</beans>
