@Override
public String execute(String previousOut, RenderContext renderContext, Resource resource, RenderChain chain)
throws Exception {
try {
final JahiaUserRequestWrapper request = new JahiaUserRequestWrapper(renderContext.getUser(), renderContext.getRequest(), renderContext.getMainResource().getWorkspace());
final HttpServletResponse response = renderContext.getResponse();
final ServletContext servletContext = Jahia.getStaticServletConfig().getServletContext();
final PortletContainer container = (PortletContainer) servletContext.getAttribute(AttributeKeys.PORTLET_CONTAINER);
final PortalRequestContext portalRequestContext = new PortalRequestContext(servletContext, request, response);
final PortalURL portalURL = portalRequestContext.getRequestedPortalURL();
final String actionWindowId = portalURL.getActionWindow();
final String resourceWindowId = portalURL.getResourceWindow();
PortletWindowConfig actionWindowConfig = null;
PortletWindowConfig resourceWindowConfig = null;
if (resourceWindowId != null) {
resourceWindowConfig = PortletWindowConfig.fromId(resourceWindowId);
} else if (actionWindowId != null) {
actionWindowConfig = PortletWindowConfig.fromId(actionWindowId);
}
// Action window config will only exist if there is an action request.
if (actionWindowConfig != null) {
flushPortletCache(renderContext.getUser(), actionWindowConfig, renderContext.getMainResource().getWorkspace());
PortletWindowImpl portletWindow = new PortletWindowImpl(container, actionWindowConfig, portalURL);
//if (logger.isDebugEnabled()) {
logger.debug("Processing action request for window: "
+ portletWindow.getId().getStringId());
//}
EntryPointInstance entryPointInstance = ServicesRegistry.getInstance().getApplicationsManagerService().getEntryPointInstance(actionWindowConfig.getMetaInfo(), renderContext.getMainResource().getWorkspace());
if (entryPointInstance != null) {
request.setEntryPointInstance(entryPointInstance);
} else {
logger.warn("Couldn't find related entryPointInstance, roles might not work properly !");
}
// copy jahia attibutes nested by the portlet