ExoPortletInvocationContext portletInvocationContext = new ExoPortletInvocationContext(prcontext, uiPortlet_);
List<Cookie> requestCookies = new ArrayList<Cookie>(Arrays.asList(prcontext.getRequest().getCookies()));
RenderInvocation renderInvocation = new RenderInvocation(portletInvocationContext);
renderInvocation.setClientContext(new AbstractClientContext(prcontext.getRequest(), requestCookies));
renderInvocation.setServerContext(new AbstractServerContext(prcontext.getRequest(), prcontext.getResponse()));
// instance context
InstanceContext instanceContext;
if (portletContext.getType() instanceof WSRPPortletStateType)
{
WSRP wsrp = (WSRP)portletContext.getState();
AccessMode accessMode = AccessMode.CLONE_BEFORE_WRITE;
if (wsrp.isCloned())
{
accessMode = AccessMode.READ_WRITE;
}
instanceContext = new ExoPortletInstanceContext(wsrp.getPortletId(), accessMode);
}
else
{
ExoPortletState exo = (ExoPortletState)portletContext.getState();
instanceContext = new ExoPortletInstanceContext(exo.getPortletId());
}
renderInvocation.setInstanceContext(instanceContext);
renderInvocation.setUserContext(new AbstractUserContext(prcontext.getRequest()));
renderInvocation.setWindowContext(new AbstractWindowContext(uiPortlet_.getWindowId()));
renderInvocation.setPortalContext(new AbstractPortalContext(Collections.singletonMap(
"javax.portlet.markup.head.element.support", "true")));
renderInvocation.setSecurityContext(new AbstractSecurityContext(prcontext.getRequest()));
renderInvocation.setTarget(portletContext);
renderInvocation.setMode(Mode.create(PortletMode.EDIT.toString()));
renderInvocation.setWindowState(org.gatein.pc.api.WindowState.create(uiPortlet_.getCurrentWindowState()
.toString()));
PortletInvocationResponse portletResponse = uiPortlet_.invoke(renderInvocation);
String content;