changeset 549:b86a7b700bc3 digilibPDF

more cleanup and refactoring
author robcast
date Tue, 14 Dec 2010 09:10:20 +0100
parents bc9196347188
children f9a4288fc7c4
files servlet/src/digilib/servlet/PDFCache.java
diffstat 1 files changed, 13 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/servlet/src/digilib/servlet/PDFCache.java	Mon Dec 13 15:35:25 2010 +0100
+++ b/servlet/src/digilib/servlet/PDFCache.java	Tue Dec 14 09:10:20 2010 +0100
@@ -132,23 +132,30 @@
 		
         if (status == STATUS_NONEXISTENT) {
         	// not there -- start creation
-            createNewPdfDocument(pdfji, docid);
-            notifyUser(status, docid, request, response);
+            try {
+				createNewPdfDocument(pdfji, docid);
+	            notifyUser(status, docid, request, response);
+			} catch (FileNotFoundException e) {
+				// error in pdf creation
+                logger.error(e.getMessage());
+				notifyUser(STATUS_ERROR, docid, request, response);
+			}
         } else if (status == STATUS_DONE) {
         	// pdf created -- send it
             try {
                 sendFile(docid, getDownloadFilename(pdfji), response);
             } catch (IOException e) {
-                e.printStackTrace();
+            	// sending didn't work
                 logger.error(e.getMessage());
             }
         } else {
+        	// should be work in progress
             notifyUser(status, docid, request, response);
         }
 	}
 
 	/**
-	 * depending on the documents status, redirect the user to an appropriate waiting- or download-site
+	 * depending on the documents status, redirect the user to the appropriate waiting or download page.
 	 * 
 	 * @param status
 	 * @param documentid
@@ -167,8 +174,8 @@
 			logger.debug("PDFCache: "+documentid+" has STATUS_WIP.");
 			jsp = JSP_WIP;
 
-			// estimate remaining work time
-			// tell the user he/she has to wait
+			// TODO: estimate remaining work time
+			// TODO: tell the user he/she has to wait
 		} else if(status == STATUS_DONE){
 			logger.debug("PDFCache: "+documentid+" has STATUS_DONE.");
 		} else {