1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.jetspeed.container.url.impl;
18
19 import javax.servlet.http.HttpServletRequest;
20
21 import org.apache.jetspeed.PortalContext;
22 import org.apache.jetspeed.container.state.NavigationalState;
23 import org.apache.jetspeed.container.url.BasePortalURL;
24
25 /***
26 * QueryStringEncodingPortalURL encodes the NavigationalState as query parameter
27 * *
28 * @author <a href="mailto:ate@apache.org">Ate Douma</a>
29 * @version $Id: QueryStringEncodingPortalURL.java 516448 2007-03-09 16:25:47Z ate $
30 */
31 public class QueryStringEncodingPortalURL extends AbstractPortalURL
32 {
33 public QueryStringEncodingPortalURL(NavigationalState navState, PortalContext portalContext, BasePortalURL base)
34 {
35 super(navState, portalContext, base);
36 }
37
38 public QueryStringEncodingPortalURL(NavigationalState navState, PortalContext portalContext)
39 {
40 super(navState, portalContext);
41 }
42
43 public QueryStringEncodingPortalURL(String characterEncoding, NavigationalState navState, PortalContext portalContext)
44 {
45 super(characterEncoding, navState, portalContext);
46 }
47
48 public QueryStringEncodingPortalURL(HttpServletRequest request, String characterEncoding, NavigationalState navState, PortalContext portalContext)
49 {
50 super(request, characterEncoding, navState, portalContext);
51 }
52
53 protected void decodePathAndNavigationalState(HttpServletRequest request)
54 {
55 setEncodedNavigationalState(request.getParameter(getNavigationalStateParameterName()));
56 String path = null;
57 if (request.getPathInfo() != null)
58 {
59 path = request.getPathInfo();
60 int length = path.length();
61 if ( length > 1 && path.endsWith("/") )
62 {
63 path = path.substring(0, length-1);
64 }
65 }
66 setPath(path);
67 }
68
69 protected String createPortletURL(String encodedNavigationalState, boolean secure)
70 {
71 StringBuffer buffer = new StringBuffer(getBaseURL(secure));
72 buffer.append(getBasePath());
73 if ( getPath() != null )
74 {
75 buffer.append(getPath());
76 }
77 if ( encodedNavigationalState != null )
78 {
79 buffer.append("?");
80 buffer.append(getNavigationalStateParameterName());
81 buffer.append("=");
82 buffer.append(encodedNavigationalState);
83 }
84 return buffer.toString();
85 }
86 }