changeset 177:830b0111a0c9

Servlet version 1.17b2 - new mapping file for "virtual directories" - direct file URLs now work without extension (even with wrong ones)
author robcast
date Mon, 10 Nov 2003 21:06:02 +0100
parents 67ff8c7fecb9
children 3258490649b5
files servlet/src/digilib/servlet/DigilibConfiguration.java servlet/src/digilib/servlet/Scaler.java
diffstat 2 files changed, 20 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/servlet/src/digilib/servlet/DigilibConfiguration.java	Mon Nov 10 20:59:00 2003 +0100
+++ b/servlet/src/digilib/servlet/DigilibConfiguration.java	Mon Nov 10 21:06:02 2003 +0100
@@ -32,6 +32,7 @@
 import digilib.auth.XMLAuthOps;
 import digilib.image.DocuImage;
 import digilib.image.DocuImageImpl;
+import digilib.io.AliasingDocuDirCache;
 import digilib.io.DocuDirCache;
 import digilib.io.FileOps;
 import digilib.io.XMLListLoader;
@@ -97,7 +98,7 @@
 		String[] bd = { "/docuserver/images", "/docuserver/scaled/small" };
 		putParameter("basedir-list", bd, null, 'f');
 		// use authentication information
-		putParameter("use-authorization", Boolean.TRUE, null, 'f');
+		putParameter("use-authorization", Boolean.FALSE, null, 'f');
 		// authentication configuration file
 		putParameter("auth-file", "digilib-auth.xml", null, 'f');
 		// sending image files as-is allowed
@@ -112,6 +113,10 @@
 		putParameter("subsample-minimum", new Float(2f), null, 'f');
 		// default scaling quality
 		putParameter("default-quality", new Integer(1), null, 'f');
+		// use mapping file to translate paths
+		putParameter("use-mapping", Boolean.FALSE, null, 'f');
+		// mapping file location
+		putParameter("mapping-file", "digilib-map.xml", null, 'f');
 	}
 
 	/** Constructor taking a ServletConfig.
@@ -200,7 +205,19 @@
 		// directory cache
 		String[] bd = (String[]) getValue("basedir-list");
 		int[] fcs = { FileOps.CLASS_IMAGE, FileOps.CLASS_TEXT};
-		DocuDirCache dirCache = new DocuDirCache(bd, fcs);
+		DocuDirCache dirCache;
+		if (getAsBoolean("use-mapping")) {
+			// with mapping file
+			String mapConfPath = getAsString("mapping-file");
+			if (! mapConfPath.startsWith("/")) {
+				// relative path -> use getRealPath to resolve in WEB-INF
+				mapConfPath = c.getServletContext().getRealPath("WEB-INF/"+mapConfPath);
+			}
+			dirCache = new AliasingDocuDirCache(bd, fcs, mapConfPath);
+		} else {
+			// without mapping
+			dirCache = new DocuDirCache(bd, fcs);
+		}
 		setValue("servlet.dir.cache", dirCache);
 		// useAuthentication
 		if (getAsBoolean("use-authorization")) {
--- a/servlet/src/digilib/servlet/Scaler.java	Mon Nov 10 20:59:00 2003 +0100
+++ b/servlet/src/digilib/servlet/Scaler.java	Mon Nov 10 21:06:02 2003 +0100
@@ -56,7 +56,7 @@
 public class Scaler extends HttpServlet {
 
 	// digilib servlet version (for all components)
-	public static final String dlVersion = "1.16b2";
+	public static final String dlVersion = "1.17b2";
 
 	// Utils instance with debuglevel
 	Utils util;