portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pau...@apache.org
Subject cvs commit: jakarta-jetspeed/build build.xml
Date Tue, 09 Apr 2002 04:36:35 GMT
paulsp      02/04/08 21:36:35

  Modified:    src/java/org/apache/jetspeed/util/template JetspeedLink.java
               src/java/org/apache/jetspeed/portal/portlets
                        VelocityPortlet.java
               build    build.xml
  Added:       src/java/org/apache/jetspeed/util/template
                        BaseJetspeedLink.java
  Log:
  Part of PEID implementation
  o Moved JetspeedLink.java to BaseJetspeedLink.java leaving JetspeedLink.java
    to define the interface.
  
  o Updated VelocityPortlet to use the appropriate class when getting the jlink
    tool
  
  o To use the BaseJetspeedLink tool, change the jlink tool property in TR.p
    to the following:
       tool.request.jlink=org.apache.jetspeed.util.template.BaseJetspeedLink
  
  o Implemented some suggestions from Glenn Golden
  
  Revision  Changes    Path
  1.2       +53 -206   jakarta-jetspeed/src/java/org/apache/jetspeed/util/template/JetspeedLink.java
  
  Index: JetspeedLink.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/util/template/JetspeedLink.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- JetspeedLink.java	4 Apr 2002 03:49:23 -0000	1.1
  +++ JetspeedLink.java	9 Apr 2002 04:36:35 -0000	1.2
  @@ -55,23 +55,10 @@
   package org.apache.jetspeed.util.template;
   
   // Jetspeed
  -import org.apache.jetspeed.om.profile.Profile;
  -import org.apache.jetspeed.om.profile.ProfileException;
  -import org.apache.jetspeed.om.profile.ProfileLocator;
   import org.apache.jetspeed.portal.Portlet;
  -import org.apache.jetspeed.portal.PortletSet;
  -import org.apache.jetspeed.portal.PortletController;
  -import org.apache.jetspeed.portal.PanedPortletController;
  -import org.apache.jetspeed.services.Profiler;
  -import org.apache.jetspeed.services.resources.JetspeedResources;
  -import org.apache.jetspeed.services.rundata.JetspeedRunData;
   
   // Turbine
  -import org.apache.turbine.util.RunData;
  -import org.apache.turbine.util.Log;
   import org.apache.turbine.util.DynamicURI;
  -import org.apache.turbine.util.template.TemplateLink;
  -import org.apache.turbine.services.pull.ApplicationTool;
   
   /**
    * <p>A customized version of the TemplateLink which can handle portlet
  @@ -83,110 +70,48 @@
    * rendering code. This is done currently in VelocityPortlet.</p>
    *
    * @author <a href="mailto:paulsp@apache.org">Paul Spencer</a>
  - * @version $Id: JetspeedLink.java,v 1.1 2002/04/04 03:49:23 paulsp Exp $
  + * @version $Id: JetspeedLink.java,v 1.2 2002/04/09 04:36:35 paulsp Exp $
    */
  -public class JetspeedLink implements ApplicationTool
  +public interface  JetspeedLink 
   {
  -    
  -    // parameter names for the Jetspeed framework elements
  -//    public static final String PANEID_KEY = "js_pane";
  -//    public static final String PORTLETID_KEY = "js_peid";
  -    
  -    
  -    /**
  -     *<p>Request to which we refer.</p>
  -     */
  -    private JetspeedRunData rundata = null;
  -    
  -    /**
  -     * Profile locator from <code>rundata</code>.  This is here
  -     * for performance reasons.
  -     */
  -    private ProfileLocator locator = null;
  -    
  -    /**
  -     * @deprecated Use JetspeedResources.PATH_PANEL_KEY. This is a from JetspeedTemplateLink
  -     */
  -    public static final String PANEL_KEY = "select-panel";
  -    /**
  -     * @deprecated JetspeedResources.PATH_PORTLET_KEY. This is a from JetspeedTemplateLink
  -     */
  -    public static final String PORTLET_KEY = "portlet";
  -    /**
  -     *<p>The portlet that will be used to build the reference.</p>
  -     * @deprecated This is a from JetspeedTemplateLink
  -     */
  -    protected Portlet activePortlet = null;
  -    
  -    /**
  -     * Empty constructor.for introspection
  -     */
  -    public JetspeedLink()
  -    {
  -    }
  -    
       /**
  -     * Constructor required by ApplicationTool interface
  +     * Return an link to a specific portal element
        *
  -     * @param data A Jetspeed RunData object.
  +     * @param peid of the portal element
  +     * @return DynamicURI to specific portal element
        */
  -    public JetspeedLink(RunData data)
  -    {
  -        init(data);
  -    }
  -    
  +     public DynamicURI setPortalElement(String peid);
  +     
       /**
        * Return an link to a specific portlet using the portet's id
        *
        * @param peid of the portlet
  -     * @throws ProfileException if the profile detects an error
  -     * @return DynamicURI to spedific portlet
  +     * @return DynamicURI to specific portlet
        */
  -    public DynamicURI forPortletById(String peid) throws ProfileException
  -    {
  -        DynamicURI uri = Profiler.makeDynamicURI(rundata, locator);
  -        return uri.addPathInfo( JetspeedResources.PATH_PORTLETID_KEY, peid);
  -    }
  +    public DynamicURI setPortletById(String peid);
       
       /**
        * Return a link to a specific pane using the pane's id
        *
        * @param paneId of the Pane
  -     * @throws ProfileException if the profile detects an error
        * @return  URI to specific portlet
        */
  -    public DynamicURI forPaneById(String paneId) throws ProfileException
  -    {
  -        DynamicURI uri = Profiler.makeDynamicURI(rundata, locator);
  -        return uri.addPathInfo(JetspeedResources.PATH_PANEID_KEY, paneId);
  -    }
  -    
  -    /**
  -     * Return a link to the root portlet or pane
  -     * @throws ProfileException if the profile detects an error
  -     * @return  URI to the root portlet/pane
  -     */
  -    public DynamicURI getRoot() throws ProfileException
  -    {
  -        return Profiler.makeDynamicURI(rundata, locator);
  -    }
  +    public DynamicURI setPaneById(String paneId);
       
       /**
        * Return a URL, as a string, the the root page or pane.
        *
        * @return a URL, as a string, the the root page or pane.
        */
  -    public String toString()
  -    {
  -        try
  -        {
  -            return Profiler.makeDynamicURI(rundata, locator).toString();
  -        } catch (ProfileException e)
  -        {
  -            return new DynamicURI(rundata).toString();
  -        }
  -    }
  -    
  +    public String toString();
  +
  +    /**
  +     * Return the action key.  Used by velocity templates, i.e. $jlink.ActionKey
  +     *
  +     * @return the action parameter name
  +     */
  +    public String getActionKey();
  +
       /**
        * Depracated methods from JetspeedTemplateLink.
        */
  @@ -194,7 +119,7 @@
       /**
        * <p> Set the portlet giving context to this Link object.</p>
        *
  -     * This method is from JetspeeTemplateLink and is only here
  +     * This method is from JetspeedTemplateLink and is only here
        * for backward compatibility. This it should not be used for
        * any new development.  Also any problems with this method will
        * not be fixed
  @@ -202,16 +127,13 @@
        * @param portlet the name of the active portlet
        * @deprecated the name is confusing. Use @see(#forPaneById()) instead.
        */
  -    public void setPortlet(Portlet portlet)
  -    {
  -        this.activePortlet=portlet;
  -    }
  +    public void setPortlet(Portlet portlet);
       
       
       /**
        * Add a portlet reference in the link.
        *
  -     * This method is from JetspeeTemplateLink and is only here
  +     * This method is from JetspeedTemplateLink and is only here
        * for backward compatibility. This it should not be used for
        * any new development.  Also any problems with this method will
        * not be fixed
  @@ -220,15 +142,12 @@
        * @deprecated the name is confusing. Use @see(#forPortletById()) instead.
        * @return a DynamicURI referencing the named portlet for easy link construction in
template
        */
  -    public DynamicURI setPortlet(String portlet)
  -    {
  -        return this.forPortlet( portlet );
  -    }
  +    public DynamicURI setPortlet(String portlet);
       
       /**
        * Add a portlet reference in the link.
        *
  -     * This method is from JetspeeTemplateLink and is only here
  +     * This method is from JetspeedTemplateLink and is only here
        * for backward compatibility. This it should not be used for
        * any new development.  Also any problems with this method will
        * not be fixed
  @@ -237,22 +156,12 @@
        * @deprecated Use @see(#forPortletById()) instead.
        * @return a DynamicURI referencing the named portlet for easy link construction in
template
        */
  -    public DynamicURI forPortlet(String portlet)
  -    {
  -        try
  -        {
  -            DynamicURI uri = Profiler.makeDynamicURI(rundata, locator);
  -            return uri.addPathInfo(JetspeedResources.PATH_PORTLET_KEY, portlet);
  -        } catch ( ProfileException e)
  -        {
  -            return null;
  -        }
  -    }
  +    public DynamicURI forPortlet(String portlet);
       
       /**
        * Add a select-panel reference in the link
        *
  -     * This method is from JetspeeTemplateLink and is only here
  +     * This method is from JetspeedTemplateLink and is only here
        * for backward compatibility. This it should not be used for
        * any new development.  Also any problems with this method will
        * not be fixed
  @@ -261,38 +170,12 @@
        * @deprecated Use @see(#forPaneById()) instead.
        * @return a self reference for easy link construction in template
        */
  -    public DynamicURI setPanel(String panel)
  -    {
  -        PortletController controller = activePortlet.getPortletConfig().getPortletSet().getController();
  -        
  -        String id = null;
  -        
  -        if (controller instanceof PanedPortletController)
  -        {
  -            PortletSet set = controller.getPortlets();
  -            Portlet portlet = null;
  -            if (null != set)
  -            {
  -                portlet = set.getPortletByName(panel);
  -            }
  -            if (portlet != null)
  -                id = portlet.getID();
  -        }
  -        
  -        try
  -        {
  -            DynamicURI uri = Profiler.makeDynamicURI(rundata, locator);
  -            return uri.addPathInfo(JetspeedResources.PATH_PANEID_KEY, id);
  -        } catch ( ProfileException e)
  -        {
  -            return null;
  -        }
  -    }
  +    public DynamicURI setPanel(String panel);
       
       /**
        * <p>Use the activePortlet to get the current Panel name (key).</p>
        *
  -     * This method is from JetspeeTemplateLink and is only here
  +     * This method is from JetspeedTemplateLink and is only here
        * for backward compatibility. This it should not be used for
        * any new development.  Also any problems with this method will
        * not be fixed
  @@ -300,73 +183,37 @@
        * @deprecated Use @see(#forPaneById()) instead.
        * @return the panel parameter name
        */
  -    public String getPanelKey()
  -    {
  -        String panelName = PANEL_KEY;
  -        try
  -        {
  -            PortletController controller = activePortlet.getPortletConfig()
  -            .getPortletSet()
  -            .getController();
  -            
  -            if (controller instanceof PanedPortletController)
  -            {
  -                panelName=((PanedPortletController)controller).getParameterName();
  -            }
  -            
  -        }
  -        catch (Exception e)
  -        {
  -            panelName = PANEL_KEY;
  -        }
  -        
  -        return panelName;
  -    }
  +    public String getPanelKey();
       
       /**
  -     * Methods required by ApplictionTool interface
  +     * Return a link to the root portlet or pane with additional
  +     * item on the path
  +     *
  +     * This method is from JetspeedTemplateLink and is only here
  +     * for backward compatibility. This it should not be used for
  +     * any new development.  Also any problems with this method will
  +     * not be fixed.
        *
  +     * @param name of item to add to the path
  +     * @param value of item to add to the path
  +     * @return DynamicURI to specific portlet
        */
  -    
  +    public DynamicURI addPathInfo ( String name, Object value );
  +
       /**
  -     * This will initialise a JetspeedTool object that was
  -     * constructed with the default constructor (ApplicationTool
  -     * method).
  +     * Return a link to the root portlet or pane with additional
  +     * item on the path
  +     *
  +     * This method is from JetspeedTemplateLink and is only here
  +     * for backward compatibility. This it should not be used for
  +     * any new development.  Also any problems with this method will
  +     * not be fixed.
        *
  -     * @param data assumed to be a RunData object
  +     * @param name of item to add to the path
  +     * @param value of item to add to the path
  +     * @return DynamicURI to specific portlet
        */
  -    
  -    public void init(Object data)
  -    {
  -        this.rundata = (JetspeedRunData)data;
  -        
  -        Profile profile = null;
  -        try
  -        {
  -            profile = Profiler.getProfile(rundata);
  -        }
  -        catch (Exception e)
  -        {
  -            locator = null;
  -            return;
  -        }
  -        
  -        // Get ProfileLocator for path info.
  -        if ((profile instanceof ProfileLocator) == false)
  -        {
  -            locator = null;
  -            return;
  -        }
  -        locator = (ProfileLocator) profile;
  +    public DynamicURI addQueryData ( String name, Object value );
  +
           
  -        return;
  -    }
  -    /**
  -     * Refresh method - does nothing
  -     */
  -    public void refresh()
  -    {
  -        // empty
  -    }
  -    
   }
  
  
  
  1.1                  jakarta-jetspeed/src/java/org/apache/jetspeed/util/template/BaseJetspeedLink.java
  
  Index: BaseJetspeedLink.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;
  
  // Jetspeed
  import org.apache.jetspeed.om.profile.Profile;
  import org.apache.jetspeed.om.profile.ProfileException;
  import org.apache.jetspeed.om.profile.ProfileLocator;
  import org.apache.jetspeed.portal.Portlet;
  import org.apache.jetspeed.portal.PortletSet;
  import org.apache.jetspeed.portal.PortletController;
  import org.apache.jetspeed.portal.PanedPortletController;
  import org.apache.jetspeed.services.Profiler;
  import org.apache.jetspeed.services.resources.JetspeedResources;
  import org.apache.jetspeed.services.rundata.JetspeedRunData;
  import org.apache.jetspeed.util.template.JetspeedLink;
  
  // Turbine
  import org.apache.turbine.util.RunData;
  import org.apache.turbine.util.Log;
  import org.apache.turbine.util.DynamicURI;
  import org.apache.turbine.util.template.TemplateLink;
  import org.apache.turbine.services.pull.ApplicationTool;
  import org.apache.turbine.services.pool.TurbinePool;
  import org.apache.turbine.services.pool.PoolService;
  import org.apache.turbine.services.TurbineServices;
  
  /**
   * <p>A customized version of the TemplateLink which can handle portlet
   * references.</p>
   *
   * <p>It is inserted into the template context by Turbine, via request tools.</p>
   *
   * <p>Each portlet must call setPortlet(this) on it before entering the template
   * rendering code. This is done currently in VelocityPortlet.</p>
   *
   * @author <a href="mailto:paulsp@apache.org">Paul Spencer</a>
   * @version $Id: BaseJetspeedLink.java,v 1.1 2002/04/09 04:36:35 paulsp Exp $
   */
  public class BaseJetspeedLink implements ApplicationTool, JetspeedLink
  {
      
      /**
       *<p>Request to which we refer.</p>
       */
      private JetspeedRunData rundata = null;
      
      /**
       * Profile locator from <code>rundata</code>.  This is here
       * for performance reasons.
       */
      private ProfileLocator locator = null;
      
      /**
       * Profile from <code>rundata</code>.  This is here
       * for performance reasons.
       */
      private Profile profile = null;
      /**
       * @deprecated Use JetspeedResources.PATH_PANEL_KEY. This is a from JetspeedTemplateLink
       */
      public static final String PANEL_KEY = "select-panel";
      /**
       * @deprecated Use JetspeedResources.PATH_ACTION_KEY. This is a from JetspeedTemplateLink
       */
      public static final String ACTION_KEY = "action";
      /**
       * @deprecated JetspeedResources.PATH_PORTLET_KEY. This is a from JetspeedTemplateLink
       */
      public static final String PORTLET_KEY = "portlet";
      /**
       *<p>The portlet that will be used to build the reference.</p>
       * @deprecated This is a from JetspeedTemplateLink
       */
      protected Portlet activePortlet = null;
  
      /**
       * Empty constructor.for introspection
       */
      public BaseJetspeedLink()
      {
      }
      
      /**
       * Constructor required by ApplicationTool interface
       *
       * @param data A Jetspeed RunData object.
       */
      public BaseJetspeedLink(RunData data)
      {
          init(data);
      }
      
      
      /**
       * Return an link to a specific portal element
       *
       * @param peid of the portal element
       * @return DynamicURI to specific portal element
       */
      /**
       * Return an link to a specific portal element
       *
       * @param peid of the portal element
       * @return DynamicURI to specific portal element
       */
      public DynamicURI setPortalElement(String peid)
      {
          if (profile.getDocument().getEntryById( peid) != null)
              return setPortletById( peid);
          else
              return setPaneById(peid);
      }
      
      /**
       * Return an link to a specific portlet using the portet's id
       *
       * @param peid of the portlet
       * @throws ProfileException if the profile detects an error
       * @return DynamicURI to specific portlet
       */
      public DynamicURI setPortletById(String peid)
      {
          try
          {
              DynamicURI uri = getRoot();
              if ((peid != null) && (peid.length() > 0))
                  uri.addPathInfo( JetspeedResources.PATH_PORTLETID_KEY, peid);
              return uri;
          } catch (ProfileException e)
          {
              e.printStackTrace();
              return null;
          }
      }
      
      /**
       * Return a link to a specific pane using the pane's id
       *
       * @param paneId of the Pane
       * @throws ProfileException if the profile detects an error
       * @return  URI to specific portlet
       */
      public DynamicURI setPaneById(String paneId)
      {
          try
          {
              DynamicURI uri = getRoot();
              if ((paneId != null) && (paneId.length() > 0))
                  uri.addPathInfo(JetspeedResources.PATH_PANEID_KEY, paneId);
              return uri;
          } catch (ProfileException e)
          {
              e.printStackTrace();
              return null;
          }
      }
      
      /**
       * Return a link to the root portlet or pane
       *
       * @throws ProfileException if the profile detects an error
       * @return  URI to the root portlet/pane
       */
      private DynamicURI getRoot() throws ProfileException
      {
          DynamicURI uri = null;
          if (profile == null)
          {
              profile = Profiler.getProfile(rundata);
              
              // Get ProfileLocator for path info.
              if ((profile instanceof ProfileLocator) == true)
              {
                  locator = (ProfileLocator) profile;
                  if (locator != null)
                      uri = Profiler.makeDynamicURI(rundata, locator);
              }
          }
          if (uri == null)
              uri = new DynamicURI( rundata);
          
          // Add current template to URI, if their is one
          String template = rundata.getRequestedTemplate();
          if (template != null)
              uri.addPathInfo( JetspeedResources.PATH_TEMPLATE_KEY, template);
          
          return uri;
      }
      
      /**
       * Return a URL, as a string, the the root page or pane.
       *
       * @return a URL, as a string, the the root page or pane.
       */
      public String toString()
      {
          try
          {
              return getRoot().toString();
          } catch (ProfileException e)
          {
              e.printStackTrace();
              return null;
          }
      }
      
      /**
       * Return the action key.  Used by velocity templates, i.e. $jlink.ActionKey
       *
       * @return the action parameter name
       */
      public String getActionKey()
      {
          return JetspeedResources.PATH_ACTION_KEY;
      }
      
      /**
       * Depracated methods from JetspeedTemplateLink.
       */
      
      /**
       * <p> Set the portlet giving context to this Link object.</p>
       *
       * This method is from JetspeedTemplateLink and is only here
       * for backward compatibility. This it should not be used for
       * any new development.  Also any problems with this method will
       * not be fixed
       *
       * @param portlet the name of the active portlet
       * @deprecated the name is confusing. Use @see(#forPaneById()) instead.
       */
      public void setPortlet(Portlet portlet)
      {
          this.activePortlet=portlet;
      }
      
      
      /**
       * Add a portlet reference in the link.
       *
       * This method is from JetspeedTemplateLink and is only here
       * for backward compatibility. This it should not be used for
       * any new development.  Also any problems with this method will
       * not be fixed
       *
       * @param portlet the name of the portlet to link to
       * @deprecated the name is confusing. Use @see(#forPortletById()) instead.
       * @return a DynamicURI referencing the named portlet for easy link construction in
template
       */
      public DynamicURI setPortlet(String portlet)
      {
          return this.forPortlet( portlet );
      }
      
      /**
       * Add a portlet reference in the link.
       *
       * This method is from JetspeedTemplateLink and is only here
       * for backward compatibility. This it should not be used for
       * any new development.  Also any problems with this method will
       * not be fixed
       *
       * @param portlet the name of the portlet to link to
       * @deprecated Use @see(#forPortletById()) instead.
       * @return a DynamicURI referencing the named portlet for easy link construction in
template
       */
      public DynamicURI forPortlet(String portlet)
      {
          try
          {
              DynamicURI uri = getRoot();
              if ((portlet != null) && (portlet.length() > 0))
                  uri.addPathInfo(JetspeedResources.PATH_PORTLET_KEY, portlet);
              return uri;
          } catch ( ProfileException e)
          {
              return null;
          }
      }
      
      /**
       * Add a select-panel reference in the link
       *
       * This method is from JetspeedTemplateLink and is only here
       * for backward compatibility. This it should not be used for
       * any new development.  Also any problems with this method will
       * not be fixed
       *
       * @param portlet the name of the portlet to link to
       * @deprecated Use @see(#forPaneById()) instead.
       * @return a self reference for easy link construction in template
       */
      public DynamicURI setPanel(String panel)
      {
          PortletController controller = activePortlet.getPortletConfig().getPortletSet().getController();
          
          String id = null;
          
          if (controller instanceof PanedPortletController)
          {
              PortletSet set = controller.getPortlets();
              Portlet portlet = null;
              if (null != set)
              {
                  portlet = set.getPortletByName(panel);
              }
              if (portlet != null)
                  id = portlet.getID();
          }
          
          try
          {
              DynamicURI uri = getRoot();
              if ((id != null) && (id.length() > 0))
                  uri.addPathInfo(JetspeedResources.PATH_PANEID_KEY, id);
              return uri;
          } catch ( ProfileException e)
          {
              return null;
          }
      }
      
      /**
       * <p>Use the activePortlet to get the current Panel name (key).</p>
       *
       * This method is from JetspeedTemplateLink and is only here
       * for backward compatibility. This it should not be used for
       * any new development.  Also any problems with this method will
       * not be fixed
       *
       * @deprecated Use @see(#forPaneById()) instead.
       * @return the panel parameter name
       */
      public String getPanelKey()
      {
          String panelName = PANEL_KEY;
          try
          {
              PortletController controller = activePortlet.getPortletConfig()
              .getPortletSet()
              .getController();
              
              if (controller instanceof PanedPortletController)
              {
                  panelName=((PanedPortletController)controller).getParameterName();
              }
              
          }
          catch (Exception e)
          {
              panelName = PANEL_KEY;
          }
          
          return panelName;
      }
      
      /**
       * Return a link to the root portlet or pane with additional
       * item on the path.
       *
       * This method is from JetspeedTemplateLink and is only here
       * for backward compatibility. This it should not be used for
       * any new development.  Also any problems with this method will
       * not be fixed.
       *
       * @param name of item to add to the path
       * @param value of item to add to the path
       * @deprecated
       * @throws ProfileException if the profile detects an error
       * @return DynamicURI to specific portlet
       */
      public DynamicURI addPathInfo(String name, Object value)
      {
          try
          {
              DynamicURI uri = getRoot();
              return uri.addPathInfo( name, value);
          } catch (ProfileException e)
          {
              e.printStackTrace();
              return null;
          }
      }
      
      /**
       * Return a link to the root portlet or pane with an additional
       * query item on the path
       *
       * This method is from JetspeedTemplateLink and is only here
       * for backward compatibility. This it should not be used for
       * any new development.  Also any problems with this method will
       * not be fixed.
       *
       * @param name of item to add to the path
       * @param value of item to add to the path
       * @throws ProfileException if the profile detects an error
       * @deprecated
       * @return DynamicURI to specific portlet
       */
      public DynamicURI addQueryData( String name, Object value )
      {
          try
          {
              DynamicURI uri = getRoot();
              return uri.addQueryData( name, value);
          } catch (ProfileException e)
          {
              e.printStackTrace();
              return null;
          }
      }
      
      /**
       * Methods required by ApplictionTool interface
       *
       */
      
      /**
       * This will initialise a JetspeedLink object that was
       * constructed with the default constructor (ApplicationTool
       * method).
       *
       * @param data assumed to be a RunData object
       */
      
      public void init(Object data)
      {
          // Keeping init small and fast
          this.rundata = (JetspeedRunData)data;
          profile = null;
          locator = null;
          return;
      }
      /**
       * Refresh method - does nothing
       */
      public void refresh()
      {
          // empty
      }
      
  }
  
  
  
  1.15      +11 -2     jakarta-jetspeed/src/java/org/apache/jetspeed/portal/portlets/VelocityPortlet.java
  
  Index: VelocityPortlet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/portal/portlets/VelocityPortlet.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- VelocityPortlet.java	23 Mar 2002 22:18:17 -0000	1.14
  +++ VelocityPortlet.java	9 Apr 2002 04:36:35 -0000	1.15
  @@ -66,6 +66,7 @@
   import org.apache.jetspeed.portal.PortletException;
   import org.apache.jetspeed.portal.PortletConfig;
   import org.apache.jetspeed.services.TemplateLocator;
  +import org.apache.jetspeed.util.template.JetspeedLink;
   import org.apache.jetspeed.util.template.JetspeedTemplateLink;
   import org.apache.jetspeed.services.JetspeedSecurity;
   import org.apache.jetspeed.services.security.JetspeedSecurityService;
  @@ -166,8 +167,16 @@
           
           //We need to initialize the jlink tool with ourselves to
           // enable links between portlets.
  -        JetspeedTemplateLink jlink = (JetspeedTemplateLink) context.get( "jlink" );
  -        jlink.setPortlet( this );
  +
  +        Object jlink = context.get( "jlink" );
  +        if (jlink instanceof JetspeedLink )
  +            ((JetspeedLink)jlink).setPortlet( this );
  +        else
  +        {
  +            // FIXME:  This is to be deprecated
  +            if (jlink instanceof JetspeedTemplateLink )
  +                ((JetspeedTemplateLink)jlink).setPortlet( this );
  +        }
   
           String actionName = getPortletConfig().getInitParameter("action");
           
  
  
  
  1.138     +6 -2      jakarta-jetspeed/build/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/build/build.xml,v
  retrieving revision 1.137
  retrieving revision 1.138
  diff -u -r1.137 -r1.138
  --- build.xml	6 Apr 2002 18:09:47 -0000	1.137
  +++ build.xml	9 Apr 2002 04:36:35 -0000	1.138
  @@ -643,7 +643,9 @@
               <!-- Cactus unit tests -->
               <test name="org.apache.jetspeed.modules.actions.TestJLoginUser"/>
               <test name="org.apache.jetspeed.test.TestBasicSanity"/>
  -
  +<!--
  +            <test name="org.apache.jetspeed.util.template.TestJetspeedLink"/>
  +-->
           </junit>
       </target>
   
  @@ -670,7 +672,9 @@
               <!-- Cactus unit tests -->
               <test name="org.apache.jetspeed.modules.actions.TestJLoginUser"/>
               <test name="org.apache.jetspeed.test.TestBasicSanity"/>
  -                
  +<!--
  +            <test name="org.apache.jetspeed.util.template.TestJetspeedLink"/>
  +-->
           </junit>
       </target>
   
  
  
  

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