View Javadoc
1   /******************************************************************************
2    * SlideShowPageController.java - The Spring controller for the Slide Show
3    * 
4    * PicMan - The BuckoSoft Picture Manager in Java
5    * Copyright(c) 2009 - Dick Balaska
6    * 
7    */
8   package com.buckosoft.PicMan.web;
9   
10  import java.io.IOException;
11  import java.util.HashMap;
12  import java.util.Map;
13  
14  import javax.servlet.ServletException;
15  import javax.servlet.http.HttpServletRequest;
16  import javax.servlet.http.HttpServletResponse;
17  
18  import org.apache.commons.logging.Log;
19  import org.apache.commons.logging.LogFactory;
20  import org.springframework.web.servlet.ModelAndView;
21  
22  import com.buckosoft.BSAccount.web.BSAccountPageController;
23  import com.buckosoft.BSAccount.web.BSAccountUserWebSession;
24  import com.buckosoft.PicMan.business.PicManFacade;
25  import com.buckosoft.PicMan.domain.User;
26  
27  /**
28   * The Spring controller for the Slide Show. <br>
29   * See <a href="http://cvs.buckosoft.com/Projects/java/PicMan/PicMan/WebContent/WEB-INF/jsp/SlideShowPage.jsp">SlideShowPage.jsp</a>
30   * which is pretty boring.  All the good stuff happens in the javascript
31   * <a href="http://cvs.buckosoft.com/Projects/java/PicMan/PicMan/WebContent/js/picBrowser.js">picBrowser.js</a>
32   * @author Dick Balaska
33   * @since 2009/06/09
34   * @see <a href="http://cvs.buckosoft.com/Projects/java/PicMan/PicMan/src/com/buckosoft/PicMan/web/SlideShowPageController.java">SlideShowPageController.java</a>
35   */
36  public class SlideShowPageController extends BSAccountPageController {
37  	private static final boolean DEBUG = false;
38      protected final Log logger = LogFactory.getLog(getClass());
39  
40  	private PicManFacade	pmf;
41  	
42  	/** Set the reference to the PicMan API.
43  	 * @param pmf The PicManFacade
44  	 */
45  	public void setPicMan(PicManFacade pmf) { this.pmf = pmf; }
46  
47  	/** Spring standard http request handler
48  	 * @param request The http request
49  	 * @param response The http response
50  	 * @return The Spring Model and View
51  	 */ 
52  	public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
53  				throws ServletException, IOException {
54  
55  		BSAccountUserWebSession userWebSession = this.bsAccountMan.getUserWebSession(request);
56  		User user = null;
57  		if (userWebSession != null)
58  			user = (User)userWebSession.getUser();
59  		if (DEBUG)
60  			logger.info("formBackingObject session " + userWebSession);
61  		
62  		String now = (new java.util.Date()).toString();
63  
64  		Map<String, Object> myModel = new HashMap<String, Object>();
65  		myModel.put("userWebSession", userWebSession);
66  		myModel.put("usr", user);
67  		myModel.put("user", null);
68  		myModel.put("now", now);
69  		myModel.put("sets", pmf.getDB().getSets());
70  
71  		return new ModelAndView("SlideShowPage", "model", myModel);
72  	}
73  }