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 * SessionNavigationalState, stores nav parameters in the session, not on URL
33 *
34 * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
35 * @version $Id: SessionNavigationalState.java 553340 2007-07-04 22:00:09Z taylor $
36 */
37 public class SessionNavigationalState extends AbstractNavigationalState
38 {
39 private Map currentPageWindowStates;
40
41 public SessionNavigationalState(NavigationalStateCodec codec, JetspeedContentCache cache)
42 {
43 super(codec, cache);
44 }
45
46 public SessionNavigationalState(NavigationalStateCodec codec, JetspeedContentCache cache, JetspeedContentCache decorationCache)
47 {
48 super(codec, cache, decorationCache);
49 }
50
51 public synchronized void sync(RequestContext context)
52 {
53 PortletWindowRequestNavigationalStates requestStates = getPortletWindowRequestNavigationalStates();
54
55
56 boolean transientNavState = requestStates.getResourceWindow() != null;
57
58 String clearCacheWindowId = null;
59
60 if (!transientNavState)
61 {
62
63
64
65 String requestMaximizedWindowId = null;
66
67 if ( requestStates.getMaximizedWindow() != null )
68 {
69 requestMaximizedWindowId = requestStates.getMaximizedWindow().getId().toString();
70 WindowState state = requestStates.getPortletWindowNavigationalState(requestMaximizedWindowId).getWindowState();
71 transientNavState = JetspeedActions.SOLO_STATE.equals(state);
72 clearCacheWindowId = requestMaximizedWindowId;
73 }
74
75 }
76 if (transientNavState)
77 {
78
79
80 if (clearCacheWindowId != null)
81 {
82 HttpSession session = context.getRequest().getSession();
83 if ( session != null )
84 {
85 PortletWindowSessionNavigationalStates sessionStates = (PortletWindowSessionNavigationalStates)session.getAttribute(NavigationalState.NAVSTATE_SESSION_KEY);
86 if ( sessionStates != null )
87 {
88 sessionStates.removeFromCache(context, clearCacheWindowId, cache);
89 ContentPage page = context.getPage();
90 sessionStates.removeFromCache(context, page.getId(), decorationCache);
91 }
92 }
93 }
94 }
95 else
96 {
97 HttpSession session = context.getRequest().getSession();
98 if ( session != null )
99 {
100 PortletWindowSessionNavigationalStates sessionStates = (PortletWindowSessionNavigationalStates)session.getAttribute(NavigationalState.NAVSTATE_SESSION_KEY);
101 if ( sessionStates == null )
102 {
103 sessionStates = new PortletWindowSessionNavigationalStates(isRenderParameterStateFull());
104 session.setAttribute(NavigationalState.NAVSTATE_SESSION_KEY, sessionStates);
105 }
106 Page page = context.getPage();
107 sessionStates.sync(context, (Page) context.getPage(), requestStates, cache, decorationCache);
108 if (isNavigationalParameterStateFull() && isRenderParameterStateFull())
109 {
110 currentPageWindowStates = sessionStates.getWindowStates(page);
111 }
112 }
113 }
114 }
115
116 public Map getCurrentPageWindowStates()
117 {
118 return currentPageWindowStates;
119 }
120
121 public boolean isNavigationalParameterStateFull()
122 {
123 return true;
124 }
125
126 public boolean isRenderParameterStateFull()
127 {
128 return false;
129 }
130 }