jvanzyl     01/07/12 13:23:57

  Modified:    src/java/org/apache/turbine/services/jsp
                        TurbineJspService.java
               src/java/org/apache/turbine/services/rundata
                        DefaultTurbineRunData.java
               src/java/org/apache/turbine/services/template
                        BaseTemplateEngineService.java TemplateService.java
                        TurbineTemplate.java TurbineTemplateService.java
  Log:
  - updating services to match changes in rendering subsystem.
  
  Revision  Changes    Path
  1.18      +2 -2      
jakarta-turbine/src/java/org/apache/turbine/services/jsp/TurbineJspService.java
  
  Index: TurbineJspService.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine/src/java/org/apache/turbine/services/jsp/TurbineJspService.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- TurbineJspService.java    2001/07/10 01:04:16     1.17
  +++ TurbineJspService.java    2001/07/12 20:23:41     1.18
  @@ -62,7 +62,7 @@
   import javax.servlet.http.HttpServletRequest;
   import org.apache.turbine.RunData;
   import org.apache.turbine.util.TurbineException;
  -import org.apache.turbine.services.jsp.util.JspLink;
  +//import org.apache.turbine.services.jsp.util.JspLink;
   import org.apache.turbine.services.InitializationException;
   import org.apache.turbine.services.template.BaseTemplateEngineService;
   import org.apache.turbine.services.template.TurbineTemplate;
  @@ -116,7 +116,7 @@
       public void addDefaultObjects(RunData data)
       {
           HttpServletRequest req = data.getRequest();
  -        req.setAttribute(LINK, new JspLink(data));
  +        //req.setAttribute(LINK, new JspLink(data));
           req.setAttribute(RUNDATA, data);
       }
   
  
  
  
  1.12      +20 -7     
jakarta-turbine/src/java/org/apache/turbine/services/rundata/DefaultTurbineRunData.java
  
  Index: DefaultTurbineRunData.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine/src/java/org/apache/turbine/services/rundata/DefaultTurbineRunData.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- DefaultTurbineRunData.java        2001/07/10 01:04:31     1.11
  +++ DefaultTurbineRunData.java        2001/07/12 20:23:45     1.12
  @@ -54,21 +54,16 @@
    * <http://www.apache.org/>.
    */
   
  -// Java Core Classes
   import java.util.Locale;
   import java.util.Vector;
   import java.util.Hashtable;
   import java.io.PrintWriter;
   import java.io.IOException;
  -
  -// Java Servlet Classes
   import javax.servlet.ServletConfig;
   import javax.servlet.ServletContext;
   import javax.servlet.http.HttpSession;
   import javax.servlet.http.HttpServletRequest;
   import javax.servlet.http.HttpServletResponse;
  -
  -// Turbine Utility Classes
   import org.apache.turbine.om.security.User;
   import org.apache.turbine.RunData;
   import org.apache.turbine.util.CookieParser;
  @@ -84,7 +79,7 @@
   import org.apache.turbine.services.template.TurbineTemplate;
   import org.apache.turbine.services.mimetype.TurbineMimeTypes;
   
  -// ECS Classes
  +//!! These have to go ECS Classes
   import org.apache.ecs.Document;
   import org.apache.ecs.Element;
   import org.apache.ecs.StringElement;
  @@ -108,7 +103,7 @@
    * @author <a href="mailto:[EMAIL PROTECTED]";>Jon S. Stevens</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Bernie Hoeneisen</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Daniel Rall</a>
  - * @version $Id: DefaultTurbineRunData.java,v 1.11 2001/07/10 01:04:31 jvanzyl Exp $
  + * @version $Id: DefaultTurbineRunData.java,v 1.12 2001/07/12 20:23:45 jvanzyl Exp $
    */
   public class DefaultTurbineRunData
       extends RecyclableSupport
  @@ -318,6 +313,19 @@
        */
       private Hashtable varDebug = new Hashtable();
   
  +    //!! NEW
  +    private String target;
  +    
  +    public void setTarget(String target)
  +    {
  +        this.target = target;
  +    }
  +    
  +    public String getTarget()
  +    {
  +        return target;
  +    }        
  +
       /**
        * Attempts to get the User object from the session.  If it does
        * not exist, it returns null.
  @@ -662,6 +670,10 @@
   
       public String getLayout()
       {
  +        //!! need to get rid of all template references
  +        // in rundata!
  +        
  +        /*
           if ( this.layout == null )
           {
               // This will return something if the template
  @@ -674,6 +686,7 @@
                   layout = "DefaultLayout";
               }
           }
  +        */
   
           return this.layout;
       }
  
  
  
  1.9       +5 -1      
jakarta-turbine/src/java/org/apache/turbine/services/template/BaseTemplateEngineService.java
  
  Index: BaseTemplateEngineService.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine/src/java/org/apache/turbine/services/template/BaseTemplateEngineService.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- BaseTemplateEngineService.java    2001/07/10 01:04:36     1.8
  +++ BaseTemplateEngineService.java    2001/07/12 20:23:49     1.9
  @@ -68,7 +68,7 @@
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Daniel Rall</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Jason van Zyl</a>
  - * @version $Id: BaseTemplateEngineService.java,v 1.8 2001/07/10 01:04:36 jvanzyl 
Exp $
  + * @version $Id: BaseTemplateEngineService.java,v 1.9 2001/07/12 20:23:49 jvanzyl 
Exp $
    */
   public abstract class BaseTemplateEngineService 
       extends BaseService
  @@ -181,6 +181,9 @@
           // screen instead of template in cases where multiple Screens map 
           // to one template. The template is hardcoded into the Screen in 
           // this instance. In this case this action is skipped.
  +        
  +        /*
  +        
           if (!data.hasScreen())
           {
               // This is effectively getting the "template" parameter
  @@ -205,6 +208,7 @@
               }
               data.setScreen(screen);
           }
  +        */
       }
   
       public void doPostBuild(RunData data)
  
  
  
  1.16      +3 -119    
jakarta-turbine/src/java/org/apache/turbine/services/template/TemplateService.java
  
  Index: TemplateService.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine/src/java/org/apache/turbine/services/template/TemplateService.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- TemplateService.java      2001/07/10 01:04:36     1.15
  +++ TemplateService.java      2001/07/12 20:23:50     1.16
  @@ -72,16 +72,11 @@
    * @author <a href="mailto:[EMAIL PROTECTED]";>Jason van Zyl</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Daniel Rall</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Ilkka Priha</a>
  - * @version $Id: TemplateService.java,v 1.15 2001/07/10 01:04:36 jvanzyl Exp $
  + * @version $Id: TemplateService.java,v 1.16 2001/07/12 20:23:50 jvanzyl Exp $
    */
   public interface TemplateService 
       extends Service
   {
  -    public static final String DEFAULT_PAGE = "default.page";
  -    public static final String DEFAULT_SCREEN = "default.screen";
  -    public static final String DEFAULT_LAYOUT = "default.layout";
  -    public static final String DEFAULT_NAVIGATION = "default.navigation";
  -    public static final String DEFAULT_ERROR_SCREEN = "default.error.screen";
   
       /**
        * The key under which this service is stored in TurbineServices.
  @@ -91,119 +86,6 @@
       public static final String CONTEXT = "TEMPLATE_CONTEXT";
   
       /**
  -     * Get the default template name extension specified 
  -     * in the template service properties.
  -     *
  -     * @return The default the extension.
  -     */
  -    public String getDefaultExtension();
  -    
  -    /**
  -     * Get the default page module name of the template engine
  -     * service corresponding to the default template name extension.
  -     *
  -     * @return The default page module name.
  -     */
  -    public String getDefaultPageModule();
  -    
  -    /**
  -     * Get the default screen module name of the template engine
  -     * service corresponding to the default template name extension.
  -     *
  -     * @return The default screen module name.
  -     */
  -    public String getDefaultScreenModule();
  -    
  -    /**
  -     * Get the default layout module name of the template engine
  -     * service corresponding to the default template name extension.
  -     *
  -     * @return The default layout module name.
  -     */
  -    public String getDefaultLayoutModule();
  -    
  -    /**
  -     * Get the default navigation module name of the template engine
  -     * service corresponding to the default template name extension.
  -     *
  -     * @return The default navigation module name.
  -     */
  -    public String getDefaultNavigationModule();
  -
  -    /**
  -     * Get the default layout template name of the template engine
  -     * service corresponding to the default template name extension.
  -     *
  -     * @return The default layout template name.
  -     */
  -    public String getDefaultLayoutTemplate();
  -
  -    /**
  -     * Get the default layout template name of the template engine
  -     * service corresponding to the template name extension of 
  -     * the named template.
  -     *
  -     * @param template The template name.
  -     * @return The default layout template name.
  -     */
  -    public String getDefaultLayoutTemplate(String template);
  -    
  -    /**
  -     * Locate and return the name of the screen module to be used
  -     * with the named screen template.
  -     *
  -     * @param template The screen template name.
  -     * @return The found screen module name.
  -     * @exception Exception, a generic exception.
  -     */
  -    public String getScreenModule(String template)
  -        throws Exception;
  -
  -    /**
  -     * Locate and return the name of the layout module to be used
  -     * with the named layout template. 
  -     *
  -     * @param template The layout template name.
  -     * @return The found layout module name.
  -     * @exception Exception, a generic exception.
  -     */
  -    public String getLayoutModule(String template)
  -        throws Exception;
  -
  -    /**
  -     * Locate and return the name of the navigation module to be used
  -     * with the named navigation template. 
  -     *
  -     * @param template The navigation template name.
  -     * @return The found navigation module name.
  -     * @exception Exception, a generic exception.
  -     */
  -    public String getNavigationModule(String name)
  -        throws Exception;
  -
  -    /**
  -     * Locate and return the name of the screen template corresponding
  -     * to the given template name parameter.
  -     *
  -     * @param template The template name parameter.
  -     * @return The found screen template name.
  -     * @exception Exception, a generic exception.
  -     */
  -    public String getScreenTemplate(String template)
  -        throws Exception;
  -
  -    /**
  -     * Locate and return the name of the layout template corresponding
  -     * to the given screen template name parameter.
  -     *
  -     * @param template The template name parameter.
  -     * @return The found screen template name.
  -     * @exception Exception, a generic exception.
  -     */
  -    public String getLayoutTemplate(String template)
  -        throws Exception;
  -
  -    /**
        * Translates the supplied template paths into their Turbine-canonical
        * equivalent (probably absolute paths).
        *
  @@ -251,4 +133,6 @@
   
       public void doPostBuild(RunData data)
           throws Exception;
  +
  +    public boolean templateExists(String template);
   }
  
  
  
  1.9       +3 -104    
jakarta-turbine/src/java/org/apache/turbine/services/template/TurbineTemplate.java
  
  Index: TurbineTemplate.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine/src/java/org/apache/turbine/services/template/TurbineTemplate.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- TurbineTemplate.java      2001/07/10 01:04:37     1.8
  +++ TurbineTemplate.java      2001/07/12 20:23:51     1.9
  @@ -66,7 +66,7 @@
    * getting a Screen that is associated with a screen template.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>John D. McNally</a>
  - * @version $Id: TurbineTemplate.java,v 1.8 2001/07/10 01:04:37 jvanzyl Exp $
  + * @version $Id: TurbineTemplate.java,v 1.9 2001/07/12 20:23:51 jvanzyl Exp $
    */
   public abstract class TurbineTemplate
   {
  @@ -82,101 +82,6 @@
               .getInstance().getService(TemplateService.SERVICE_NAME);
       }
   
  -    /**
  -     * Locate and return the name of a screen template.
  -     *
  -     * @param key A String which is the key to the template.
  -     * @return A String with the screen template path.
  -     * @exception Exception, a generic exception.
  -     */
  -    public static final String getScreenTemplate(String key)
  -        throws Exception
  -    {
  -        return getService().getScreenTemplate(key);
  -    }
  -    
  -    /**
  -     * Locate and return the name of a layout template.
  -     *
  -     * @param name A String with the name of the template.
  -     * @return A String with the layout template path.
  -     * @exception Exception, a generic exception.
  -     */
  -    public static final String getLayoutTemplate(String name)
  -        throws Exception
  -    {
  -        return getService().getLayoutTemplate(name);
  -    }
  -
  -    /**
  -     * Locate and return the name of a Navigation module.
  -     *
  -     * @param name A String with the name of the template.
  -     * @return A String with the name of the navigation.
  -     * @exception Exception, a generic exception.
  -     */
  -    public static final String getNavigationModule(String name)
  -        throws Exception
  -    {
  -        return getService().getNavigationModule(name);
  -    }
  -        
  -    /**
  -     * Locate and return the name of a Screen module.
  -     *
  -     * @param name A String with the name of the template.
  -     * @return A String with the name of the screen.
  -     * @exception Exception, a generic exception.
  -     */
  -    public static final String getScreenModule(String name)
  -        throws Exception
  -    {
  -        return getService().getScreenModule(name);
  -    }
  -
  -    /**
  -     * Get the default extension given in the properties file.
  -     *
  -     * @return A String with the extension.
  -     */
  -    public static final String getDefaultExtension()
  -    {
  -        return getService().getDefaultExtension();
  -    }
  -    
  -    /**
  -     * Get the Screen template given in the properties file.
  -     *
  -     * @return A String which is the value of the TemplateService 
  -     * default.screen property.
  -     */
  -    public static final String getDefaultScreenModule()
  -    {
  -        return getService().getDefaultScreenModule();
  -    }
  -    
  -    /**
  -     * Get the default Navigation given in the properties file.
  -     *
  -     * @return A String which is the value of the TemplateService 
  -     * default.navigation property.
  -     */
  -    public static final String getDefaultNavigationModule()
  -    {
  -        return getService().getDefaultNavigationModule();
  -    }
  -
  -    /**
  -     * Get the default layout template given in the properties file.
  -     *
  -     * @return A String which is the value of the TemplateService 
  -     * default.layout.template property.
  -     */
  -    public static final String getDefaultLayoutTemplate()
  -    {
  -        return getService().getDefaultLayoutTemplate();
  -    }
  -
       public static final void registerTemplateEngineService(TemplateEngineService 
service)
       {
           getService().registerTemplateEngineService(service);
  @@ -240,15 +145,9 @@
       }
   
       // NEW
  -
  -    public static final String getDefaultPageModule()
  -    {
  -        return getService().getDefaultPageModule();
  -    }
   
  -    public static final String getDefaultLayoutModule()
  +    public static final boolean templateExists(String template)
       {
  -        return getService().getDefaultLayoutModule();
  +        return getService().templateExists(template);
       }
  -
   }
  
  
  
  1.48      +7 -596    
jakarta-turbine/src/java/org/apache/turbine/services/template/TurbineTemplateService.java
  
  Index: TurbineTemplateService.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine/src/java/org/apache/turbine/services/template/TurbineTemplateService.java,v
  retrieving revision 1.47
  retrieving revision 1.48
  diff -u -r1.47 -r1.48
  --- TurbineTemplateService.java       2001/07/10 01:04:37     1.47
  +++ TurbineTemplateService.java       2001/07/12 20:23:52     1.48
  @@ -105,7 +105,7 @@
    * @author <a href="mailto:[EMAIL PROTECTED]";>Jason van Zyl</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Daniel Rall</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Ilkka Priha</a>
  - * @version $Id: TurbineTemplateService.java,v 1.47 2001/07/10 01:04:37 jvanzyl Exp 
$
  + * @version $Id: TurbineTemplateService.java,v 1.48 2001/07/12 20:23:52 jvanzyl Exp 
$
    */
   public class TurbineTemplateService 
       extends BaseService
  @@ -117,43 +117,11 @@
        */
       protected static final String NO_FILE_EXT = "";
   
  -    /**
  -     * The keys of template objects provided by the service.
  -     */
  -    protected static final int PAGE_KEY = 0;
  -    protected static final int SCREEN_KEY = 1;
  -    protected static final int LAYOUT_KEY = 2;
  -    protected static final int NAVIGATION_KEY = 3;
  -    protected static final int LAYOUT_TEMPLATE_KEY = 4;
  -    protected static final int SCREEN_TEMPLATE_KEY = 5;
  -
  -    /** 
  -     * The hashtables used to cache template object names. 
  -     */
  -    private Hashtable[] templateNameCache = new Hashtable[6];
  -
       /** 
  -     * Flag set if cache is to be used. 
  -     */
  -    private boolean useCache = false;
  -
  -    /** 
        * Default extension for templates. 
        */
       private String defaultExtension;
   
  -    /** 
  -     * Default template with the default extension. 
  -     */
  -    private String defaultTemplate;
  -
  -    private String defaultPageModule;
  -    private String defaultLayoutModule;
  -    private String defaultNavigationModule;
  -    private String defaultScreenModule;
  -
  -    private String[] defaultModules;
  -
       /**
        * The mappings of template file extensions to {@link
        * org.apache.turbine.services.template.TemplateEngineService}
  @@ -226,230 +194,9 @@
        */
       private void initTemplate()
       {
  -         // Get the default extension to use if nothing 
  -         // else is applicable.
  -        defaultExtension = 
getConfiguration().getString("default.extension",NO_FILE_EXT);
  -        defaultTemplate = "Default." + defaultExtension;
  -
  -        defaultPageModule = getConfiguration().getString(DEFAULT_PAGE);
  -        defaultLayoutModule = getConfiguration().getString(DEFAULT_LAYOUT);
  -        defaultNavigationModule = getConfiguration().getString(DEFAULT_NAVIGATION);
  -        defaultScreenModule = getConfiguration().getString(DEFAULT_SCREEN);
  -        
  -        defaultModules = new String[]
  -        {
  -            defaultPageModule,
  -            defaultScreenModule,
  -            defaultLayoutModule,
  -            defaultNavigationModule
  -        };
  -        
  -        // Check to see if we are going to be caching modules.
  -        useCache = Turbine.getConfiguration().getBoolean("module.cache",true);
  -        
  -        if (useCache)
  -        {
  -            int screenSize = getConfiguration().getInt("screen.cache.size",5);
  -            int screenTemplateSize = 
getConfiguration().getInt("screen.cache.size",50);
  -            int layoutSize = getConfiguration().getInt("layout.cache.size",5);
  -            int layoutTemplateSize = 
getConfiguration().getInt("layout.cache.size",5);
  -            int navigationSize = 
getConfiguration().getInt("navigation.cache.size",10);
  -            
  -            // Create hashtables for each object type, 
  -            // the first one for pages is not used.
  -            templateNameCache[PAGE_KEY] = null;
  -            templateNameCache[SCREEN_KEY] = 
  -                new Hashtable((int) (1.25 * screenSize) + 1);
  -            templateNameCache[SCREEN_TEMPLATE_KEY] = 
  -                new Hashtable((int) (1.25 * screenTemplateSize) + 1);
  -            templateNameCache[LAYOUT_KEY] = 
  -                new Hashtable((int) (1.25 * layoutSize) + 1);
  -            templateNameCache[LAYOUT_TEMPLATE_KEY] = 
  -                new Hashtable((int) (1.25 * layoutTemplateSize) + 1);
  -            templateNameCache[NAVIGATION_KEY] = 
  -                new Hashtable((int) (1.25 * navigationSize) + 1);
  -        }
  -    }
  -
  -    // These four methods return the default modules, these
  -    // are now unified and are not dependent on the template
  -    // engine.
  -
  -    /**
  -     * Get the default template name extension specified 
  -     * in the template service properties.
  -     *
  -     * @return The default the extension.
  -     */
  -    public String getDefaultExtension()
  -    {
  -        return defaultExtension;
  -    }
  -  
  -    /**
  -     * Get the default page module name of the template engine
  -     * service corresponding to the default template name extension.
  -     *
  -     * @return The default page module name.
  -     */
  -    public String getDefaultPageModule()
  -    {
  -        return defaultPageModule;
  -    }
  -
  -    /**
  -     * Get the default layout module name of the template engine
  -     * service corresponding to the default template name extension.
  -     *
  -     * @return The default layout module name.
  -     */
  -    public String getDefaultLayoutModule()
  -    {
  -        return defaultLayoutModule;
  -    }
  -
  -    /**
  -     * Get the default navigation module name of the template engine
  -     * service corresponding to the default template name extension.
  -     *
  -     * @return The default navigation module name.
  -     */
  -    public String getDefaultNavigationModule()
  -    {
  -        return defaultNavigationModule;
  -    }
  -
  -    /**
  -     * Get the default screen module name of the template engine
  -     * service corresponding to the default template name extension.
  -     *
  -     * @return The default screen module name.
  -     */
  -    public String getDefaultScreenModule()
  -    {
  -        return defaultScreenModule;
  -    }
  -
  -    /**
  -     * Get the default page template name of the template engine
  -     * service corresponding to the default template name extension.
  -     *
  -     * @return The default layout template name.
  -     */
  -    public String getDefaultPageTemplate()
  -    {
  -        return getDefaultLayoutTemplate(defaultTemplate);
       }
   
       /**
  -     * Get the default layout template name of the template engine
  -     * service corresponding to the default template name extension.
  -     *
  -     * @return The default layout template name.
  -     */
  -    public String getDefaultLayoutTemplate()
  -    {
  -        return getDefaultLayoutTemplate(defaultTemplate);
  -    }
  -  
  -    /**
  -     * Get the default layout template name of the template engine
  -     * service corresponding to the template name extension of 
  -     * the named template.
  -     *
  -     * @param template The template name.
  -     * @return The default layout template name.
  -     */
  -    public String getDefaultLayoutTemplate(String template)
  -    {
  -        TemplateEngineService tes = getTemplateEngineService(template);
  -        
  -        String layoutTemplate = (String) 
tes.getTemplateEngineServiceConfiguration().
  -            get(TemplateEngineService.DEFAULT_LAYOUT_TEMPLATE);
  -        
  -        if ((layoutTemplate != null) &&
  -            (layoutTemplate.indexOf('.') < 0))
  -        {
  -          int dotIndex = template.lastIndexOf('.');
  -          layoutTemplate += dotIndex >= 0 ?
  -              template.substring(dotIndex) : '.' + defaultExtension;
  -        }
  -        return layoutTemplate;
  -    }
  -  
  -    /**
  -     * Locate and return the name of the screen module to be used
  -     * with the named screen template.
  -     *
  -     * @param template The screen template name.
  -     * @return The found screen module name.
  -     * @exception Exception, a generic exception.
  -     */
  -    public String getScreenModule(String template)
  -        throws Exception
  -    {
  -        return getCachedModule(template,SCREEN_KEY);
  -    }
  -  
  -    /**
  -     * Locate and return the name of the layout module to be used
  -     * with the named layout template. 
  -     *
  -     * @param template The layout template name.
  -     * @return The found layout module name.
  -     * @exception Exception, a generic exception.
  -     */
  -    public String getLayoutModule(String template)
  -        throws Exception
  -    {
  -        return getCachedModule(template,LAYOUT_KEY);
  -    }
  -  
  -    /**
  -     * Locate and return the name of the navigation module to be used
  -     * with the named navigation template. 
  -     *
  -     * @param template The navigation template name.
  -     * @return The found navigation module name.
  -     * @exception Exception, a generic exception.
  -     */
  -    public String getNavigationModule(String template)
  -        throws Exception
  -    {
  -        return getCachedModule(template,NAVIGATION_KEY);
  -    }
  -  
  -    /**
  -     * Locate and return the name of the screen template corresponding
  -     * to the given template name parameter.
  -     *
  -     * @param template The template name parameter.
  -     * @return The found screen template name.
  -     * @exception Exception, a generic exception.
  -     */
  -    public String getScreenTemplate(String template)
  -        throws Exception
  -    {
  -        return getCachedModule(template,SCREEN_TEMPLATE_KEY);
  -    }
  -    
  -    /**
  -     * Locate and return the name of the layout template corresponding
  -     * to the given screen template name parameter.
  -     *
  -     * @param template The template name parameter.
  -     * @return The found screen template name.
  -     * @exception Exception, a generic exception.
  -     */
  -    public String getLayoutTemplate(String template)
  -        throws Exception
  -    {
  -        // This doesn't mesh getLayoutTemplating using
  -        // getCachedModule. that's confusing.
  -        return getCachedModule(template,LAYOUT_TEMPLATE_KEY);
  -    }
  -  
  -    /**
        * Translates the supplied template paths into their Turbine-canonical
        * equivalent (probably absolute paths).
        *
  @@ -486,6 +233,12 @@
           return false;
       }
   
  +    public boolean templateExists(String template)
  +    {
  +        TemplateEngineService tes = getTemplateEngineService(template);
  +        return tes.templateExists(template);
  +    }
  +
       /**
        * Registers the provided template engine for use by the
        * <code>TemplateService</code>.
  @@ -531,348 +284,6 @@
           }
       }
       
  -    /**
  -     * Get the default module name of the template engine
  -     * service corresponding to the template name extension of 
  -     * the named template.
  -     *
  -     * @param template The template name.
  -     * @param key The module type key.
  -     * @return The default page module name.
  -     */
  -    protected String getDefaultModule(String template, int key)
  -    {
  -        return defaultModules[key];
  -    }
  -  
  -    /**
  -     * Get the cached template object name.
  -     * If caching is not in use or the name is not in the cache,
  -     * try to find the name from the template directories. 
  -     * 
  -     * @param template The template name.
  -     * @param key The object type key.
  -     * @return The cached name.
  -     * @exception Exception, a generic exception.
  -     */
  -    protected String getCachedModule(String template, int key)
  -        throws Exception
  -    {
  -        // Add a default extension if missing.
  -        if (template.indexOf('.') < 0)
  -        {
  -            template += '.' + defaultExtension;
  -        }
  -    
  -        // Check the cache first.
  -        String found;
  -        if (useCache)
  -        {
  -            found = (String) templateNameCache[key].get(template);
  -            if (found != null)
  -            {
  -                return found;
  -            }
  -        }
  -    
  -        // Not in the cache, try to find it.
  -        switch (key)
  -        {
  -            case SCREEN_TEMPLATE_KEY:
  -                found = getParsedScreenTemplate(template);
  -                break;
  -
  -            case LAYOUT_TEMPLATE_KEY:
  -                found = getParsedLayoutTemplate(template);
  -                break;
  -                
  -            default:
  -                found = getParsedModule(template,key);
  -        }
  -    
  -        // Put the found name to the cache.
  -        if (useCache)
  -        {
  -            templateNameCache[key].put(template,found);
  -        }
  -    
  -        return found;
  -    }
  -
  -    /**
  -     * Get the parsed module name for the specified template.
  -     * 
  -     * @param template The template name.
  -     * @param key The module type key.
  -     * @return The parsed module name.
  -     * @exception Exception, a generaic exception.
  -     */
  -    protected String getParsedModule(String template, int key)
  -        throws Exception
  -    {
  -        // Parse the template name and change it into a package.
  -        StringBuffer pckage = new StringBuffer();
  -        int i = parseTemplatePath(template,pckage);
  -        if (pckage.charAt(0) == '/')
  -        {
  -            pckage.deleteCharAt(0);
  -            i--;
  -        }
  -        if (i >= 0)
  -        {
  -            for (int j = 0; j <= i; j++)
  -            {
  -                if (pckage.charAt(j) == '/')
  -                {
  -                    pckage.setCharAt(j,'.');
  -                }
  -            }
  -        }
  -  
  -        // Remove a possible file extension.
  -        for (int j = i + 1; j < pckage.length(); j++)
  -        {
  -            if (pckage.charAt(j) == '.')
  -            {
  -                pckage.delete(j,pckage.length());
  -                break;
  -            }
  -        }
  -  
  -        // Try first an exact match for a module having the same
  -        // name as the input template, traverse then upper level
  -        // packages to find a default module named Default.
  -        int j = 9999;
  -        String module;
  -        while (j-- > 0)
  -        {
  -            module = pckage.toString();
  -            try
  -            {
  -                switch (key)
  -                {
  -                    case SCREEN_KEY:
  -                        Turbine.getModuleLoader().getModule(Turbine.SCREENS,module);
  -                        return module;
  -          
  -                    case LAYOUT_KEY:
  -                        Turbine.getModuleLoader().getModule(Turbine.LAYOUTS,module);
  -                        return module;
  -          
  -                    case NAVIGATION_KEY:
  -                        
Turbine.getModuleLoader().getModule(Turbine.NAVIGATIONS,module);
  -                        return module;
  -                }
  -            }
  -            catch (Exception x) 
  -            { 
  -            }
  -    
  -            pckage.setLength(i + 1);
  -            if (i > 0)
  -            {
  -                // We have still packages to traverse.
  -                for (i = pckage.length() - 2; i >= 0; i--)
  -                {
  -                    if (pckage.charAt(i) == '.')
  -                    { 
  -                        break;
  -                    }
  -                }
  -            }
  -            else if (j > 0)
  -            {
  -                // Only the main level left.
  -                j = 1;
  -            }
  -            pckage.append("Default");
  -        }
  -
  -        // Not found, return the default module name.
  -        return getDefaultModule(template,key);
  -    }
  -
  -    /**
  -     * Get the parsed screen template name for the specified template.
  -     * 
  -     * @param template The template name.
  -     * @return The parsed screen template name.
  -     * @exception Exception, a generic exception.
  -     */
  -    protected String getParsedScreenTemplate(String template)
  -        throws Exception
  -    {
  -        // Parse the template name.
  -        StringBuffer path = new StringBuffer();
  -        parseTemplatePath(template,path);
  -        if (path.charAt(0) != '/')
  -        {
  -            path.insert(0,'/');
  -        }
  -        path.insert(0,"screens");
  -    
  -        // Let the template engine service to check its existance.
  -        TemplateEngineService tes = getTemplateEngineService(template);
  -        
  -        if ((tes == null) || !tes.templateExists(path.toString()))
  -        {
  -            throw new Exception(
  -                "Screen template '" + template + "' not found");
  -        }
  -        
  -        return path.substring(7);
  -    }
  -
  -    /**
  -     * Get the parsed layout template name for the specified template.
  -     * 
  -     * @param template The template name.
  -     * @return The parsed layout template name.
  -     * @exception Exception, a generic exception.
  -     */
  -    protected String getParsedLayoutTemplate(String template)
  -        throws Exception
  -    {
  -        // Parse the template name.
  -        StringBuffer path = new StringBuffer();
  -        int i = parseTemplatePath(template,path);
  -        if (path.charAt(0) != '/')
  -        {
  -            path.insert(0,'/');
  -            i++;
  -        }
  -        path.insert(0,"layouts");
  -        i += 7;
  -    
  -        // Try first an exact match for a layout template having the same
  -        // name as the input template, traverse then upper level
  -        // directories to find the default layout template.
  -        TemplateEngineService tes = getTemplateEngineService(template);
  -        
  -        getCategory().debug("[TurbineTemplateService] template: " + template);
  -        getCategory().debug("[TurbineTemplateService] tes: " + tes);
  -        
  -        if (tes == null)
  -        {
  -            throw new Exception(
  -                "Layout template '" + template + "' not found");
  -        }
  -
  -        String defaultLayout = getDefaultLayoutTemplate(template);
  -        
  -        getCategory().debug("[TurbineTemplateService] defaultLayout: " + 
defaultLayout);
  -        
  -        if (defaultLayout != null)
  -        {
  -            if (defaultLayout.length() == 0)
  -            {
  -                defaultLayout = null;
  -            }
  -            else if (defaultLayout.charAt(0) != '/')
  -            {
  -                defaultLayout = '/' + defaultLayout;
  -            }
  -        }
  -    
  -        int j = 9999;
  -        String layoutTemplate;
  -        while (j-- > 0)
  -        {
  -            layoutTemplate = path.toString();
  -
  -            if (tes.templateExists(layoutTemplate))
  -            {
  -                return layoutTemplate.substring(7);
  -            }
  -            
  -            if (defaultLayout == null)
  -            {
  -                throw new Exception(
  -                    "Layout template '" + template + "' not found");
  -            }
  -      
  -            path.setLength(i);
  -            if (i > 8)
  -            {
  -                // We have still directories to traverse.
  -                for (i = path.length() - 2; i >= 8; i--)
  -                {
  -                    if (path.charAt(i) == '/')
  -                    { 
  -                        break;
  -                    }
  -                }
  -            }
  -            else if (j > 0)
  -            {
  -                // Only the main level left.
  -                j = 1;
  -            }
  -            path.append(defaultLayout);
  -        }
  -
  -        // Not found, return the default layout 
  -        // template as such.
  -        return defaultLayout;
  -    }
  -
  -    /**
  -     * Parse the template name collected from URL parameters or
  -     * template context to a path name. Double slashes are changed
  -     * into single ones and commas used as path delemiters in
  -     * URL parameters are changed into slashes. Empty names or
  -     * names without a file part are not accepted.
  -     * 
  -     * @param template The template name.
  -     * @param buffer A buffer for the result.
  -     * @return The index of the separator between the path and the name.
  -     * @exception Exception Malformed template name.
  -     */
  -    private int parseTemplatePath(String template,
  -                                  StringBuffer buffer)
  -        throws Exception
  -    {
  -        char c;
  -        int j = 0;
  -        int ind = -1;
  -        buffer.setLength(0);
  -        buffer.append(template);
  -        int len = buffer.length();
  -        while (j < len)
  -        {
  -            c = buffer.charAt(j);
  -            if (c == ',')
  -            {
  -                c = '/';
  -                buffer.setCharAt(j,c);
  -            }
  -            if (c == '/')
  -            {
  -                ind = j;
  -                if (j < (len - 1))
  -                {
  -                    c = buffer.charAt(j + 1);
  -                    if ((c == '/') ||
  -                        (c == ','))
  -                    {
  -                        buffer.deleteCharAt(j);
  -                        len--;
  -                        continue;
  -                    }
  -                }
  -            }
  -            j++;
  -        }
  -        if ((len == 0) ||
  -            (ind >= (len - 1)))
  -        {
  -            throw new Exception(
  -                "Syntax error in template name '" + template + '\'');
  -        }
  -        return ind;
  -    }
  -    
  -
       public String handleRequest(TemplateContext context, String template)
           throws TurbineException
       {
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to