View Javadoc
1   /******************************************************************************
2    * ShowErrorPageController.java - The Spring controller to show the details of an error
3    * 
4    * PicMan - The BuckoSoft Picture Manager in Java
5    * Copyright(c) 2008 - 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.springframework.web.servlet.ModelAndView;
19  
20  import com.buckosoft.BSAccount.web.BSAccountPageController;
21  import com.buckosoft.BSAccount.web.BSAccountUserWebSession;
22  import com.buckosoft.PicMan.business.PicManFacade;
23  
24  /** The Spring controller to show the details of an error
25   * @author Dick Balaska
26   */
27  public class ShowErrorPageController extends BSAccountPageController {
28  	private PicManFacade	pmf;
29  	
30  	public void setPicMan(PicManFacade pmf) { this.pmf = pmf; }
31  	public PicManFacade getPicMan() { return(pmf); }
32  
33  	public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
34  				throws ServletException, IOException {
35  
36  		BSAccountUserWebSession userWebSession = this.bsAccountMan.getUserWebSession(request);
37  		
38  		Map<String, Object> myModel = new HashMap<String, Object>();
39  		myModel.put("now", new java.util.Date().toString());
40  		myModel.put("userWebSession", userWebSession);
41  		myModel.put("picMan", getPicMan());
42  
43  		String v = request.getParameter("e");
44  		if (v == null)
45  			myModel.put("eString", "No Error Specified");
46  		else {
47  			int i = Integer.parseInt(v);
48  			Throwable t = pmf.getError(i);
49  			myModel.put("error", t);
50  		}
51  		return new ModelAndView("ShowErrorPage", "model", myModel);
52  	}
53  	
54  }