View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    * 
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   * 
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.jetspeed.container.state.impl;
18  
19  import org.apache.jetspeed.cache.JetspeedContentCache;
20  import org.apache.jetspeed.container.PageHistoryValve;
21  import org.apache.jetspeed.request.RequestContext;
22  
23  /***
24   * SessionFullClearOnChangePageNavigationalState, stores all nav parameters in the session, including render parameters
25   *
26   * @author <a href="mailto:kmoh.raj@gmail.com">Mohan Kannapareddy</a>
27   * @version $Id$
28   */
29  
30  public class SessionFullExtendedNavigationalState extends SessionFullNavigationalState 
31  {
32  	private boolean clearStateOnPageChangeEnabled = false;
33  
34  	
35  	public SessionFullExtendedNavigationalState(NavigationalStateCodec codec,JetspeedContentCache cache)
36  	{
37  		super(codec, cache);
38  	}
39      public SessionFullExtendedNavigationalState(NavigationalStateCodec codec, JetspeedContentCache cache, JetspeedContentCache decorationCache)
40      {
41          super(codec, cache, decorationCache);
42      }
43  
44      public SessionFullExtendedNavigationalState(NavigationalStateCodec codec, JetspeedContentCache cache, JetspeedContentCache decorationCache, boolean clearStateOnPageChangeEnabled)
45      {
46          super(codec, cache, decorationCache);
47          this.clearStateOnPageChangeEnabled = clearStateOnPageChangeEnabled;
48      }
49      
50      protected boolean clearPagePortletsModeAndWindowState(RequestContext context)
51      {
52          String contextKey = PageHistoryValve.REQUEST_CLEAR_PORTLETS_MODE_AND_WINDOWSTATE_KEY;
53          boolean result = false;
54          if (clearStateOnPageChangeEnabled)
55          {
56              Boolean pageNavigationEvent = (Boolean) context.getAttribute(contextKey);
57              if ((pageNavigationEvent != null))
58              {
59                  result = pageNavigationEvent.booleanValue();
60              }
61          }
62          //Just to be safe make it false
63          context.setAttribute(contextKey, Boolean.FALSE);
64          
65      	return result;
66      }
67      
68      public synchronized void sync(RequestContext context)
69      {
70          // JS2-806, check the session for a psuedo inter page navigation.
71          boolean resetPagePortlets = false;
72          if (clearStateOnPageChangeEnabled)
73          {
74              resetPagePortlets = clearPagePortletsModeAndWindowState(context);
75              if (log.isDebugEnabled())
76              {
77                  log.debug("resetPagePortlets:" + resetPagePortlets);
78              }
79          }
80  
81          // push the informaion up to SessionNavigationalState, so that we can handle it appropriately there
82          setClearPortletsModeAndWindowStateEnabled(resetPagePortlets);
83          //Inform the super
84          super.sync(context);
85      }
86  }