Coverage report

  %line %branch
org.apache.jetspeed.container.ContainerValve
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;
 18  
 
 19  
 import javax.servlet.http.HttpServletResponse;
 20  
 
 21  
 import org.apache.jetspeed.request.RequestContext;
 22  
 import org.apache.jetspeed.container.state.MutableNavigationalState;
 23  
 import org.apache.jetspeed.om.page.Page;
 24  
 import org.apache.jetspeed.om.common.portlet.MutablePortletEntity;
 25  
 import org.apache.jetspeed.om.window.impl.PortletWindowImpl;
 26  
 import org.apache.jetspeed.pipeline.PipelineException;
 27  
 import org.apache.jetspeed.pipeline.valve.AbstractValve;
 28  
 import org.apache.jetspeed.pipeline.valve.ValveContext;
 29  
 import org.apache.pluto.om.window.PortletWindow;
 30  
 
 31  
 /**
 32  
  * Determines the action window in the current request If no action was found,
 33  
  * sets the request context's action window to null denoting that there is no
 34  
  * targeted action for this request otherwise the target action window is set
 35  
  * here
 36  
  * 
 37  
  * @author <a href="mailto:david@bluesunrise.com">David Sean Taylor</a>
 38  
  * @version $Id: ContainerValve.java 589933 2007-10-30 01:51:50Z woonsan $
 39  
  */
 40  0
 public class ContainerValve extends AbstractValve
 41  
 {
 42  
     public void invoke(RequestContext request, ValveContext context) throws PipelineException
 43  
     {
 44  
         try
 45  
         {
 46  
             // create a session if not already created, necessary for Tomcat 5
 47  0
             request.getRequest().getSession(true);
 48  
 
 49  
             // PortletContainerServices.prepare();
 50  0
             MutableNavigationalState state = (MutableNavigationalState)request.getPortalURL().getNavigationalState();
 51  0
             if (state != null)
 52  
             {
 53  0
                 boolean redirect = false;
 54  0
                 Page page = request.getPage();
 55  0
                 PortletWindow window = state.getPortletWindowOfResource();
 56  0
                 if (window != null && page.getFragmentById(window.getId().toString()) == class="keyword">null)
 57  
                 {
 58  
                     // target window doesn't exists anymore or the target page is not accessible (anymore)
 59  0
                     request.getResponse().sendError(HttpServletResponse.SC_NOT_FOUND);
 60  0
                     return;
 61  
                 }
 62  0
                 window = state.getPortletWindowOfAction();
 63  0
                 if (window != null && page.getFragmentById(window.getId().toString()) == class="keyword">null)
 64  
                 {
 65  0
                     if (!((PortletWindowImpl) window).isInstantlyRendered())
 66  
                     {
 67  
                         // target window doesn't exists anymore or the target page is not accessible (anymore)
 68  
                         // remove any navigational state for the window
 69  0
                         state.removeState(window);
 70  
                         // as this is an action request which cannot be handled, perform a direct redirect after sync state (for the other windows)
 71  0
                         redirect = true;
 72  
                     }
 73  
                 }
 74  0
                 window = state.getMaximizedWindow();
 75  0
                 if (window != null && page.getFragmentById(window.getId().toString()) == class="keyword">null)
 76  
                 {
 77  
                     // target window doesn't exists anymore or the target page is not accessible (anymore)
 78  
                     // remove any navigational state for the window
 79  0
                     state.removeState(window);
 80  
                 }
 81  0
                 state.sync(request);
 82  0
                 if (redirect)
 83  
                 {
 84  
                     // target page doesn't contain (anymore) the targeted windowOfAction 
 85  
                     // this can also occur when a session is expired and the target page isn't accessible for the anonymous user
 86  
                     // Redirect the user back to the target page (with possibly retaining the other windows navigational state).
 87  0
                     request.getResponse().sendRedirect(request.getPortalURL().getPortalURL());
 88  0
                     return;
 89  
                 }
 90  
 
 91  0
                 PortletWindow actionWindow = state.getPortletWindowOfAction();
 92  0
                 if (null == actionWindow)
 93  
                 {
 94  
                     // set to null to denote that no action was requested
 95  0
                     request.setActionWindow(null);
 96  
                 }
 97  
                 else
 98  
                 {
 99  
                     // set the requested action window
 100  0
                     request.setActionWindow(actionWindow);
 101  
                 }
 102  
             }
 103  
         }
 104  0
         catch (Exception e)
 105  
         {
 106  0
             throw new PipelineException(e);
 107  0
         }
 108  
         // Pass control to the next Valve in the Pipeline
 109  0
         context.invokeNext(request);
 110  0
     }
 111  
 
 112  
     public String toString()
 113  
     {
 114  0
         return "ContainerValve";
 115  
     }
 116  
 }

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