comparison servlet/src/digilib/pdf/PDFFileWorker.java @ 557:0885f5ca5b24 digilibPDF

more refactoring and rearranging pdf and image generation works now
author robcast
date Thu, 16 Dec 2010 21:19:11 +0100
parents servlet/src/digilib/servlet/PDFFileWorker.java@5cc180bb0a5c
children fd2ef7e46119
comparison
equal deleted inserted replaced
556:5cc180bb0a5c 557:0885f5ca5b24
1 /**
2 *
3 */
4 package digilib.pdf;
5
6 import java.io.File;
7 import java.io.FileNotFoundException;
8 import java.io.FileOutputStream;
9 import java.io.OutputStream;
10 import java.util.concurrent.Callable;
11
12 import digilib.image.DocuImage;
13 import digilib.servlet.DigilibConfiguration;
14 import digilib.servlet.PDFRequest;
15 import digilib.util.DigilibJobCenter;
16
17 /**
18 * @author casties
19 *
20 */
21 public class PDFFileWorker implements Callable<File> {
22 /** the wrapped PDFStreamWorker */
23 protected PDFStreamWorker streamWorker;
24
25 /** the temporary output file */
26 protected File tempFile;
27
28 /** the final output file */
29 protected File finalFile;
30
31 /** Create new PDFFileWorker.
32 * @param dlConfig
33 * @param tempFile
34 * @param job_info
35 * @param imageJobCenter
36 * @throws FileNotFoundException
37 */
38 public PDFFileWorker(DigilibConfiguration dlConfig,
39 File tempFile, File finalFile,
40 PDFRequest job_info,
41 DigilibJobCenter<DocuImage> imageJobCenter) throws FileNotFoundException {
42 this.tempFile = tempFile;
43 OutputStream outstream = new FileOutputStream(tempFile);
44 this.finalFile = finalFile;
45 this.streamWorker = new PDFStreamWorker(dlConfig, outstream, job_info, imageJobCenter);
46 }
47
48 @Override
49 public File call() throws Exception {
50 OutputStream outstream = streamWorker.call();
51 outstream.flush();
52 // move temporary to final file
53 tempFile.renameTo(finalFile);
54 return finalFile;
55 }
56
57
58 }