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);
}
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);
}
Aggregations