portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From na...@apache.org
Subject cvs commit: jakarta-jetspeed/src/java/org/apache/jetspeed/util/template JetspeedTemplateNavigation.java
Date Sat, 24 Nov 2001 00:44:37 GMT
nacho       01/11/23 16:44:37

  Modified:    src/java/org/apache/jetspeed/services/template
                        TemplateLocatorService.java
                        JetspeedTemplateLocatorService.java
               src/java/org/apache/jetspeed/services TemplateLocator.java
               src/java/org/apache/jetspeed/services/jsp/tags
                        NavigationTag.java
               src/java/org/apache/jetspeed/modules/pages
                        JetspeedVelocityPage.java
  Added:       src/java/org/apache/jetspeed/util/template
                        JetspeedTemplateNavigation.java
  Log:
  Adding directory matching l10n to Navigations
  
  Revision  Changes    Path
  1.3       +13 -1     jakarta-jetspeed/src/java/org/apache/jetspeed/services/template/TemplateLocatorService.java
  
  Index: TemplateLocatorService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/template/TemplateLocatorService.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TemplateLocatorService.java	2001/11/16 03:32:07	1.2
  +++ TemplateLocatorService.java	2001/11/24 00:44:36	1.3
  @@ -81,7 +81,7 @@
    * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
    * @author <a href="mailto:paulsp@apache.org">Paul Spencer</a>
    * @author <a href="mailto:kimptoc_mail@yahoo.com">Chris Kimpton</a>
  - * @version $Id: TemplateLocatorService.java,v 1.2 2001/11/16 03:32:07 paulsp Exp $
  + * @version $Id: TemplateLocatorService.java,v 1.3 2001/11/24 00:44:36 nacho Exp $
    */
   
   public interface TemplateLocatorService extends Service
  @@ -149,6 +149,18 @@
        *          or null if not found.
        */
       public String locateControllerTemplate(RunData data, String template);
  +
  +    /**
  +     * Locate a navigation template using Jetspeed template location algorithm, searching
by
  +     * mediatype and language criteria extracted from the request state in rundata.
  +     *
  +     * @param data The rundata for the request.
  +     * @param template The name of the template.
  +     *
  +     * @return The path relative to the controllers directory for the requested controller
template,
  +     *          or null if not found.
  +     */
  +    public String locateNavigationTemplate(RunData data, String template);
   
       /**
        * Locate an email template using Jetspeed template location algorithm, searching by
  
  
  
  1.3       +34 -1     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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- JetspeedTemplateLocatorService.java	2001/11/16 03:32:07	1.2
  +++ JetspeedTemplateLocatorService.java	2001/11/24 00:44:36	1.3
  @@ -109,7 +109,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.2 2001/11/16 03:32:07 paulsp Exp
$
  + * @version $Id: JetspeedTemplateLocatorService.java,v 1.3 2001/11/24 00:44:36 nacho Exp
$
    */
   
   public class JetspeedTemplateLocatorService   extends TurbineBaseService
  @@ -121,6 +121,7 @@
       private final static String DIR_PORTLETS = "/portlets";
       private final static String DIR_CONTROLS = "/controls";
       private final static String DIR_CONTROLLERS = "/controllers";
  +    private final static String DIR_NAVIGATIONS = "/navigations";
       private final static String DIR_EMAILS = "/emails";
       private static final String PATH_SEPARATOR = "/";
   
  @@ -344,6 +345,38 @@
           }
           if (null != located)
               return DIR_CONTROLLERS + located;
  +        return null;
  +    }
  +
  +        /**
  +     * Locate a controller template using Jetspeed template location algorithm, searching
by
  +     * mediatype and language criteria extracted from the request state in rundata.
  +     *
  +     * @param data The rundata for the request.
  +     * @param template The name of the template.
  +     *
  +     * @return The path relative to the controllers directory for the requested controller
template,
  +     *          or null if not found.
  +     */
  +    public String locateNavigationTemplate(RunData data, String template)
  +    {
  +        String path = localizeTemplateName(data);
  +
  +        String located = locateTemplate(data, DIR_NAVIGATIONS, path, template);
  +        if (null == located)
  +        {
  +            // Try to locate it directly on file system, perhaps it was recently added
  +            useNameCache = false;
  +            located = locateTemplate(data, DIR_NAVIGATIONS, path, template);
  +            if (null != located)
  +            {
  +                // add it to the map
  +                templateMap.put( located, null );
  +            }
  +            useNameCache = true;
  +        }
  +        if (null != located)
  +            return located;
           return null;
       }
   
  
  
  
  1.3       +9 -1      jakarta-jetspeed/src/java/org/apache/jetspeed/services/TemplateLocator.java
  
  Index: TemplateLocator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/TemplateLocator.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TemplateLocator.java	2001/11/16 03:49:12	1.2
  +++ TemplateLocator.java	2001/11/24 00:44:36	1.3
  @@ -69,7 +69,7 @@
    * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
    * @author <a href="mailto:paulsp@apache.org">Paul Spencer</a>
    * @author <a href="mailto:kimptoc_mail@yahoo.com">Chris Kimpton</a>
  - * @version $Id: TemplateLocator.java,v 1.2 2001/11/16 03:49:12 paulsp Exp $
  + * @version $Id: TemplateLocator.java,v 1.3 2001/11/24 00:44:36 nacho Exp $
    */
   public class TemplateLocator
   {
  @@ -122,6 +122,14 @@
       public static String locateControllerTemplate(RunData data, String template)
       {
           return getService().locateControllerTemplate(data, template);
  +    }
  +
  +    /**
  +     * @see TemplateLocatorService#locateNavigationTemplate
  +     */
  +    public static String locateNavigationTemplate(RunData data, String template)
  +    {
  +        return getService().locateNavigationTemplate(data, template);
       }
   
       /**
  
  
  
  1.3       +7 -4      jakarta-jetspeed/src/java/org/apache/jetspeed/services/jsp/tags/NavigationTag.java
  
  Index: NavigationTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/jsp/tags/NavigationTag.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- NavigationTag.java	2001/03/07 06:48:39	1.2
  +++ NavigationTag.java	2001/11/24 00:44:37	1.3
  @@ -58,7 +58,10 @@
   import javax.servlet.jsp.*;
   import javax.servlet.jsp.tagext.*;
   
  -// Turbine Classes 
  +// JetSpeed Classes
  +import org.apache.jetspeed.services.TemplateLocator;
  +
  +// Turbine Classes
   import org.apache.turbine.modules.NavigationLoader;
   import org.apache.turbine.util.*;
   import org.apache.turbine.services.template.TemplateService;
  @@ -68,7 +71,7 @@
   
   /**
    * Supporting class for the navigation tag.
  - * Includes a navigation JSP. If the respective tag parameter is set, 
  + * Includes a navigation JSP. If the respective tag parameter is set,
    * different JSPs will be choosen, depending on whether the user has 
    * already logged in or not.
    *
  @@ -117,14 +120,14 @@
           String module   = null;
   
           RunData data = (RunData)pageContext.getAttribute(JspService.RUNDATA, PageContext.REQUEST_SCOPE);
  -
           try
           {  
               /* LOGGED_IN */
               if ( (data != null) && (data.getUser() != null) && data.getUser().hasLoggedIn()
&& (loggedInTemplate != null) ) 
                 template = loggedInTemplate;
   
  -            data.getTemplateInfo().setNavigationTemplate(template);
  +            data.getTemplateInfo().setNavigationTemplate(
  +                        TemplateLocator.locateNavigationTemplate(data,template));
   
               pageContext.getOut().flush();
               module = ((TemplateService)TurbineServices.getInstance().getService(
  
  
  
  1.3       +4 -2      jakarta-jetspeed/src/java/org/apache/jetspeed/modules/pages/JetspeedVelocityPage.java
  
  Index: JetspeedVelocityPage.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/modules/pages/JetspeedVelocityPage.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- JetspeedVelocityPage.java	2001/03/07 06:44:15	1.2
  +++ JetspeedVelocityPage.java	2001/11/24 00:44:37	1.3
  @@ -65,7 +65,7 @@
    * Extends JetspeedTemplatePage to set the Velocity template Context.
    *
    * @author <a href="mailto:raphael@apache.org">RaphaŽl Luta</a>
  - * @version $Id: JetspeedVelocityPage.java,v 1.2 2001/03/07 06:44:15 taylor Exp $
  + * @version $Id: JetspeedVelocityPage.java,v 1.3 2001/11/24 00:44:37 nacho Exp $
    */
   public class JetspeedVelocityPage extends JetspeedTemplatePage
   {
  @@ -90,7 +90,9 @@
           context.put("clink", new ContentTemplateLink(data));
           // the jetspeed configuration elements
           context.put("config", new JetspeedResources());
  -        
  +        // New JetSpeed NAvigation Generator
  +        context.put("jnavigation", new JetspeedTemplateNavigation(data));
  +
           data.getTemplateInfo().setTemplateContext(VelocityService.CONTEXT, context);
       }
   }
  
  
  
  1.1                  jakarta-jetspeed/src/java/org/apache/jetspeed/util/template/JetspeedTemplateNavigation.java
  
  Index: JetspeedTemplateNavigation.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *     "Apache Jetspeed" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache" or
   *    "Apache Jetspeed", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.jetspeed.util.template;
  
  import org.apache.turbine.util.template.*;
  import org.apache.turbine.util.RunData;
  import org.apache.jetspeed.services.TemplateLocator;
  /**
   * A Class that produce localized navigations.
   *
   *
   * @author Ignacio J. Ortega
   */
  public class JetspeedTemplateNavigation extends TemplateNavigation {
  
  
      private RunData data;
  
      public JetspeedTemplateNavigation(RunData data) {
          super(data);
          this.data=data;
      }
  
      public TemplateNavigation setTemplate(String template) {
          return super.setTemplate(TemplateLocator.locateNavigationTemplate(data,template));
      }
  }
  
  
  
  

--
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