# HG changeset patch
# User robcast
# Date 1390848084 -3600
# Node ID 5d02e7f08917eaf64627e554a763b334e5862291
# Parent 3ab98c1847b798945db76ffaeccaa8ed392c3977
small fixes.
diff -r 3ab98c1847b7 -r 5d02e7f08917 common/src/main/java/digilib/conf/DigilibConfiguration.java
--- a/common/src/main/java/digilib/conf/DigilibConfiguration.java Fri Jan 24 18:03:20 2014 +0100
+++ b/common/src/main/java/digilib/conf/DigilibConfiguration.java Mon Jan 27 19:41:24 2014 +0100
@@ -84,7 +84,7 @@
// maximum destination image size (0 means no limit)
newParameter("max-image-size", new Integer(0), null, 'f');
// allow image toolkit to use disk cache
- newParameter("img-diskcache-allowed", Boolean.TRUE, null, 'f');
+ newParameter("img-diskcache-allowed", Boolean.FALSE, null, 'f');
// default type of error message (image, text, code)
newParameter("default-errmsg-type", "image", null, 'f');
// prefix for IIIF image API paths (used by DigilibRequest)
@@ -111,9 +111,11 @@
}
if (!param.setValueFromString((String) confEntry.getValue())) {
/*
- * automatic conversion failed -- try special casesß
+ * automatic conversion failed -- try special cases
*/
- logger.warn("Unable to parse config parameter: "+param.getName());
+ if (!setSpecialValueFromString(param, (String) confEntry.getValue())) {
+ logger.warn("Unable to parse config parameter: "+param.getName());
+ }
}
} else {
// parameter unknown -- just add
@@ -129,6 +131,20 @@
}
}
+
+ /**
+ * Set non-standard value in Parameter param. Returns true if successful.
+ *
+ * @param param
+ * @param value
+ * @return
+ */
+ protected boolean setSpecialValueFromString(Parameter param, String value) {
+ // should be overridden
+ return false;
+ }
+
+
/**
* Configure digilib.
*
@@ -137,13 +153,7 @@
@SuppressWarnings("unchecked")
public void configure() {
DigilibConfiguration config = this;
- if (DigilibConfiguration.isLoggerConfigured) {
- logger.debug("Logger already configured!");
- } else {
- // we start log4j with a default logger config
- BasicConfigurator.configure();
- DigilibConfiguration.isLoggerConfigured = true;
- }
+ setupLogger();
/*
* initialise static DocuImage class instance
*/
@@ -172,4 +182,17 @@
ImageIO.setUseCache(dc);
}
+ /**
+ * Configure Log4J (using BasicConfigurator).
+ */
+ public static void setupLogger() {
+ if (DigilibConfiguration.isLoggerConfigured) {
+ logger.debug("Logger already configured!");
+ } else {
+ // we start log4j with a default logger config
+ BasicConfigurator.configure();
+ DigilibConfiguration.isLoggerConfigured = true;
+ }
+ }
+
}
diff -r 3ab98c1847b7 -r 5d02e7f08917 common/src/main/java/digilib/image/ImageJobDescription.java
--- a/common/src/main/java/digilib/image/ImageJobDescription.java Fri Jan 24 18:03:20 2014 +0100
+++ b/common/src/main/java/digilib/image/ImageJobDescription.java Mon Jan 27 19:41:24 2014 +0100
@@ -38,7 +38,6 @@
import digilib.io.DocuDirectory;
import digilib.io.FileOpException;
import digilib.io.FileOps;
-import digilib.io.FileOps.FileClass;
import digilib.io.ImageInput;
import digilib.io.ImageSet;
import digilib.util.ImageSize;
@@ -306,7 +305,7 @@
if (dirCache == null) {
throw new FileOpException("No DirCache configured!");
}
- imageSet = (ImageSet) dirCache.getFile(getFilePath(), getAsInt("pn"), FileClass.IMAGE);
+ imageSet = (ImageSet) dirCache.getFile(getFilePath(), getAsInt("pn"));
if (imageSet == null) {
throw new FileOpException("File " + getFilePath() + "(" + getAsInt("pn") + ") not found.");
}
@@ -570,7 +569,8 @@
qual = 0;
else if (hasOption("q1"))
qual = 1;
- else if (hasOption("q2")) qual = 2;
+ else if (hasOption("q2"))
+ qual = 2;
return qual;
}
diff -r 3ab98c1847b7 -r 5d02e7f08917 common/src/main/java/digilib/image/ImageLoaderDocuImage.java
--- a/common/src/main/java/digilib/image/ImageLoaderDocuImage.java Fri Jan 24 18:03:20 2014 +0100
+++ b/common/src/main/java/digilib/image/ImageLoaderDocuImage.java Mon Jan 27 19:41:24 2014 +0100
@@ -186,7 +186,7 @@
// RenderingHints.VALUE_ANTIALIAS_OFF);
// setup interpolation quality
if (qual > 0) {
- logger.debug("quality q1");
+ logger.debug("quality q1+");
renderHint.put(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
} else {
logger.debug("quality q0");
diff -r 3ab98c1847b7 -r 5d02e7f08917 common/src/main/java/digilib/io/DocuDirCache.java
--- a/common/src/main/java/digilib/io/DocuDirCache.java Fri Jan 24 18:03:20 2014 +0100
+++ b/common/src/main/java/digilib/io/DocuDirCache.java Mon Jan 27 19:41:24 2014 +0100
@@ -60,10 +60,8 @@
protected AtomicInteger misses = new AtomicInteger(0);
/**
- * Constructor with array of base directory names and file class.
+ * Constructor with digilib configuration and file class.
*
- * @param bd
- * base directory names
* @param fc
* @param dlConfig
*/
@@ -73,10 +71,7 @@
}
/**
- * Constructor with array of base directory names.
- *
- * @param bd
- * base directory names
+ * Default constructor. Uses FileClass.IMAGE.
*/
public DocuDirCache() {
// default file class is CLASS_IMAGE
@@ -115,7 +110,7 @@
/**
* Add a directory to the cache and check its parents.
* Always returns the correct Object from the cache,
- * either newDir one or another one.
+ * either newDir or the cached one.
*
* @param newDir
* @return dir
@@ -141,7 +136,7 @@
/**
* Returns the DocuDirent with the pathname fn
and the index
- * in
.
+ * in
of FileClass fc.
*
* If fn
is a file then the corresponding DocuDirent is
* returned and the index is ignored.
diff -r 3ab98c1847b7 -r 5d02e7f08917 common/src/main/java/digilib/io/DocuDirectory.java
--- a/common/src/main/java/digilib/io/DocuDirectory.java Fri Jan 24 18:03:20 2014 +0100
+++ b/common/src/main/java/digilib/io/DocuDirectory.java Mon Jan 27 19:41:24 2014 +0100
@@ -175,7 +175,9 @@
*
*/
public void readMeta() {
- meta.readMeta(this);
+ if (meta != null) {
+ meta.readMeta(this);
+ }
}
@@ -184,7 +186,9 @@
*
*/
public void checkMeta() {
- meta.checkMeta(this);
+ if (meta != null) {
+ meta.checkMeta(this);
+ }
}
diff -r 3ab98c1847b7 -r 5d02e7f08917 common/src/main/java/digilib/io/ImageCacheStream.java
--- a/common/src/main/java/digilib/io/ImageCacheStream.java Fri Jan 24 18:03:20 2014 +0100
+++ b/common/src/main/java/digilib/io/ImageCacheStream.java Mon Jan 27 19:41:24 2014 +0100
@@ -35,7 +35,7 @@
*/
public class ImageCacheStream extends ImageStream {
- private ImageInputStream iis = null;
+ protected ImageInputStream iis = null;
/** Create ImageCacheStream from InputStream and mime-type.
*
@@ -52,7 +52,9 @@
* InputStream. This class is provided for cases where it is not
* possible to create a writable temporary file.
*/
- iis = ImageIO.createImageInputStream(stream);
+ if (stream != null) {
+ iis = ImageIO.createImageInputStream(stream);
+ }
}
/*
@@ -75,4 +77,19 @@
return iis;
}
+ /* (non-Javadoc)
+ * @see digilib.io.ImageStream#setInputStream(java.io.InputStream)
+ */
+ @Override
+ public void setInputStream(InputStream stream) {
+ super.setInputStream(stream);
+ if (stream != null) {
+ try {
+ iis = ImageIO.createImageInputStream(stream);
+ } catch (IOException e) {
+ // nothing to do, really.
+ }
+ }
+ }
+
}
diff -r 3ab98c1847b7 -r 5d02e7f08917 common/src/main/java/digilib/io/ImageSet.java
--- a/common/src/main/java/digilib/io/ImageSet.java Fri Jan 24 18:03:20 2014 +0100
+++ b/common/src/main/java/digilib/io/ImageSet.java Mon Jan 27 19:41:24 2014 +0100
@@ -220,7 +220,7 @@
}
/**
- * Adds an ImageImput to this ImageSet.
+ * Adds an ImageInput to this ImageSet.
*
* The images should be added in the order of higher to lower resolutions.
* The first image is considered the hires "original".
@@ -234,5 +234,22 @@
f.setParent(this);
return list.add(f);
}
+
+
+ /**
+ * Append all ImageInputs from another ImageSet (at the end).
+ *
+ * Changes the parents of the ImageInputs to this ImageSet.
+ *
+ * @param imgs
+ */
+ public void append(ImageSet imgs) {
+ // append list
+ list.addAll(imgs.list);
+ // change parents
+ for (ImageInput ii : imgs.list) {
+ ii.setParent(this);
+ }
+ }
}
diff -r 3ab98c1847b7 -r 5d02e7f08917 common/src/main/java/digilib/io/ImageStream.java
--- a/common/src/main/java/digilib/io/ImageStream.java Fri Jan 24 18:03:20 2014 +0100
+++ b/common/src/main/java/digilib/io/ImageStream.java Mon Jan 27 19:41:24 2014 +0100
@@ -63,4 +63,11 @@
return stream;
}
+ /**
+ * @param stream the stream to set
+ */
+ public void setInputStream(InputStream stream) {
+ this.stream = stream;
+ }
+
}
diff -r 3ab98c1847b7 -r 5d02e7f08917 common/src/main/java/digilib/meta/MetaFactory.java
--- a/common/src/main/java/digilib/meta/MetaFactory.java Fri Jan 24 18:03:20 2014 +0100
+++ b/common/src/main/java/digilib/meta/MetaFactory.java Mon Jan 27 19:41:24 2014 +0100
@@ -46,6 +46,10 @@
protected static Class fileMetaClass;
public static FileMeta getFileMetaInstance() {
+ if (fileMetaClass == null) {
+ logger.warn("No FileMeta class!");
+ return null;
+ }
FileMeta mo = null;
try {
mo = fileMetaClass.newInstance();
@@ -56,6 +60,10 @@
}
public static DirMeta getDirMetaInstance() {
+ if (dirMetaClass == null) {
+ logger.warn("No DirMeta class!");
+ return null;
+ }
DirMeta mo = null;
try {
mo = dirMetaClass.newInstance();