Coverage report

  %line %branch
org.apache.jetspeed.container.url.impl.PathInfoEncodingPortalURL
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.url.impl;
 18  
 
 19  
 import java.util.StringTokenizer;
 20  
 
 21  
 import javax.servlet.http.HttpServletRequest;
 22  
 
 23  
 import org.apache.jetspeed.PortalContext;
 24  
 import org.apache.jetspeed.container.state.NavigationalState;
 25  
 import org.apache.jetspeed.container.url.BasePortalURL;
 26  
 
 27  
 /**
 28  
  * PathInfoEncodingPortalURL encodes the NavigationalState as PathInfo element
 29  
  * *
 30  
  * @author <a href="mailto:ate@apache.org">Ate Douma</a>
 31  
  * @version $Id: PathInfoEncodingPortalURL.java 605989 2007-12-20 18:26:54Z ate $
 32  
  */
 33  
 public class PathInfoEncodingPortalURL extends AbstractPortalURL
 34  
 {
 35  
     public PathInfoEncodingPortalURL(NavigationalState navState, PortalContext portalContext, BasePortalURL base)
 36  
     {
 37  0
         super(navState, portalContext, base);
 38  0
     }
 39  
 
 40  
     public PathInfoEncodingPortalURL(NavigationalState navState, PortalContext portalContext)
 41  
     {
 42  0
         super(navState, portalContext);
 43  0
     }
 44  
 
 45  
     public PathInfoEncodingPortalURL(String characterEncoding, NavigationalState navState, PortalContext portalContext)
 46  
     {
 47  0
         super(characterEncoding, navState, portalContext);
 48  0
     }
 49  
 
 50  
     public PathInfoEncodingPortalURL(HttpServletRequest request, String characterEncoding, NavigationalState navState, PortalContext portalContext)
 51  
     {
 52  0
         super(request, characterEncoding, navState, portalContext);
 53  0
     }
 54  
 
 55  
     protected void decodePathAndNavigationalState(HttpServletRequest request)
 56  
     {
 57  0
         String path = null;
 58  0
         String encodedNavState = null;
 59  
 
 60  0
         String pathInfo = request.getPathInfo();
 61  0
         if (pathInfo != null)
 62  
         {
 63  0
             StringTokenizer tokenizer = new StringTokenizer(request.getPathInfo(),"/");
 64  0
             StringBuffer buffer = new StringBuffer();
 65  
             String token;
 66  0
             boolean foundNavState = false;
 67  0
             String navStatePrefix = getNavigationalStateParameterName() +":";
 68  0
             while (tokenizer.hasMoreTokens())
 69  
             {
 70  0
                 token = tokenizer.nextToken();
 71  0
                 if (!foundNavState && token.startsWith(navStatePrefix))
 72  
                 {
 73  0
                     foundNavState = true;
 74  0
                     if ( token.length() > navStatePrefix.length() )
 75  
                     {
 76  0
                         encodedNavState = token.substring(navStatePrefix.length());
 77  
                     }
 78  
                 }
 79  
                 else
 80  
                 {
 81  0
                     buffer.append("/");
 82  0
                     buffer.append(token);
 83  
                 }
 84  
             }
 85  0
             if ( buffer.length() > 0 )
 86  
             {
 87  0
                 path = buffer.toString();
 88  
             }
 89  
             else
 90  
             {
 91  0
                 path = "/";
 92  
             }
 93  
         }
 94  0
         setPath(path);
 95  0
         setEncodedNavigationalState(encodedNavState);
 96  0
     }
 97  
 
 98  
     protected String createPortletURL(String encodedNavState, boolean secure)
 99  
     {
 100  0
         StringBuffer buffer = new StringBuffer(getBaseURL(secure));
 101  0
         buffer.append(getBasePath());
 102  0
         if ( encodedNavState != null )
 103  
         {
 104  0
             buffer.append("/");
 105  0
             buffer.append(getNavigationalStateParameterName());
 106  0
             buffer.append(":");
 107  0
             buffer.append(encodedNavState);
 108  
         }
 109  0
         if ( getPath() != null )
 110  
         {
 111  0
             buffer.append(getPath());
 112  
         }
 113  0
         return buffer.toString();
 114  
     }
 115  
 
 116  
     public boolean isPathInfoEncodingNavState()
 117  
     {
 118  0
         return true;
 119  
     }        
 120  
 }

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