instanceContext = createInstanceContext(portletContext, getAccessMode(), portletInstanceKey);
WindowContext windowContext = createWindowContext(portletContext.getId(), runtimeContext);
// prepare the invocation
WSRPPortletInvocationContext context = new WSRPPortletInvocationContext(mediaType, securityContext, portalContext, userContext, instanceContext, windowContext);
PortletInvocation invocation = initInvocation(context);
// mark the invocation as coming from WSRP
final HashMap<String, Object> attributes = new HashMap<String, Object>();
attributes.put(WSRPConstants.FROM_WSRP_ATTRIBUTE_NAME, Boolean.TRUE);
invocation.setRequestAttributes(attributes);
invocation.setTarget(portlet.getContext());
invocation.setWindowState(WSRPUtils.getJSR168WindowStateFromWSRPName(markupRequest.getWindowState()));
invocation.setMode(WSRPUtils.getJSR168PortletModeFromWSRPName(markupRequest.getMode()));
NavigationalContext navigationalContext = params.getNavigationalContext();
if (navigationalContext != null)
{
StateString navigationalState = createNavigationalState(navigationalContext.getOpaqueValue());
invocation.setNavigationalState(navigationalState);
List<NamedString> publicParams = navigationalContext.getPublicValues();
if (ParameterValidation.existsAndIsNotEmpty(publicParams))
{
Map<String, String[]> publicNS = WSRPUtils.createPublicNSFrom(publicParams);
invocation.setPublicNavigationalState(publicNS);
}
}
context.contextualize(invocation);
setInvocation(invocation);