package org.yacos.web.PCmember.controller;
import org.springframework.web.servlet.mvc.SimpleFormController;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import java.io.IOException;
import java.util.List;
import org.yacos.web.system.session.SessionService;
import org.yacos.core.article.Article;
import org.yacos.core.article.IArticleManager;
import org.yacos.core.exceptions.ConferenceDoesntExistException;


public class ValidateArticleController extends SimpleFormController {

    protected final Log logger = LogFactory.getLog(getClass());
    
    private IArticleManager articleManager;

	public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException{
		
        logger.info("Returning validateArticle view");
        //FIXME  user "toto" a remplacer par le vrai PCmembre
        List<Article> listArticleValidate;
		//listArticleValidate = articleManager.getArticlesOfMember(SessionService.getInstance().getCurrentConferenceId(),"toto");
        try {
			listArticleValidate = articleManager.getArticles(SessionService.getInstance().getCurrentConferenceId());
			 getServletContext().setAttribute("listArticleValidate", listArticleValidate);
		} catch (ConferenceDoesntExistException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
       

        return new ModelAndView("validateArticle");
    }
	
	public IArticleManager getArticleManager() {
		return articleManager;
	}
	
	public void setArticleManager(IArticleManager articleManager) {
		this.articleManager = articleManager;
	}
}