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 588430 2007-10-26 00:08:07Z 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 request.setAttribute( JetspeedDesktop.DESKTOP_ENABLED_REQUEST_ATTRIBUTE, Boolean.TRUE );
54 }
55 else
56 {
57 request.setPortalURL(navComponent.createURL(request.getRequest(), request.getCharacterEncoding()));
58 }
59
60 }
61 }
62 catch (Exception e)
63 {
64 throw new PipelineException(e);
65 }
66
67 context.invokeNext( request );
68 }
69
70 public String toString()
71 {
72 return "PortalURLValveImpl";
73 }
74 }