package org.yacos.web.chairman.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;
import org.yacos.core.article.Article;
import org.yacos.core.article.IArticleManager;
import org.yacos.core.conferences.Conference;
import org.yacos.core.conferences.IConferenceManager;
import org.yacos.core.users.IUserManager;
import org.yacos.web.system.session.SessionService;

public class DispatchArticleListController implements Controller{
	
	protected final Log logger = LogFactory.getLog(getClass());

	private IArticleManager articleManager; 
	public IArticleManager getArticleManager() {
		return articleManager;
	}
	public void setArticleManager(IArticleManager articleManager) {
		this.articleManager = articleManager;
	}

	private IUserManager userManager;
	public IUserManager getUserManager() {
		return userManager;
	}
	public void setUserManager(IUserManager userManager) {
		this.userManager = userManager;
	}

	private IConferenceManager conferenceManager; 
	public IConferenceManager getConferenceManager() {
		return conferenceManager;
	}
	public void setConferenceManager(IConferenceManager conferenceManager) {
		this.conferenceManager = conferenceManager;
	}
	public ModelAndView handleRequest(HttpServletRequest arg0,
			HttpServletResponse arg1) throws Exception {
		//FIXME mettre article de la requete
		
		Conference conf = SessionService.getInstance().getCurrentConference();
		List<Article> listArticles = articleManager.getArticles(conf.getId());
		logger.info("returning dispatchArticleList with "+ listArticles.size() +" article");
		return new ModelAndView("dispatchArticleList","articles", listArticles);
	}

	
	
}
