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-2/portal/src/webapp/WEB-INF/psml/user/anon/html default.psml
Date Wed, 08 Oct 2003 04:36:39 GMT
taylor      2003/10/07 21:36:39

  Modified:    applications/demo/src/java/org/apache/jetspeed/demo/preferences
                        PreferencePortlet.java
               portal/src/java/org/apache/jetspeed/engine/core
                        PortalContextProviderImpl.java
               portal/src/java/org/apache/jetspeed/services/information
                        InformationProviderServiceImpl.java
                        StaticInformationProviderImpl.java
               portal/src/webapp/WEB-INF/conf jetspeed.properties
               portal/src/webapp/WEB-INF/psml/user/anon/html default.psml
  Added:       portal/src/java/org/apache/jetspeed/engine/core
                        PortalContextImpl.java
  Log:
  Fixed nasty bug in Portal Context Provider and infinite loop.
  Jetspeed's Portal Context is now implemented, retrieving portal info and default modes and
states from the jetspeed configuration properties.
  
  Enabled the PreferencesPortlet, however it is still not listing prefs and is now receiving
an illegal state exception.
  
  Revision  Changes    Path
  1.5       +3 -2      jakarta-jetspeed-2/applications/demo/src/java/org/apache/jetspeed/demo/preferences/PreferencePortlet.java
  
  Index: PreferencePortlet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/applications/demo/src/java/org/apache/jetspeed/demo/preferences/PreferencePortlet.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- PreferencePortlet.java	13 Aug 2003 21:48:51 -0000	1.4
  +++ PreferencePortlet.java	8 Oct 2003 04:36:39 -0000	1.5
  @@ -82,6 +82,7 @@
        */
       protected void doView(RenderRequest request, RenderResponse response) throws PortletException,
IOException
       {
  +        PortletContext context = getPortletContext();        
           String attribute = (String) request.getAttribute("invokeMessage");
           if (attribute != null)
           {
  @@ -90,7 +91,7 @@
               response.getWriter().println("Got attribute set in ACTION: " + attribute +
"<br/>");
           }
           request.setAttribute("viewMessage", "My Mode is view.");
  -        PortletContext context = getPortletContext();
  +
           PortletRequestDispatcher rd = context.getRequestDispatcher("/WEB-INF/demo/preference/pref-view.jsp");
           rd.include(request, response);
       }
  
  
  
  1.4       +135 -13   jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/engine/core/PortalContextProviderImpl.java
  
  Index: PortalContextProviderImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/engine/core/PortalContextProviderImpl.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- PortalContextProviderImpl.java	6 Oct 2003 00:31:51 -0000	1.3
  +++ PortalContextProviderImpl.java	8 Oct 2003 04:36:39 -0000	1.4
  @@ -54,10 +54,15 @@
   package org.apache.jetspeed.engine.core;
   
   import java.util.Collection;
  -import java.util.Collections;
  +import java.util.Enumeration;
  +import java.util.HashMap;
  +import java.util.Vector;
  +import javax.portlet.PortletMode;
  +import javax.portlet.WindowState;
   
   import javax.portlet.PortalContext;
  -import org.apache.pluto.core.impl.PortalContextImpl;
  +
  +import org.apache.jetspeed.Jetspeed;
   import org.apache.pluto.services.information.PortalContextProvider;
   
   /**
  @@ -70,11 +75,37 @@
       implements PortalContextProvider
   {
       PortalContextImpl portalContext = null;
  +    /** Portal information */
  +
  +    private String info = null;
  +    private String portalName = null;
  +    private String portalVersion = null;
  +    
  +    /** supported portlet modes by this portal */
  +    private Vector modes;
  +
  +    /** supported window states by this portal */
  +    private Vector states;
  +
  +    /** portal properties */
  +    private HashMap properties = new HashMap();
   
   
       public PortalContextProviderImpl()
       {
  -        portalContext = new PortalContextImpl();
  +        portalContext = new PortalContextImpl(this);
  +        
  +        modes = getDefaultModes();
  +
  +        // these are the minimum states that the portal needs to support
  +
  +        states = getDefaultStates(); 
  +
  +        // set info
  +        portalName = Jetspeed.getContext().getConfiguration().getString("portal.name");
  +        portalVersion = Jetspeed.getContext().getConfiguration().getString("portal.version");
        
  +        info = portalName + "/" + portalVersion;   
  +        
       }
       
       /* (non-Javadoc)
  @@ -95,8 +126,7 @@
        */
       public String getPortalInfo()
       {
  -        
  -        return portalContext.getPortalInfo();
  +        return info;
       }
   
       /** 
  @@ -105,12 +135,16 @@
        * </p>
        * 
        * @see org.apache.pluto.services.information.PortalContextProvider#getProperty(java.lang.String)
  -     * @param arg0
  +     * @param name
        * @return
        */
  -    public String getProperty(String arg0)
  +    public String getProperty(String name)
       {        
  -        return portalContext.getProperty(arg0);
  +        if (name == null) 
  +        {
  +            throw new IllegalArgumentException("Property name == null");
  +        }
  +        return(String) properties.get(name);
       }
   
       /** 
  @@ -123,7 +157,7 @@
        */
       public Collection getPropertyNames()
       {     
  -        return Collections.list(portalContext.getPropertyNames());
  +        return properties.keySet();
       }
   
       /** 
  @@ -136,8 +170,7 @@
        */
       public Collection getSupportedPortletModes()
       {
  -        
  -        return Collections.list(portalContext.getSupportedPortletModes());
  +        return modes;
       }
   
       /** 
  @@ -150,7 +183,96 @@
        */
       public Collection getSupportedWindowStates()
       {        
  -        return Collections.list(portalContext.getSupportedWindowStates());
  +        return states;
  +    }
  +
  +    private Vector getDefaultModes()
  +    {
  +        Vector m = new Vector();
  +        String[] supportedModes = Jetspeed.getContext().getConfiguration().getStringArray("supported.portletmode");
  +        
  +        for (int i=0; i<supportedModes.length; i++) 
  +        {
  +            m.add(new PortletMode(supportedModes[i].toString().toLowerCase()));
  +        }
  +
  +        return m;
  +    }
  +
  +    private Vector getDefaultStates()
  +    {
  +        Vector s = new Vector();
  +        String[] supportedStates = Jetspeed.getContext().getConfiguration().getStringArray("supported.windowstate");
  +
  +        for (int i=0; i<supportedStates.length; i++) 
  +        {
  +            s.add(new WindowState(supportedStates[i].toString().toLowerCase()));
  +        }
  +
  +        return s;
  +    }
  +
  +    public void setProperty(String name, String value)
  +    {
  +        if (name == null) 
  +        {
  +            throw new IllegalArgumentException("Property name == null");
  +        }
  +        properties.put(name, value);
  +    }      
  +
  +    // expects enumeration of PortletMode objects
  +
  +    public void setSupportedPortletModes(Enumeration portletModes)
  +    {
  +        Vector v = new Vector();
  +
  +        while (portletModes.hasMoreElements()) 
  +        {
  +            v.add(portletModes.nextElement());
  +        }
  +
  +        modes = v;
  +    }
  +
  +
  +
  +    // expects enumeration of WindowState objects
  +
  +    public void setSupportedWindowStates(Enumeration windowStates)
  +    {
  +        Vector v = new Vector();
  +        while (windowStates.hasMoreElements()) 
  +        {
  +            v.add(windowStates.nextElement());
  +        }
  +
  +        states = v;
  +    }
  +
  +
  +
  +    /**
  +     * reset all values to default portlet modes and window states;
  +     * delete all properties and set the given portlet information
  +     * as portlet info string.
  +     * 
  +     * @param  
  +     * @param portalInfo  portal information string that will be returned
  +     *                    by the <code>getPortalInfo</code> call.
  +     */
  +    public void reset(String portalInfo)
  +
  +    {
  +        info = new String(portalInfo);
  +
  +        // these are the minimum modes that the portal needs to support
  +        modes = getDefaultModes();
  +
  +        // these are the minimum states that the portal needs to support
  +        states = getDefaultStates();    
  +
  +        properties.clear();
       }
   
   }
  
  
  
  1.1                  jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/engine/core/PortalContextImpl.java
  
  Index: PortalContextImpl.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.engine.core;
  
  import java.util.Enumeration;
  
  import javax.portlet.PortalContext;
  
  import org.apache.pluto.services.information.PortalContextProvider;
  import org.apache.pluto.util.Enumerator;
  
  /**
   * PortalContextImpl
   *
   * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
   * @version $Id: PortalContextImpl.java,v 1.1 2003/10/08 04:36:39 taylor Exp $
   */
  public class PortalContextImpl implements PortalContext
  {
      PortalContextProvider provider = null;
  
      public PortalContextImpl(PortalContextProvider provider) 
      {
          this.provider = provider;
      }
      
      /* (non-Javadoc)
       * @see javax.portlet.PortalContext#getProperty(java.lang.String)
       */
      public String getProperty(String name)
      {
          if (name == null)
          {
              throw new IllegalArgumentException("Property name == null");
          }
          return provider.getProperty(name);
      }
      
      /* (non-Javadoc)
       * @see javax.portlet.PortalContext#getPropertyNames()
       */
      public Enumeration getPropertyNames()
      {
          return(new Enumerator(provider.getPropertyNames()));
      }
      
      /* (non-Javadoc)
       * @see javax.portlet.PortalContext#getSupportedPortletModes()
       */
      public Enumeration getSupportedPortletModes()
      {
          return new Enumerator(provider.getSupportedPortletModes());
      }
      
      /* (non-Javadoc)
       * @see javax.portlet.PortalContext#getSupportedWindowStates()
       */
      public Enumeration getSupportedWindowStates()
      {
          return new Enumerator(provider.getSupportedWindowStates());        
      }
      
      /* (non-Javadoc)
       * @see javax.portlet.PortalContext#getPortalInfo()
       */
      public String getPortalInfo()
      {
          return provider.getPortalInfo();        
      }
  }
  
  
  
  1.4       +5 -10     jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/services/information/InformationProviderServiceImpl.java
  
  Index: InformationProviderServiceImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/services/information/InformationProviderServiceImpl.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- InformationProviderServiceImpl.java	6 Oct 2003 00:34:52 -0000	1.3
  +++ InformationProviderServiceImpl.java	8 Oct 2003 04:36:39 -0000	1.4
  @@ -57,13 +57,8 @@
   import org.apache.commons.logging.LogFactory;
   import org.apache.fulcrum.BaseService;
   import org.apache.fulcrum.InitializationException;
  -import org.apache.jetspeed.engine.core.PortalContextProviderImpl;
  -import org.apache.jetspeed.engine.core.PortalURL;
  -import org.apache.jetspeed.engine.core.PortletActionProviderImpl;
   import org.apache.pluto.factory.Factory;
   import org.apache.pluto.services.information.DynamicInformationProvider;
  -import org.apache.pluto.services.information.PortalContextProvider;
  -import org.apache.pluto.services.information.PortletActionProvider;
   import org.apache.pluto.services.information.StaticInformationProvider;
   
   /**
  @@ -115,14 +110,14 @@
       public DynamicInformationProvider getDynamicProvider(javax.servlet.http.HttpServletRequest
request)
       {
           DynamicInformationProvider provider =
  -            (DynamicInformationProvider) request.getAttribute("org.apache.engine.core.DynamicInformationProvider");
  +            (DynamicInformationProvider) request.getAttribute("org.apache.jetspeed.engine.core.DynamicInformationProvider");
   
           log.info("Dynamic information provider " + provider);
   
           if (provider == null)
           {
               provider = new DynamicInformationProviderImpl(request, servletConfig);
  -            request.setAttribute("org.apache.engine.core.DynamicInformationProvider", provider);
  +            request.setAttribute("org.apache.jetspeed.engine.core.DynamicInformationProvider",
provider);
           }
   
           return provider;
  @@ -143,7 +138,7 @@
       //
       //        return provider;
       //    }
  -    //	
  +
       //    public PortletActionProvider getPortletActionProvider(javax.servlet.http.HttpServletRequest
request)
       //    {
       //        PortletActionProvider provider =
  @@ -151,7 +146,7 @@
       //
       //        if (provider == null)
       //        {
  -    //        	        	
  +
       //            provider = new PortletActionProviderImpl(request, servletConfig);
       //            request.setAttribute("org.apache.engine.core.PortletActionProvider",
provider);
       //        }
  
  
  
  1.3       +3 -3      jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/services/information/StaticInformationProviderImpl.java
  
  Index: StaticInformationProviderImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/services/information/StaticInformationProviderImpl.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- StaticInformationProviderImpl.java	6 Oct 2003 00:34:52 -0000	1.2
  +++ StaticInformationProviderImpl.java	8 Oct 2003 04:36:39 -0000	1.3
  @@ -105,12 +105,12 @@
               javax.servlet.ServletContext context = config.getServletContext();
   
               PortalContextProvider provider =
  -                (PortalContextProvider) context.getAttribute("org.apache.engine.core.PortalContextProvider");
  +                (PortalContextProvider) context.getAttribute("org.apache.jetspeed.engine.core.PortalContextProvider");
   
               if (provider == null)
               {
                   provider = new PortalContextProviderImpl();
  -                context.setAttribute("org.apache.engine.core.PortalContextProvider", provider);
  +                context.setAttribute("org.apache.jetspeed.engine.core.PortalContextProvider",
provider);
               }
   
               return provider;
  
  
  
  1.6       +4 -1      jakarta-jetspeed-2/portal/src/webapp/WEB-INF/conf/jetspeed.properties
  
  Index: jetspeed.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/webapp/WEB-INF/conf/jetspeed.properties,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- jetspeed.properties	7 Oct 2003 04:44:52 -0000	1.5
  +++ jetspeed.properties	8 Oct 2003 04:36:39 -0000	1.6
  @@ -6,6 +6,9 @@
   #
   # ------------------------------------------------------------------------
   
  +portal.name = Jetspeed
  +portal.version = 2.0
  +
   # -------------------------------------------------------------------
   #  Portlet Mode Support
   # -------------------------------------------------------------------
  
  
  
  1.5       +1 -1      jakarta-jetspeed-2/portal/src/webapp/WEB-INF/psml/user/anon/html/default.psml
  
  Index: default.psml
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/webapp/WEB-INF/psml/user/anon/html/default.psml,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- default.psml	7 Oct 2003 21:38:17 -0000	1.4
  +++ default.psml	8 Oct 2003 04:36:39 -0000	1.5
  @@ -12,6 +12,6 @@
       <entry type="ref" name="CustomerInfo" parent="CustomerInfo"/>
       <entry type="ref" name="CustomerDetail" parent="CustomerDetail"/>
       <entry type="ref" name="JMXPortlet" parent="JMXPortlet"/>
  -<!--    <entry type="ref" name="PreferencePortlet" parent="PreferencePortlet"/>
-->
  +    <entry type="ref" name="PreferencePortlet" parent="PreferencePortlet"/> 
       
   </portlets>
  
  
  

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