Search in sources :

Example 1 with IPortalRequestInfo

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);
}
Also used : CharacterEventReader(org.apereo.portal.character.stream.CharacterEventReader) CharacterEvent(org.apereo.portal.character.stream.events.CharacterEvent) IPortalRequestInfo(org.apereo.portal.url.IPortalRequestInfo) RenderingPipelineConfigurationException(org.apereo.portal.rendering.RenderingPipelineConfigurationException) CharacterDataEvent(org.apereo.portal.character.stream.events.CharacterDataEvent) PrintWriter(java.io.PrintWriter)

Example 2 with IPortalRequestInfo

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();
}
Also used : IPortalRequestInfo(org.apereo.portal.url.IPortalRequestInfo) List(java.util.List) ArrayList(java.util.ArrayList) ImmutableList(com.google.common.collect.ImmutableList) IPortletRequestInfo(org.apereo.portal.url.IPortletRequestInfo) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow)

Example 3 with IPortalRequestInfo

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;
}
Also used : WindowState(javax.portlet.WindowState) IPortalRequestInfo(org.apereo.portal.url.IPortalRequestInfo) IPortletRequestInfo(org.apereo.portal.url.IPortletRequestInfo) UrlType(org.apereo.portal.url.UrlType) ParameterMap(org.apereo.portal.url.ParameterMap) Map(java.util.Map) IPortletWindowId(org.apereo.portal.portlet.om.IPortletWindowId) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow) PortletMode(javax.portlet.PortletMode) UrlState(org.apereo.portal.url.UrlState)

Example 4 with IPortalRequestInfo

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;
}
Also used : IPortalRequestInfo(org.apereo.portal.url.IPortalRequestInfo) UrlState(org.apereo.portal.url.UrlState)

Example 5 with IPortalRequestInfo

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;
}
Also used : IPortalRequestInfo(org.apereo.portal.url.IPortalRequestInfo) UrlState(org.apereo.portal.url.UrlState)

Aggregations

IPortalRequestInfo (org.apereo.portal.url.IPortalRequestInfo)25 IPortletWindow (org.apereo.portal.portlet.om.IPortletWindow)12 IPortletWindowId (org.apereo.portal.portlet.om.IPortletWindowId)8 IPortletRequestInfo (org.apereo.portal.url.IPortletRequestInfo)6 UrlState (org.apereo.portal.url.UrlState)6 Locale (java.util.Locale)3 PortletRequestContextImpl (org.apereo.portal.portlet.container.PortletRequestContextImpl)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 PrintWriter (java.io.PrintWriter)2 WindowState (javax.portlet.WindowState)2 CharacterEventReader (org.apereo.portal.character.stream.CharacterEventReader)2 CharacterDataEvent (org.apereo.portal.character.stream.events.CharacterDataEvent)2 CharacterEvent (org.apereo.portal.character.stream.events.CharacterEvent)2 IPortletEntity (org.apereo.portal.portlet.om.IPortletEntity)2 PortletRenderResult (org.apereo.portal.portlet.rendering.PortletRenderResult)2 JsonParseException (com.fasterxml.jackson.core.JsonParseException)1 JsonMappingException (com.fasterxml.jackson.databind.JsonMappingException)1 ImmutableList (com.google.common.collect.ImmutableList)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1