Clover coverage report - Code Coverage for tapestry-portlet release 4.0-beta-8
Coverage timestamp: Sat Sep 24 2005 11:55:29 EDT
file stats: LOC: 171   Methods: 22
NCLOC: 113   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
PortletWebRequest.java 100% 74.2% 68.2% 74.6%
coverage coverage
 1    // Copyright 2005 The Apache Software Foundation
 2    //
 3    // Licensed under the Apache License, Version 2.0 (the "License");
 4    // you may not use this file except in compliance with the License.
 5    // You may obtain a copy of the License at
 6    //
 7    // http://www.apache.org/licenses/LICENSE-2.0
 8    //
 9    // Unless required by applicable law or agreed to in writing, software
 10    // distributed under the License is distributed on an "AS IS" BASIS,
 11    // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12    // See the License for the specific language governing permissions and
 13    // limitations under the License.
 14   
 15    package org.apache.tapestry.portlet;
 16   
 17    import java.security.Principal;
 18    import java.util.List;
 19    import java.util.Locale;
 20   
 21    import javax.portlet.PortletRequest;
 22    import javax.portlet.PortletSession;
 23   
 24    import org.apache.hivemind.util.Defense;
 25    import org.apache.tapestry.describe.DescriptionReceiver;
 26    import org.apache.tapestry.web.WebRequest;
 27    import org.apache.tapestry.web.WebSession;
 28    import org.apache.tapestry.web.WebUtils;
 29   
 30    /**
 31    * Implementation of {@link org.apache.tapestry.web.WebRequest} that adapts a
 32    * {@link PortletRequest).
 33    *
 34    * @author Howard M. Lewis Ship
 35    * @since 4.0
 36    */
 37    public class PortletWebRequest implements WebRequest
 38    {
 39    private final PortletRequest _portletRequest;
 40   
 41    private WebSession _webSession;
 42   
 43  20 public PortletWebRequest(PortletRequest portletRequest)
 44    {
 45  20 Defense.notNull(portletRequest, "portletRequest");
 46   
 47  20 _portletRequest = portletRequest;
 48    }
 49   
 50  1 public List getParameterNames()
 51    {
 52  1 return WebUtils.toSortedList(_portletRequest.getParameterNames());
 53    }
 54   
 55  1 public String getParameterValue(String parameterName)
 56    {
 57  1 return _portletRequest.getParameter(parameterName);
 58    }
 59   
 60  1 public String[] getParameterValues(String parameterName)
 61    {
 62  1 return _portletRequest.getParameterValues(parameterName);
 63    }
 64   
 65  1 public String getContextPath()
 66    {
 67  1 return _portletRequest.getContextPath();
 68    }
 69   
 70  3 public WebSession getSession(boolean create)
 71    {
 72  3 if (_webSession != null)
 73  1 return _webSession;
 74   
 75  2 PortletSession session = _portletRequest.getPortletSession(create);
 76   
 77  2 if (session != null)
 78  1 _webSession = new PortletWebSession(session);
 79   
 80  2 return _webSession;
 81    }
 82   
 83  1 public String getScheme()
 84    {
 85  1 return _portletRequest.getScheme();
 86    }
 87   
 88  1 public String getServerName()
 89    {
 90  1 return _portletRequest.getServerName();
 91    }
 92   
 93  1 public int getServerPort()
 94    {
 95  1 return _portletRequest.getServerPort();
 96    }
 97   
 98    /**
 99    * Returns "<PortletRequest>", because portlets don't have a notion of request URI.
 100    */
 101   
 102  1 public String getRequestURI()
 103    {
 104  1 return "<PortletRequest>";
 105    }
 106   
 107  1 public void forward(String URL)
 108    {
 109  1 unsupported("forward");
 110    }
 111   
 112  0 public String getActivationPath()
 113    {
 114  0 return "";
 115    }
 116   
 117  1 public List getAttributeNames()
 118    {
 119  1 return WebUtils.toSortedList(_portletRequest.getAttributeNames());
 120    }
 121   
 122  1 public Object getAttribute(String name)
 123    {
 124  1 return _portletRequest.getAttribute(name);
 125    }
 126   
 127  4 public void setAttribute(String name, Object attribute)
 128    {
 129  4 if (attribute == null)
 130  3 _portletRequest.removeAttribute(name);
 131    else
 132  1 _portletRequest.setAttribute(name, attribute);
 133    }
 134   
 135  1 protected final void unsupported(String methodName)
 136    {
 137  1 throw new UnsupportedOperationException(PortletMessages.unsupportedMethod(methodName));
 138    }
 139   
 140  0 public void describeTo(DescriptionReceiver receiver)
 141    {
 142  0 receiver.describeAlternate(_portletRequest);
 143    }
 144   
 145  0 public Locale getLocale()
 146    {
 147  0 return _portletRequest.getLocale();
 148    }
 149   
 150  0 public String getHeader(String name)
 151    {
 152  0 unsupported("getHeader");
 153   
 154  0 return null;
 155    }
 156   
 157  0 public String getRemoteUser()
 158    {
 159  0 return _portletRequest.getRemoteUser();
 160    }
 161   
 162  0 public Principal getUserPrincipal()
 163    {
 164  0 return _portletRequest.getUserPrincipal();
 165    }
 166   
 167  0 public boolean isUserInRole(String role)
 168    {
 169  0 return _portletRequest.isUserInRole(role);
 170    }
 171    }