Coverage Report - org.apache.turbine.modules.screens.VelocityCachedScreen
 
Classes in this File Line Coverage Branch Coverage Complexity
VelocityCachedScreen
0%
0/16
0%
0/2
4
 
 1  
 package org.apache.turbine.modules.screens;
 2  
 
 3  
 /*
 4  
  * Licensed to the Apache Software Foundation (ASF) under one
 5  
  * or more contributor license agreements.  See the NOTICE file
 6  
  * distributed with this work for additional information
 7  
  * regarding copyright ownership.  The ASF licenses this file
 8  
  * to you under the Apache License, Version 2.0 (the
 9  
  * "License"); you may not use this file except in compliance
 10  
  * with the License.  You may obtain a copy of the License at
 11  
  *
 12  
  *   http://www.apache.org/licenses/LICENSE-2.0
 13  
  *
 14  
  * Unless required by applicable law or agreed to in writing,
 15  
  * software distributed under the License is distributed on an
 16  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 17  
  * KIND, either express or implied.  See the License for the
 18  
  * specific language governing permissions and limitations
 19  
  * under the License.
 20  
  */
 21  
 
 22  
 import org.apache.commons.lang.StringUtils;
 23  
 import org.apache.commons.lang.exception.ExceptionUtils;
 24  
 import org.apache.turbine.TurbineConstants;
 25  
 import org.apache.turbine.pipeline.PipelineData;
 26  
 import org.apache.turbine.util.RunData;
 27  
 import org.apache.velocity.context.Context;
 28  
 
 29  
 /**
 30  
  * VelocityCachedScreen is Turbine 2.3.3 VelocityDirectScreen (same package)
 31  
  * with methods added for {@link PipelineData}.
 32  
  * It is is a screen class which buffers its output
 33  
  * before flushing the output stream. It is used in Jetspeed-1 portal.
 34  
  * <p>
 35  
  * @author <a href="mailto:mbryson@mont.mindspring.com">Dave Bryson</a>
 36  
  * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
 37  
  * @version $Id$
 38  
  */
 39  0
 public class VelocityCachedScreen
 40  
     extends VelocityScreen
 41  
 {
 42  
     /** The prefix for lookup up screen pages */
 43  0
     private String prefix = getPrefix() + "/";
 44  
 
 45  
     /**
 46  
      * This builds the Velocity template.
 47  
      *
 48  
      * @param pipelineData Turbine information.
 49  
      * @return A ConcreteElement.
 50  
      * @throws Exception a generic exception.
 51  
      */
 52  
     @Override
 53  
     public String buildTemplate(PipelineData pipelineData)
 54  
         throws Exception
 55  
     {
 56  0
         RunData data = getRunData(pipelineData);
 57  0
         Context context = velocity.getContext(pipelineData);
 58  
 
 59  0
         String screenTemplate = data.getTemplateInfo().getScreenTemplate();
 60  0
         String templateName
 61  
             = templateService.getScreenTemplateName(screenTemplate);
 62  
 
 63  
         // The Template Service could not find the Screen
 64  0
         if (StringUtils.isEmpty(templateName))
 65  
         {
 66  0
             log.error("Screen " + screenTemplate + " not found!");
 67  0
             throw new Exception("Could not find screen for " + screenTemplate);
 68  
         }
 69  
 
 70  
         try
 71  
         {
 72  0
             velocity.handleRequest(context, prefix + templateName, data.getOut());
 73  
         }
 74  0
         catch (Exception e)
 75  
         {
 76  
             // If there is an error, build a $processingException and
 77  
             // attempt to call the error.vm template in the screens
 78  
             // directory.
 79  0
             context.put (TurbineConstants.PROCESSING_EXCEPTION_PLACEHOLDER, e.toString());
 80  0
             context.put (TurbineConstants.STACK_TRACE_PLACEHOLDER, ExceptionUtils.getStackTrace(e));
 81  
 
 82  0
             velocity.handleRequest(context, prefix + templateError, data.getOut());
 83  0
         }
 84  
 
 85  0
         return null;
 86  
     }
 87  
 }
 88  
 
 89