// process the response
consumer.getSessionHandler().updateSessionIfNeeded(markupResponse.getSessionContext(), invocation,
requestPrecursor.getPortletHandle());
MarkupContext markupContext = markupResponse.getMarkupContext();
String markup = markupContext.getMarkupString();
byte[] binary = markupContext.getMarkupBinary();
if (markup != null && binary != null)
{
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.isUseCachedMarkup())
{
//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.isRequiresUrlRewriting()));
}
else
{
// todo: need to deal with binary
}
String mimeType = markupContext.getMimeType();
if (mimeType == null || mimeType.length() == 0)
{
return new ErrorResponse(new IllegalArgumentException("No MIME type was provided for portlet content."));
}
// generate appropriate CacheControl
org.gatein.pc.api.cache.CacheControl cacheControl = createCacheControl(markupContext);
FragmentResponse result = new FragmentResponse(null, null, mimeType, null, markup,
markupContext.getPreferredTitle(), cacheControl, invocation.getPortalContext().getModes());
log.debug("Response processed");
return result;
}