portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject cvs commit: jakarta-jetspeed/webapp/WEB-INF/conf demo-portlets.xreg portlets.xreg
Date Tue, 03 Feb 2004 19:37:09 GMT
taylor      2004/02/03 11:37:09

  Modified:    webapp/WEB-INF/conf demo-portlets.xreg portlets.xreg
  Added:       src/java/org/apache/jetspeed/portal/portlets
                        RedirectPortlet.java
  Log:
  The Redirect portlet is a new portlet to enable Jetspeed menu options to redirect outside
of the portal
  You may need to tweak the clearing of the js_pane state in Jetspeed's menus depending on
the level
  of menus where this portlet is located.
  To test it out try redirecting, and then hitting the back link and ensure that all links
are still go
  Also try going back to http://localhost:8080/jetspeed/portal and ensure that you arent getting
infinite redirects
  
  Revision  Changes    Path
  1.1                  jakarta-jetspeed/src/java/org/apache/jetspeed/portal/portlets/RedirectPortlet.java
  
  Index: RedirectPortlet.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2003 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",
   *    "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.portal.portlets;
  
  import java.io.IOException;
  
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  
  import org.apache.ecs.ConcreteElement;
  import org.apache.jetspeed.portal.PortletSet;
  import org.apache.jetspeed.services.logging.JetspeedLogFactoryService;
  import org.apache.jetspeed.services.logging.JetspeedLogger;
  import org.apache.jetspeed.services.resources.JetspeedResources;
  import org.apache.jetspeed.services.rundata.JetspeedRunData;
  import org.apache.jetspeed.services.statemanager.SessionState;
  import org.apache.jetspeed.util.JetspeedClearElement;
  import org.apache.turbine.util.RunData;
  
  /**
   * RedirectPortlet can be used for menu options that redirect directly 
   * to a URL outside of the portal.
   *
   * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
   * @version $Id: RedirectPortlet.java,v 1.1 2004/02/03 19:37:08 taylor Exp $
   */
  public class RedirectPortlet extends AbstractInstancePortlet
  {           
      private static final JetspeedLogger logger = JetspeedLogFactoryService.getLogger(RedirectPortlet.class.getName());
     
      
      public ConcreteElement getContent(RunData rundata)
      {
          String menuLevel = this.getPortletConfig().getInitParameter("menuLevel");      
 
          int menus = 1;        
          try 
          {
              if (menuLevel != null)
              {
                  menus = Integer.parseInt(menuLevel);
              }
          }
          catch (Exception e)
          {
              logger.error("failed to parse menu level from Redirect Portlet");
          }
          
          // clear the pane ids of all parents so we don't get lock out the portal on return
by recursive redirection
          PortletSet set = this.getPortletConfig().getPortletSet();
          int count = 0;
          while (set != null && count <= menus)
          {
              clearState(rundata, set);
              set = set.getPortletConfig().getPortletSet();
              count++;
          }
                       
          String url = this.getPortletConfig().getInitParameter("url");
          rundata.setRedirectURI(url);
          HttpServletRequest request = rundata.getRequest();
          HttpServletResponse response = rundata.getResponse();
          try
          {
              response.sendRedirect(url);
          }
          catch (IOException e)
          {
              String message = "Failed to redirect to " + url;
              logger.error(message, e);
              return new JetspeedClearElement(message);
          }
          return new JetspeedClearElement(url);        
      }
      
      private void clearState(RunData rundata, PortletSet set)
      {
          SessionState state = ((JetspeedRunData)rundata).getPortletSessionState(set.getID());
          state.setAttribute(JetspeedResources.PATH_PANEID_KEY, null);
      }
  }
  
  
  
  1.46      +19 -0     jakarta-jetspeed/webapp/WEB-INF/conf/demo-portlets.xreg
  
  Index: demo-portlets.xreg
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/webapp/WEB-INF/conf/demo-portlets.xreg,v
  retrieving revision 1.45
  retrieving revision 1.46
  diff -u -r1.45 -r1.46
  --- demo-portlets.xreg	3 Feb 2004 04:26:16 -0000	1.45
  +++ demo-portlets.xreg	3 Feb 2004 19:37:08 -0000	1.46
  @@ -774,4 +774,23 @@
           <parameter name="simulateDelay" value="2" hidden="false" cachedOnName="true"
cachedOnValue="true"/>
           <category group="Jetspeed">finance.stocks</category>
       </portlet-entry>
  +    <portlet-entry name="RedirectToJetspeed" hidden="false" type="ref" parent="RedirectPortlet"
application="false">
  +        <meta-info>
  +            <title>Redirect to Jetspeed</title>
  +            <description>From a menu option (pane), redirect to a URL outside the
portal</description>
  +        </meta-info>
  +        <parameter name="url" value="http://jakarta.apache.org/jetspeed" hidden="false"/>
  +        <security-ref parent="default"/>
  +        <category>demo</category>
  +    </portlet-entry>
  +    <portlet-entry name="RedirectToApache" hidden="false" type="ref" parent="RedirectPortlet"
application="false">
  +        <meta-info>
  +            <title>Redirect to Apache</title>
  +        <description>From a menu option (pane), redirect to a URL outside the portal</description>
  +        </meta-info>
  +        <parameter name="url" value="http://www.apache.org" hidden="false"/>
  +        <security-ref parent="default"/>
  +        <category>demo</category>
  +    </portlet-entry>
  +
   </registry>
  
  
  
  1.45      +22 -0     jakarta-jetspeed/webapp/WEB-INF/conf/portlets.xreg
  
  Index: portlets.xreg
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/webapp/WEB-INF/conf/portlets.xreg,v
  retrieving revision 1.44
  retrieving revision 1.45
  diff -u -r1.44 -r1.45
  --- portlets.xreg	3 Feb 2004 04:26:16 -0000	1.44
  +++ portlets.xreg	3 Feb 2004 19:37:08 -0000	1.45
  @@ -305,4 +305,26 @@
           </parameter>
           <category>applet</category>
       </portlet-entry>
  +    <portlet-entry name="RedirectPortlet" hidden="false" type="abstract" application="false">
  +        <classname>org.apache.jetspeed.portal.portlets.RedirectPortlet</classname>
  +        <meta-info>
  +            <title>Redirect Portlet</title>
  +            <description>Redirects the portal to the configured URL when associated
with a Jetspeed menu.</description>
  +        </meta-info>
  +        <media-type ref="html"/>
  +        <media-type ref="wml"/>
  +        <parameter name="url" value="http://jakarta.apache.org" hidden="false">
  +            <meta-info>
  +                <title>URL</title>
  +                <description>Redirects a menu option to this URL</description>
  +            </meta-info>
  +        </parameter>
  +        <parameter name="menuLevel" value="1" hidden="false">
  +            <meta-info>
  +                <title>Menu Level</title>
  +                <description>Number (integer) of menus to clear the pane state for</description>
  +            </meta-info>
  +        </parameter>
  +        <category>web</category>
  +    </portlet-entry>
   </registry>
  
  
  

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


Mime
View raw message