001    package org.apache.turbine.modules.navigations;
002    
003    
004    /*
005     * Licensed to the Apache Software Foundation (ASF) under one
006     * or more contributor license agreements.  See the NOTICE file
007     * distributed with this work for additional information
008     * regarding copyright ownership.  The ASF licenses this file
009     * to you under the Apache License, Version 2.0 (the
010     * "License"); you may not use this file except in compliance
011     * with the License.  You may obtain a copy of the License at
012     *
013     *   http://www.apache.org/licenses/LICENSE-2.0
014     *
015     * Unless required by applicable law or agreed to in writing,
016     * software distributed under the License is distributed on an
017     * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
018     * KIND, either express or implied.  See the License for the
019     * specific language governing permissions and limitations
020     * under the License.
021     */
022    
023    
024    import org.apache.ecs.ConcreteElement;
025    
026    import org.apache.turbine.modules.Navigation;
027    import org.apache.turbine.pipeline.PipelineData;
028    
029    import org.apache.turbine.util.RunData;
030    
031    /**
032     * Base Template Navigation.
033     *
034     * @author <a href="mailto:mbryson@mont.mindspring.com">Dave Bryson</a>
035     * @author <a href="mailto:peter@courcoux.biz">Peter Courcoux</a>
036     * @version $Id: TemplateNavigation.java 1066561 2011-02-02 18:15:37Z ludwig $
037     */
038    public abstract class TemplateNavigation
039            extends Navigation
040    {
041        /**
042         * WebMacro Navigations extending this class should overide this
043         * method to perform any particular business logic and add
044         * information to the context.
045         *
046         * @deprecated Use PipelineData version instead.
047         * @param data Turbine information.
048         * @throws Exception a generic exception.
049         */
050        @Deprecated
051        protected abstract void doBuildTemplate(RunData data)
052                throws Exception;
053    
054        /**
055         * WebMacro Navigations extending this class should overide this
056         * method to perform any particular business logic and add
057         * information to the context.
058         *
059         * @param data Turbine information.
060         * @throws Exception a generic exception.
061         */
062        protected void doBuildTemplate(PipelineData pipelineData)
063                throws Exception
064        {
065                RunData data = getRunData(pipelineData);
066                doBuildTemplate(data);
067        }
068    
069    
070        /**
071         * This Builds the WebMacro/FreeMarker/etc template.
072         * @deprecated Use PipelineData version
073         * @param data Turbine information.
074         * @return A ConcreteElement.
075         * @throws Exception a generic exception.
076         */
077        @Deprecated
078        public abstract ConcreteElement buildTemplate(RunData data)
079                throws Exception;
080    
081        /**
082         * This Builds the WebMacro/FreeMarker/etc template.
083         * Should revert to abstract when RunData goes.
084         * @param pipelineData Turbine information.
085         * @return A ConcreteElement.
086         * @throws Exception a generic exception.
087         */
088        public ConcreteElement buildTemplate(PipelineData pipelineData)
089        throws Exception
090            {
091                RunData data = getRunData(pipelineData);
092                return buildTemplate(data);
093            }
094    
095        /**
096         * Calls doBuildTemplate() and then buildTemplate().
097         *
098         * @param data Turbine information.
099         * @return A ConcreteElement.
100         * @throws Exception a generic exception.
101         */
102        @Override
103        protected ConcreteElement doBuild(RunData data)
104                throws Exception
105        {
106            doBuildTemplate(data);
107            return buildTemplate(data);
108        }
109    
110        /**
111         * Calls doBuildTemplate() and then buildTemplate().
112         *
113         * @param data Turbine information.
114         * @return A ConcreteElement.
115         * @throws Exception a generic exception.
116         */
117        @Override
118        protected ConcreteElement doBuild(PipelineData pipelineData)
119                throws Exception
120        {
121                RunData data = getRunData(pipelineData);
122            return doBuild(data);
123        }
124    
125    }