All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.mapfish.print.servlet.job.impl.FilePrintJob Maven / Gradle / Ivy

There is a newer version: 3.22.0
Show newest version
package org.mapfish.print.servlet.job.impl;

import org.mapfish.print.config.WorkingDirectories;
import org.mapfish.print.processor.Processor;
import org.mapfish.print.servlet.job.PrintJob;
import org.springframework.beans.factory.annotation.Autowired;

import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;

/**
 * A PrintJob implementation that write results to files.
 * 

*/ public class FilePrintJob extends PrintJob { @Autowired private WorkingDirectories workingDirectories; @Override protected final PrintResult withOpenOutputStream(final PrintAction function) throws Exception { final File reportFile = new File(this.workingDirectories.getReports(), getEntry().getReferenceId()); FileOutputStream out = null; BufferedOutputStream bout = null; final Processor.ExecutionContext executionContext; try { out = new FileOutputStream(reportFile); bout = new BufferedOutputStream(out); executionContext = function.run(bout); } finally { try { if (bout != null) { bout.close(); } } finally { if (out != null) { out.close(); } } } return new PrintResult(reportFile.toURI(), reportFile.length(), executionContext); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy