1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
package org.apache.jetspeed.cache.impl; |
19 |
|
|
20 |
|
import java.io.Serializable; |
21 |
|
import java.util.Iterator; |
22 |
|
import java.util.List; |
23 |
|
|
24 |
|
import org.apache.jetspeed.cache.ContentCacheKey; |
25 |
|
import org.apache.jetspeed.desktop.JetspeedDesktop; |
26 |
|
import org.apache.jetspeed.request.RequestContext; |
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
public class JetspeedContentCacheKey implements ContentCacheKey, Serializable |
49 |
|
{ |
50 |
0 |
private String username = null; |
51 |
0 |
private String pipeline = null; |
52 |
0 |
private String windowId = null; |
53 |
0 |
private String sessionId = null; |
54 |
0 |
private String requestParameter = null; |
55 |
0 |
private String sessionAttribute = null; |
56 |
0 |
private String key = ""; |
57 |
|
|
58 |
|
public JetspeedContentCacheKey(List segments, RequestContext context, String windowId) |
59 |
0 |
{ |
60 |
0 |
boolean first = true; |
61 |
0 |
Iterator si = segments.iterator(); |
62 |
0 |
while (si.hasNext()) |
63 |
|
{ |
64 |
0 |
String segment = (String)si.next(); |
65 |
0 |
if (segment.equals("username")) |
66 |
|
{ |
67 |
0 |
this.username = context.getUserPrincipal().getName(); |
68 |
0 |
key = (first) ? this.username : key + EhPortletContentCacheElementImpl.KEY_SEPARATOR + class="keyword">this.username; |
69 |
|
} |
70 |
0 |
else if (segment.equals("windowid")) |
71 |
|
{ |
72 |
0 |
this.windowId = windowId; |
73 |
0 |
key = (first) ? this.windowId : key + EhPortletContentCacheElementImpl.KEY_SEPARATOR + class="keyword">this.windowId; |
74 |
|
} |
75 |
0 |
else if (segment.equals("sessionid")) |
76 |
|
{ |
77 |
0 |
this.sessionId = context.getRequest().getSession().getId(); |
78 |
0 |
key = (first) ? this.sessionId : key + EhPortletContentCacheElementImpl.KEY_SEPARATOR + class="keyword">this.sessionId; |
79 |
|
} |
80 |
0 |
else if (segment.equals("pipeline")) |
81 |
|
{ |
82 |
0 |
String encoder = context.getRequestParameter(JetspeedDesktop.DESKTOP_ENCODER_REQUEST_PARAMETER); |
83 |
0 |
if (encoder != null && encoder.equals(JetspeedDesktop.DESKTOP_ENCODER_REQUEST_PARAMETER_VALUE)) |
84 |
|
{ |
85 |
0 |
this.pipeline = "desktop"; |
86 |
|
} |
87 |
|
else |
88 |
|
{ |
89 |
0 |
this.pipeline = "portal"; |
90 |
|
} |
91 |
0 |
key = (first) ? this.pipeline : key + EhPortletContentCacheElementImpl.KEY_SEPARATOR + class="keyword">this.pipeline; |
92 |
0 |
} |
93 |
0 |
else if (segment.startsWith("request")) |
94 |
|
{ |
95 |
0 |
int pos = segment.indexOf("."); |
96 |
0 |
if (pos > -1) |
97 |
|
{ |
98 |
0 |
String parameterName = segment.substring(pos); |
99 |
0 |
this.requestParameter = context.getRequestParameter(parameterName); |
100 |
0 |
if (this.requestParameter != null) |
101 |
|
{ |
102 |
0 |
key = (first) ? this.requestParameter : key + EhPortletContentCacheElementImpl.KEY_SEPARATOR + class="keyword">this.requestParameter; |
103 |
|
} |
104 |
|
} |
105 |
0 |
} |
106 |
0 |
else if (segment.startsWith("session")) |
107 |
|
{ |
108 |
0 |
int pos = segment.indexOf("."); |
109 |
0 |
if (pos > -1) |
110 |
|
{ |
111 |
0 |
String attributeName = segment.substring(pos); |
112 |
0 |
this.sessionAttribute = (String)context.getSessionAttribute(attributeName); |
113 |
0 |
if (this.sessionAttribute != null) |
114 |
|
{ |
115 |
0 |
key = (first) ? this.sessionAttribute : key + EhPortletContentCacheElementImpl.KEY_SEPARATOR + class="keyword">this.sessionAttribute; |
116 |
|
} |
117 |
|
} |
118 |
|
} |
119 |
0 |
first = false; |
120 |
0 |
} |
121 |
|
|
122 |
0 |
} |
123 |
|
|
124 |
|
public JetspeedContentCacheKey() |
125 |
0 |
{ |
126 |
0 |
} |
127 |
|
|
128 |
|
public void createFromUser(String username, String pipeline, String windowId) |
129 |
|
{ |
130 |
0 |
this.setUsername(username); |
131 |
0 |
this.setPipeline(pipeline); |
132 |
0 |
this.setWindowId(windowId); |
133 |
0 |
this.key = class="keyword">this.getUsername() + |
134 |
|
EhPortletContentCacheElementImpl.KEY_SEPARATOR + |
135 |
|
this.getPipeline() + |
136 |
|
EhPortletContentCacheElementImpl.KEY_SEPARATOR + |
137 |
|
this.getWindowId(); |
138 |
0 |
} |
139 |
|
|
140 |
|
public void createFromSession(String sessionId, String pipeline, String windowId) |
141 |
|
{ |
142 |
0 |
this.setSessionId(sessionId); |
143 |
0 |
this.setPipeline(pipeline); |
144 |
0 |
this.setWindowId(windowId); |
145 |
0 |
this.key = class="keyword">this.getSessionId() + |
146 |
|
EhPortletContentCacheElementImpl.KEY_SEPARATOR + |
147 |
|
this.getPipeline() + |
148 |
|
EhPortletContentCacheElementImpl.KEY_SEPARATOR + |
149 |
|
this.getWindowId(); |
150 |
0 |
} |
151 |
|
|
152 |
|
public String getKey() |
153 |
|
{ |
154 |
0 |
return this.key; |
155 |
|
} |
156 |
|
|
157 |
|
public String getPipeline() |
158 |
|
{ |
159 |
0 |
return this.pipeline; |
160 |
|
} |
161 |
|
|
162 |
|
public String getRequestParameter() |
163 |
|
{ |
164 |
0 |
return this.requestParameter; |
165 |
|
} |
166 |
|
|
167 |
|
public String getSessionAttribute() |
168 |
|
{ |
169 |
0 |
return this.sessionAttribute; |
170 |
|
} |
171 |
|
|
172 |
|
public String getSessionId() |
173 |
|
{ |
174 |
0 |
return this.sessionId; |
175 |
|
} |
176 |
|
|
177 |
|
public String getUsername() |
178 |
|
{ |
179 |
0 |
return this.username; |
180 |
|
} |
181 |
|
|
182 |
|
public String getWindowId() |
183 |
|
{ |
184 |
0 |
return this.windowId; |
185 |
|
} |
186 |
|
|
187 |
|
|
188 |
|
public void setPipeline(String pipeline) |
189 |
|
{ |
190 |
0 |
this.pipeline = pipeline; |
191 |
0 |
} |
192 |
|
|
193 |
|
|
194 |
|
public void setRequestParameter(String requestParameter) |
195 |
|
{ |
196 |
0 |
this.requestParameter = requestParameter; |
197 |
0 |
} |
198 |
|
|
199 |
|
|
200 |
|
public void setSessionAttribute(String sessionAttribute) |
201 |
|
{ |
202 |
0 |
this.sessionAttribute = sessionAttribute; |
203 |
0 |
} |
204 |
|
|
205 |
|
|
206 |
|
public void setSessionId(String sessionId) |
207 |
|
{ |
208 |
0 |
this.sessionId = sessionId; |
209 |
0 |
} |
210 |
|
|
211 |
|
|
212 |
|
public void setUsername(String username) |
213 |
|
{ |
214 |
0 |
this.username = username; |
215 |
0 |
} |
216 |
|
|
217 |
|
|
218 |
|
public void setWindowId(String windowId) |
219 |
|
{ |
220 |
0 |
this.windowId = windowId; |
221 |
0 |
} |
222 |
|
} |