[jboss-jira] [JBoss JIRA] Commented: (JBPORTAL-2436) JBPC 2.0 : ResourceResponse.setCharacterEncoding always throws UnsupportedOperationException

Bernard de Terwangne (JIRA) jira-events at lists.jboss.org
Tue Aug 4 04:12:29 EDT 2009


    [ https://jira.jboss.org/jira/browse/JBPORTAL-2436?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12478739#action_12478739 ] 

Bernard de Terwangne commented on JBPORTAL-2436:
------------------------------------------------

Thomas,

Good question. JSR-286 explicitly states that calling setContentType is no longer required as it was in JSR-168. For the default value, they write : "If the portlet does not specify a content type before the getWriter or getPortletOutputStream methods the portlet container assumes the content type of the PortletRequest.getResponseContentType() method and resolves wildcards on a best-can-do basis." 

On the other hand it seems that the spec writers assumed that setContentType should be used only to set the media type at least for render requests : "For the render response the setContentType method must throw an IllegalArgumentException if the content type set does not match (including wildcard matching) any of the content types returned by the getResponseContentType method of the PortletRequest objectcxii. For the render response the portlet container should ignore any character encoding specified as part of the content type and treat the content type as if the character encoding was not specified.". Nothing is clear for resource phase.

It looks like the assume the default media type (in case setCharacterEncoding is called with no call on setContentType) should be PortletRequest.getResponseContentType() that would be either the portal default or the first media type from portlet.xml.

All this is very unclear. I can tell you that the current version of Liferay continues throwing an exception if you don't call setContentType before getWriter ignoring the spec change mentionned earlier.

It would make sence for me to throw ex exception in getWriter if the user has called setCharacterEncoding but not setContentType (that is you have to set content type header but don't know the media type).

Hope it does not give you too many nightmares.

Bernard

> JBPC 2.0 : ResourceResponse.setCharacterEncoding always throws UnsupportedOperationException
> --------------------------------------------------------------------------------------------
>
>                 Key: JBPORTAL-2436
>                 URL: https://jira.jboss.org/jira/browse/JBPORTAL-2436
>             Project: JBoss Portal
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>          Components: Portal Core
>    Affects Versions: Portlet-2.0
>         Environment: Any
>            Reporter: Bernard de Terwangne
>
> package org.jboss.portal.portlet.impl.jsr168.api;
> ...
> public class ResourceResponseImpl extends MimeResponseImpl implements ResourceResponse
> {
> ...
>    public void setLocale(Locale locale)
>    {
>       throw new UnsupportedOperationException();
>    }
>    public void setCharacterEncoding(String s)
>    {
>       throw new UnsupportedOperationException();
>    }
>    public void setContentLength(int i)
>    {
>       throw new UnsupportedOperationException();
>    }
> ...
> }
> Problems come when you want to deploy your portlet on JBoss PortletContainer and on other portals. JSR-286 does not state that portals my throw UnsupportedOperationException.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the jboss-jira mailing list