annotate servlet3/src/main/java/digilib/servlet/DigilibServletConfiguration.java @ 960:b2d97b842612

moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules. default build uses jai-imageio (now only one additional JAR in webapp!).
author robcast
date Wed, 25 Jan 2012 15:13:06 +0100
parents 7bcc6765c209
children 4e368c85cce4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
903
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
1 /*
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
2 * DigilibConfiguration -- Holding all parameters for digilib servlet.
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
3 *
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
4 * Digital Image Library servlet components
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
5 *
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
6 * Copyright (C) 2001, 2002 Robert Casties (robcast@mail.berlios.de)
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
7 *
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify it
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
9 * under the terms of the GNU General Public License as published by the Free
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
10 * Software Foundation; either version 2 of the License, or (at your option)
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
11 * any later version.
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
12 *
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
13 * Please read license.txt for the full details. A copy of the GPL may be found
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
14 * at http://www.gnu.org/copyleft/lgpl.html
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
15 *
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License along with
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
17 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
18 * Place, Suite 330, Boston, MA 02111-1307 USA
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
19 *
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
20 */
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
21
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
22 package digilib.servlet;
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
23
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
24 import java.io.File;
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
25 import java.util.Map;
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
26 import java.util.Map.Entry;
930
333e60e5cae9 new counter for open requests.
robcast
parents: 925
diff changeset
27 import java.util.concurrent.atomic.AtomicInteger;
903
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
28
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
29 import javax.servlet.ServletContext;
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
30 import javax.servlet.ServletException;
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
31
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
32 import digilib.image.DocuImageImpl;
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
33 import digilib.io.FileOps;
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
34 import digilib.util.Parameter;
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
35 import digilib.util.XMLListLoader;
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
36
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
37 /**
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
38 * Class to hold the digilib servlet configuration parameters. The parameters
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
39 * can be read from the digilib-config file and be passed to other servlets or
911
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
40 * beans. <br>
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
41 * errorImgFileName: image file to send in case of error. <br>
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
42 * denyImgFileName: image file to send if access is denied. <br>
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
43 * baseDirs: array of base directories in order of preference (prescaled
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
44 * versions first). <br>
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
45 * useAuth: use authentication information. <br>
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
46 * authConfPath: authentication configuration file. <br>
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
47 * ... <br>
903
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
48 *
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
49 * @author casties
911
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
50 *
903
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
51 */
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
52 public class DigilibServletConfiguration extends DigilibConfiguration {
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
53
937
7bcc6765c209 improved runtime statistics
robcast
parents: 930
diff changeset
54 /** time the webapp (i.e. this class) was loaded */
7bcc6765c209 improved runtime statistics
robcast
parents: 930
diff changeset
55 public final Long webappStartTime = System.currentTimeMillis();
7bcc6765c209 improved runtime statistics
robcast
parents: 930
diff changeset
56
7bcc6765c209 improved runtime statistics
robcast
parents: 930
diff changeset
57 /** counter for HttpRequests (mostly for debugging) */
7bcc6765c209 improved runtime statistics
robcast
parents: 930
diff changeset
58 public AtomicInteger webappRequestCnt = new AtomicInteger(0);
7bcc6765c209 improved runtime statistics
robcast
parents: 930
diff changeset
59
930
333e60e5cae9 new counter for open requests.
robcast
parents: 925
diff changeset
60 /** counter for open HttpRequests (mostly for debugging) */
333e60e5cae9 new counter for open requests.
robcast
parents: 925
diff changeset
61 public AtomicInteger openRequestCnt = new AtomicInteger(0);
333e60e5cae9 new counter for open requests.
robcast
parents: 925
diff changeset
62
911
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
63 /**
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
64 * Definition of parameters and default values.
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
65 */
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
66 protected void initParams() {
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
67 /*
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
68 * Definition of parameters and default values. System parameters that
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
69 * are not read from config file have a type 's'.
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
70 */
903
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
71
911
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
72 // digilib servlet version
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
73 newParameter("servlet.version", digilib.servlet.Scaler.getVersion(),
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
74 null, 's');
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
75 // configuration file location
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
76 newParameter("servlet.config.file", null, null, 's');
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
77 // DocuDirCache instance
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
78 newParameter("servlet.dir.cache", null, null, 's');
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
79 // DocuImage class instance
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
80 newParameter("servlet.docuimage.class",
960
b2d97b842612 moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents: 937
diff changeset
81 digilib.image.ImageLoaderDocuImage.class, null, 's');
911
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
82 // AuthOps instance for authentication
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
83 newParameter("servlet.auth.op", null, null, 's');
903
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
84 // Executor for image operations
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
85 newParameter("servlet.worker.imageexecutor", null, null, 's');
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
86 // Executor for PDF operations
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
87 newParameter("servlet.worker.pdfexecutor", null, null, 's');
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
88 // Executor for PDF-image operations
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
89 newParameter("servlet.worker.pdfimageexecutor", null, null, 's');
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
90
911
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
91 /*
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
92 * parameters that can be read from config file have a type 'f'
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
93 */
903
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
94
911
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
95 // image file to send in case of error
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
96 newParameter("error-image", new File("img/digilib-error.png"), null,
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
97 'f');
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
98 // image file to send if access is denied
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
99 newParameter("denied-image", new File("img/digilib-denied.png"), null,
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
100 'f');
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
101 // image file to send if image file not found
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
102 newParameter("notfound-image", new File("img/digilib-notfound.png"),
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
103 null, 'f');
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
104 // base directories in order of preference (prescaled versions last)
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
105 String[] bd = { "/docuserver/images", "/docuserver/scaled/small" };
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
106 newParameter("basedir-list", bd, null, 'f');
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
107 // use authentication information
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
108 newParameter("use-authorization", Boolean.FALSE, null, 'f');
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
109 // authentication configuration file
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
110 newParameter("auth-file", new File("digilib-auth.xml"), null, 'f');
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
111 // sending image files as-is allowed
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
112 newParameter("sendfile-allowed", Boolean.TRUE, null, 'f');
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
113 // Type of DocuImage instance
960
b2d97b842612 moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents: 937
diff changeset
114 newParameter("docuimage-class", "digilib.image.ImageLoaderDocuImage", null, 'f');
911
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
115 // part of URL used to indicate authorized access
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
116 newParameter("auth-url-path", "authenticated/", null, 'f');
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
117 // degree of subsampling on image load
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
118 newParameter("subsample-minimum", new Float(2f), null, 'f');
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
119 // default scaling quality
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
120 newParameter("default-quality", new Integer(1), null, 'f');
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
121 // use mapping file to translate paths
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
122 newParameter("use-mapping", Boolean.FALSE, null, 'f');
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
123 // mapping file location
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
124 newParameter("mapping-file", new File("digilib-map.xml"), null, 'f');
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
125 // log4j config file location
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
126 newParameter("log-config-file", new File("log4j-config.xml"), null, 'f');
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
127 // maximum destination image size (0 means no limit)
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
128 newParameter("max-image-size", new Integer(0), null, 'f');
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
129 // number of working threads
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
130 newParameter("worker-threads", new Integer(1), null, 'f');
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
131 // max number of waiting threads
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
132 newParameter("max-waiting-threads", new Integer(20), null, 'f');
925
66f1ba72d07b added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents: 911
diff changeset
133 // timeout for worker threads (ms)
66f1ba72d07b added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents: 911
diff changeset
134 newParameter("worker-timeout", new Integer(60000), null, 'f');
911
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
135 // number of pdf-generation threads
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
136 newParameter("pdf-worker-threads", new Integer(1), null, 'f');
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
137 // max number of waiting pdf-generation threads
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
138 newParameter("pdf-max-waiting-threads", new Integer(20), null, 'f');
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
139 // number of pdf-image generation threads
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
140 newParameter("pdf-image-worker-threads", new Integer(1), null, 'f');
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
141 // max number of waiting pdf-image generation threads
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
142 newParameter("pdf-image-max-waiting-threads", new Integer(10), null,
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
143 'f');
903
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
144 // PDF generation temp directory
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
145 newParameter("pdf-temp-dir", "pdf_temp", null, 'f');
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
146 // PDF generation cache directory
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
147 newParameter("pdf-cache-dir", "pdf_cache", null, 'f');
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
148 // allow image toolkit to use disk cache
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
149 newParameter("img-diskcache-allowed", Boolean.TRUE, null, 'f');
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
150 // default type of error message (image, text, code)
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
151 newParameter("default-errmsg-type", "image", null, 'f');
911
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
152 }
903
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
153
911
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
154 /**
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
155 * Constructor taking a ServletConfig. Reads the config file location from
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
156 * an init parameter and loads the config file. Calls
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
157 * <code>readConfig()</code>.
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
158 *
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
159 * @see readConfig()
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
160 */
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
161 public DigilibServletConfiguration(ServletContext c) throws Exception {
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
162 readConfig(c);
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
163 }
903
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
164
911
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
165 /**
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
166 * read parameter list from the XML file in init parameter "config-file" or
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
167 * file digilib-config.xml
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
168 */
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
169 @SuppressWarnings("unchecked")
903
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
170 public void readConfig(ServletContext c) throws Exception {
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
171
911
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
172 /*
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
173 * Get config file name. The file name is first looked for as an init
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
174 * parameter, then in a fixed location in the webapp.
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
175 */
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
176 if (c == null) {
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
177 // no config no file...
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
178 return;
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
179 }
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
180 String fn = c.getInitParameter("config-file");
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
181 if (fn == null) {
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
182 fn = ServletOps.getConfigFile("digilib-config.xml", c);
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
183 if (fn == null) {
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
184 logger.fatal("readConfig: no param config-file");
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
185 throw new ServletException("ERROR: no digilib config file!");
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
186 }
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
187 }
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
188 File f = new File(fn);
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
189 // setup config file list reader
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
190 XMLListLoader lilo = new XMLListLoader("digilib-config", "parameter",
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
191 "name", "value");
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
192 // read config file into HashMap
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
193 Map<String, String> confTable = lilo.loadURL(f.toURL().toString());
903
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
194
911
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
195 // set config file path parameter
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
196 setValue("servlet.config.file", f.getCanonicalPath());
903
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
197
911
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
198 /*
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
199 * read parameters
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
200 */
903
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
201
911
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
202 for (Entry<String, String> confEntry : confTable.entrySet()) {
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
203 Parameter p = get(confEntry.getKey());
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
204 if (p != null) {
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
205 if (p.getType() == 's') {
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
206 // type 's' Parameters are not overwritten.
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
207 continue;
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
208 }
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
209 if (!p.setValueFromString(confEntry.getValue())) {
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
210 /*
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
211 * automatic conversion failed -- try special cases
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
212 */
903
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
213
911
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
214 // basedir-list
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
215 if (confEntry.getKey().equals("basedir-list")) {
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
216 // split list into directories
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
217 String[] dirs = FileOps.pathToArray(confEntry.getValue());
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
218 for (int j = 0; j < dirs.length; j++) {
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
219 // make relative directory paths be inside the webapp
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
220 dirs[j] = ServletOps.getFile(dirs[j], c);
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
221 }
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
222 if (dirs != null) {
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
223 p.setValue(dirs);
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
224 }
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
225 }
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
226 }
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
227 } else {
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
228 // parameter unknown -- just add
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
229 newParameter(confEntry.getKey(), null, confEntry.getValue(),
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
230 'f');
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
231 }
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
232 }
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
233 // initialise static DocuImage class instance
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
234 DigilibServletConfiguration.docuImageClass = (Class<DocuImageImpl>) Class
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
235 .forName(getAsString("docuimage-class"));
0cea7e608080 add relative-basedir back in. fix digicat.
robcast
parents: 903
diff changeset
236 }
903
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
237
7779b37d1d05 refactored into maven modules per servlet type.
robcast
parents:
diff changeset
238 }