changeset 252:59250ea2ad55

servlet version 1.19b5 - filename and dpi in request - filename and dpi in dlInfo-*
author robcast
date Wed, 25 Aug 2004 01:06:30 +0200
parents 465641fd157c
children 2adfb8bea870
files servlet/src/digilib/servlet/DocumentBean.java
diffstat 1 files changed, 32 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/servlet/src/digilib/servlet/DocumentBean.java	Wed Aug 25 01:06:29 2004 +0200
+++ b/servlet/src/digilib/servlet/DocumentBean.java	Wed Aug 25 01:06:30 2004 +0200
@@ -35,6 +35,8 @@
 import digilib.auth.AuthOps;
 import digilib.io.DocuDirCache;
 import digilib.io.DocuDirectory;
+import digilib.io.FileOps;
+import digilib.io.ImageFileset;
 
 public class DocumentBean {
 
@@ -178,6 +180,36 @@
 	}
 
 	/**
+	 * Sets the current DigilibRequest. Also completes information in the request.
+	 * 
+	 * @param dlRequest
+	 *            The dlRequest to set.
+	 */
+	public void setRequest(DigilibRequest dlRequest) throws Exception {
+		this.dlRequest = dlRequest;
+		if (dirCache == null) {
+			return;
+		}
+		String fn = dlRequest.getFilePath();
+		// get information about the file
+		ImageFileset fileset = (ImageFileset) dirCache.getFile(fn, dlRequest
+				.getAsInt("pn"), FileOps.CLASS_IMAGE);
+		if (fileset == null) {
+			return;
+		}
+		// add file name
+		dlRequest.setValue("img.fn", fileset.getName());
+		// add dpi
+		dlRequest.setValue("img.dpix", new Double(fileset.getResX()));
+		dlRequest.setValue("img.dpiy", new Double(fileset.getResY()));
+		// get number of pages in directory
+		DocuDirectory dd = dirCache.getDirectory(fn);
+		if (dd != null) {
+			dlRequest.setValue("pt", dd.size());
+		}
+	}
+
+	/**
 	 * get the first page number in the directory (not yet functional)
 	 */
 	public int getFirstPage(DigilibRequest request) {
@@ -265,11 +297,4 @@
 		return dlRequest;
 	}
 
-	/**
-	 * @param dlRequest
-	 *            The dlRequest to set.
-	 */
-	public void setRequest(DigilibRequest dlRequest) {
-		this.dlRequest = dlRequest;
-	}
 }
\ No newline at end of file