Author: julien(a)jboss.com
Date: 2008-03-18 21:02:18 -0400 (Tue, 18 Mar 2008)
New Revision: 10322
Modified:
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/AbstractPortletControllerContext.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/RenderResponseImpl.java
Log:
updated portlet module to use the new media type and media type map
Modified:
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/AbstractPortletControllerContext.java
===================================================================
---
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/AbstractPortletControllerContext.java 2008-03-19
00:41:18 UTC (rev 10321)
+++
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/AbstractPortletControllerContext.java 2008-03-19
01:02:18 UTC (rev 10322)
@@ -24,8 +24,8 @@
package org.jboss.portal.portlet.controller.impl;
import org.jboss.portal.common.util.MarkupInfo;
-import org.jboss.portal.common.util.MediaType;
import org.jboss.portal.common.io.Serialization;
+import org.jboss.portal.common.net.media.MediaType;
import org.jboss.portal.portlet.Portlet;
import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.controller.PortletControllerContext;
@@ -70,7 +70,7 @@
public static final PortalContext PORTAL_CONTEXT = new
AbstractPortalContext(Collections.singletonMap("javax.portlet.markup.head.element.support",
"true"));
/** . */
- public static final MarkupInfo MARKUP_INFO = new MarkupInfo(MediaType.HTML,
"UTF8");
+ public static final MarkupInfo MARKUP_INFO = new MarkupInfo(MediaType.TEXT_HTML,
"UTF8");
/** . */
public static final int NAV_SCOPE = 0;
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestImpl.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestImpl.java 2008-03-19
00:41:18 UTC (rev 10321)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestImpl.java 2008-03-19
01:02:18 UTC (rev 10322)
@@ -28,7 +28,6 @@
import org.jboss.portal.common.util.MultiValuedPropertyMap;
import org.jboss.portal.common.util.SimpleMultiValuedPropertyMap;
import org.jboss.portal.common.util.ContentInfo;
-import org.jboss.portal.common.net.media.MediaType;
import org.jboss.portal.portlet.impl.jsr168.PortletApplicationImpl;
import org.jboss.portal.portlet.impl.jsr168.PortletContainerImpl;
import org.jboss.portal.portlet.impl.jsr168.PortletUtils;
@@ -366,7 +365,7 @@
public String getResponseContentType()
{
- return invocation.getContext().getMarkupInfo().getContentType().toString();
+ return invocation.getContext().getMarkupInfo().getContentType().getValue();
}
public Enumeration<String> getResponseContentTypes()
@@ -579,17 +578,13 @@
{
// Get content type
ContentInfo si = invocation.getContext().getMarkupInfo();
- String contentType = si.getContentType().toString();
- //
- MediaType mediaType = MediaType.create(contentType);
-
// Get the modes for this content type
CapabilitiesInfo capabilities = container.getInfo().getCapabilities();
// Add all the modes
Set<Mode> modes = new HashSet<Mode>();
- for (ModeInfo modeInfo : capabilities.getModes(mediaType))
+ for (ModeInfo modeInfo : capabilities.getModes(si.getContentType()))
{
modes.add(modeInfo.getMode());
}
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/RenderResponseImpl.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/RenderResponseImpl.java 2008-03-19
00:41:18 UTC (rev 10321)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/RenderResponseImpl.java 2008-03-19
01:02:18 UTC (rev 10322)
@@ -31,11 +31,9 @@
import org.jboss.portal.portlet.info.ModeInfo;
import org.jboss.portal.portlet.cache.CacheControl;
import org.jboss.portal.Mode;
-import org.jboss.portal.common.util.MediaType;
import javax.portlet.RenderResponse;
import javax.portlet.PortletMode;
-import javax.activation.MimeTypeParseException;
import java.util.Collection;
import java.util.Set;
import java.util.LinkedHashSet;
@@ -104,58 +102,45 @@
public void setContentType(String contentType)
{
- try
+ // Remove the unused appended charset first
+ int index = contentType.indexOf(';');
+ if (index != -1)
{
- // Remove the unused appended charset first
- int index = contentType.indexOf(';');
- if (index != -1)
- {
- contentType = contentType.substring(0, index);
- }
+ contentType = contentType.substring(0, index);
+ }
- // Find the content type among the media type we know
- MediaType requestedMediaType = MediaType.parseMimeType(contentType);
-
- // Get the response media type
+ // Get the response media type
// ContentInfo info = invocation.getContext().getMarkupInfo();
// MediaType responseMediaType = info.getContentType();
- // Check if the requested media type is allowed as a subtype of the main
response
+ // Check if the requested media type is allowed as a subtype of the main response
// if (!responseMediaType.isAllowedSubType(requestedMediaType))
// {
// throw new IllegalArgumentException("Content type not accepted");
// }
- //
- Mode currentMode = preq.invocation.getMode();
+ //
+ Mode currentMode = preq.invocation.getMode();
- org.jboss.portal.common.net.media.MediaType mediaType =
org.jboss.portal.common.net.media.MediaType.create(contentType);
+ org.jboss.portal.common.net.media.MediaType mediaType =
org.jboss.portal.common.net.media.MediaType.create(contentType);
- PortletInfo info = preq.container.getInfo();
- CapabilitiesInfo capabilities = info.getCapabilities();
- Set<ModeInfo> compatibleModes = capabilities.getModes(mediaType);
- for (ModeInfo modeInfo : compatibleModes)
+ PortletInfo info = preq.container.getInfo();
+ CapabilitiesInfo capabilities = info.getCapabilities();
+ Set<ModeInfo> compatibleModes = capabilities.getModes(mediaType);
+ for (ModeInfo modeInfo : compatibleModes)
+ {
+ if (currentMode.equals(modeInfo.getMode()))
{
- if (currentMode.equals(modeInfo.getMode()))
- {
- // Set the content type
- super.setContentType(contentType);
+ // Set the content type
+ super.setContentType(contentType);
- //
- return;
- }
+ //
+ return;
}
-
- //
- throw new IllegalArgumentException("Mime type " + contentType + "
not accepted as content type");
-
}
- catch (MimeTypeParseException e)
- {
- IllegalArgumentException ex = new IllegalArgumentException("Content type
not accepted");
- ex.initCause(e);
- throw ex;
- }
+
+ //
+ throw new IllegalArgumentException("Mime type " + contentType + "
not accepted as content type");
}
protected ContentResponse createMarkupResponse(ResponseProperties properties,
Map<String, Object> attributeMap, String contentType, byte[] bytes, String chars,
CacheControl cacheControl)
Show replies by date