Commit 582b3c5c authored by robcast's avatar robcast

added config option iiif-slash-replacement (default "!"). Changed constructor...

added config option iiif-slash-replacement (default "!"). Changed constructor of ParameterMap (move out initParams).
parent 975aa1e4
......@@ -57,7 +57,7 @@ public class DigilibConfiguration extends ParameterMap {
/** digilib version */
public static String getClassVersion() {
return "2.3.0";
return "2.3.1";
}
/* non-static getVersion for Java inheritance */
......@@ -94,6 +94,8 @@ public class DigilibConfiguration extends ParameterMap {
newParameter("default-errmsg-type", "image", null, 'f');
// prefix for IIIF image API paths (used by DigilibRequest)
newParameter("iiif-prefix", "IIIF", null, 'f');
// character to use as slash-replacement in IIIF identifier part
newParameter("iiif-slash-replacement", "!", null, 'f');
}
/**
......
......@@ -67,6 +67,9 @@ public class DigilibRequest extends ParameterMap {
/** IIIF path prefix (taken from config) */
protected String iiifPrefix = "IIIF";
/** IIIF slash replacement (taken from config) */
protected String iiifSlashReplacement = null;
/** error message while configuring */
public String errorMessage = null;
......@@ -78,6 +81,7 @@ public class DigilibRequest extends ParameterMap {
public DigilibRequest() {
super(30);
initParams();
}
/**
......@@ -86,8 +90,9 @@ public class DigilibRequest extends ParameterMap {
* @param config
*/
public DigilibRequest(DigilibConfiguration config) {
super();
super(30);
this.config = config;
initParams();
}
/**
......@@ -169,6 +174,7 @@ public class DigilibRequest extends ParameterMap {
*/
if (config != null) {
iiifPrefix = config.getAsString("iiif-prefix");
iiifSlashReplacement = config.getAsString("iiif-slash-replacement");
}
}
......@@ -418,6 +424,10 @@ public class DigilibRequest extends ParameterMap {
// still escape chars -- decode again
identifier = URLDecoder.decode(identifier, "UTF-8");
}
if (iiifSlashReplacement != null && identifier.contains(iiifSlashReplacement)) {
// change replacement back to slash
identifier = identifier.replace(iiifSlashReplacement, "/");
}
setValueFromString("fn", identifier);
} catch (UnsupportedEncodingException e) {
errorMessage = "Error decoding identifier in IIIF path!";
......
......@@ -45,21 +45,20 @@ public class ParameterMap {
protected OptionsSet options;
/** Default constructor.
*
* Does not call initParams().
*/
public ParameterMap() {
params = new HashMap<String, Parameter>();
options = new OptionsSet();
initParams();
}
/** Constructor with initial size.
* Does not call initParams().
* @param size
*/
public ParameterMap(int size) {
params = new HashMap<String, Parameter>(size);
options = new OptionsSet();
initParams();
}
/** Shallow copy constructor.
......@@ -69,6 +68,7 @@ public class ParameterMap {
@SuppressWarnings("unchecked")
public static ParameterMap cloneInstance(ParameterMap pm) {
ParameterMap newPm = new ParameterMap();
// TODO: initParams?
// clone params to this map
newPm.params = (HashMap<String, Parameter>) pm.params.clone();
newPm.options = (OptionsSet) pm.options.clone();
......@@ -82,6 +82,7 @@ public class ParameterMap {
*/
public static ParameterMap getInstance(ParameterMap pm) {
ParameterMap newPm = new ParameterMap();
// TODO: initParams?
// add all params to this map
newPm.params.putAll(pm.params);
newPm.initOptions();
......
......@@ -76,6 +76,7 @@ public class DigilibServletRequest extends DigilibRequest {
* @throws ImageOpException
*/
public DigilibServletRequest(HttpServletRequest request) {
super();
setWithRequest(request);
initOptions();
}
......@@ -88,7 +89,7 @@ public class DigilibServletRequest extends DigilibRequest {
* @throws ImageOpException
*/
public DigilibServletRequest(HttpServletRequest request, DigilibConfiguration config) {
this.config = config;
super(config);
setWithRequest(request);
initOptions();
}
......@@ -99,6 +100,7 @@ public class DigilibServletRequest extends DigilibRequest {
*/
@Override
protected void initParams() {
// TODO: check if we can call super.initParams()
/*
* Definition of parameters and default values. Parameter of type 's'
* are for the servlet.
......@@ -175,13 +177,14 @@ public class DigilibServletRequest extends DigilibRequest {
newParameter("img.pix_x", new Integer(0), null, 'c');
// hires image size y
newParameter("img.pix_y", new Integer(0), null, 'c');
/*
* TODO: check if we can remove these
* // total number of pages
* newParameter("pt", new Integer(0), null, 'c');
* // marks
* newParameter("mk", "", null, 'c');
* set local variables from config
*/
if (config != null) {
iiifPrefix = config.getAsString("iiif-prefix");
iiifSlashReplacement = config.getAsString("iiif-slash-replacement");
}
}
/*
......
......@@ -61,7 +61,7 @@ public class Scaler extends HttpServlet {
private static final long serialVersionUID = -5439198888139362735L;
/** digilib servlet version (for all components) */
public static final String version = "2.3.0 noasync";
public static final String version = "2.3.1 noasync";
/** servlet error codes */
public static enum Error {
......@@ -161,7 +161,7 @@ public class Scaler extends HttpServlet {
accountlog.debug("GetLastModified from " + request.getRemoteAddr() + " for " + request.getQueryString());
long mtime = -1;
// create new request
DigilibServletRequest dlReq = new DigilibServletRequest(request);
DigilibServletRequest dlReq = new DigilibServletRequest(request, dlConfig);
DocuDirectory dd = dirCache.getDirectory(dlReq.getFilePath());
if (dd != null) {
mtime = dd.getDirMTime() / 1000 * 1000;
......@@ -223,7 +223,7 @@ public class Scaler extends HttpServlet {
long startTime = System.currentTimeMillis();
// parse request
DigilibServletRequest dlRequest = new DigilibServletRequest(request);
DigilibServletRequest dlRequest = new DigilibServletRequest(request, dlConfig);
// extract the job information
ImageJobDescription jobTicket = ImageJobDescription.getInstance(dlRequest, dlConfig);
......
......@@ -55,7 +55,7 @@ public class ScalerNoThread extends HttpServlet {
private static final long serialVersionUID = 1450947819851623306L;
/** digilib servlet version (for all components) */
public static final String version = "2.3.0 nothread";
public static final String version = "2.3.1 nothread";
/** servlet error codes */
public static enum Error {
......@@ -144,7 +144,7 @@ public class ScalerNoThread extends HttpServlet {
accountlog.debug("GetLastModified from " + request.getRemoteAddr() + " for " + request.getQueryString());
long mtime = -1;
// create new request
DigilibServletRequest dlReq = new DigilibServletRequest(request);
DigilibServletRequest dlReq = new DigilibServletRequest(request, dlConfig);
DocuDirectory dd = dirCache.getDirectory(dlReq.getFilePath());
if (dd != null) {
mtime = dd.getDirMTime() / 1000 * 1000;
......@@ -206,7 +206,7 @@ public class ScalerNoThread extends HttpServlet {
long startTime = System.currentTimeMillis();
// parse request
DigilibServletRequest dlRequest = new DigilibServletRequest(request);
DigilibServletRequest dlRequest = new DigilibServletRequest(request, dlConfig);
// extract the job information
ImageJobDescription jobTicket = ImageJobDescription.getInstance(dlRequest, dlConfig);
......
......@@ -166,7 +166,7 @@ public class Scaler extends HttpServlet {
long mtime = -1;
try {
// create new digilib request
DigilibServletRequest dlReq = new DigilibServletRequest(request);
DigilibServletRequest dlReq = new DigilibServletRequest(request, dlConfig);
DocuDirectory dd = dirCache.getDirectory(dlReq.getFilePath());
if (dd != null) {
mtime = dd.getDirMTime() / 1000 * 1000;
......@@ -234,7 +234,7 @@ public class Scaler extends HttpServlet {
final long startTime = System.currentTimeMillis();
// parse request
DigilibServletRequest dlRequest = new DigilibServletRequest(request);
DigilibServletRequest dlRequest = new DigilibServletRequest(request, dlConfig);
// extract the job information
final ImageJobDescription jobTicket = ImageJobDescription.getInstance(dlRequest, dlConfig);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment