1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
package org.apache.jetspeed.container.state.impl; |
18 |
|
|
19 |
|
import java.util.Map; |
20 |
|
|
21 |
|
import javax.portlet.WindowState; |
22 |
|
import javax.servlet.http.HttpSession; |
23 |
|
|
24 |
|
import org.apache.commons.logging.Log; |
25 |
|
import org.apache.commons.logging.LogFactory; |
26 |
|
import org.apache.jetspeed.JetspeedActions; |
27 |
|
import org.apache.jetspeed.cache.JetspeedContentCache; |
28 |
|
import org.apache.jetspeed.container.state.NavigationalState; |
29 |
|
import org.apache.jetspeed.om.page.ContentPage; |
30 |
|
import org.apache.jetspeed.om.page.Page; |
31 |
|
import org.apache.jetspeed.request.RequestContext; |
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
|
44 |
|
public class SessionNavigationalState extends AbstractNavigationalState |
45 |
|
{ |
46 |
0 |
protected final Log log = LogFactory.getLog(getClass()); |
47 |
|
private Map currentPageWindowStates; |
48 |
0 |
private boolean clearPortletsModeAndWindowStateEnabled = false; |
49 |
|
|
50 |
|
public SessionNavigationalState(NavigationalStateCodec codec, JetspeedContentCache cache) |
51 |
|
{ |
52 |
0 |
super(codec, cache); |
53 |
0 |
} |
54 |
|
|
55 |
|
public SessionNavigationalState(NavigationalStateCodec codec, JetspeedContentCache cache, JetspeedContentCache decorationCache) |
56 |
|
{ |
57 |
0 |
super(codec, cache, decorationCache); |
58 |
0 |
} |
59 |
|
|
60 |
|
public synchronized void sync(RequestContext context) |
61 |
|
{ |
62 |
0 |
PortletWindowRequestNavigationalStates requestStates = getPortletWindowRequestNavigationalStates(); |
63 |
|
|
64 |
|
|
65 |
0 |
boolean transientNavState = requestStates.getResourceWindow() != null; |
66 |
|
|
67 |
0 |
String clearCacheWindowId = null; |
68 |
|
|
69 |
0 |
if (!transientNavState) |
70 |
|
{ |
71 |
|
|
72 |
|
|
73 |
|
|
74 |
0 |
String requestMaximizedWindowId = null; |
75 |
|
|
76 |
0 |
if ( requestStates.getMaximizedWindow() != null ) |
77 |
|
{ |
78 |
0 |
requestMaximizedWindowId = requestStates.getMaximizedWindow().getId().toString(); |
79 |
0 |
WindowState state = requestStates.getPortletWindowNavigationalState(requestMaximizedWindowId).getWindowState(); |
80 |
0 |
transientNavState = JetspeedActions.SOLO_STATE.equals(state); |
81 |
0 |
clearCacheWindowId = requestMaximizedWindowId; |
82 |
|
} |
83 |
|
|
84 |
|
} |
85 |
0 |
if (transientNavState) |
86 |
|
{ |
87 |
|
|
88 |
|
|
89 |
0 |
if (clearCacheWindowId != null) |
90 |
|
{ |
91 |
0 |
HttpSession session = context.getRequest().getSession(); |
92 |
0 |
if ( session != null ) |
93 |
|
{ |
94 |
0 |
PortletWindowSessionNavigationalStates sessionStates = (PortletWindowSessionNavigationalStates)session.getAttribute(NavigationalState.NAVSTATE_SESSION_KEY); |
95 |
0 |
if ( sessionStates != null ) |
96 |
|
{ |
97 |
0 |
sessionStates.removeFromCache(context, clearCacheWindowId, cache); |
98 |
0 |
ContentPage page = context.getPage(); |
99 |
0 |
sessionStates.removeFromCache(context, page.getId(), decorationCache); |
100 |
|
} |
101 |
|
} |
102 |
0 |
} |
103 |
|
} |
104 |
|
else |
105 |
|
{ |
106 |
0 |
HttpSession session = context.getRequest().getSession(); |
107 |
0 |
if ( session != null ) |
108 |
|
{ |
109 |
0 |
PortletWindowSessionNavigationalStates sessionStates = (PortletWindowSessionNavigationalStates)session.getAttribute(NavigationalState.NAVSTATE_SESSION_KEY); |
110 |
0 |
if ( sessionStates == null ) |
111 |
|
{ |
112 |
0 |
sessionStates = new PortletWindowSessionNavigationalStates(isRenderParameterStateFull()); |
113 |
0 |
session.setAttribute(NavigationalState.NAVSTATE_SESSION_KEY, sessionStates); |
114 |
|
} |
115 |
0 |
Page page = context.getPage(); |
116 |
|
|
117 |
0 |
if (isClearPortletsModeAndWindowStateEnabled()) |
118 |
|
{ |
119 |
0 |
sessionStates.changeAllPortletsToViewModeAndNormalWindowState(context, page, requestStates, cache, decorationCache); |
120 |
|
} |
121 |
|
else |
122 |
|
{ |
123 |
0 |
sessionStates.sync(context, (Page) context.getPage(), requestStates, cache, decorationCache); |
124 |
|
} |
125 |
0 |
if (isNavigationalParameterStateFull() && isRenderParameterStateFull()) |
126 |
|
{ |
127 |
0 |
currentPageWindowStates = sessionStates.getWindowStates(page); |
128 |
|
} |
129 |
|
} |
130 |
|
} |
131 |
0 |
} |
132 |
|
|
133 |
|
public Map getCurrentPageWindowStates() |
134 |
|
{ |
135 |
0 |
return currentPageWindowStates; |
136 |
|
} |
137 |
|
|
138 |
|
public boolean isNavigationalParameterStateFull() |
139 |
|
{ |
140 |
0 |
return true; |
141 |
|
} |
142 |
|
|
143 |
|
public boolean isRenderParameterStateFull() |
144 |
|
{ |
145 |
0 |
return false; |
146 |
|
} |
147 |
|
|
148 |
|
protected void setClearPortletsModeAndWindowStateEnabled( |
149 |
|
boolean clearPortletsModeAndWindowStateEnabled) |
150 |
|
{ |
151 |
0 |
this.clearPortletsModeAndWindowStateEnabled = clearPortletsModeAndWindowStateEnabled; |
152 |
0 |
} |
153 |
|
|
154 |
|
protected boolean isClearPortletsModeAndWindowStateEnabled() |
155 |
|
{ |
156 |
0 |
return clearPortletsModeAndWindowStateEnabled; |
157 |
|
} |
158 |
|
} |