1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
package org.apache.jetspeed.decoration; |
18 |
|
|
19 |
|
import java.util.ArrayList; |
20 |
|
import java.util.Collections; |
21 |
|
import java.util.HashMap; |
22 |
|
import java.util.Iterator; |
23 |
|
import java.util.List; |
24 |
|
import java.util.Properties; |
25 |
|
|
26 |
|
import javax.portlet.PortletMode; |
27 |
|
import javax.portlet.WindowState; |
28 |
|
|
29 |
|
import org.apache.commons.logging.Log; |
30 |
|
import org.apache.commons.logging.LogFactory; |
31 |
|
import org.apache.jetspeed.JetspeedActions; |
32 |
|
import org.apache.jetspeed.PortalReservedParameters; |
33 |
|
import org.apache.jetspeed.cache.CacheElement; |
34 |
|
import org.apache.jetspeed.cache.ContentCacheKey; |
35 |
|
import org.apache.jetspeed.cache.JetspeedContentCache; |
36 |
|
import org.apache.jetspeed.components.portletentity.PortletEntityNotStoredException; |
37 |
|
import org.apache.jetspeed.container.url.PortalURL; |
38 |
|
import org.apache.jetspeed.container.window.FailedToRetrievePortletWindow; |
39 |
|
import org.apache.jetspeed.container.window.PortletWindowAccessor; |
40 |
|
import org.apache.jetspeed.decoration.caches.SessionPathResolverCache; |
41 |
|
import org.apache.jetspeed.om.common.portlet.PortletApplication; |
42 |
|
import org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite; |
43 |
|
import org.apache.jetspeed.om.page.ContentFragment; |
44 |
|
import org.apache.jetspeed.om.page.ContentPage; |
45 |
|
import org.apache.jetspeed.om.page.Fragment; |
46 |
|
import org.apache.jetspeed.om.page.Page; |
47 |
|
import org.apache.jetspeed.pipeline.PipelineException; |
48 |
|
import org.apache.jetspeed.pipeline.valve.AbstractValve; |
49 |
|
import org.apache.jetspeed.pipeline.valve.Valve; |
50 |
|
import org.apache.jetspeed.pipeline.valve.ValveContext; |
51 |
|
import org.apache.jetspeed.request.RequestContext; |
52 |
|
import org.apache.jetspeed.security.SecurityAccessController; |
53 |
|
import org.apache.pluto.om.portlet.ContentTypeSet; |
54 |
|
import org.apache.pluto.om.window.PortletWindow; |
55 |
|
|
56 |
|
|
57 |
|
|
58 |
|
|
59 |
|
|
60 |
|
|
61 |
|
|
62 |
|
|
63 |
|
|
64 |
|
|
65 |
|
|
66 |
|
|
67 |
|
|
68 |
|
|
69 |
|
|
70 |
|
|
71 |
|
public class DecorationValve extends AbstractValve implements Valve |
72 |
|
{ |
73 |
|
public static final String ACTION_IMAGE_EXTENSION_ATTR = "actionImageExtension"; |
74 |
|
public static final String IS_AJAX_DECORATION_REQUEST = "org.apache.jetspeed.decoration.ajax"; |
75 |
|
|
76 |
0 |
protected final static Log log = LogFactory.getLog(DecorationValve.class); |
77 |
|
|
78 |
|
private final DecorationFactory decorationFactory; |
79 |
|
|
80 |
|
private final PortletWindowAccessor windowAccessor; |
81 |
|
|
82 |
0 |
private HashMap decoratorActionsAdapterCache = new HashMap(); |
83 |
|
|
84 |
|
private DecoratorActionsFactory defaultDecoratorActionsFactory; |
85 |
|
|
86 |
0 |
private JetspeedContentCache cache = null; |
87 |
|
|
88 |
0 |
private boolean useSessionForThemeCaching = false; |
89 |
|
|
90 |
0 |
private boolean maxOnEdit = false; |
91 |
|
|
92 |
|
|
93 |
|
|
94 |
|
|
95 |
|
protected SecurityAccessController accessController; |
96 |
|
|
97 |
|
public DecorationValve(DecorationFactory decorationFactory, PortletWindowAccessor windowAccessor,SecurityAccessController accessController) |
98 |
|
{ |
99 |
0 |
this(decorationFactory, windowAccessor, accessController, null); |
100 |
0 |
} |
101 |
|
|
102 |
|
public DecorationValve(DecorationFactory decorationFactory, PortletWindowAccessor windowAccessor, |
103 |
|
SecurityAccessController accessController, JetspeedContentCache cache) |
104 |
|
{ |
105 |
0 |
this(decorationFactory, windowAccessor, accessController, cache, false); |
106 |
0 |
} |
107 |
|
|
108 |
|
public DecorationValve(DecorationFactory decorationFactory, PortletWindowAccessor windowAccessor, |
109 |
|
SecurityAccessController accessController, JetspeedContentCache cache, |
110 |
|
boolean useSessionForThemeCaching) |
111 |
0 |
{ |
112 |
0 |
this.decorationFactory = decorationFactory; |
113 |
0 |
this.windowAccessor = windowAccessor; |
114 |
0 |
this.defaultDecoratorActionsFactory = new DefaultDecoratorActionsFactory(); |
115 |
|
|
116 |
0 |
this.accessController = accessController; |
117 |
0 |
this.cache = cache; |
118 |
0 |
this.useSessionForThemeCaching = useSessionForThemeCaching; |
119 |
0 |
} |
120 |
|
|
121 |
|
public void invoke(RequestContext requestContext, ValveContext context) throws PipelineException |
122 |
|
{ |
123 |
|
|
124 |
0 |
boolean isAjaxRequest = (context == null); |
125 |
0 |
initFragments( requestContext, isAjaxRequest, null ); |
126 |
|
|
127 |
|
|
128 |
0 |
if (!isAjaxRequest) |
129 |
|
{ |
130 |
0 |
context.invokeNext(requestContext); |
131 |
|
} |
132 |
0 |
} |
133 |
|
|
134 |
|
|
135 |
|
public void initFragments( RequestContext requestContext, boolean isAjaxRequest, List fragments ) |
136 |
|
{ |
137 |
0 |
if (isAjaxRequest) |
138 |
|
{ |
139 |
0 |
requestContext.setAttribute(IS_AJAX_DECORATION_REQUEST, new Boolean(true)); |
140 |
|
} |
141 |
|
|
142 |
0 |
ContentPage page = requestContext.getPage(); |
143 |
|
|
144 |
|
|
145 |
0 |
if (requestContext |
146 |
|
.getSessionAttribute(PortalReservedParameters.PAGE_THEME_OVERRIDE_ATTRIBUTE) != null) |
147 |
|
{ |
148 |
0 |
String decoratorName = (String) requestContext |
149 |
|
.getSessionAttribute(PortalReservedParameters.PAGE_THEME_OVERRIDE_ATTRIBUTE); |
150 |
0 |
page.setDefaultDecorator(decoratorName, Fragment.LAYOUT); |
151 |
|
} |
152 |
|
|
153 |
0 |
PageActionAccess pageActionAccess = (PageActionAccess)requestContext.getAttribute(PortalReservedParameters.PAGE_EDIT_ACCESS_ATTRIBUTE); |
154 |
0 |
String themeCacheKey = null; |
155 |
0 |
ContentCacheKey themeContentCacheKey = null; |
156 |
0 |
Theme theme = null; |
157 |
|
|
158 |
0 |
if (useCache()) |
159 |
|
{ |
160 |
0 |
if (pageActionAccess.isEditing() == false) |
161 |
|
{ |
162 |
|
|
163 |
0 |
if (this.useSessionForThemeCaching) |
164 |
|
{ |
165 |
0 |
themeCacheKey = cache.createSessionKey(requestContext); |
166 |
0 |
theme = (Theme) requestContext.getSessionAttribute(themeCacheKey); |
167 |
|
} |
168 |
|
else |
169 |
|
{ |
170 |
0 |
themeContentCacheKey = cache.createCacheKey(requestContext, page.getId()); |
171 |
0 |
CacheElement themeCacheElem = cache.get(themeContentCacheKey); |
172 |
|
|
173 |
0 |
if (themeCacheElem != null) |
174 |
|
{ |
175 |
0 |
theme = (Theme) themeCacheElem.getContent(); |
176 |
|
} |
177 |
|
} |
178 |
|
} |
179 |
|
} |
180 |
|
|
181 |
0 |
if (theme != null) |
182 |
|
{ |
183 |
0 |
theme.init(page, decorationFactory, requestContext); |
184 |
0 |
requestContext.setAttribute(PortalReservedParameters.PAGE_THEME_ATTRIBUTE, theme); |
185 |
0 |
boolean solo = isSoloMode(requestContext); |
186 |
0 |
SessionPathResolverCache sessionPathResolver = new SessionPathResolverCache( requestContext.getRequest().getSession() ); |
187 |
0 |
initDepthFragmentDecorations(requestContext, theme, page.getRootContentFragment(), |
188 |
|
pageActionAccess, isAjaxRequest, |
189 |
|
((DecorationFactoryImpl) decorationFactory).getResourceValidator(), |
190 |
|
sessionPathResolver, (theme.isInvalidated() && !solo)); |
191 |
|
|
192 |
0 |
if (theme.isInvalidated() && !solo) |
193 |
|
{ |
194 |
0 |
if (this.useSessionForThemeCaching) |
195 |
|
{ |
196 |
0 |
requestContext.setSessionAttribute(themeCacheKey, theme); |
197 |
|
} |
198 |
|
else |
199 |
|
{ |
200 |
0 |
CacheElement themeCacheElem = cache.createElement(themeContentCacheKey, theme); |
201 |
0 |
cache.put(themeCacheElem); |
202 |
|
} |
203 |
0 |
theme.setInvalidated(false); |
204 |
|
} |
205 |
0 |
return; |
206 |
|
} |
207 |
0 |
theme = decorationFactory.getTheme(page, requestContext); |
208 |
0 |
requestContext.setAttribute(PortalReservedParameters.PAGE_THEME_ATTRIBUTE, theme); |
209 |
0 |
if ( fragments == null || fragments.size() == 0 ) |
210 |
|
{ |
211 |
0 |
ContentFragment rootFragment = page.getRootContentFragment(); |
212 |
0 |
initDepthFragments(requestContext, theme, rootFragment, pageActionAccess, isAjaxRequest, fragments); |
213 |
0 |
} |
214 |
|
else |
215 |
|
{ |
216 |
0 |
Iterator fragmentsIter = fragments.iterator(); |
217 |
0 |
while ( fragmentsIter.hasNext() ) |
218 |
|
{ |
219 |
0 |
ContentFragment fragment = (ContentFragment)fragmentsIter.next(); |
220 |
0 |
initFragment(requestContext, theme, fragment, pageActionAccess, isAjaxRequest); |
221 |
0 |
} |
222 |
|
} |
223 |
|
|
224 |
0 |
if (useCache() && !isSoloMode(requestContext)) |
225 |
|
{ |
226 |
0 |
if (themeContentCacheKey == null && themeCacheKey == class="keyword">null) |
227 |
|
{ |
228 |
0 |
if (this.useSessionForThemeCaching) |
229 |
|
{ |
230 |
0 |
themeCacheKey = cache.createSessionKey(requestContext); |
231 |
0 |
requestContext.getRequest().getSession().removeAttribute(themeCacheKey); |
232 |
|
} |
233 |
|
else |
234 |
|
{ |
235 |
0 |
themeContentCacheKey = cache.createCacheKey(requestContext, page.getId()); |
236 |
0 |
cache.remove(themeContentCacheKey); |
237 |
|
} |
238 |
|
} |
239 |
|
else |
240 |
|
{ |
241 |
0 |
if (this.useSessionForThemeCaching) |
242 |
|
{ |
243 |
0 |
themeContentCacheKey = cache.createCacheKey(requestContext, page.getId()); |
244 |
0 |
requestContext.setSessionAttribute(themeCacheKey, theme); |
245 |
|
} |
246 |
|
else |
247 |
|
{ |
248 |
0 |
CacheElement themeCacheElem = cache.createElement(themeContentCacheKey, theme); |
249 |
0 |
cache.put(themeCacheElem); |
250 |
|
} |
251 |
|
} |
252 |
|
} |
253 |
0 |
} |
254 |
|
|
255 |
|
protected boolean isSoloMode(RequestContext requestContext) |
256 |
|
{ |
257 |
0 |
boolean solo = false; |
258 |
0 |
PortletWindow window = requestContext.getPortalURL().getNavigationalState().getMaximizedWindow(); |
259 |
0 |
boolean maximized = (window != null); |
260 |
0 |
if (maximized) |
261 |
|
{ |
262 |
0 |
solo = JetspeedActions.SOLO_STATE.equals(requestContext.getPortalURL().getNavigationalState().getMappedState(window)); |
263 |
|
} |
264 |
0 |
return solo; |
265 |
|
} |
266 |
|
|
267 |
|
protected boolean useCache() |
268 |
|
{ |
269 |
0 |
return this.cache != null; |
270 |
|
} |
271 |
|
|
272 |
|
public String toString() |
273 |
|
{ |
274 |
0 |
return "DecorationValve"; |
275 |
|
} |
276 |
|
|
277 |
|
public DecoratorActionsFactory getDecoratorActionsAdapter(Decoration decoration) |
278 |
|
{ |
279 |
|
|
280 |
0 |
String decoratorActionsAdapterClassName = decoration.getProperty("actions.factory"); |
281 |
0 |
if ( decoratorActionsAdapterClassName == null ) |
282 |
|
{ |
283 |
0 |
decoratorActionsAdapterClassName = defaultDecoratorActionsFactory.getClass().getName(); |
284 |
|
} |
285 |
0 |
synchronized (decoratorActionsAdapterCache) |
286 |
|
{ |
287 |
0 |
DecoratorActionsFactory adapter = (DecoratorActionsFactory)decoratorActionsAdapterCache.get(decoratorActionsAdapterClassName); |
288 |
0 |
if ( adapter == null ) |
289 |
|
{ |
290 |
|
try |
291 |
|
{ |
292 |
0 |
adapter = (DecoratorActionsFactory)Class.forName(decoratorActionsAdapterClassName).newInstance(); |
293 |
0 |
adapter.setMaximizeOnEdit(this.maxOnEdit); |
294 |
|
} |
295 |
0 |
catch (Exception e) |
296 |
|
{ |
297 |
0 |
log.error("Failed to instantiate custom DecoratorActionsAdaptor "+decoratorActionsAdapterClassName+", falling back to default.",e); |
298 |
0 |
adapter = (DecoratorActionsFactory)decoratorActionsAdapterCache.get(defaultDecoratorActionsFactory.getClass().getName()); |
299 |
0 |
if ( adapter == null ) |
300 |
|
{ |
301 |
0 |
adapter = defaultDecoratorActionsFactory; |
302 |
|
} |
303 |
0 |
} |
304 |
0 |
decoratorActionsAdapterCache.put(decoratorActionsAdapterClassName,adapter); |
305 |
|
} |
306 |
0 |
return adapter; |
307 |
0 |
} |
308 |
|
} |
309 |
|
|
310 |
|
|
311 |
|
|
312 |
|
|
313 |
|
|
314 |
|
|
315 |
|
|
316 |
|
|
317 |
|
|
318 |
|
|
319 |
|
|
320 |
|
protected boolean initActionsForFragment(RequestContext requestContext, |
321 |
|
ContentFragment fragment, |
322 |
|
PageActionAccess pageActionAccess, |
323 |
|
Decoration decoration, |
324 |
|
boolean isAjaxRequest) throws FailedToRetrievePortletWindow, PortletEntityNotStoredException |
325 |
|
{ |
326 |
0 |
boolean fragmentSupportsActions = false; |
327 |
0 |
PortletWindow window = windowAccessor.getPortletWindow(fragment); |
328 |
0 |
PortletDefinitionComposite portlet = (PortletDefinitionComposite) window.getPortletEntity().getPortletDefinition(); |
329 |
|
|
330 |
0 |
if (null == portlet) |
331 |
|
{ |
332 |
0 |
return fragmentSupportsActions; |
333 |
|
} |
334 |
|
|
335 |
0 |
List actions = Collections.EMPTY_LIST; |
336 |
|
|
337 |
0 |
PortletMode currentMode = requestContext.getPortalURL().getNavigationalState().getMode(window); |
338 |
0 |
WindowState currentState = requestContext.getPortalURL().getNavigationalState().getState(window); |
339 |
0 |
ContentTypeSet content = portlet.getContentTypeSet(); |
340 |
|
|
341 |
0 |
if ( fragment.equals(requestContext.getPage().getRootFragment()) ) |
342 |
|
{ |
343 |
0 |
fragmentSupportsActions = true; |
344 |
0 |
actions = getPageModes(requestContext, window, content, currentMode, currentState, pageActionAccess, decoration, isAjaxRequest); |
345 |
|
} |
346 |
0 |
else if ( !Fragment.LAYOUT.equals(fragment.getType()) ) |
347 |
|
{ |
348 |
0 |
fragmentSupportsActions = true; |
349 |
0 |
String fragmentId = fragment.getId(); |
350 |
0 |
PortletApplication pa = (PortletApplication)window.getPortletEntity().getPortletDefinition().getPortletApplicationDefinition(); |
351 |
|
|
352 |
0 |
String portletName = portlet.getUniqueName(); |
353 |
|
|
354 |
0 |
PortletMode currentMappedMode = pa.getMappedPortletMode(currentMode); |
355 |
0 |
WindowState currentMappedState = pa.getMappedWindowState(currentState); |
356 |
|
|
357 |
|
Object action; |
358 |
|
PortletMode mappedMode; |
359 |
|
PortletMode customMode; |
360 |
|
WindowState mappedState; |
361 |
|
WindowState customState; |
362 |
|
|
363 |
0 |
ArrayList actionTemplates = new ArrayList(); |
364 |
|
|
365 |
0 |
DecoratorActionsFactory actionsAdapter = getDecoratorActionsAdapter(decoration); |
366 |
|
|
367 |
0 |
Iterator iter = actionsAdapter.getSupportedActions(requestContext, pa, window, currentMappedMode, currentMappedState, decoration).iterator(); |
368 |
|
|
369 |
0 |
String currentModeAction = null; |
370 |
0 |
String currentStateAction = null; |
371 |
|
|
372 |
0 |
while ( iter.hasNext() ) |
373 |
|
{ |
374 |
0 |
action = iter.next(); |
375 |
0 |
if ( action instanceof PortletMode ) |
376 |
|
{ |
377 |
0 |
mappedMode = (PortletMode)action; |
378 |
0 |
customMode = pa.getCustomPortletMode(mappedMode); |
379 |
|
|
380 |
0 |
if ( customMode != null ) |
381 |
|
{ |
382 |
0 |
boolean equalsCurrentMode = customMode.equals(currentMode); |
383 |
0 |
if ( equalsCurrentMode ) |
384 |
|
{ |
385 |
0 |
currentModeAction = mappedMode.toString(); |
386 |
|
} |
387 |
0 |
if ( ! equalsCurrentMode || isAjaxRequest ) |
388 |
|
{ |
389 |
0 |
if ( content.supportsPortletMode(customMode) |
390 |
|
&& (!PortletMode.EDIT.equals(customMode) || pageActionAccess.isEditAllowed()) |
391 |
|
&& pageActionAccess.checkPortletMode(fragmentId, portletName, mappedMode) |
392 |
|
) |
393 |
|
{ |
394 |
0 |
actionTemplates.add(new DecoratorActionTemplate(mappedMode, customMode)); |
395 |
|
} |
396 |
|
} |
397 |
0 |
} |
398 |
|
} |
399 |
0 |
else if ( action instanceof WindowState ) |
400 |
|
{ |
401 |
0 |
mappedState = (WindowState)action; |
402 |
0 |
customState = pa.getCustomWindowState(mappedState); |
403 |
|
|
404 |
0 |
if ( customState != null ) |
405 |
|
{ |
406 |
0 |
boolean equalsCurrentState = customState.equals(currentState); |
407 |
0 |
if ( equalsCurrentState ) |
408 |
|
{ |
409 |
0 |
currentStateAction = mappedState.toString(); |
410 |
|
} |
411 |
0 |
if ( ! equalsCurrentState || isAjaxRequest ) |
412 |
|
{ |
413 |
0 |
if ( pageActionAccess.checkWindowState(fragmentId, portletName, mappedState ) ) |
414 |
|
{ |
415 |
0 |
actionTemplates.add(new DecoratorActionTemplate(mappedState, customState)); |
416 |
|
} |
417 |
|
} |
418 |
0 |
} |
419 |
|
} |
420 |
|
} |
421 |
0 |
actions = actionsAdapter.getDecoratorActions(requestContext, pa, window, currentMode, currentState, decoration, actionTemplates,portlet,fragment,accessController); |
422 |
|
|
423 |
0 |
decoration.setCurrentModeAction( currentModeAction ); |
424 |
0 |
decoration.setCurrentStateAction( currentStateAction ); |
425 |
|
} |
426 |
|
|
427 |
0 |
decoration.setActions( actions ); |
428 |
|
|
429 |
0 |
return fragmentSupportsActions; |
430 |
|
} |
431 |
|
|
432 |
|
|
433 |
|
|
434 |
|
|
435 |
|
|
436 |
|
|
437 |
|
|
438 |
|
|
439 |
|
|
440 |
|
|
441 |
|
|
442 |
|
|
443 |
|
|
444 |
|
|
445 |
|
|
446 |
|
protected List getPageModes(RequestContext requestContext, PortletWindow window, ContentTypeSet content, |
447 |
|
PortletMode mode, WindowState state, PageActionAccess pageActionAccess, Decoration decoration, |
448 |
|
boolean isAjaxRequest) |
449 |
|
{ |
450 |
0 |
List pageModes = new ArrayList(); |
451 |
|
|
452 |
|
|
453 |
|
try |
454 |
|
{ |
455 |
0 |
if (mode.equals(PortletMode.HELP) || !state.equals(WindowState.NORMAL)) |
456 |
|
{ |
457 |
|
|
458 |
0 |
PortalURL portalURL = requestContext.getPortalURL(); |
459 |
0 |
String action = requestContext.getResponse().encodeURL( (isAjaxRequest) |
460 |
|
? portalURL.createNavigationalEncoding(window, PortletMode.VIEW, WindowState.NORMAL) |
461 |
|
: portalURL.createPortletURL(window, PortletMode.VIEW, WindowState.NORMAL, portalURL.isSecure()).toString() ); |
462 |
0 |
String actionName = PortletMode.VIEW.toString(); |
463 |
0 |
pageModes.add(new DecoratorAction(actionName, requestContext.getLocale(), decoration.getResource("images/" + actionName + ".gif"),action,DecoratorActionTemplate.ACTION_TYPE_MODE)); |
464 |
0 |
} |
465 |
0 |
else if ( pageActionAccess.isEditAllowed() ) |
466 |
|
{ |
467 |
0 |
String targetMode = pageActionAccess.isEditing() ? PortletMode.VIEW.toString() : PortletMode.EDIT.toString(); |
468 |
0 |
PortalURL portalURL = requestContext.getPortalURL(); |
469 |
0 |
HashMap parameters = new HashMap(); |
470 |
0 |
String[] paramValues = new String[]{targetMode}; |
471 |
0 |
parameters.put("pageMode",paramValues); |
472 |
|
|
473 |
|
|
474 |
0 |
String action = requestContext.getResponse().encodeURL( (isAjaxRequest) |
475 |
|
? portalURL.createNavigationalEncoding(window, parameters, PortletMode.VIEW, WindowState.NORMAL, true) |
476 |
|
: portalURL.createPortletURL(window, parameters, PortletMode.VIEW, WindowState.NORMAL, true, portalURL.isSecure()).toString() ); |
477 |
0 |
pageModes.add(new DecoratorAction(targetMode, requestContext.getLocale(), decoration.getResource("images/" + targetMode + ".gif"), action,DecoratorActionTemplate.ACTION_TYPE_MODE)); |
478 |
|
|
479 |
|
|
480 |
|
|
481 |
0 |
if (content.supportsPortletMode(PortletMode.HELP)) |
482 |
|
{ |
483 |
0 |
if ( pageActionAccess.isEditing() ) |
484 |
|
{ |
485 |
|
|
486 |
0 |
paramValues[0] = PortletMode.VIEW.toString(); |
487 |
0 |
action = requestContext.getResponse().encodeURL( (isAjaxRequest) |
488 |
|
? portalURL.createNavigationalEncoding(window, parameters, PortletMode.HELP, WindowState.MAXIMIZED, true) |
489 |
|
: portalURL.createPortletURL(window, parameters, PortletMode.HELP, WindowState.MAXIMIZED, true, portalURL.isSecure()).toString() ); |
490 |
|
} |
491 |
|
else |
492 |
|
{ |
493 |
|
|
494 |
0 |
action = requestContext.getResponse().encodeURL( (isAjaxRequest) |
495 |
|
? portalURL.createNavigationalEncoding(window, PortletMode.HELP, WindowState.MAXIMIZED) |
496 |
|
: portalURL.createPortletURL(window,PortletMode.HELP, WindowState.MAXIMIZED, portalURL.isSecure()).toString() ); |
497 |
|
} |
498 |
0 |
String actionName = PortletMode.HELP.toString(); |
499 |
0 |
pageModes.add(new DecoratorAction(actionName, requestContext.getLocale(), decoration.getResource("images/" + actionName + ".gif"), action,DecoratorActionTemplate.ACTION_TYPE_MODE)); |
500 |
|
} |
501 |
|
} |
502 |
|
} |
503 |
0 |
catch (Exception e) |
504 |
|
{ |
505 |
0 |
log.warn("Unable to initalize PageLayout actions", e); |
506 |
0 |
pageModes = null; |
507 |
0 |
} |
508 |
|
|
509 |
0 |
return pageModes; |
510 |
|
} |
511 |
|
|
512 |
|
|
513 |
|
|
514 |
|
|
515 |
|
|
516 |
|
|
517 |
|
|
518 |
|
|
519 |
|
|
520 |
|
|
521 |
|
|
522 |
|
protected void initDepthFragments(RequestContext requestContext, |
523 |
|
Theme theme, |
524 |
|
ContentFragment fragment, |
525 |
|
PageActionAccess pageActionAccess, |
526 |
|
boolean isAjaxRequest, |
527 |
|
List collectFragments ) |
528 |
|
{ |
529 |
0 |
final List contentFragments = fragment.getContentFragments(); |
530 |
|
|
531 |
0 |
if(contentFragments != null && contentFragments.size() > 0) |
532 |
|
{ |
533 |
0 |
Iterator itr = contentFragments.iterator(); |
534 |
0 |
while(itr.hasNext()) |
535 |
|
{ |
536 |
0 |
ContentFragment aFragment = (ContentFragment) itr.next(); |
537 |
0 |
initDepthFragments(requestContext, theme, aFragment, pageActionAccess, isAjaxRequest, collectFragments); |
538 |
0 |
} |
539 |
|
} |
540 |
|
|
541 |
0 |
if ( initFragment(requestContext, theme, fragment, pageActionAccess, isAjaxRequest) ) |
542 |
|
{ |
543 |
0 |
if ( collectFragments != null ) |
544 |
|
{ |
545 |
0 |
collectFragments.add( fragment ); |
546 |
|
} |
547 |
|
} |
548 |
0 |
} |
549 |
|
|
550 |
|
protected boolean initFragment(RequestContext requestContext, |
551 |
|
Theme theme, |
552 |
|
ContentFragment fragment, |
553 |
|
PageActionAccess pageActionAccess, |
554 |
|
boolean isAjaxRequest) |
555 |
|
{ |
556 |
0 |
boolean fragmentSupportsActions = false; |
557 |
|
try |
558 |
|
{ |
559 |
0 |
Decoration decoration = theme.getDecoration(fragment); |
560 |
0 |
fragment.setDecoration(decoration); |
561 |
0 |
fragmentSupportsActions = initActionsForFragment(requestContext, fragment, pageActionAccess, decoration, isAjaxRequest); |
562 |
|
} |
563 |
0 |
catch (Exception e) |
564 |
|
{ |
565 |
0 |
log.warn("Unable to initalize actions for fragment "+fragment.getId(), e); |
566 |
0 |
} |
567 |
0 |
return fragmentSupportsActions; |
568 |
|
} |
569 |
|
|
570 |
|
|
571 |
|
|
572 |
|
|
573 |
|
|
574 |
|
|
575 |
|
|
576 |
|
|
577 |
|
|
578 |
|
|
579 |
|
|
580 |
|
|
581 |
|
|
582 |
|
protected void initDepthFragmentDecorations(RequestContext requestContext, |
583 |
|
Theme theme, |
584 |
|
ContentFragment fragment, |
585 |
|
PageActionAccess pageActionAccess, |
586 |
|
boolean isAjaxRequest, |
587 |
|
ResourceValidator validator, |
588 |
|
PathResolverCache pathResolverCache, |
589 |
|
boolean reloadActionList) |
590 |
|
{ |
591 |
0 |
final List contentFragments = fragment.getContentFragments(); |
592 |
|
|
593 |
0 |
if(contentFragments != null && contentFragments.size() > 0) |
594 |
|
{ |
595 |
0 |
Iterator itr = contentFragments.iterator(); |
596 |
0 |
while(itr.hasNext()) |
597 |
|
{ |
598 |
0 |
ContentFragment aFragment = (ContentFragment) itr.next(); |
599 |
0 |
initDepthFragmentDecorations(requestContext, theme, aFragment, |
600 |
|
pageActionAccess, isAjaxRequest, |
601 |
|
validator, pathResolverCache, reloadActionList); |
602 |
0 |
} |
603 |
|
} |
604 |
|
|
605 |
|
try |
606 |
|
{ |
607 |
|
|
608 |
0 |
Decoration decoration = theme.getDecoration(fragment); |
609 |
|
|
610 |
0 |
Properties config = ((DecorationFactoryImpl) decorationFactory).getConfiguration(decoration.getName(), fragment.getType()); |
611 |
0 |
((BaseDecoration) decoration).init(config, validator, pathResolverCache); |
612 |
|
|
613 |
0 |
fragment.setDecoration(decoration); |
614 |
|
|
615 |
0 |
if (reloadActionList) |
616 |
|
{ |
617 |
0 |
initActionsForFragment(requestContext, fragment, pageActionAccess, decoration, isAjaxRequest); |
618 |
|
} |
619 |
|
} |
620 |
0 |
catch (Exception e) |
621 |
|
{ |
622 |
0 |
log.warn("Unable to initalize actions for fragment "+fragment.getId(), e); |
623 |
0 |
} |
624 |
0 |
} |
625 |
|
|
626 |
|
public void setMaximizeOnEdit(boolean maxOnEdit) |
627 |
|
{ |
628 |
0 |
this.maxOnEdit = maxOnEdit; |
629 |
0 |
this.defaultDecoratorActionsFactory.setMaximizeOnEdit(maxOnEdit); |
630 |
0 |
} |
631 |
|
|
632 |
|
public boolean getMaximizeOnEdit() |
633 |
|
{ |
634 |
0 |
return this.maxOnEdit; |
635 |
|
} |
636 |
|
} |