You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pluto-dev@portals.apache.org by bl...@apache.org on 2004/01/16 13:24:01 UTC

cvs commit: jakarta-pluto/portal/src/java/org/apache/pluto/portalImpl/om/portlet/impl ContentTypeSetImpl.java ContentTypeImpl.java

blumm       2004/01/16 04:24:01

  Modified:    container/src/java/org/apache/pluto/om/portlet
                        ContentTypeSet.java ContentType.java
               container/src/java/org/apache/pluto/core/impl
                        ActionResponseImpl.java PortletRequestImpl.java
                        PortletModeHelper.java
               portal/src/java/org/apache/pluto/portalImpl/om/portlet/impl
                        ContentTypeSetImpl.java ContentTypeImpl.java
  Log:
  Problem:  setPortletMode() at the ActionResponse fails, if the original
  Request comes from an HTML Form.
  The internal implementation is testing the HttpServletRequest.getContentType()
  against the Portlet's mime types. In the case of an HTML form in IE6
  getContentType() results in application/x-www-form-urlencoded.
  This finally leads into a PortletModeException. 
  PR:26193
  Obtained from:
  Submitted by:	
  Reviewed by:	
  CVS: ----------------------------------------------------------------------
  CVS: PR:
  CVS:   If this change addresses a PR in the problem report tracking
  CVS:   database, then enter the PR number(s) here.
  CVS: Obtained from:
  CVS:   If this change has been taken from another system, such as NCSA,
  CVS:   then name the system in this line, otherwise delete it.
  CVS: Submitted by:
  CVS:   If this code has been contributed to Apache by someone else; i.e.,
  CVS:   they sent us a patch or a new module, then include their name/email
  CVS:   address here. If this is your work then delete this line.
  CVS: Reviewed by:
  CVS:   If we are doing pre-commit code reviews and someone else has
  CVS:   reviewed your changes, include their name(s) here.
  CVS:   If you have not had it reviewed then delete this line.
  
  Revision  Changes    Path
  1.2       +6 -0      jakarta-pluto/container/src/java/org/apache/pluto/om/portlet/ContentTypeSet.java
  
  Index: ContentTypeSet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-pluto/container/src/java/org/apache/pluto/om/portlet/ContentTypeSet.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ContentTypeSet.java	7 Jan 2004 20:37:19 -0000	1.1
  +++ ContentTypeSet.java	16 Jan 2004 12:24:00 -0000	1.2
  @@ -86,5 +86,11 @@
        * @return the content type object
        */
       public ContentType get(String contentType);
  +    
  +	/**
  +	 * Return true if the given portlet mode is supported for any content type
  +	 * in this set.
  +	 */
  +	public boolean supportsPortletMode(javax.portlet.PortletMode portletMode);
   
   }
  
  
  
  1.2       +5 -0      jakarta-pluto/container/src/java/org/apache/pluto/om/portlet/ContentType.java
  
  Index: ContentType.java
  ===================================================================
  RCS file: /home/cvs/jakarta-pluto/container/src/java/org/apache/pluto/om/portlet/ContentType.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ContentType.java	7 Jan 2004 20:37:19 -0000	1.1
  +++ ContentType.java	16 Jan 2004 12:24:00 -0000	1.2
  @@ -89,4 +89,9 @@
        */
       public java.util.Iterator getPortletModes();
   
  +	/**
  +	 * Returns true if the given portlet mode is supported for this content type.
  +	 * @return boolean
  +	 */
  +	public boolean supportsPortletMode(javax.portlet.PortletMode portletMode);
   }
  
  
  
  1.2       +5 -1      jakarta-pluto/container/src/java/org/apache/pluto/core/impl/ActionResponseImpl.java
  
  Index: ActionResponseImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-pluto/container/src/java/org/apache/pluto/core/impl/ActionResponseImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ActionResponseImpl.java	7 Jan 2004 20:37:17 -0000	1.1
  +++ ActionResponseImpl.java	16 Jan 2004 12:24:00 -0000	1.2
  @@ -126,7 +126,10 @@
           boolean supported = provider.isPortletModeAllowed(portletMode);
   
           // check if portlet supports portlet mode as well
  -        supported &= PortletModeHelper.isPortletModeAllowedByPortlet(getInternalPortletWindow(), this.getHttpServletRequest().getContentType(), portletMode);
  +        if (supported)
  +        {
  +            supported = PortletModeHelper.isPortletModeAllowedByPortlet(getInternalPortletWindow(), portletMode);
  +        }
   
           // if porlet mode is allowed
           if (supported) {
  @@ -135,6 +138,7 @@
               throw new PortletModeException("Can't set this PortletMode",portletMode);
   
           redirectAllowed = false;
  +
       }
   
       public void sendRedirect(String location) throws java.io.IOException
  
  
  
  1.2       +1 -3      jakarta-pluto/container/src/java/org/apache/pluto/core/impl/PortletRequestImpl.java
  
  Index: PortletRequestImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-pluto/container/src/java/org/apache/pluto/core/impl/PortletRequestImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PortletRequestImpl.java	7 Jan 2004 20:37:18 -0000	1.1
  +++ PortletRequestImpl.java	16 Jan 2004 12:24:00 -0000	1.2
  @@ -130,9 +130,7 @@
           // check if portlet supports portlet mode as well
           if (supported)
           {
  -            supported = PortletModeHelper.isPortletModeAllowedByPortlet(portletWindow,
  -                                                                        this._getHttpServletRequest().getContentType(),
  -                                                                        portletMode);
  +            supported = PortletModeHelper.isPortletModeAllowedByPortlet(portletWindow, portletMode);
           }
   
           return supported;
  
  
  
  1.2       +9 -21     jakarta-pluto/container/src/java/org/apache/pluto/core/impl/PortletModeHelper.java
  
  Index: PortletModeHelper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-pluto/container/src/java/org/apache/pluto/core/impl/PortletModeHelper.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PortletModeHelper.java	7 Jan 2004 20:37:18 -0000	1.1
  +++ PortletModeHelper.java	16 Jan 2004 12:24:00 -0000	1.2
  @@ -57,31 +57,19 @@
   
   package org.apache.pluto.core.impl;
   
  -import java.util.Iterator;
  -
   import javax.portlet.PortletMode;
   
  -import org.apache.pluto.om.portlet.ContentType;
   import org.apache.pluto.om.window.PortletWindow;
   
   public class PortletModeHelper
   {
  -    public static boolean isPortletModeAllowedByPortlet(PortletWindow portletWindow, 
  -                                                        String contentType, 
  -                                                        PortletMode portletMode) 
  -    {
  -        // check if portlet supports portlet mode
  -        boolean supported = false;
  -        ContentType ct = portletWindow.getPortletEntity().getPortletDefinition().getContentTypeSet().get(contentType);
  -        if (ct == null)
  -        {
  -            return false;
  -        }
  -        Iterator modes = ct.getPortletModes();
  -        while (!supported && modes.hasNext())
  -        {
  -            supported = ((PortletMode)modes.next()).equals(portletMode);
  -        }
  -        return supported;
  -    }
  +	public static boolean isPortletModeAllowedByPortlet(PortletWindow portletWindow, 
  +														PortletMode portletMode) 
  +	{
  +		// check if portlet supports portlet mode
  +		boolean supported = portletWindow.getPortletEntity().getPortletDefinition().getContentTypeSet().supportsPortletMode(portletMode);
  +       
  +		return supported;
  +	}
  +
   }
  
  
  
  1.2       +39 -3     jakarta-pluto/portal/src/java/org/apache/pluto/portalImpl/om/portlet/impl/ContentTypeSetImpl.java
  
  Index: ContentTypeSetImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-pluto/portal/src/java/org/apache/pluto/portalImpl/om/portlet/impl/ContentTypeSetImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ContentTypeSetImpl.java	7 Jan 2004 20:37:22 -0000	1.1
  +++ ContentTypeSetImpl.java	16 Jan 2004 12:24:00 -0000	1.2
  @@ -57,17 +57,23 @@
   
   package org.apache.pluto.portalImpl.om.portlet.impl;
   
  -import org.apache.pluto.om.portlet.*;
  -import org.apache.pluto.util.StringUtils;
  -import java.util.*;
  +import java.util.ArrayList;
  +import java.util.Collection;
  +import java.util.Iterator;
   
  +import org.apache.pluto.om.portlet.ContentType;
  +import org.apache.pluto.om.portlet.ContentTypeSet;
   import org.apache.pluto.portalImpl.om.common.AbstractSupportSet;
  +import org.apache.pluto.util.StringUtils;
   
   public class ContentTypeSetImpl extends AbstractSupportSet
   implements ContentTypeSet, java.io.Serializable {
   
   
       // ContentTypeSet implementation.
  +
  +	// special content type that represents the union of all supported markups
  +	private ContentType anyContentType;
       
       public ContentType get(String contentType)
       {
  @@ -81,6 +87,32 @@
           return null;
       }
   
  +	// support implemenation
  +    public void postLoad(Object parameter) throws Exception
  +    {
  +    	super.postLoad(parameter);
  +    	
  +    	Collection allPortletModes = new ArrayList();
  +
  +    	Iterator contentTypes = this.iterator();
  +		while (contentTypes.hasNext()){
  +			ContentType aContentType = (ContentType)contentTypes.next();
  +			Iterator portletModes = aContentType.getPortletModes();
  +			
  +			while(portletModes.hasNext()) {
  +				Object portletMode = portletModes.next();
  +				if(!allPortletModes.contains(portletMode)) {
  +					allPortletModes.add(portletMode);	 
  +				}
  +			}
  +		}
  +		
  +		ContentTypeImpl _anyContentType = new ContentTypeImpl();
  +		_anyContentType.setPortletModes(allPortletModes);
  +		anyContentType = _anyContentType;
  +	}
  +
  +
       // additional methods.
   
       public String toString()
  @@ -100,4 +132,8 @@
           }
           return buffer.toString();
       }    
  +
  +	public boolean supportsPortletMode(javax.portlet.PortletMode portletMode) {
  +		return anyContentType.supportsPortletMode(portletMode);
  +	}
   }
  
  
  
  1.2       +4 -0      jakarta-pluto/portal/src/java/org/apache/pluto/portalImpl/om/portlet/impl/ContentTypeImpl.java
  
  Index: ContentTypeImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-pluto/portal/src/java/org/apache/pluto/portalImpl/om/portlet/impl/ContentTypeImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ContentTypeImpl.java	7 Jan 2004 20:37:22 -0000	1.1
  +++ ContentTypeImpl.java	16 Jan 2004 12:24:00 -0000	1.2
  @@ -137,6 +137,10 @@
           this.portletModes = portletModes;
       }
   
  +    public boolean supportsPortletMode(javax.portlet.PortletMode portletMode)
  +    {
  +    	return portletModes.contains(portletMode);
  +    }	
       
       public String toString()
       {