{
String message = "Failed to find Servlet context for Portlet Application: " + portletApplicationName;
log.error(message);
throw new PortletException(message);
}
PortletInstance portletInstance = portletFactory.getPortletInstance(appContext, portletDefinition);
RequestDispatcher dispatcher = appContext.getRequestDispatcher(servletMappingName);
if (null == dispatcher)
{
String message =
"Failed to get Request Dispatcher for Portlet Application: "
+ portletApplicationName
+ ", servlet: "
+ servletMappingName;
log.error(message);
throw new PortletException(message);
}
// gather all required data from request and response
ServletRequest servletRequest = this.requestResponseUnwrapper.unwrapPortletRequest(portletRequest);
ServletResponse servletResponse = this.requestResponseUnwrapper.unwrapPortletResponse(portletResponse);
try
{
RequestContext requestContext = (RequestContext) servletRequest.getAttribute(PortalReservedParameters.REQUEST_CONTEXT_ATTRIBUTE);
if (isParallelMode)
{
synchronized (servletRequest)
{
servletRequest.setAttribute(ContainerConstants.PORTLET, portletInstance);
servletRequest.setAttribute(ContainerConstants.PORTLET_CONFIG, portletInstance.getConfig());
servletRequest.setAttribute(ContainerConstants.PORTLET_REQUEST, portletRequest);
servletRequest.setAttribute(ContainerConstants.PORTLET_RESPONSE, portletResponse);
servletRequest.setAttribute(ContainerConstants.METHOD_ID, methodID);
servletRequest.setAttribute(ContainerConstants.PORTLET_NAME, app.getName()+"::"+portletDefinition.getName());
servletRequest.setAttribute(ContainerConstants.PORTAL_CONTEXT, ((HttpServletRequest) servletRequest).getContextPath());
}
}
else
{
servletRequest.setAttribute(ContainerConstants.PORTLET, portletInstance);
servletRequest.setAttribute(ContainerConstants.PORTLET_CONFIG, portletInstance.getConfig());
servletRequest.setAttribute(ContainerConstants.PORTLET_REQUEST, portletRequest);
servletRequest.setAttribute(ContainerConstants.PORTLET_RESPONSE, portletResponse);
servletRequest.setAttribute(ContainerConstants.METHOD_ID, methodID);
servletRequest.setAttribute(ContainerConstants.PORTLET_NAME, app.getName()+"::"+portletDefinition.getName());
servletRequest.setAttribute(ContainerConstants.PORTAL_CONTEXT, requestContext.getRequest().getContextPath());
}
// Store same request attributes into the worker in parallel mode.
if (isParallelMode)
{
CurrentWorkerContext.setAttribute(ContainerConstants.PORTLET, portletInstance);
CurrentWorkerContext.setAttribute(ContainerConstants.PORTLET_CONFIG, portletInstance.getConfig());
CurrentWorkerContext.setAttribute(ContainerConstants.PORTLET_REQUEST, portletRequest);
CurrentWorkerContext.setAttribute(ContainerConstants.PORTLET_RESPONSE, portletResponse);
CurrentWorkerContext.setAttribute(ContainerConstants.METHOD_ID, methodID);
CurrentWorkerContext.setAttribute(ContainerConstants.PORTLET_NAME, app.getName()+"::"+portletDefinition.getName());
CurrentWorkerContext.setAttribute(ContainerConstants.PORTAL_CONTEXT, ((HttpServletRequest) servletRequest).getContextPath());