portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kimp...@apache.org
Subject cvs commit: jakarta-jetspeed/xdocs changes.xml
Date Thu, 09 May 2002 08:44:54 GMT
kimptoc     02/05/09 01:44:54

  Modified:    src/java/org/apache/jetspeed/services/template
                        JetspeedTemplateLocatorService.java
               webapp/WEB-INF/conf JetspeedResources.properties
                        TurbineResources.properties
               xdocs    changes.xml
  Log:
  Added support for multiple template root directories - thanks to Craig Setera
  
  Revision  Changes    Path
  1.7       +50 -14    jakarta-jetspeed/src/java/org/apache/jetspeed/services/template/JetspeedTemplateLocatorService.java
  
  Index: JetspeedTemplateLocatorService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/template/JetspeedTemplateLocatorService.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- JetspeedTemplateLocatorService.java	7 Feb 2002 22:20:06 -0000	1.6
  +++ JetspeedTemplateLocatorService.java	9 May 2002 08:44:53 -0000	1.7
  @@ -59,9 +59,12 @@
   import java.io.IOException;
   
   // java.util
  +import java.util.Iterator;
  +import java.util.List;
   import java.util.Map;
   import java.util.HashMap;
   import java.util.Locale;
  +import java.util.StringTokenizer;
   
   import javax.servlet.ServletConfig;
   
  @@ -109,7 +112,7 @@
    * @author <a href="mailto:rapahel@apache.org">Raphael Luta</a>
    * @author <a href="mailto:paulsp@apache.org">Paul Spener</a>
    * @author <a href="mailto:kimptoc_mail@yahoo.com">Chris Kimpton</a>
  - * @version $Id: JetspeedTemplateLocatorService.java,v 1.6 2002/02/07 22:20:06 sgala Exp
$
  + * @version $Id: JetspeedTemplateLocatorService.java,v 1.7 2002/05/09 08:44:53 kimptoc
Exp $
    */
   
   public class JetspeedTemplateLocatorService   extends TurbineBaseService
  @@ -129,10 +132,9 @@
       private final static String MSG_MISSING_PARAMETER =
           "JetspeedTemplateLocatorService initialization failed. Missing parameter:";
   
  -    // the template root directory, webapp relative
  -    private String templateRoot;
  -    // the absolute path to the template root directory
  -    private String templateRootPath;
  +    // the template root directories, webapp relative
  +    private String[] templateRoots;
  +    
       // use the name cache when looking up a template
       private boolean useNameCache = true;
   
  @@ -440,6 +442,31 @@
        */
       private String locateTemplate(RunData data, String resourceType, String path, String
template)
       {
  +        String located = null;
  +
  +        // Iterate through each of the template roots
  +        for (int i = 0; i < templateRoots.length; i++) {
  +            located = locateTemplate(data, resourceType, path, template, templateRoots[i]);
  +            if (located != null) break;
  +        }
  +
  +        return located;
  +    }
  +    
  +    /**
  +     * General template location algorithm. Starts with the most specific resource,
  +     * including mediatype + nls specification, and fallsback to least specific.
  +     *
  +     * @param data The rundata for the request.
  +     * @param resourceType The path specific to the resource type sought (eg /screens).
  +     * @param path The fullest path to the template based on simple NLS/mediatype directory.
  +     * @param template The name of the template.
  +     * @param templateRoot The template root to be searched.
  +     *
  +     * @return the exact path to the template, or null if not found.
  +     */
  +    private String locateTemplate(RunData data, String resourceType, String path, String
template, String templateRoot)
  +    {
           String finalPath;
   
           // make sure resourceType doesn't end with "/" but starts with "/"
  @@ -618,21 +645,30 @@
       private void initConfiguration() throws InitializationException
       {
   
  -        templateRoot = JetspeedResources.getString(TurbineServices.SERVICE_PREFIX
  +        templateRoots = JetspeedResources.getStringArray(TurbineServices.SERVICE_PREFIX
                                                  + TemplateLocatorService.SERVICE_NAME
                                                  + CONFIG_TEMPLATE_ROOT);
  -        if (templateRoot == null)
  +        if ((templateRoots == null) || (templateRoots.length == 0))
               throw new InitializationException(
                   MSG_MISSING_PARAMETER  + CONFIG_TEMPLATE_ROOT);
  -        if (!templateRoot.endsWith(PATH_SEPARATOR))
  -            templateRoot = templateRoot + PATH_SEPARATOR;
  -
  +                
           templateMap = new HashMap();
  -        // traverse starting from the root template directory and add resources
  -        templateRootPath = TurbineServlet.getRealPath( templateRoot );
  -        if (null != templateRootPath)
  -            loadNameCache( templateRootPath, "" );
   
  +        for (int i = 0; i < templateRoots.length; i++) {
  +            String templateRoot = templateRoots[i];
  +
  +            if (!templateRoot.endsWith(PATH_SEPARATOR)) {
  +                templateRoot = templateRoot + PATH_SEPARATOR;
  +            }
  +
  +            if (Log.getLogger().isDebugEnabled()) Log.debug("Adding templateRoot:"+templateRoot);
  +
  +            // traverse starting from the root template directory and add resources
  +            String templateRootPath = TurbineServlet.getRealPath( templateRoot );
  +            if (null != templateRootPath) {
  +                loadNameCache( templateRootPath, "" );
  +            }
  +        }
       }
   
       /**
  
  
  
  1.76      +5 -1      jakarta-jetspeed/webapp/WEB-INF/conf/JetspeedResources.properties
  
  Index: JetspeedResources.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/webapp/WEB-INF/conf/JetspeedResources.properties,v
  retrieving revision 1.75
  retrieving revision 1.76
  diff -u -r1.75 -r1.76
  --- JetspeedResources.properties	7 May 2002 15:17:48 -0000	1.75
  +++ JetspeedResources.properties	9 May 2002 08:44:54 -0000	1.76
  @@ -1,7 +1,7 @@
   ################################################################################
   # Jetspeed Configuration                             
   # Author: Kevin A. Burton (burton@apache.org)
  -# $Id: JetspeedResources.properties,v 1.75 2002/05/07 15:17:48 raphael Exp $
  +# $Id: JetspeedResources.properties,v 1.76 2002/05/09 08:44:54 kimptoc Exp $
   ################################################################################
   # This is the main file you will need to configuration Jetspeed.  If there are 
   # any secondary files they will be pointed to from this file.
  @@ -438,6 +438,10 @@
   # The Template Locator is implemented as a Turbine service.
   services.TemplateLocator.classname=org.apache.jetspeed.services.template.JetspeedTemplateLocatorService
   
  +# This parameter supports a comma separated list of directories
  +# Each directory is searched in order to find a template.
  +# This is useful for example, in defining application specific templates in a separate
structure from the jetspeed core templates
  +# Note this needs to be set in 3 places - for the jsp loader and vm loader in TR.p and
for the template locator in JR.p
   services.TemplateLocator.templateRoot=/WEB-INF/templates
   
   #########################################
  
  
  
  1.51      +12 -2     jakarta-jetspeed/webapp/WEB-INF/conf/TurbineResources.properties
  
  Index: TurbineResources.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/webapp/WEB-INF/conf/TurbineResources.properties,v
  retrieving revision 1.50
  retrieving revision 1.51
  diff -u -r1.50 -r1.51
  --- TurbineResources.properties	3 May 2002 15:06:26 -0000	1.50
  +++ TurbineResources.properties	9 May 2002 08:44:54 -0000	1.51
  @@ -1,5 +1,5 @@
   # -------------------------------------------------------------------
  -# $Id: TurbineResources.properties,v 1.50 2002/05/03 15:06:26 ggolden Exp $
  +# $Id: TurbineResources.properties,v 1.51 2002/05/09 08:44:54 kimptoc Exp $
   #
   # This is the configuration file for Turbine.
   #
  @@ -644,7 +644,13 @@
   services.VelocityService.resource.loader = file
   services.VelocityService.file.resource.loader.description = Velocity File Resource Loader
   services.VelocityService.file.resource.loader.class = org.apache.velocity.runtime.resource.loader.FileResourceLoader
  +
  +# This parameter supports a comma separated list of directories
  +# Each directory is searched in order to find a template.
  +# This is useful for example, in defining application specific templates in a separate
structure from the jetspeed core templates
  +# Note this needs to be set in 3 places - for the jsp loader and vm loader in TR.p and
for the template locator in JR.p
   services.VelocityService.file.resource.loader.path = /WEB-INF/templates/vm
  +
   services.VelocityService.file.resource.loader.cache = false
   services.VelocityService.file.resource.loader.modificationCheckInterval = 2
   
  @@ -666,8 +672,12 @@
   services.JspService.default.error.screen = JspErrorScreen
   services.JspService.default.layout.template = /default.jsp
   
  -#services.JspService.templates =/WEB-INF/templates/jsp
  +# This parameter supports a comma separated list of directories
  +# Each directory is searched in order to find a template.
  +# This is useful for example, in defining application specific templates in a separate
structure from the jetspeed core templates
  +# Note this needs to be set in 3 places - for the jsp loader and vm loader in TR.p and
for the template locator in JR.p
   services.JspService.templates =/WEB-INF/templates/jsp
  +
   services.JspService.buffer.size = 8192
   
   # -------------------------------------------------------------------
  
  
  
  1.39      +4 -1      jakarta-jetspeed/xdocs/changes.xml
  
  Index: changes.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/xdocs/changes.xml,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- changes.xml	28 Apr 2002 21:00:00 -0000	1.38
  +++ changes.xml	9 May 2002 08:44:54 -0000	1.39
  @@ -1,6 +1,6 @@
   <?xml version="1.0" encoding="iso-8859-1"?>
   <!--
  -$Id: changes.xml,v 1.38 2002/04/28 21:00:00 kimptoc Exp $
  +$Id: changes.xml,v 1.39 2002/05/09 08:44:54 kimptoc Exp $
   -->
   <document>
     <properties>
  @@ -239,6 +239,9 @@
   </li>
   <li>
     Add - 2002/04/28 - highlight disabled/unconfirmed users on the user browser page and
add paging through users (CK)
  +</li>
  +<li>
  +  Add - 2002/05/09 - Added support for multiple template root directories - thanks to Craig
Setera (CK)
   </li>
   </ul>
   </section>
  
  
  

--
To unsubscribe, e-mail:   <mailto:jetspeed-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:jetspeed-dev-help@jakarta.apache.org>


Mime
View raw message