Coverage Report - org.apache.turbine.services.jsp.util.JspNavigation
 
Classes in this File Line Coverage Branch Coverage Complexity
JspNavigation
0%
0/17
N/A
2
 
 1  
 package org.apache.turbine.services.jsp.util;
 2  
 
 3  
 
 4  
 import org.apache.logging.log4j.LogManager;
 5  
 
 6  
 /*
 7  
  * Licensed to the Apache Software Foundation (ASF) under one
 8  
  * or more contributor license agreements.  See the NOTICE file
 9  
  * distributed with this work for additional information
 10  
  * regarding copyright ownership.  The ASF licenses this file
 11  
  * to you under the Apache License, Version 2.0 (the
 12  
  * "License"); you may not use this file except in compliance
 13  
  * with the License.  You may obtain a copy of the License at
 14  
  *
 15  
  *   http://www.apache.org/licenses/LICENSE-2.0
 16  
  *
 17  
  * Unless required by applicable law or agreed to in writing,
 18  
  * software distributed under the License is distributed on an
 19  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 20  
  * KIND, either express or implied.  See the License for the
 21  
  * specific language governing permissions and limitations
 22  
  * under the License.
 23  
  */
 24  
 
 25  
 
 26  
 import org.apache.logging.log4j.Logger;
 27  
 import org.apache.turbine.modules.NavigationLoader;
 28  
 import org.apache.turbine.services.TurbineServices;
 29  
 import org.apache.turbine.services.template.TemplateService;
 30  
 import org.apache.turbine.util.RunData;
 31  
 
 32  
 /**
 33  
  * Returns output of a Navigation module. An instance of this is placed in the
 34  
  * request by the JspLayout. This allows template authors to
 35  
  * set the navigation template they'd like to place in their templates.<br>
 36  
  * Here's how it's used in a JSP template:<br>
 37  
  * <code>
 38  
  * &lt;%useBean id="navigation" class="JspNavigation" scope="request" %&gt;
 39  
  * ...
 40  
  * &lt;%= navigation.setTemplate("admin_navigation.jsp") %&gt;
 41  
  * </code>
 42  
  * @author <a href="john.mcnally@clearink.com">John D. McNally</a>
 43  
  * @author <a href="mbryson@mont.mindspring.com">Dave Bryson</a>
 44  
  * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
 45  
  * @version $Id: JspNavigation.java 1854688 2019-03-03 10:36:42Z tv $
 46  
  */
 47  
 public class JspNavigation
 48  
 {
 49  
     /** Logging */
 50  0
     private static Logger log = LogManager.getLogger(JspNavigation.class);
 51  
 
 52  
     /* The RunData object */
 53  
     private final RunData data;
 54  
 
 55  
     /**
 56  
      * Constructor
 57  
      *
 58  
      * @param data Turbine request data
 59  
      */
 60  
     public JspNavigation(RunData data)
 61  0
     {
 62  0
         this.data = data;
 63  0
     }
 64  
 
 65  
     /**
 66  
      * builds the output of the navigation template
 67  
      * @param template the name of the navigation template
 68  
      */
 69  
     public void setTemplate(String template)
 70  
     {
 71  0
         data.getTemplateInfo().setNavigationTemplate(template);
 72  0
         String module = null;
 73  
         try
 74  
         {
 75  0
             TemplateService templateService = (TemplateService)TurbineServices.getInstance().getService(TemplateService.SERVICE_NAME);
 76  0
             module = templateService.getNavigationName(template);
 77  0
             NavigationLoader.getInstance().exec(data, module);
 78  
         }
 79  0
         catch (Exception e)
 80  
         {
 81  0
             String message = "Error processing navigation template:" +
 82  
                     template + " using module: " + module;
 83  0
             log.error(message, e);
 84  
             try
 85  
             {
 86  0
                 data.getResponse().getWriter().print(message);
 87  
             }
 88  0
             catch (java.io.IOException ioe)
 89  
             {
 90  
                 // ignore
 91  0
             }
 92  0
         }
 93  0
     }
 94  
 }