package org.yacos.web.author.controller;

import java.io.IOException;
import java.util.List;

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 org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.SimpleFormController;
import org.yacos.core.article.Article;
import org.yacos.core.article.IArticleManager;
import org.yacos.web.system.controller.NoConferenceSelectedException;
import org.yacos.web.system.session.SessionService;

public class ManageArticleController extends SimpleFormController {

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

	public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException, NoConferenceSelectedException {
		
        logger.info("Returning manageArticle view");
        
        List<Article> listArticle;
		listArticle = articleManager.getArticleOfAuthor(SessionService.getInstance().getCurrentConferenceId(), SessionService.getInstance().getCurrentUserLogin());

        return new ModelAndView("manageArticle", "listArticle", listArticle);
    }

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

}