Mercurial > hg > digilib-old
comparison servlet/src/digilib/servlet/Scaler.java @ 867:987cfe401970 stream
add default error message type config.
author | robcast |
---|---|
date | Thu, 10 Mar 2011 21:21:10 +0100 |
parents | ace973a106b5 |
children |
comparison
equal
deleted
inserted
replaced
866:5431156f7b9d | 867:987cfe401970 |
---|---|
29 public class Scaler extends HttpServlet { | 29 public class Scaler extends HttpServlet { |
30 | 30 |
31 private static final long serialVersionUID = 5289386646192471549L; | 31 private static final long serialVersionUID = 5289386646192471549L; |
32 | 32 |
33 /** digilib servlet version (for all components) */ | 33 /** digilib servlet version (for all components) */ |
34 public static final String version = "1.9.1a24"; | 34 public static final String version = "1.9.1a26"; |
35 | 35 |
36 /** servlet error codes */ | 36 /** servlet error codes */ |
37 public static enum Error {UNKNOWN, AUTH, FILE, IMAGE}; | 37 public static enum Error {UNKNOWN, AUTH, FILE, IMAGE}; |
38 | 38 |
39 /** type of error message */ | 39 /** type of error message */ |
40 public static enum ErrMsg {IMAGE, TEXT, CODE}; | 40 public static enum ErrMsg {IMAGE, TEXT, CODE}; |
41 | |
42 /** default error message type */ | |
43 public static ErrMsg defaultErrMsgType = ErrMsg.IMAGE; | |
41 | 44 |
42 /** logger for accounting requests */ | 45 /** logger for accounting requests */ |
43 protected static Logger accountlog = Logger.getLogger("account.request"); | 46 protected static Logger accountlog = Logger.getLogger("account.request"); |
44 | 47 |
45 /** gengeral logger for this class */ | 48 /** gengeral logger for this class */ |
116 errorImgFile = ServletOps.getFile( | 119 errorImgFile = ServletOps.getFile( |
117 (File) dlConfig.getValue("error-image"), context); | 120 (File) dlConfig.getValue("error-image"), context); |
118 notfoundImgFile = ServletOps.getFile( | 121 notfoundImgFile = ServletOps.getFile( |
119 (File) dlConfig.getValue("notfound-image"), context); | 122 (File) dlConfig.getValue("notfound-image"), context); |
120 sendFileAllowed = dlConfig.getAsBoolean("sendfile-allowed"); | 123 sendFileAllowed = dlConfig.getAsBoolean("sendfile-allowed"); |
124 try { | |
125 defaultErrMsgType = ErrMsg.valueOf(dlConfig.getAsString("default-errmsg-type")); | |
126 } catch (Exception e) { | |
127 // nothing to do | |
128 } | |
121 } | 129 } |
122 | 130 |
123 /** | 131 /** |
124 * Returns modification time relevant to the request for caching. | 132 * Returns modification time relevant to the request for caching. |
125 * | 133 * |
196 DigilibRequest dlRequest = new DigilibRequest(request); | 204 DigilibRequest dlRequest = new DigilibRequest(request); |
197 // extract the job information | 205 // extract the job information |
198 final ImageJobDescription jobTicket = ImageJobDescription.getInstance(dlRequest, dlConfig); | 206 final ImageJobDescription jobTicket = ImageJobDescription.getInstance(dlRequest, dlConfig); |
199 | 207 |
200 // type of error reporting | 208 // type of error reporting |
201 ErrMsg errMsgType = ErrMsg.IMAGE; | 209 ErrMsg errMsgType = defaultErrMsgType; |
202 if (dlRequest.hasOption("errtxt")) { | 210 if (dlRequest.hasOption("errimg")) { |
211 errMsgType = ErrMsg.IMAGE; | |
212 } else if (dlRequest.hasOption("errtxt")) { | |
203 errMsgType = ErrMsg.TEXT; | 213 errMsgType = ErrMsg.TEXT; |
204 } else if (dlRequest.hasOption("errcode")) { | 214 } else if (dlRequest.hasOption("errcode")) { |
205 errMsgType = ErrMsg.CODE; | 215 errMsgType = ErrMsg.CODE; |
206 } | 216 } |
207 | 217 |