use of org.apereo.portal.url.IPortalRequestInfo in project uPortal by Jasig.
the class PortalEventFactoryImpl method publishPortletResourceExecutionEvent.
@Override
public void publishPortletResourceExecutionEvent(HttpServletRequest request, Object source, IPortletWindowId portletWindowId, long executionTime, boolean usedBrowserCache, boolean usedPortalCache) {
final PortalEvent.PortalEventBuilder eventBuilder = this.createPortalEventBuilder(source, request);
final PortletExecutionEvent.PortletExecutionEventBuilder portletEventBuilder = this.createPortletExecutionEventBuilder(eventBuilder, portletWindowId, executionTime, false);
// Get the resource Id
final IPortalRequestInfo portalRequestInfo = this.urlSyntaxProvider.getPortalRequestInfo(request);
final String resourceId = getResourceId(portletWindowId, portalRequestInfo);
final PortletResourceExecutionEvent portletResourceExecutionEvent = new PortletResourceExecutionEvent(portletEventBuilder, resourceId, usedBrowserCache, usedPortalCache);
this.applicationEventPublisher.publishEvent(portletResourceExecutionEvent);
}
use of org.apereo.portal.url.IPortalRequestInfo in project uPortal by Jasig.
the class PortalController method actionRequest.
/**
* HTTP POST required for security.
*/
@RequestMapping(headers = { "org.apereo.portal.url.UrlType=ACTION" }, method = RequestMethod.POST)
public void actionRequest(HttpServletRequest request, HttpServletResponse response) throws IOException {
final IPortalRequestInfo portalRequestInfo = this.urlSyntaxProvider.getPortalRequestInfo(request);
final IPortletRequestInfo portletRequestInfo = portalRequestInfo.getTargetedPortletRequestInfo();
final IPortalUrlBuilder actionRedirectUrl;
if (portletRequestInfo != null) {
final IPortletWindowId targetWindowId = portletRequestInfo.getPortletWindowId();
actionRedirectUrl = this.portalUrlProvider.getPortalUrlBuilderByPortletWindow(request, targetWindowId, UrlType.RENDER);
} else {
final String targetedLayoutNodeId = portalRequestInfo.getTargetedLayoutNodeId();
if (targetedLayoutNodeId != null) {
actionRedirectUrl = this.portalUrlProvider.getPortalUrlBuilderByLayoutNode(request, targetedLayoutNodeId, UrlType.RENDER);
} else {
actionRedirectUrl = this.portalUrlProvider.getDefaultUrl(request);
}
}
// Stuff the action-redirect URL builder into the request so other code can use it during
// request processing
this.portalUrlProvider.convertToPortalActionUrlBuilder(request, actionRedirectUrl);
if (portletRequestInfo != null) {
final IPortletWindowId targetWindowId = portletRequestInfo.getPortletWindowId();
try {
this.portletExecutionManager.doPortletAction(targetWindowId, request, response);
} catch (RuntimeException e) {
this.logger.error("Exception thrown while executing portlet action for: " + portletRequestInfo, e);
// TODO this should be a constant right?
actionRedirectUrl.setParameter("portletActionError", targetWindowId.toString());
}
}
sendRedirect(actionRedirectUrl, response);
}
use of org.apereo.portal.url.IPortalRequestInfo in project uPortal by Jasig.
the class PortletWindowRegistryImpl method getPortletWindow.
@Override
public Tuple<IPortletWindow, StartElement> getPortletWindow(HttpServletRequest request, StartElement element) {
// Check if the layout node explicitly specifies the window id
final Attribute windowIdAttribute = element.getAttributeByName(PORTLET_WINDOW_ID_ATTR_NAME);
if (windowIdAttribute != null) {
final String windowIdStr = windowIdAttribute.getValue();
final IPortletWindowId portletWindowId = this.getPortletWindowId(request, windowIdStr);
final IPortletWindow portletWindow = this.getPortletWindow(request, portletWindowId);
return new Tuple<>(portletWindow, element);
}
// No explicit window id, look it up based on the layout node id
final Attribute nodeIdAttribute = element.getAttributeByName(IUserLayoutManager.ID_ATTR_NAME);
final String layoutNodeId = nodeIdAttribute.getValue();
IPortletWindow portletWindow = this.getOrCreateDefaultPortletWindowByLayoutNodeId(request, layoutNodeId);
if (portletWindow == null) {
// No window for the layout node, return null
return null;
}
final IPortalRequestInfo portalRequestInfo = this.urlSyntaxProvider.getPortalRequestInfo(request);
if (portalRequestInfo.getUrlState() == UrlState.DETACHED) {
/*
* We want to handle DETACHED portlet windows differently/explicitly,
* but we need to be aware there may be other portlets on the page
* besides the targeted one. These would be portlets in regions
* (Respondr theme) -- such as DynamicRespondrSkin.
*
* We need to confirm, therefore, that this is actually the portlet
* in DETACHED. If it is, we'll send back a 'stateless' PortletWindow.
*/
if (portalRequestInfo.getTargetedPortletWindowId().toString().contains("_" + layoutNodeId + "_")) {
final IPortletWindowId portletWindowId = portletWindow.getPortletWindowId();
portletWindow = this.getOrCreateStatelessPortletWindow(request, portletWindowId);
}
}
element = this.addPortletWindowId(element, portletWindow.getPortletWindowId());
return new Tuple<>(portletWindow, element);
}
use of org.apereo.portal.url.IPortalRequestInfo in project uPortal by Jasig.
the class UserLayoutParameterProcessor method processParameters.
@Override
@SuppressWarnings("FallThrough")
public boolean processParameters(HttpServletRequest request, HttpServletResponse response) {
final IPortalRequestInfo portalRequestInfo = this.urlSyntaxProvider.getPortalRequestInfo(request);
final IUserInstance userInstance = this.userInstanceManager.getUserInstance(request);
final IUserPreferencesManager preferencesManager = userInstance.getPreferencesManager();
final IUserLayoutManager userLayoutManager = preferencesManager.getUserLayoutManager();
final String tabId = portalRequestInfo.getTargetedLayoutNodeId();
if (tabId != null) {
this.stylesheetUserPreferencesService.setStylesheetParameter(request, PreferencesScope.STRUCTURE, "focusedTabID", tabId);
}
// on a portlet, it will get overwritten with the new value below.
if (userLayoutManager instanceof TransientUserLayoutManagerWrapper) {
final TransientUserLayoutManagerWrapper transientUserLayoutManagerWrapper = (TransientUserLayoutManagerWrapper) userLayoutManager;
transientUserLayoutManagerWrapper.setFocusedId(null);
}
final UrlState urlState = portalRequestInfo.getUrlState();
switch(urlState) {
case DETACHED:
this.stylesheetUserPreferencesService.setStylesheetParameter(request, PreferencesScope.STRUCTURE, "detached", Boolean.TRUE.toString());
case MAX:
{
final IPortletRequestInfo portletRequestInfo = portalRequestInfo.getTargetedPortletRequestInfo();
if (portletRequestInfo != null) {
final IPortletWindowId targetWindowId = portletRequestInfo.getPortletWindowId();
final IPortletWindow portletWindow = this.portletWindowRegistry.getPortletWindow(request, targetWindowId);
final IPortletEntity portletEntity = portletWindow.getPortletEntity();
final String channelSubscribeId = portletEntity.getLayoutNodeId();
this.stylesheetUserPreferencesService.setStylesheetParameter(request, PreferencesScope.STRUCTURE, "userLayoutRoot", channelSubscribeId);
if (userLayoutManager instanceof TransientUserLayoutManagerWrapper) {
// get wrapper implementation for focusing
final TransientUserLayoutManagerWrapper transientUserLayoutManagerWrapper = (TransientUserLayoutManagerWrapper) userLayoutManager;
// .. and now set it as the focused id
transientUserLayoutManagerWrapper.setFocusedId(channelSubscribeId);
}
// If portletRequestInfo was null just fall through to NORMAL state
break;
}
}
case NORMAL:
default:
{
this.stylesheetUserPreferencesService.setStylesheetParameter(request, PreferencesScope.STRUCTURE, "userLayoutRoot", IUserLayout.ROOT_NODE_NAME);
break;
}
}
return true;
}
use of org.apereo.portal.url.IPortalRequestInfo in project uPortal by Jasig.
the class DynamicRenderingPipeline method renderState.
@Override
public void renderState(HttpServletRequest req, HttpServletResponse res) throws IOException {
// Disable page caching
res.setHeader("pragma", "no-cache");
res.setHeader("Cache-Control", "no-cache, max-age=0, must-revalidate");
res.setDateHeader("Expires", 0);
final long startTime = System.nanoTime();
final PipelineEventReader<CharacterEventReader, CharacterEvent> pipelineEventReader = this.pipeline.getEventReader(req, res);
final String mediaType = getMediaType(req, res, pipelineEventReader);
// set the response mime type
final String contentType = mediaType + "; charset=" + CHARACTER_SET;
res.setContentType(contentType);
final PrintWriter writer = res.getWriter();
for (final CharacterEvent event : pipelineEventReader) {
if (CharacterEventTypes.CHARACTER != event.getEventType()) {
throw new RenderingPipelineConfigurationException("Only " + CharacterEventTypes.CHARACTER + " events are supported in the top level renderer. " + event.getEventType() + " is not supported.");
}
final String data = ((CharacterDataEvent) event).getData();
writer.print(data);
writer.flush();
res.flushBuffer();
}
final long executionTime = System.nanoTime() - startTime;
final IPortalRequestInfo portalRequestInfo = this.urlSyntaxProvider.getPortalRequestInfo(req);
this.portalEventFactory.publishPortalRenderEvent(req, this, req.getPathInfo(), executionTime, portalRequestInfo);
}
Aggregations