1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.jetspeed.container.url.impl;
19
20 import org.apache.jetspeed.container.state.NavigationalStateComponent;
21 import org.apache.jetspeed.pipeline.PipelineException;
22 import org.apache.jetspeed.pipeline.valve.AbstractValve;
23 import org.apache.jetspeed.pipeline.valve.ValveContext;
24 import org.apache.jetspeed.request.RequestContext;
25 import org.apache.jetspeed.desktop.JetspeedDesktop;
26
27 /***
28 * Creates the PortalURL for the current Request
29 *
30 * @author <a href="mailto:ate@apache.org">Ate Douma</a>
31 * @version $Id: PortalURLValveImpl.java 540314 2007-05-21 21:51:53Z smilek $
32 */
33 public class PortalURLValveImpl extends AbstractValve
34 {
35 private NavigationalStateComponent navComponent;
36
37 public PortalURLValveImpl(NavigationalStateComponent navComponent)
38 {
39 this.navComponent = navComponent;
40 }
41
42 public void invoke(RequestContext request, ValveContext context)
43 throws PipelineException
44 {
45 try
46 {
47 if ( request.getPortalURL() == null )
48 {
49 String encoding = request.getRequestParameter(JetspeedDesktop.DESKTOP_ENCODER_REQUEST_PARAMETER);
50 if (encoding != null && encoding.equals(JetspeedDesktop.DESKTOP_ENCODER_REQUEST_PARAMETER_VALUE))
51 {
52 request.setPortalURL(navComponent.createDesktopURL(request.getRequest(), request.getCharacterEncoding()));
53 }
54 else
55 {
56 request.setPortalURL(navComponent.createURL(request.getRequest(), request.getCharacterEncoding()));
57 }
58
59 }
60 }
61 catch (Exception e)
62 {
63 throw new PipelineException(e);
64 }
65
66 context.invokeNext( request );
67 }
68
69 public String toString()
70 {
71 return "PortalURLValveImpl";
72 }
73 }