Coverage report

  %line %branch
org.apache.jetspeed.container.state.impl.SessionNavigationalState
0% 
0% 

 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 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  
  * SessionNavigationalState, stores nav parameters in the session, not on URL
 35  
  *
 36  
  * <p>
 37  
  * Added the ability to reset portlet mode and window states to VIEW and NORMAL in the case
 38  
  * of page navigation. JS2-806
 39  
  * </p>
 40  
  *
 41  
  * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
 42  
  * @version $Id: SessionNavigationalState.java 593807 2007-11-10 19:22:03Z taylor $
 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  
         // for Resource (PortletURL) requests, session state is never synchronized
 65  0
         boolean transientNavState = requestStates.getResourceWindow() != null;
 66  
         
 67  0
         String clearCacheWindowId = null;
 68  
         
 69  0
         if (!transientNavState)
 70  
         {
 71  
             // Check if a maximized window is set in the request.
 72  
             // This can mean a window with state MAXIMIZED *or* SOLO.
 73  
             // With a SOLO state, also skip all synchroniziations!
 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  
             // no navState synchronizations
 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  
                 // JS2-806
 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  
 }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.