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.jetspeed.JetspeedActions; |
25 |
|
import org.apache.jetspeed.cache.JetspeedContentCache; |
26 |
|
import org.apache.jetspeed.container.state.NavigationalState; |
27 |
|
import org.apache.jetspeed.om.page.ContentPage; |
28 |
|
import org.apache.jetspeed.om.page.Page; |
29 |
|
import org.apache.jetspeed.request.RequestContext; |
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
public class SessionNavigationalState extends AbstractNavigationalState |
38 |
|
{ |
39 |
|
private Map currentPageWindowStates; |
40 |
|
|
41 |
|
public SessionNavigationalState(NavigationalStateCodec codec, JetspeedContentCache cache) |
42 |
|
{ |
43 |
0 |
super(codec, cache); |
44 |
0 |
} |
45 |
|
|
46 |
|
public SessionNavigationalState(NavigationalStateCodec codec, JetspeedContentCache cache, JetspeedContentCache decorationCache) |
47 |
|
{ |
48 |
0 |
super(codec, cache, decorationCache); |
49 |
0 |
} |
50 |
|
|
51 |
|
public synchronized void sync(RequestContext context) |
52 |
|
{ |
53 |
0 |
PortletWindowRequestNavigationalStates requestStates = getPortletWindowRequestNavigationalStates(); |
54 |
|
|
55 |
|
|
56 |
0 |
boolean transientNavState = requestStates.getResourceWindow() != null; |
57 |
|
|
58 |
0 |
String clearCacheWindowId = null; |
59 |
|
|
60 |
0 |
if (!transientNavState) |
61 |
|
{ |
62 |
|
|
63 |
|
|
64 |
|
|
65 |
0 |
String requestMaximizedWindowId = null; |
66 |
|
|
67 |
0 |
if ( requestStates.getMaximizedWindow() != null ) |
68 |
|
{ |
69 |
0 |
requestMaximizedWindowId = requestStates.getMaximizedWindow().getId().toString(); |
70 |
0 |
WindowState state = requestStates.getPortletWindowNavigationalState(requestMaximizedWindowId).getWindowState(); |
71 |
0 |
transientNavState = JetspeedActions.SOLO_STATE.equals(state); |
72 |
0 |
clearCacheWindowId = requestMaximizedWindowId; |
73 |
|
} |
74 |
|
|
75 |
|
} |
76 |
0 |
if (transientNavState) |
77 |
|
{ |
78 |
|
|
79 |
|
|
80 |
0 |
if (clearCacheWindowId != null) |
81 |
|
{ |
82 |
0 |
HttpSession session = context.getRequest().getSession(); |
83 |
0 |
if ( session != null ) |
84 |
|
{ |
85 |
0 |
PortletWindowSessionNavigationalStates sessionStates = (PortletWindowSessionNavigationalStates)session.getAttribute(NavigationalState.NAVSTATE_SESSION_KEY); |
86 |
0 |
if ( sessionStates != null ) |
87 |
|
{ |
88 |
0 |
sessionStates.removeFromCache(context, clearCacheWindowId, cache); |
89 |
0 |
ContentPage page = context.getPage(); |
90 |
0 |
sessionStates.removeFromCache(context, page.getId(), decorationCache); |
91 |
|
} |
92 |
|
} |
93 |
0 |
} |
94 |
|
} |
95 |
|
else |
96 |
|
{ |
97 |
0 |
HttpSession session = context.getRequest().getSession(); |
98 |
0 |
if ( session != null ) |
99 |
|
{ |
100 |
0 |
PortletWindowSessionNavigationalStates sessionStates = (PortletWindowSessionNavigationalStates)session.getAttribute(NavigationalState.NAVSTATE_SESSION_KEY); |
101 |
0 |
if ( sessionStates == null ) |
102 |
|
{ |
103 |
0 |
sessionStates = new PortletWindowSessionNavigationalStates(isRenderParameterStateFull()); |
104 |
0 |
session.setAttribute(NavigationalState.NAVSTATE_SESSION_KEY, sessionStates); |
105 |
|
} |
106 |
0 |
Page page = context.getPage(); |
107 |
0 |
sessionStates.sync(context, (Page) context.getPage(), requestStates, cache, decorationCache); |
108 |
0 |
if (isNavigationalParameterStateFull() && isRenderParameterStateFull()) |
109 |
|
{ |
110 |
0 |
currentPageWindowStates = sessionStates.getWindowStates(page); |
111 |
|
} |
112 |
|
} |
113 |
|
} |
114 |
0 |
} |
115 |
|
|
116 |
|
public Map getCurrentPageWindowStates() |
117 |
|
{ |
118 |
0 |
return currentPageWindowStates; |
119 |
|
} |
120 |
|
|
121 |
|
public boolean isNavigationalParameterStateFull() |
122 |
|
{ |
123 |
0 |
return true; |
124 |
|
} |
125 |
|
|
126 |
|
public boolean isRenderParameterStateFull() |
127 |
|
{ |
128 |
0 |
return false; |
129 |
|
} |
130 |
|
} |