Search in sources :

Example 1 with CharacterDataEvent

use of org.apereo.portal.character.stream.events.CharacterDataEvent in project uPortal by Jasig.

the class JsonLayoutRenderingPipeline method renderState.

@Override
public void renderState(HttpServletRequest req, HttpServletResponse res) throws ServletException, 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);
    // set the response mime type
    final String contentType = "application/json; 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);
}
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 CharacterDataEvent

use of org.apereo.portal.character.stream.events.CharacterDataEvent in project uPortal by Jasig.

the class DynamicRenderingPipeline method renderState.

@Override
public void renderState(HttpServletRequest req, HttpServletResponse res) throws ServletException, 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);
}
Also used : CharacterEventReader(org.apereo.portal.character.stream.CharacterEventReader) CharacterEvent(org.apereo.portal.character.stream.events.CharacterEvent) IPortalRequestInfo(org.apereo.portal.url.IPortalRequestInfo) CharacterDataEvent(org.apereo.portal.character.stream.events.CharacterDataEvent) PrintWriter(java.io.PrintWriter)

Aggregations

PrintWriter (java.io.PrintWriter)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 IPortalRequestInfo (org.apereo.portal.url.IPortalRequestInfo)2 RenderingPipelineConfigurationException (org.apereo.portal.rendering.RenderingPipelineConfigurationException)1