1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.jetspeed.login.impl;
18
19 import java.io.IOException;
20
21 import javax.servlet.RequestDispatcher;
22 import javax.servlet.ServletException;
23
24 import org.apache.commons.logging.Log;
25 import org.apache.commons.logging.LogFactory;
26 import org.apache.jetspeed.pipeline.PipelineException;
27 import org.apache.jetspeed.pipeline.valve.AbstractValve;
28 import org.apache.jetspeed.pipeline.valve.LoginViewValve;
29 import org.apache.jetspeed.pipeline.valve.ValveContext;
30 import org.apache.jetspeed.request.RequestContext;
31
32 /***
33 * LoginJSPViewValveImpl
34 *
35 * TODO: move this class into a new component?
36 * @author <a href="mailto:shinsuke@yahoo.co.jp">Shinsuke Sugaya</a>
37 * @version $Id: LoginJSPViewValve.java 186726 2004-06-05 05:13:09Z shinsuke $
38 */
39 public class LoginJSPViewValve extends AbstractValve implements LoginViewValve
40 {
41 private static final Log log = LogFactory.getLog(LoginJSPViewValve.class);
42
43 private static final String DEFAULT_TEMPLATE_PATH = "/WEB-INF/templates/login";
44
45 private String templatePath;
46
47 public LoginJSPViewValve()
48 {
49 templatePath = DEFAULT_TEMPLATE_PATH;
50 }
51
52 public LoginJSPViewValve(String templatePath)
53 {
54 this.templatePath = templatePath;
55 }
56
57
58
59
60
61
62
63 public void invoke(RequestContext request, ValveContext context) throws PipelineException
64 {
65 String loginTemplateFile = templatePath + "/" + request.getMediaType() + "/login.jsp";
66
67 try
68 {
69 RequestDispatcher rd = request.getRequest().getRequestDispatcher(loginTemplateFile);
70 rd.include(request.getRequest(), request.getResponse());
71 }
72 catch (ServletException e)
73 {
74 log.warn("The included login template file threw the exception.", e);
75 throw new PipelineException("The included login template file threw the exception.", e);
76 }
77 catch (IOException e)
78 {
79 log.warn("I/O error occurred on the included login template file.", e);
80 throw new PipelineException("I/O error occurred on the included login template file.", e);
81 }
82
83
84 context.invokeNext(request);
85 }
86
87 public String toString()
88 {
89 return "LoginViewValve";
90 }
91 }