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 java.util.StringTokenizer; |
20 |
|
|
21 |
|
import javax.servlet.http.HttpServletRequest; |
22 |
|
|
23 |
|
import org.apache.jetspeed.PortalContext; |
24 |
|
import org.apache.jetspeed.container.state.NavigationalState; |
25 |
|
import org.apache.jetspeed.container.url.BasePortalURL; |
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
public class PathInfoEncodingPortalURL extends AbstractPortalURL |
34 |
|
{ |
35 |
|
public PathInfoEncodingPortalURL(NavigationalState navState, PortalContext portalContext, BasePortalURL base) |
36 |
|
{ |
37 |
0 |
super(navState, portalContext, base); |
38 |
0 |
} |
39 |
|
|
40 |
|
public PathInfoEncodingPortalURL(NavigationalState navState, PortalContext portalContext) |
41 |
|
{ |
42 |
0 |
super(navState, portalContext); |
43 |
0 |
} |
44 |
|
|
45 |
|
public PathInfoEncodingPortalURL(String characterEncoding, NavigationalState navState, PortalContext portalContext) |
46 |
|
{ |
47 |
0 |
super(characterEncoding, navState, portalContext); |
48 |
0 |
} |
49 |
|
|
50 |
|
public PathInfoEncodingPortalURL(HttpServletRequest request, String characterEncoding, NavigationalState navState, PortalContext portalContext) |
51 |
|
{ |
52 |
0 |
super(request, characterEncoding, navState, portalContext); |
53 |
0 |
} |
54 |
|
|
55 |
|
protected void decodePathAndNavigationalState(HttpServletRequest request) |
56 |
|
{ |
57 |
0 |
String path = null; |
58 |
0 |
String encodedNavState = null; |
59 |
|
|
60 |
0 |
String pathInfo = request.getPathInfo(); |
61 |
0 |
if (pathInfo != null) |
62 |
|
{ |
63 |
0 |
StringTokenizer tokenizer = new StringTokenizer(request.getPathInfo(),"/"); |
64 |
0 |
StringBuffer buffer = new StringBuffer(); |
65 |
|
String token; |
66 |
0 |
boolean foundNavState = false; |
67 |
0 |
String navStatePrefix = getNavigationalStateParameterName() +":"; |
68 |
0 |
while (tokenizer.hasMoreTokens()) |
69 |
|
{ |
70 |
0 |
token = tokenizer.nextToken(); |
71 |
0 |
if (!foundNavState && token.startsWith(navStatePrefix)) |
72 |
|
{ |
73 |
0 |
foundNavState = true; |
74 |
0 |
if ( token.length() > navStatePrefix.length() ) |
75 |
|
{ |
76 |
0 |
encodedNavState = token.substring(navStatePrefix.length()); |
77 |
|
} |
78 |
|
} |
79 |
|
else |
80 |
|
{ |
81 |
0 |
buffer.append("/"); |
82 |
0 |
buffer.append(token); |
83 |
|
} |
84 |
|
} |
85 |
0 |
if ( buffer.length() > 0 ) |
86 |
|
{ |
87 |
0 |
path = buffer.toString(); |
88 |
|
} |
89 |
|
else |
90 |
|
{ |
91 |
0 |
path = "/"; |
92 |
|
} |
93 |
|
} |
94 |
0 |
setPath(path); |
95 |
0 |
setEncodedNavigationalState(encodedNavState); |
96 |
0 |
} |
97 |
|
|
98 |
|
protected String createPortletURL(String encodedNavState, boolean secure) |
99 |
|
{ |
100 |
0 |
StringBuffer buffer = new StringBuffer(getBaseURL(secure)); |
101 |
0 |
buffer.append(getBasePath()); |
102 |
0 |
if ( encodedNavState != null ) |
103 |
|
{ |
104 |
0 |
buffer.append("/"); |
105 |
0 |
buffer.append(getNavigationalStateParameterName()); |
106 |
0 |
buffer.append(":"); |
107 |
0 |
buffer.append(encodedNavState); |
108 |
|
} |
109 |
0 |
if ( getPath() != null ) |
110 |
|
{ |
111 |
0 |
buffer.append(getPath()); |
112 |
|
} |
113 |
0 |
return buffer.toString(); |
114 |
|
} |
115 |
|
|
116 |
|
public boolean isPathInfoEncodingNavState() |
117 |
|
{ |
118 |
0 |
return true; |
119 |
|
} |
120 |
|
} |