Coverage report

  %line %branch
org.apache.jetspeed.container.JetspeedPortletContainerWrapper
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 java.io.IOException;
 20  
 import java.util.Properties;
 21  
 
 22  
 import javax.portlet.PortletException;
 23  
 import javax.servlet.ServletConfig;
 24  
 import javax.servlet.http.HttpServletRequest;
 25  
 import javax.servlet.http.HttpServletResponse;
 26  
 
 27  
 import org.apache.commons.logging.Log;
 28  
 import org.apache.commons.logging.LogFactory;
 29  
 import org.apache.jetspeed.engine.servlet.ServletRequestFactory;
 30  
 import org.apache.jetspeed.engine.servlet.ServletResponseFactory;
 31  
 import org.apache.pluto.PortletContainer;
 32  
 import org.apache.pluto.PortletContainerException;
 33  
 import org.apache.pluto.om.window.PortletWindow;
 34  
 import org.apache.pluto.services.PortletContainerEnvironment;
 35  
 
 36  
 /**
 37  
  * Portlet Container Wrapper to secure access to portlet container.
 38  
  *
 39  
  * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
 40  
  * @version $Id: JetspeedPortletContainerWrapper.java 516448 2007-03-09 16:25:47Z ate $
 41  
  */
 42  
 public class JetspeedPortletContainerWrapper implements PortletContainerWrapper
 43  
 {
 44  0
     private boolean initialized = false;
 45  0
     private static final Log log = LogFactory.getLog(JetspeedPortletContainerWrapper.class);
 46  
     private final PortletContainer pluto;
 47  
     private final String containerId;
 48  
     private final Properties properties;
 49  
     private final PortletContainerEnvironment environment;
 50  
     private final ServletConfig servletConfig;
 51  
     
 52  
     private ServletRequestFactory requestFactory;
 53  
     private ServletResponseFactory responseFactory;
 54  
 
 55  
     public JetspeedPortletContainerWrapper(PortletContainer pluto, String containerId, 
 56  
             ServletConfig servletConfig, PortletContainerEnvironment env, Properties properties)
 57  0
     {
 58  0
         this.pluto = pluto;
 59  0
         this.containerId = containerId;
 60  0
         this.environment = env;
 61  0
         this.properties = properties;
 62  0
         this.servletConfig = servletConfig;
 63  0
     }
 64  
     
 65  
     public JetspeedPortletContainerWrapper(PortletContainer pluto, String containerId, 
 66  
             ServletConfig servletConfig, PortletContainerEnvironment env)
 67  
     {
 68  0
         this(pluto, containerId, servletConfig, env, new Properties());
 69  0
     }
 70  
     
 71  
     /**
 72  
      * Allows starting of the container without providing calling the 
 73  
      * <code>init()</code> method without all of the arguments as the
 74  
      * arguments have already been provided in the constructor.
 75  
      * 
 76  
      * @throws PortletContainerException
 77  
      */
 78  
     public void start() throws PortletContainerException
 79  
     {
 80  0
         log.info("Attmepting to start Pluto portal container...");
 81  0
         this.init(containerId, servletConfig, environment, properties);
 82  0
         log.info("Pluto portlet container successfully started.");
 83  0
     }
 84  
   
 85  
     /**
 86  
      * initialization is still handled outside component architecture, since Pluto is not a component
 87  
      */
 88  
     public synchronized void init(
 89  
         String uniqueContainerId,
 90  
         ServletConfig servletConfig,
 91  
         PortletContainerEnvironment environment,
 92  
         Properties props)
 93  
         throws PortletContainerException
 94  
     {
 95  
 
 96  0
         pluto.init(uniqueContainerId, servletConfig, environment, props);
 97  0
         initialized = true;
 98  0
     }
 99  
 
 100  
     public synchronized void shutdown() throws PortletContainerException
 101  
     {
 102  0
         initialized = false;
 103  0
         pluto.shutdown();
 104  0
     }
 105  
 
 106  
     public void renderPortlet(PortletWindow portletWindow, HttpServletRequest servletRequest, HttpServletResponse servletResponse)
 107  
         throws PortletException, IOException, PortletContainerException
 108  
     {
 109  
                 
 110  0
         if(portletWindow.getPortletEntity() == null)
 111  
         {
 112  0
             log.warn("Could not render PortletWindow "+ portletWindow.getId() + " as it has no PortletEntity defined.");
 113  0
             return;
 114  
         }        
 115  
         
 116  0
         if(portletWindow.getPortletEntity().getPortletDefinition() == null)
 117  
         {
 118  0
             log.warn("Could not render PortletWindow"+ portletWindow.getId() + " as it has no PortletDefintion defined.");
 119  0
             return;
 120  
         }
 121  0
         pluto.renderPortlet(portletWindow, servletRequest, servletResponse);
 122  
         // TODO: figure out how to access pluto-services before container kicks in
 123  
         //                              ServletObjectAccess.getServletRequest(servletRequest),
 124  
         //                              ServletObjectAccess.getServletResponse(servletResponse));
 125  0
     }
 126  
 
 127  
     public void processPortletAction(
 128  
         PortletWindow portletWindow,
 129  
         HttpServletRequest servletRequest,
 130  
         HttpServletResponse servletResponse)
 131  
         throws PortletException, IOException, PortletContainerException
 132  
     {
 133  0
         pluto.processPortletAction(portletWindow, servletRequest, servletResponse);
 134  
         //                                     ServletObjectAccess.getServletRequest(servletRequest),
 135  
         //                                     ServletObjectAccess.getServletResponse(servletResponse));
 136  0
     }
 137  
 
 138  
     public void portletLoad(PortletWindow portletWindow, HttpServletRequest servletRequest, HttpServletResponse servletResponse)
 139  
         throws PortletException, PortletContainerException
 140  
     {
 141  0
         pluto.portletLoad(
 142  
             portletWindow,
 143  
             requestFactory.getServletRequest(servletRequest, portletWindow),
 144  
             responseFactory.getServletResponse(servletResponse));
 145  0
     }
 146  
 
 147  
     /**
 148  
      * <p>
 149  
      * isInitialized
 150  
      * </p>
 151  
      *
 152  
      * @see org.apache.pluto.PortletContainer#isInitialized()
 153  
      * @return
 154  
      */
 155  
     public boolean isInitialized()
 156  
     {
 157  0
         return initialized;
 158  
     }
 159  
 
 160  
     public void setRequestFactory(ServletRequestFactory requestFactory)
 161  
     {
 162  0
         this.requestFactory = requestFactory;
 163  0
     }
 164  
 
 165  
     public void setResponseFactory(ServletResponseFactory responseFactory)
 166  
     {
 167  0
         this.responseFactory = responseFactory;
 168  0
     }
 169  
 
 170  
 }

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