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.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  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  
         // for Resource (PortletURL) requests, session state is never synchronized
 56  0
         boolean transientNavState = requestStates.getResourceWindow() != null;
 57  
         
 58  0
         String clearCacheWindowId = null;
 59  
         
 60  0
         if (!transientNavState)
 61  
         {
 62  
             // Check if a maximized window is set in the request.
 63  
             // This can mean a window with state MAXIMIZED *or* SOLO.
 64  
             // With a SOLO state, also skip all synchroniziations!
 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  
             // no navState synchronizations
 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  
 }

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