package org.dvdexchange.web;
import java.io.IOException;
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.dvdexchange.domain.DvdCollection;
import org.dvdexchange.domain.User;
import org.dvdexchange.service.DvdLibrary;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;
public class DvdLibraryController implements Controller {
protected final Log logger = LogFactory.getLog(getClass());
private DvdLibrary m_dvdLibrary;
public void setDvdLibrary(DvdLibrary dvdLibrary) {
m_dvdLibrary = dvdLibrary;
}
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
User user = (User) request.getSession().getAttribute("user");
DvdCollection dvdList = m_dvdLibrary.getDvdsAvailableForUser(user);
DvdCollection myDvds = m_dvdLibrary.getDvdsUserOwns(user);
ModelAndView modelAndView = new ModelAndView("dvdLibrary");
modelAndView.addObject("dvdList", dvdList);
modelAndView.addObject("myDvds", myDvds);
return modelAndView;
}
}