Author: chris.laprun(a)jboss.com
Date: 2007-07-16 23:52:40 -0400 (Mon, 16 Jul 2007)
New Revision: 7792
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/RenderHandler.java
Log:
- JBPORTAL-1589: Better handling of invalid response from producers.
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/RenderHandler.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/RenderHandler.java 2007-07-17
02:48:08 UTC (rev 7791)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/RenderHandler.java 2007-07-17
03:52:40 UTC (rev 7792)
@@ -101,9 +101,23 @@
byte[] binary = markupContext.getMarkupBinary();
if (markup != null && binary != null)
{
- return new ErrorResponse(new IllegalArgumentException("Markup response
cannot contain both string and binary markup."));
+ return new ErrorResponse(new IllegalArgumentException("Markup response
cannot contain both string and binary " +
+ "markup. Per Section 6.1.10 of the WSRP specification, this is a
Producer error."));
}
+ if (markup == null && binary == null)
+ {
+ if (markupContext.getUseCachedMarkup().booleanValue())
+ {
+ //todo: deal with cache
+ }
+ else
+ {
+ return new ErrorResponse(new IllegalArgumentException("Markup response
must contain at least string or binary" +
+ " markup. Per Section 6.1.10 of the WSRP specification, this is a
Producer error."));
+ }
+ }
+
if (markup != null && markup.length() > 0)
{
markup = processMarkup(markup, invocation,
Boolean.TRUE.equals(markupContext.getRequiresUrlRewriting()));
@@ -114,7 +128,14 @@
}
FragmentResponse result = new FragmentResponse();
- result.setContentType(markupContext.getMimeType());
+
+ String mimeType = markupContext.getMimeType();
+ if (mimeType == null || mimeType.length() == 0)
+ {
+ return new ErrorResponse(new IllegalArgumentException("No MIME type was
provided for portlet content."));
+ }
+ result.setContentType(mimeType);
+
result.setTitle(markupContext.getPreferredTitle());
// cache markup if possible
Show replies by date