use of org.apereo.portal.url.IPortalRequestInfo in project uPortal by Jasig.
the class JsonLayoutRenderingPipeline method renderState.
@Override
public void renderState(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException, IllegalStateException {
// 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);
// set the response mime type
final String contentType = "application/json; charset=" + CHARACTER_SET;
res.setContentType(contentType);
final PrintWriter writer = res.getWriter();
if (pipelineEventReader != null) {
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();
}
} else {
logger.warn("PipelineEventReader is null");
throw new IllegalStateException("PipelineEventReader is null");
}
final long executionTime = System.nanoTime() - startTime;
final IPortalRequestInfo portalRequestInfo = this.urlSyntaxProvider.getPortalRequestInfo(req);
this.portalEventFactory.publishPortalRenderEvent(req, this, req.getPathInfo(), executionTime, portalRequestInfo);
}
use of org.apereo.portal.url.IPortalRequestInfo in project uPortal by Jasig.
the class PortalEventFactoryImpl method getParameters.
protected Map<String, List<String>> getParameters(HttpServletRequest httpServletRequest, IPortletWindowId portletWindowId, boolean renderRequest) {
final IPortalRequestInfo portalRequestInfo = this.urlSyntaxProvider.getPortalRequestInfo(httpServletRequest);
final IPortletRequestInfo portletRequestInfo = portalRequestInfo.getPortletRequestInfo(portletWindowId);
if (portletRequestInfo != null) {
final Map<String, List<String>> parameters = portletRequestInfo.getPortletParameters();
return pruneParameters(parameters);
}
// Only re-use render parameters on a render request
if (renderRequest) {
final IPortletWindow portletWindow = this.portletWindowRegistry.getPortletWindow(httpServletRequest, portletWindowId);
final Map<String, String[]> parameters = portletWindow.getRenderParameters();
return pruneParameters(ParameterMap.immutableCopyOfArrayMap(parameters));
}
return Collections.emptyMap();
}
use of org.apereo.portal.url.IPortalRequestInfo in project uPortal by Jasig.
the class PortletRequestParameterProcessor method processParameters.
/* (non-Javadoc)
* @see org.apereo.portal.url.processing.IRequestParameterProcessor#processParameters(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
@Override
public boolean processParameters(HttpServletRequest request, HttpServletResponse response) {
final IPortalRequestInfo portalRequestInfo = this.urlSyntaxProvider.getPortalRequestInfo(request);
final IPortletWindowId targetedPortletWindowId = portalRequestInfo.getTargetedPortletWindowId();
for (final IPortletRequestInfo portletRequestInfo : portalRequestInfo.getPortletRequestInfoMap().values()) {
final IPortletWindowId portletWindowId = portletRequestInfo.getPortletWindowId();
final IPortletWindow portletWindow = this.portletWindowRegistry.getPortletWindow(request, targetedPortletWindowId);
final UrlType urlType = portalRequestInfo.getUrlType();
switch(urlType) {
case RENDER:
{
final Map<String, List<String>> portletParameters = portletRequestInfo.getPortletParameters();
portletWindow.setRenderParameters(ParameterMap.convertListMap(portletParameters));
// fall through, render uses state/mode info
}
case ACTION:
{
final WindowState windowState = portletRequestInfo.getWindowState();
if (windowState != null) {
portletWindow.setWindowState(windowState);
}
final PortletMode portletMode = portletRequestInfo.getPortletMode();
if (portletMode != null) {
portletWindow.setPortletMode(portletMode);
}
break;
}
default:
}
// Override the window state of the targeted portlet window based on the url state
if (portletWindowId.equals(targetedPortletWindowId)) {
final UrlState urlState = portalRequestInfo.getUrlState();
switch(urlState) {
case MAX:
{
portletWindow.setWindowState(WindowState.MAXIMIZED);
break;
}
case DETACHED:
{
portletWindow.setWindowState(IPortletRenderer.DETACHED);
break;
}
case EXCLUSIVE:
{
portletWindow.setWindowState(IPortletRenderer.EXCLUSIVE);
break;
}
default:
}
}
this.portletWindowRegistry.storePortletWindow(request, portletWindow);
}
return true;
}
use of org.apereo.portal.url.IPortalRequestInfo in project uPortal by Jasig.
the class FocusedOnOnePortletPredicate method test.
@Override
public boolean test(final HttpServletRequest request) {
final IPortalRequestInfo portalRequestInfo = this.urlSyntaxProvider.getPortalRequestInfo(request);
if (null == portalRequestInfo) {
logger.warn("Portal request info was not available for this request, " + "so assuming that it does not represent focus on one portlet.");
// focused-on-one-portlet portal state.
return false;
}
final UrlState urlState = portalRequestInfo.getUrlState();
// true when there is a portal request and that request is not for a portal in NORMAL state
// i.e. portal is in some other state, like Maximized or Exclusive or Detached.
// false otherwise.
final boolean doesRequestFocusOnOnePortlet = (!(UrlState.NORMAL.equals(urlState)));
logger.debug("Determined request with UrlState {} {} focus on one portlet.", urlState, doesRequestFocusOnOnePortlet ? "does" : "does not");
return doesRequestFocusOnOnePortlet;
}
use of org.apereo.portal.url.IPortalRequestInfo in project uPortal by Jasig.
the class URLInSpecificStatePredicate method test.
@Override
public boolean test(final HttpServletRequest request) {
final IPortalRequestInfo portalRequestInfo = this.urlSyntaxProvider.getPortalRequestInfo(request);
if (null == portalRequestInfo) {
logger.warn("Portal request info was not available for this request, " + "so assuming that it does not represent focus on one portlet.");
// focused-on-one-portlet portal state.
return false;
}
final UrlState urlState = portalRequestInfo.getUrlState();
boolean stateEqual = urlState.toString().equals(state);
return isNegated ? !stateEqual : stateEqual;
}
Aggregations