use of org.finos.legend.pure.m3.execution.XLSXOutputWriter in project legend-pure by finos.
the class ExecutionManager method execute.
private void execute(CoreInstance function, ListIterable<CoreInstance> parameters, HttpResponseWriter response, HttpInformation httpInformation, boolean canStreamOutput, OutputFormat format) {
long start = System.currentTimeMillis();
try {
CanStreamState.setCanStream(canStreamOutput);
response.setIsStreamingResponse(canStreamOutput);
this.addContentTypeAndDispositionHeaders(response, httpInformation);
response.setHeader("Trailer", "X-Streaming-Error");
// Do not open outputStream in try-with-resources
OutputStream outputStream = response.getOutputStream();
try {
OutputWriter writer = this.functionExecution.newOutputWriter();
if (format == OutputFormat.XLSX) {
writer = new XLSXOutputWriter(writer);
}
this.functionExecution.start(function, parameters, outputStream, writer);
} catch (PureExecutionStreamingException ex) {
}
// outputStream must NOT be closed in case of an uncaught exception
// so the call to close must not be in a finally block or implicit in a try-with-resources
outputStream.close();
} catch (Throwable t) {
if (t instanceof RuntimeException) {
throw (RuntimeException) t;
}
if (t instanceof Error) {
throw (Error) t;
}
throw new RuntimeException(t);
} finally {
// Reset
CanStreamState.resetCanStream();
}
}
Aggregations