Mercurial > hg > digilib-old
annotate servlet/src/digilib/servlet/PDFCache.java @ 552:785fc58b68b1 digilibPDF
more cleanup and refactoring
author | robcast |
---|---|
date | Wed, 15 Dec 2010 08:58:01 +0100 |
parents | f9a4288fc7c4 |
children | 88ed97d08b97 |
rev | line source |
---|---|
500 | 1 package digilib.servlet; |
2 | |
503
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
3 import java.io.BufferedInputStream; |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
4 import java.io.File; |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
5 import java.io.FileInputStream; |
548 | 6 import java.io.FileNotFoundException; |
7 import java.io.FileOutputStream; | |
503
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
8 import java.io.IOException; |
546 | 9 import java.io.OutputStream; |
548 | 10 import java.util.concurrent.Future; |
500 | 11 |
505 | 12 import javax.servlet.RequestDispatcher; |
503
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
13 import javax.servlet.ServletConfig; |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
14 import javax.servlet.ServletContext; |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
15 import javax.servlet.ServletException; |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
16 import javax.servlet.ServletOutputStream; |
500 | 17 import javax.servlet.http.HttpServletRequest; |
18 import javax.servlet.http.HttpServletResponse; | |
19 | |
548 | 20 import digilib.image.DocuImage; |
21 | |
509 | 22 /** |
23 * A class for handling user requests for pdf documents from digilib images. | |
24 * | |
511 | 25 * If a document does not already exist, it will be enqueued for generation; if it does exist, it is sent |
26 * to the user. | |
27 * | |
509 | 28 * @author cmielack |
29 * | |
30 */ | |
31 | |
533 | 32 @SuppressWarnings("serial") |
500 | 33 public class PDFCache extends RequestHandler { |
34 | |
503
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
35 private DigilibConfiguration dlConfig = null; |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
36 |
533 | 37 public static String instanceKey = "digilib.servlet.PDFCache"; |
503
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
38 |
546 | 39 private DigilibJobCenter<OutputStream> pdfJobCenter = null; |
40 | |
548 | 41 private DigilibJobCenter<DocuImage> pdfImageJobCenter = null; |
42 | |
533 | 43 private File cache_directory = new File("cache"); |
505 | 44 |
533 | 45 private File temp_directory = new File("pdf_temp"); |
503
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
46 |
505 | 47 private static String JSP_WIP = "/pdf/wip.jsp"; |
503
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
48 |
505 | 49 private static String JSP_ERROR = "/pdf/error.jsp"; |
500 | 50 |
51 public static Integer STATUS_DONE = 0; // document exists in cache | |
52 | |
53 public static Integer STATUS_WIP = 1; // document is "work in progress" | |
54 | |
55 public static Integer STATUS_NONEXISTENT = 2; // document does not exist in cache and is not in progress | |
56 | |
57 public static Integer STATUS_ERROR = 3; // an error occurred while processing the request | |
503
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
58 |
550 | 59 public static String version = "0.3a"; |
509 | 60 |
511 | 61 // TODO ? functionality for the pre-generation of complete books/chapters using default values |
503
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
62 |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
63 |
548 | 64 public void init(ServletConfig config) throws ServletException { |
503
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
65 super.init(config); |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
66 |
531
9cedd170b581
* PDF generation works now even with subdirectories
robcast
parents:
511
diff
changeset
|
67 System.out.println("***** Digital Image Library Image PDF-Cache Servlet (version " |
9cedd170b581
* PDF generation works now even with subdirectories
robcast
parents:
511
diff
changeset
|
68 + version + ") *****"); |
546 | 69 // say hello in the log file |
531
9cedd170b581
* PDF generation works now even with subdirectories
robcast
parents:
511
diff
changeset
|
70 logger.info("***** Digital Image Library Image PDF-Cache Servlet (version " |
9cedd170b581
* PDF generation works now even with subdirectories
robcast
parents:
511
diff
changeset
|
71 + version + ") *****"); |
9cedd170b581
* PDF generation works now even with subdirectories
robcast
parents:
511
diff
changeset
|
72 |
552 | 73 ServletContext context = getServletContext(); |
503
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
74 dlConfig = (DigilibConfiguration) context.getAttribute("digilib.servlet.configuration"); |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
75 if (dlConfig == null) { |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
76 // no Configuration |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
77 throw new ServletException("No Configuration!"); |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
78 } |
533 | 79 |
80 String temp_fn = dlConfig.getAsString("pdf-temp-dir"); | |
81 temp_directory = new File(temp_fn); | |
550 | 82 if (!temp_directory.exists()) { |
83 // try to create | |
84 temp_directory.mkdirs(); | |
85 } | |
533 | 86 if (!temp_directory.isDirectory()) { |
87 throw new ServletException("Configuration error: problem with pdf-temp-dir="+temp_fn); | |
88 } | |
89 // rid the temporary directory of possible incomplete document files | |
90 emptyDirectory(temp_directory); | |
91 | |
92 String cache_fn = dlConfig.getAsString("pdf-cache-dir"); | |
93 cache_directory = new File(cache_fn); | |
550 | 94 if (!cache_directory.exists()) { |
95 // try to create | |
96 cache_directory.mkdirs(); | |
97 } | |
533 | 98 if (!cache_directory.isDirectory()) { |
99 throw new ServletException("Configuration error: problem with pdf-cache-dir="+cache_fn); | |
100 } | |
500 | 101 |
546 | 102 pdfJobCenter = (DigilibJobCenter<OutputStream>) dlConfig.getValue("servlet.worker.pdfexecutor"); |
548 | 103 pdfImageJobCenter = (DigilibJobCenter<DocuImage>) dlConfig.getValue("servlet.worker.pdfimageexecutor"); |
546 | 104 |
509 | 105 // register this instance globally |
533 | 106 context.setAttribute(instanceKey, this); |
509 | 107 |
503
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
108 } |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
109 |
511 | 110 /** |
111 * clean up any broken and unfinished files from the temporary directory. | |
112 */ | |
533 | 113 public void emptyDirectory(File temp_dir){ |
114 File[] temp_files = temp_dir.listFiles(); | |
503
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
115 |
533 | 116 for (File f: temp_files){ |
117 f.delete(); | |
503
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
118 } |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
119 } |
500 | 120 |
121 | |
122 public void processRequest(HttpServletRequest request, | |
123 HttpServletResponse response) { | |
124 | |
125 // evaluate request ( make a PDFJobDeclaration , get the DocumentId) | |
548 | 126 PDFJobDescription pdfji = new PDFJobDescription(request, dlConfig); |
500 | 127 |
503
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
128 String docid = pdfji.getDocumentId(); |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
129 |
505 | 130 // if some invalid data has been entered ... |
131 if(!pdfji.checkValidity()) { | |
132 notifyUser(STATUS_ERROR, docid, request, response); | |
133 return; | |
134 } | |
503
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
135 |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
136 int status = getStatus(docid); |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
137 |
531
9cedd170b581
* PDF generation works now even with subdirectories
robcast
parents:
511
diff
changeset
|
138 if (status == STATUS_NONEXISTENT) { |
548 | 139 // not there -- start creation |
549 | 140 try { |
141 createNewPdfDocument(pdfji, docid); | |
142 notifyUser(status, docid, request, response); | |
143 } catch (FileNotFoundException e) { | |
144 // error in pdf creation | |
145 logger.error(e.getMessage()); | |
146 notifyUser(STATUS_ERROR, docid, request, response); | |
147 } | |
531
9cedd170b581
* PDF generation works now even with subdirectories
robcast
parents:
511
diff
changeset
|
148 } else if (status == STATUS_DONE) { |
548 | 149 // pdf created -- send it |
531
9cedd170b581
* PDF generation works now even with subdirectories
robcast
parents:
511
diff
changeset
|
150 try { |
542
e2ff961001af
first step towards more standard java.util.concurrent design
robcast
parents:
533
diff
changeset
|
151 sendFile(docid, getDownloadFilename(pdfji), response); |
531
9cedd170b581
* PDF generation works now even with subdirectories
robcast
parents:
511
diff
changeset
|
152 } catch (IOException e) { |
549 | 153 // sending didn't work |
531
9cedd170b581
* PDF generation works now even with subdirectories
robcast
parents:
511
diff
changeset
|
154 logger.error(e.getMessage()); |
9cedd170b581
* PDF generation works now even with subdirectories
robcast
parents:
511
diff
changeset
|
155 } |
9cedd170b581
* PDF generation works now even with subdirectories
robcast
parents:
511
diff
changeset
|
156 } else { |
549 | 157 // should be work in progress |
531
9cedd170b581
* PDF generation works now even with subdirectories
robcast
parents:
511
diff
changeset
|
158 notifyUser(status, docid, request, response); |
9cedd170b581
* PDF generation works now even with subdirectories
robcast
parents:
511
diff
changeset
|
159 } |
500 | 160 } |
161 | |
511 | 162 /** |
549 | 163 * depending on the documents status, redirect the user to the appropriate waiting or download page. |
511 | 164 * |
165 * @param status | |
166 * @param documentid | |
167 * @param request | |
168 * @param response | |
169 */ | |
505 | 170 public void notifyUser(int status, String documentid, HttpServletRequest request, HttpServletResponse response){ |
500 | 171 |
505 | 172 String jsp=null; |
173 | |
503
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
174 if(status == STATUS_NONEXISTENT){ |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
175 // tell the user that the document has to be created before he/she can download it |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
176 logger.debug("PDFCache: "+documentid+" has STATUS_NONEXISTENT."); |
505 | 177 jsp = JSP_WIP; |
533 | 178 } else if(status == STATUS_WIP){ |
503
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
179 logger.debug("PDFCache: "+documentid+" has STATUS_WIP."); |
505 | 180 jsp = JSP_WIP; |
500 | 181 |
549 | 182 // TODO: estimate remaining work time |
183 // TODO: tell the user he/she has to wait | |
533 | 184 } else if(status == STATUS_DONE){ |
503
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
185 logger.debug("PDFCache: "+documentid+" has STATUS_DONE."); |
533 | 186 } else { |
503
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
187 logger.debug("PDFCache: "+documentid+" has STATUS_ERROR."); |
505 | 188 jsp = JSP_ERROR; |
189 } | |
500 | 190 |
505 | 191 try { |
548 | 192 // forward to the relevant jsp |
552 | 193 ServletContext context = getServletContext(); |
548 | 194 RequestDispatcher dispatch = context.getRequestDispatcher(jsp); |
505 | 195 dispatch.forward(request, response); |
196 } catch (ServletException e) { | |
197 logger.debug(e.getMessage()); | |
198 e.printStackTrace(); | |
199 } catch (IOException e) { | |
200 logger.debug(e.getMessage()); | |
201 e.printStackTrace(); | |
503
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
202 } |
505 | 203 |
500 | 204 } |
205 | |
206 | |
207 /** check the status of the document corresponding to the documentid */ | |
208 public Integer getStatus(String documentid){ | |
505 | 209 // looks into the cache and temp directory in order to find out the status of the document |
533 | 210 File cached = new File(cache_directory, documentid); |
211 File wip = new File(temp_directory, documentid); | |
505 | 212 if(cached.exists()){ |
213 return STATUS_DONE; | |
533 | 214 } else if (wip.exists()){ |
505 | 215 return STATUS_WIP; |
533 | 216 } else { |
503
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
217 return STATUS_NONEXISTENT; |
505 | 218 } |
503
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
219 } |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
220 |
511 | 221 /** |
222 * create new thread for pdf generation. | |
223 * | |
224 * @param pdfji | |
225 * @param filename | |
548 | 226 * @return |
227 * @throws FileNotFoundException | |
511 | 228 */ |
548 | 229 public Future<OutputStream> createNewPdfDocument(PDFJobDescription pdfji, String filename) throws FileNotFoundException{ |
503
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
230 // start new worker |
548 | 231 File of = this.getTempFile(filename); |
232 OutputStream os = new FileOutputStream(of); | |
233 PDFStreamWorker job = new PDFStreamWorker(dlConfig, os, pdfji, pdfImageJobCenter); | |
234 // start job | |
235 Future<OutputStream> jobTicket = pdfJobCenter.submit(job); | |
236 // what do we do with the result? | |
237 return jobTicket; | |
238 /* PDFMaker pdf_maker = new PDFMaker(context, pdfji,filename); | |
239 new Thread(pdf_maker, "PDFMaker").start();*/ | |
503
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
240 } |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
241 |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
242 |
511 | 243 /** |
244 * generate the filename the user is going to receive the pdf as | |
245 * | |
246 * @param pdfji | |
247 * @return | |
248 */ | |
548 | 249 public String getDownloadFilename(PDFJobDescription pdfji){ |
511 | 250 // filename example: digilib_example_pgs1-3.pdf |
503
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
251 String filename; |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
252 filename = "digilib_"; |
552 | 253 filename += pdfji.getAsString("fn"); |
503
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
254 filename += "_pgs" + pdfji.getAsString("pgs"); |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
255 filename += ".pdf"; |
500 | 256 |
503
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
257 return filename; |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
258 } |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
259 |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
260 /** |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
261 * sends a document to the user |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
262 * |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
263 * @param cachefile The filename of the document in cache. |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
264 * @param filename The filename used for downloading. |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
265 * @param response |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
266 * @throws IOException |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
267 */ |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
268 public void sendFile(String cachefile, String filename, HttpServletResponse response) throws IOException{ |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
269 File cached_file = null; |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
270 FileInputStream fis = null; |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
271 ServletOutputStream sos = null; |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
272 BufferedInputStream bis = null; |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
273 |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
274 try { |
511 | 275 // get file handle |
533 | 276 cached_file = new File(cache_directory, cachefile); |
511 | 277 // create necessary streams |
503
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
278 fis = new FileInputStream(cached_file); |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
279 sos = response.getOutputStream(); |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
280 bis = new BufferedInputStream(fis); |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
281 |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
282 int bytes = 0; |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
283 |
511 | 284 // set http headers |
503
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
285 response.setContentType("application/pdf"); |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
286 response.addHeader("Content-Disposition", "attachment; filename="+filename); |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
287 response.setContentLength( (int) cached_file.length()); |
511 | 288 |
289 // send the bytes | |
503
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
290 while ((bytes = bis.read()) != -1){ |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
291 sos.write(bytes); |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
292 } |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
293 } |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
294 catch(Exception e){ |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
295 logger.error(e.getMessage()); |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
296 } |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
297 finally{ |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
298 // close all streams |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
299 if (fis != null) |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
300 fis.close(); |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
301 if (bis != null) |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
302 bis.close(); |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
303 if (sos != null) |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
304 sos.close(); |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
305 } |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
500
diff
changeset
|
306 |
500 | 307 } |
509 | 308 |
533 | 309 public File getCacheDirectory(){ |
509 | 310 return cache_directory; |
311 } | |
312 | |
533 | 313 public File getTempDirectory(){ |
509 | 314 return temp_directory; |
315 } | |
533 | 316 |
317 /** | |
318 * returns a File object based on filename in the temp directory. | |
319 * @param filename | |
320 * @return | |
321 */ | |
322 public File getTempFile(String filename) { | |
323 return new File(temp_directory, filename); | |
324 } | |
325 | |
326 /** | |
327 * returns a File object based on filename in the cache directory. | |
328 * @param filename | |
329 * @return | |
330 */ | |
331 public File getCacheFile(String filename) { | |
332 return new File(cache_directory, filename); | |
333 } | |
500 | 334 } |