From d6e7b7b1c025424d39421b2b2437e1379bf35db2 Mon Sep 17 00:00:00 2001
From: Alex Dolski Cantaloupe is a standard Maven project that should open right up in any Java IDE. Cantaloupe is a standard Maven project that should open right up in any Java IDE. Simply use the same configuration file and VM options (e.g. Ideas, suggestions, feature requests, bug reports, and other kinds of feedback are welcome; contact the author, or submit an issue or pull request.
+ Ideas, suggestions, feature requests, bug reports, and other kinds of feedback are welcome; contact the author, or submit an issue or pull request. This project uses the Gitflow branching model. All changes should take place in feature branches ("feature/xxxx") that branch off from the main branch, "develop." They can then be cleanly integrated, by the release manager, into a particular release. The general process for contributing code changes is: (This section is for release managers only.) The Jekyll website compiler transforms the HTML pages in the website folder into a working static website. The build/deploy_website.rb script takes care of building the website, adding the current Javadoc to it, committing it, and deploying it to GitHub Pages. To merely preview the website without releasing it, Cantaloupe roughly uses semantic versioning. Major releases (n) break backwards compatibility in a major way. Minor releases (n.n) either do not break it, or only in a minor/trivial way. Patch releases (n.n.n) are for bugfixes only. Note that the above statement covers public API (the HTTP endpoints) only. Internals may change significantly from release to release (though this is not really likely.) Because Cantaloupe is generally intended to provide stable APIs, major version increments should be expected to be rare. Currently, the release process is mostly manual. The steps involved are: The HTTP/1.1 Cache-Control response header is configurable via the
-Developer's Guide
--Dcantaloupe.config=...
) as you would when running from a JAR.Custom Resolvers
@@ -31,7 +31,9 @@ Javadoc
Contributing
-Contributing
git push origin feature/my-new-feature
)Administrative
+
+Website
+
+cd
into the website folder and run jekyll serve
, then go to http://localhost:4000/ in a web browser.Versioning
+
+Releasing
+
+
+
From 4228ac85fd0863ef65f1c846f53cba029f976572 Mon Sep 17 00:00:00 2001
From: Alex Dolski mvn package
git tag -a {version} -m 'Tag {version}'
git push origin master; git push origin release/x.x; git push --tags
build/deploy_website.rb
generate_https_links
* key in the configuration.
diff --git a/src/test/java/edu/illinois/library/cantaloupe/resource/InformationResourceTest.java b/src/test/java/edu/illinois/library/cantaloupe/resource/InformationResourceTest.java
index 7f389ca70..56481613a 100644
--- a/src/test/java/edu/illinois/library/cantaloupe/resource/InformationResourceTest.java
+++ b/src/test/java/edu/illinois/library/cantaloupe/resource/InformationResourceTest.java
@@ -21,6 +21,7 @@ public class InformationResourceTest extends ResourceTest {
public void testCacheHeaders() {
Configuration config = Application.getConfiguration();
+ config.setProperty("cache.client.enabled", "true");
config.setProperty("cache.client.max_age", "1234");
config.setProperty("cache.client.shared_max_age", "4567");
config.setProperty("cache.client.public", "false");
diff --git a/src/test/java/edu/illinois/library/cantaloupe/resource/LandingResourceTest.java b/src/test/java/edu/illinois/library/cantaloupe/resource/LandingResourceTest.java
index 2032d19cf..5846a0021 100644
--- a/src/test/java/edu/illinois/library/cantaloupe/resource/LandingResourceTest.java
+++ b/src/test/java/edu/illinois/library/cantaloupe/resource/LandingResourceTest.java
@@ -18,6 +18,7 @@ public class LandingResourceTest extends ResourceTest {
public void testCacheHeaders() {
Configuration config = Application.getConfiguration();
+ config.setProperty("cache.client.enabled", "true");
config.setProperty("cache.client.max_age", "1234");
config.setProperty("cache.client.shared_max_age", "4567");
config.setProperty("cache.client.public", "false");
diff --git a/src/test/java/edu/illinois/library/cantaloupe/resource/ResourceTest.java b/src/test/java/edu/illinois/library/cantaloupe/resource/ResourceTest.java
index e2f0ebcdd..9ea7d240c 100644
--- a/src/test/java/edu/illinois/library/cantaloupe/resource/ResourceTest.java
+++ b/src/test/java/edu/illinois/library/cantaloupe/resource/ResourceTest.java
@@ -39,6 +39,7 @@ public static BaseConfiguration newConfiguration() {
}
public void setUp() throws Exception {
+ System.setProperty("java.awt.headless", "true");
Application.setConfiguration(newConfiguration());
Application.startServer();
}
diff --git a/website/changes.html b/website/changes.html
index 6beed0ec8..6dee49680 100644
--- a/website/changes.html
+++ b/website/changes.html
@@ -4,6 +4,12 @@
Change Log
+1.1
+
+
+
+
cache.client.enabled
key to the config file.1.0.1
diff --git a/website/client-caching.html b/website/client-caching.html
index 3ab04e975..a909bdb34 100644
--- a/website/client-caching.html
+++ b/website/client-caching.html
@@ -5,7 +5,11 @@
Client-Side Caching
cache.client.*
keys in the configuration file. The default settings look something like this:cache.client.*
keys in the configuration file. To enable or disable it, use the cache.client.enabled
key:
cache.client.enabled = true+ +
The default settings look something like this:
cache.client.max_age = 2592000 cache.client.shared_max_age = diff --git a/website/getting-started.html b/website/getting-started.html index 03ac13944..64709d348 100644 --- a/website/getting-started.html +++ b/website/getting-started.html @@ -26,6 +26,12 @@Upgrading
Upgrading is usually just a matter of downloading a new version and running it. Since instances are self-contained, new versions can run happily alongside existing ones, with each using its own config file. Sometimes there are backwards-incompatible changes to the configuration file structure, though, so check below to see if there is anything more to be done.
+1.0.x to 1.1
+ +
cache.client.enabled
key from the sample configuration.Base test case class for all Cantaloupe unit tests.
+ * + *This class is named CantaloupeTestCase and not just TestCase in order to + * prevent bugs stemming from mistakenly importing the wrong TestCase.
+ */ +public abstract class CantaloupeTestCase extends TestCase { + + static { + System.setProperty("java.awt.headless", "true"); + System.setProperty("com.sun.media.jai.disableMediaLib", "true"); + } + +} diff --git a/src/test/java/edu/illinois/library/cantaloupe/cache/CacheFactoryTest.java b/src/test/java/edu/illinois/library/cantaloupe/cache/CacheFactoryTest.java index 1c7b4af7a..11c14d975 100644 --- a/src/test/java/edu/illinois/library/cantaloupe/cache/CacheFactoryTest.java +++ b/src/test/java/edu/illinois/library/cantaloupe/cache/CacheFactoryTest.java @@ -1,10 +1,10 @@ package edu.illinois.library.cantaloupe.cache; import edu.illinois.library.cantaloupe.Application; -import junit.framework.TestCase; +import edu.illinois.library.cantaloupe.CantaloupeTestCase; import org.apache.commons.configuration.BaseConfiguration; -public class CacheFactoryTest extends TestCase { +public class CacheFactoryTest extends CantaloupeTestCase { public void testGetInstance() throws Exception { BaseConfiguration config = new BaseConfiguration(); diff --git a/src/test/java/edu/illinois/library/cantaloupe/cache/FilesystemCacheTest.java b/src/test/java/edu/illinois/library/cantaloupe/cache/FilesystemCacheTest.java index a515eb64a..38dd66c78 100644 --- a/src/test/java/edu/illinois/library/cantaloupe/cache/FilesystemCacheTest.java +++ b/src/test/java/edu/illinois/library/cantaloupe/cache/FilesystemCacheTest.java @@ -2,10 +2,10 @@ import com.fasterxml.jackson.databind.ObjectMapper; import edu.illinois.library.cantaloupe.Application; +import edu.illinois.library.cantaloupe.CantaloupeTestCase; import edu.illinois.library.cantaloupe.image.ImageInfo; import edu.illinois.library.cantaloupe.request.Identifier; import edu.illinois.library.cantaloupe.request.Parameters; -import junit.framework.TestCase; import org.apache.commons.configuration.BaseConfiguration; import org.apache.commons.io.FileUtils; import org.restlet.data.Reference; @@ -17,7 +17,7 @@ import java.io.IOException; import java.nio.file.Paths; -public class FilesystemCacheTest extends TestCase { +public class FilesystemCacheTest extends CantaloupeTestCase { File fixturePath; File imagePath; diff --git a/src/test/java/edu/illinois/library/cantaloupe/test/iiif/Iiif20ConformanceTest.java b/src/test/java/edu/illinois/library/cantaloupe/iiif/Iiif20ConformanceTest.java similarity index 99% rename from src/test/java/edu/illinois/library/cantaloupe/test/iiif/Iiif20ConformanceTest.java rename to src/test/java/edu/illinois/library/cantaloupe/iiif/Iiif20ConformanceTest.java index 48e7c73e0..9237a67f4 100644 --- a/src/test/java/edu/illinois/library/cantaloupe/test/iiif/Iiif20ConformanceTest.java +++ b/src/test/java/edu/illinois/library/cantaloupe/iiif/Iiif20ConformanceTest.java @@ -1,7 +1,8 @@ -package edu.illinois.library.cantaloupe.test.iiif; +package edu.illinois.library.cantaloupe.iiif; import com.fasterxml.jackson.databind.ObjectMapper; import edu.illinois.library.cantaloupe.Application; +import edu.illinois.library.cantaloupe.CantaloupeTestCase; import edu.illinois.library.cantaloupe.ImageServerApplication; import edu.illinois.library.cantaloupe.image.ImageInfo; import edu.illinois.library.cantaloupe.image.SourceFormat; @@ -9,7 +10,6 @@ import edu.illinois.library.cantaloupe.processor.ProcessorFactory; import edu.illinois.library.cantaloupe.request.Identifier; import edu.illinois.library.cantaloupe.request.OutputFormat; -import junit.framework.TestCase; import org.apache.commons.configuration.BaseConfiguration; import org.restlet.Client; import org.restlet.Context; @@ -39,7 +39,7 @@ * @see IIIF Image * API 2.0 */ -public class Iiif20ConformanceTest extends TestCase { +public class Iiif20ConformanceTest extends CantaloupeTestCase { private static final Identifier IMAGE = new Identifier("escher_lego.jpg"); private static final Integer PORT = 34852; diff --git a/src/test/java/edu/illinois/library/cantaloupe/image/SourceFormatTest.java b/src/test/java/edu/illinois/library/cantaloupe/image/SourceFormatTest.java index 4484b1835..f79c44777 100644 --- a/src/test/java/edu/illinois/library/cantaloupe/image/SourceFormatTest.java +++ b/src/test/java/edu/illinois/library/cantaloupe/image/SourceFormatTest.java @@ -1,10 +1,10 @@ package edu.illinois.library.cantaloupe.image; +import edu.illinois.library.cantaloupe.CantaloupeTestCase; import edu.illinois.library.cantaloupe.request.Identifier; -import junit.framework.TestCase; import org.restlet.data.MediaType; -public class SourceFormatTest extends TestCase { +public class SourceFormatTest extends CantaloupeTestCase { public void testValues() { assertNotNull(SourceFormat.valueOf("BMP")); diff --git a/src/test/java/edu/illinois/library/cantaloupe/processor/ProcessorFactoryTest.java b/src/test/java/edu/illinois/library/cantaloupe/processor/ProcessorFactoryTest.java index 62fd0bb4c..2779e5864 100644 --- a/src/test/java/edu/illinois/library/cantaloupe/processor/ProcessorFactoryTest.java +++ b/src/test/java/edu/illinois/library/cantaloupe/processor/ProcessorFactoryTest.java @@ -1,11 +1,11 @@ package edu.illinois.library.cantaloupe.processor; import edu.illinois.library.cantaloupe.Application; +import edu.illinois.library.cantaloupe.CantaloupeTestCase; import edu.illinois.library.cantaloupe.image.SourceFormat; -import junit.framework.TestCase; import org.apache.commons.configuration.BaseConfiguration; -public class ProcessorFactoryTest extends TestCase { +public class ProcessorFactoryTest extends CantaloupeTestCase { public void setUp() { BaseConfiguration config = new BaseConfiguration(); diff --git a/src/test/java/edu/illinois/library/cantaloupe/processor/ProcessorFeatureTest.java b/src/test/java/edu/illinois/library/cantaloupe/processor/ProcessorFeatureTest.java index 12de102c4..08c699b51 100644 --- a/src/test/java/edu/illinois/library/cantaloupe/processor/ProcessorFeatureTest.java +++ b/src/test/java/edu/illinois/library/cantaloupe/processor/ProcessorFeatureTest.java @@ -1,8 +1,8 @@ package edu.illinois.library.cantaloupe.processor; -import junit.framework.TestCase; +import edu.illinois.library.cantaloupe.CantaloupeTestCase; -public class ProcessorFeatureTest extends TestCase { +public class ProcessorFeatureTest extends CantaloupeTestCase { public void testValues() { assertNotNull(ProcessorFeature.valueOf("MIRRORING")); diff --git a/src/test/java/edu/illinois/library/cantaloupe/processor/ProcessorTest.java b/src/test/java/edu/illinois/library/cantaloupe/processor/ProcessorTest.java index 11830366c..7ee97ae6f 100644 --- a/src/test/java/edu/illinois/library/cantaloupe/processor/ProcessorTest.java +++ b/src/test/java/edu/illinois/library/cantaloupe/processor/ProcessorTest.java @@ -1,10 +1,10 @@ package edu.illinois.library.cantaloupe.processor; import edu.illinois.library.cantaloupe.Application; +import edu.illinois.library.cantaloupe.CantaloupeTestCase; import edu.illinois.library.cantaloupe.image.SourceFormat; import edu.illinois.library.cantaloupe.request.OutputFormat; import edu.illinois.library.cantaloupe.request.Parameters; -import junit.framework.TestCase; import org.apache.commons.configuration.BaseConfiguration; import java.awt.Dimension; @@ -20,12 +20,10 @@ /** * Contains base tests common to all Processors. */ -public abstract class ProcessorTest extends TestCase { +public abstract class ProcessorTest extends CantaloupeTestCase { static { Application.setConfiguration(new BaseConfiguration()); - System.setProperty("com.sun.media.jai.disableMediaLib", "true"); - System.setProperty("java.awt.headless", "true"); } protected SourceFormat getAnySupportedSourceFormat(Processor processor) { diff --git a/src/test/java/edu/illinois/library/cantaloupe/processor/ProcessorUtilTest.java b/src/test/java/edu/illinois/library/cantaloupe/processor/ProcessorUtilTest.java index 59999f782..92d911d0f 100644 --- a/src/test/java/edu/illinois/library/cantaloupe/processor/ProcessorUtilTest.java +++ b/src/test/java/edu/illinois/library/cantaloupe/processor/ProcessorUtilTest.java @@ -1,13 +1,13 @@ package edu.illinois.library.cantaloupe.processor; +import edu.illinois.library.cantaloupe.CantaloupeTestCase; import edu.illinois.library.cantaloupe.request.Region; import edu.illinois.library.cantaloupe.request.Rotation; import edu.illinois.library.cantaloupe.request.Size; -import junit.framework.TestCase; import java.awt.image.BufferedImage; -public class ProcessorUtilTest extends TestCase { +public class ProcessorUtilTest extends CantaloupeTestCase { public void testConvertToRgb() { // TODO: write this diff --git a/src/test/java/edu/illinois/library/cantaloupe/request/IdentifierTest.java b/src/test/java/edu/illinois/library/cantaloupe/request/IdentifierTest.java index edf2b9812..4c8423cf6 100644 --- a/src/test/java/edu/illinois/library/cantaloupe/request/IdentifierTest.java +++ b/src/test/java/edu/illinois/library/cantaloupe/request/IdentifierTest.java @@ -1,9 +1,9 @@ package edu.illinois.library.cantaloupe.request; -import junit.framework.TestCase; +import edu.illinois.library.cantaloupe.CantaloupeTestCase; import org.restlet.data.Reference; -public class IdentifierTest extends TestCase { +public class IdentifierTest extends CantaloupeTestCase { public void testEquals() { Identifier id1 = new Identifier("cats"); diff --git a/src/test/java/edu/illinois/library/cantaloupe/request/OutputFormatTest.java b/src/test/java/edu/illinois/library/cantaloupe/request/OutputFormatTest.java index 6351a8076..a221ffff7 100644 --- a/src/test/java/edu/illinois/library/cantaloupe/request/OutputFormatTest.java +++ b/src/test/java/edu/illinois/library/cantaloupe/request/OutputFormatTest.java @@ -1,9 +1,9 @@ package edu.illinois.library.cantaloupe.request; +import edu.illinois.library.cantaloupe.CantaloupeTestCase; import edu.illinois.library.cantaloupe.image.SourceFormat; -import junit.framework.TestCase; -public class OutputFormatTest extends TestCase { +public class OutputFormatTest extends CantaloupeTestCase { public void testValues() { assertNotNull(OutputFormat.valueOf("GIF")); diff --git a/src/test/java/edu/illinois/library/cantaloupe/request/ParametersTest.java b/src/test/java/edu/illinois/library/cantaloupe/request/ParametersTest.java index 2196072d6..4fea7aea7 100644 --- a/src/test/java/edu/illinois/library/cantaloupe/request/ParametersTest.java +++ b/src/test/java/edu/illinois/library/cantaloupe/request/ParametersTest.java @@ -1,8 +1,8 @@ package edu.illinois.library.cantaloupe.request; -import junit.framework.TestCase; +import edu.illinois.library.cantaloupe.CantaloupeTestCase; -public class ParametersTest extends TestCase { +public class ParametersTest extends CantaloupeTestCase { private Parameters parameters; diff --git a/src/test/java/edu/illinois/library/cantaloupe/request/QualityTest.java b/src/test/java/edu/illinois/library/cantaloupe/request/QualityTest.java index 01033e254..a68f4fc9b 100644 --- a/src/test/java/edu/illinois/library/cantaloupe/request/QualityTest.java +++ b/src/test/java/edu/illinois/library/cantaloupe/request/QualityTest.java @@ -1,8 +1,8 @@ package edu.illinois.library.cantaloupe.request; -import junit.framework.TestCase; +import edu.illinois.library.cantaloupe.CantaloupeTestCase; -public class QualityTest extends TestCase { +public class QualityTest extends CantaloupeTestCase { public void testValues() { assertNotNull(Quality.valueOf("BITONAL")); diff --git a/src/test/java/edu/illinois/library/cantaloupe/request/RegionTest.java b/src/test/java/edu/illinois/library/cantaloupe/request/RegionTest.java index 76a1da347..6509d6980 100644 --- a/src/test/java/edu/illinois/library/cantaloupe/request/RegionTest.java +++ b/src/test/java/edu/illinois/library/cantaloupe/request/RegionTest.java @@ -1,11 +1,11 @@ package edu.illinois.library.cantaloupe.request; -import junit.framework.TestCase; +import edu.illinois.library.cantaloupe.CantaloupeTestCase; import java.awt.Dimension; import java.awt.Rectangle; -public class RegionTest extends TestCase { +public class RegionTest extends CantaloupeTestCase { private Region region; diff --git a/src/test/java/edu/illinois/library/cantaloupe/request/RotationTest.java b/src/test/java/edu/illinois/library/cantaloupe/request/RotationTest.java index 0b50f1553..46b430290 100644 --- a/src/test/java/edu/illinois/library/cantaloupe/request/RotationTest.java +++ b/src/test/java/edu/illinois/library/cantaloupe/request/RotationTest.java @@ -1,8 +1,8 @@ package edu.illinois.library.cantaloupe.request; -import junit.framework.TestCase; +import edu.illinois.library.cantaloupe.CantaloupeTestCase; -public class RotationTest extends TestCase { +public class RotationTest extends CantaloupeTestCase { private Rotation rotation; diff --git a/src/test/java/edu/illinois/library/cantaloupe/request/SizeTest.java b/src/test/java/edu/illinois/library/cantaloupe/request/SizeTest.java index ef253eada..a602c8952 100644 --- a/src/test/java/edu/illinois/library/cantaloupe/request/SizeTest.java +++ b/src/test/java/edu/illinois/library/cantaloupe/request/SizeTest.java @@ -1,8 +1,8 @@ package edu.illinois.library.cantaloupe.request; -import junit.framework.TestCase; +import edu.illinois.library.cantaloupe.CantaloupeTestCase; -public class SizeTest extends TestCase { +public class SizeTest extends CantaloupeTestCase { private Size size; diff --git a/src/test/java/edu/illinois/library/cantaloupe/resolver/FilesystemResolverTest.java b/src/test/java/edu/illinois/library/cantaloupe/resolver/FilesystemResolverTest.java index eb9fda5f5..459f85ec9 100644 --- a/src/test/java/edu/illinois/library/cantaloupe/resolver/FilesystemResolverTest.java +++ b/src/test/java/edu/illinois/library/cantaloupe/resolver/FilesystemResolverTest.java @@ -1,9 +1,9 @@ package edu.illinois.library.cantaloupe.resolver; import edu.illinois.library.cantaloupe.Application; +import edu.illinois.library.cantaloupe.CantaloupeTestCase; import edu.illinois.library.cantaloupe.image.SourceFormat; import edu.illinois.library.cantaloupe.request.Identifier; -import junit.framework.TestCase; import org.apache.commons.configuration.BaseConfiguration; import java.io.File; @@ -12,7 +12,7 @@ import java.nio.file.Path; import java.nio.file.Paths; -public class FilesystemResolverTest extends TestCase { +public class FilesystemResolverTest extends CantaloupeTestCase { private static final Identifier IDENTIFIER = new Identifier("escher_lego.jpg"); diff --git a/src/test/java/edu/illinois/library/cantaloupe/resolver/HttpResolverTest.java b/src/test/java/edu/illinois/library/cantaloupe/resolver/HttpResolverTest.java index 9a831980c..16d97b922 100644 --- a/src/test/java/edu/illinois/library/cantaloupe/resolver/HttpResolverTest.java +++ b/src/test/java/edu/illinois/library/cantaloupe/resolver/HttpResolverTest.java @@ -1,15 +1,15 @@ package edu.illinois.library.cantaloupe.resolver; import edu.illinois.library.cantaloupe.Application; +import edu.illinois.library.cantaloupe.CantaloupeTestCase; import edu.illinois.library.cantaloupe.image.SourceFormat; import edu.illinois.library.cantaloupe.request.Identifier; -import junit.framework.TestCase; import org.apache.commons.configuration.BaseConfiguration; import java.io.FileNotFoundException; import java.io.IOException; -public class HttpResolverTest extends TestCase { +public class HttpResolverTest extends CantaloupeTestCase { private static final Identifier IMAGE = new Identifier("14405804_o1.jpg"); HttpResolver instance; diff --git a/src/test/java/edu/illinois/library/cantaloupe/resolver/JdbcResolverTest.java b/src/test/java/edu/illinois/library/cantaloupe/resolver/JdbcResolverTest.java index 2a53daf9a..4f2efbc1e 100644 --- a/src/test/java/edu/illinois/library/cantaloupe/resolver/JdbcResolverTest.java +++ b/src/test/java/edu/illinois/library/cantaloupe/resolver/JdbcResolverTest.java @@ -1,9 +1,9 @@ package edu.illinois.library.cantaloupe.resolver; import edu.illinois.library.cantaloupe.Application; +import edu.illinois.library.cantaloupe.CantaloupeTestCase; import edu.illinois.library.cantaloupe.image.SourceFormat; import edu.illinois.library.cantaloupe.request.Identifier; -import junit.framework.TestCase; import org.apache.commons.configuration.BaseConfiguration; import java.io.File; @@ -15,7 +15,7 @@ import java.sql.Connection; import java.sql.PreparedStatement; -public class JdbcResolverTest extends TestCase { +public class JdbcResolverTest extends CantaloupeTestCase { private JdbcResolver instance; diff --git a/src/test/java/edu/illinois/library/cantaloupe/resolver/ResolverFactoryTest.java b/src/test/java/edu/illinois/library/cantaloupe/resolver/ResolverFactoryTest.java index a148f4c0e..d441506cd 100644 --- a/src/test/java/edu/illinois/library/cantaloupe/resolver/ResolverFactoryTest.java +++ b/src/test/java/edu/illinois/library/cantaloupe/resolver/ResolverFactoryTest.java @@ -1,10 +1,10 @@ package edu.illinois.library.cantaloupe.resolver; import edu.illinois.library.cantaloupe.Application; -import junit.framework.TestCase; +import edu.illinois.library.cantaloupe.CantaloupeTestCase; import org.apache.commons.configuration.BaseConfiguration; -public class ResolverFactoryTest extends TestCase { +public class ResolverFactoryTest extends CantaloupeTestCase { public void testGetResolver() throws Exception { BaseConfiguration config = new BaseConfiguration(); diff --git a/src/test/java/edu/illinois/library/cantaloupe/resource/ComplianceLevelTest.java b/src/test/java/edu/illinois/library/cantaloupe/resource/ComplianceLevelTest.java index 6f08403d9..c5342d2e1 100644 --- a/src/test/java/edu/illinois/library/cantaloupe/resource/ComplianceLevelTest.java +++ b/src/test/java/edu/illinois/library/cantaloupe/resource/ComplianceLevelTest.java @@ -1,14 +1,14 @@ package edu.illinois.library.cantaloupe.resource; +import edu.illinois.library.cantaloupe.CantaloupeTestCase; import edu.illinois.library.cantaloupe.processor.ProcessorFeature; import edu.illinois.library.cantaloupe.request.OutputFormat; import edu.illinois.library.cantaloupe.request.Quality; -import junit.framework.TestCase; import java.util.HashSet; import java.util.Set; -public class ComplianceLevelTest extends TestCase { +public class ComplianceLevelTest extends CantaloupeTestCase { public void testGetLevel() { Setparams
is not in
+ * the correct format
+ */
+ public static Parameters fromUri(String paramsStr)
+ throws IllegalArgumentException {
+ Parameters params = new Parameters();
+ String[] parts = StringUtils.split(paramsStr, "/");
+ if (parts.length == 5) {
+ params.setIdentifier(Identifier.fromUri(parts[0]));
+ params.setRegion(Region.fromUri(parts[1]));
+ params.setSize(Size.fromUri(parts[2]));
+ params.setRotation(Rotation.fromUri(parts[3]));
+ String[] subparts = StringUtils.split(parts[4], ".");
+ if (subparts.length == 2) {
+ params.setQuality(Quality.valueOf(subparts[0].toUpperCase()));
+ params.setOutputFormat(OutputFormat.valueOf(subparts[1].toUpperCase()));
+ } else {
+ throw new IllegalArgumentException("Invalid parameters format");
+ }
+ } else {
+ throw new IllegalArgumentException("Invalid parameters format");
+ }
+ return params;
+ }
+
+ /**
+ * No-op constructor.
+ */
+ public Parameters() {}
+
+ /**
+
+
+ /**
* @param identifier From URI
* @param region From URI
* @param size From URI
@@ -41,14 +77,14 @@ public int compareTo(Parameters params) {
return (last == 0) ? this.toString().compareTo(params.toString()) : last;
}
- public OutputFormat getOutputFormat() {
- return outputFormat;
- }
-
public Identifier getIdentifier() {
return identifier;
}
+ public OutputFormat getOutputFormat() {
+ return outputFormat;
+ }
+
public Quality getQuality() {
return quality;
}
@@ -65,6 +101,32 @@ public Size getSize() {
return size;
}
+ public void setIdentifier(Identifier identifier) {
+ this.identifier = identifier;
+ }
+
+ public void setOutputFormat(OutputFormat outputFormat) {
+ this.outputFormat = outputFormat;
+ }
+
+ public void setQuality(Quality quality) {
+ this.quality = quality;
+ }
+
+ public void setRegion(Region region) {
+ this.region = region;
+ }
+
+ public void setRotation(Rotation rotation) {
+ this.rotation = rotation;
+ }
+
+ public void setSize(Size size) {
+ this.size = size;
+ }
+
+
+
/**
* @return Whether the parameters are effectively requesting the unmodified
* source image, i.e. whether they specify full region, full scale, 0
diff --git a/src/test/java/edu/illinois/library/cantaloupe/request/ParametersTest.java b/src/test/java/edu/illinois/library/cantaloupe/request/ParametersTest.java
index 4fea7aea7..b0ad47ca1 100644
--- a/src/test/java/edu/illinois/library/cantaloupe/request/ParametersTest.java
+++ b/src/test/java/edu/illinois/library/cantaloupe/request/ParametersTest.java
@@ -11,6 +11,29 @@ public void setUp() {
"default", "jpg");
}
+ public void testFromUri() {
+ parameters = Parameters.fromUri("bla/20,20,50,50/pct:90/15/bitonal.jpg");
+ assertEquals("bla", parameters.getIdentifier().toString());
+ assertEquals("20,20,50,50", parameters.getRegion().toString());
+ assertEquals(90f, parameters.getSize().getPercent());
+ assertEquals(15f, parameters.getRotation().getDegrees());
+ assertEquals(Quality.BITONAL, parameters.getQuality());
+ assertEquals(OutputFormat.JPG, parameters.getOutputFormat());
+
+ try {
+ Parameters.fromUri("bla/20,20,50,50/15/bitonal.jpg");
+ fail("Expected exception");
+ } catch (IllegalArgumentException e) {
+ // pass
+ }
+ try {
+ Parameters.fromUri("bla/20,20,50,50/pct:90/15/bitonal");
+ fail("Expected exception");
+ } catch (IllegalArgumentException e) {
+ // pass
+ }
+ }
+
public void testIsUnmodified() {
parameters = new Parameters("identifier", "full", "full", "0",
"default", "jpg");
From 42eaf22fbaa42275d02e4602920e7803175f0571 Mon Sep 17 00:00:00 2001
From: Alex Dolski FilesystemCache caches generated images and (parts of) information requests into a filesystem directory. The location of this directory is configurable, as is the "time-to-live" of the cache files.
+FilesystemCache caches generated images and (parts of) information requests into a filesystem directory. The location of this directory is configurable, as is the "time-to-live" of the cache files, with the following options:
+ +FilesystemCache.pathname
FilesystemCache.ttl_seconds
JdbcCache caches generated images and (parts of) information requests into tables in a relational database (RDBMS). This cache can be configured with the following options:
+ +JdbcCache.connection_string
jdbc:postgresql://localhost:5432/mydatabase
.JdbcCache.user
JdbcCache.password
JdbcCache.image_table
JdbcCache.info_table
JdbcCache.ttl_seconds
Note: JdbcCache has been tested with PostgreSQL 9.4 and H2 1.4. Other databases may work, but are untested. In particular, the database needs to support CREATE TABLE IF NOT EXISTS
syntax, which in the case of PostgreSQL, arrived in version 9.1.
Returns an InputStream corresponding to the given parameters.
+ * + *If an image corresponding to the given parameters exists in the + * cache but is expired, implementations should delete it.
+ * * @param params IIIF request parameters * @return An input stream corresponding to the given parameters, or null * if a non-expired image corresponding to the given parameters does not @@ -46,7 +51,10 @@ public interface Cache { InputStream getImageInputStream(Parameters params); /** - * Reads cached dimension information. + *Reads cached dimension information.
+ * + *If a dimension corresponding to the given parameters exists in the + * cache but is expired, implementations should delete it.
* * @param identifier IIIF identifier * @return Dimension corresponding to the given identifier, or null if no diff --git a/src/main/java/edu/illinois/library/cantaloupe/cache/JdbcCache.java b/src/main/java/edu/illinois/library/cantaloupe/cache/JdbcCache.java index 17581e568..2376c0aa6 100644 --- a/src/main/java/edu/illinois/library/cantaloupe/cache/JdbcCache.java +++ b/src/main/java/edu/illinois/library/cantaloupe/cache/JdbcCache.java @@ -46,7 +46,6 @@ public JdbcImageOutputStream(Connection conn, Parameters params) { @Override public void close() throws IOException { - System.out.println("closing"); try { Configuration config = Application.getConfiguration(); String sql = String.format( @@ -418,21 +417,23 @@ public Dimension getDimension(Identifier identifier) throws IOException { if (tableName != null && tableName.length() > 0) { try { String sql = String.format( - "SELECT %s, %s FROM %s WHERE %s = ? AND %s > ?", + "SELECT %s, %s, %s FROM %s WHERE %s = ?", INFO_TABLE_WIDTH_COLUMN, INFO_TABLE_HEIGHT_COLUMN, - tableName, INFO_TABLE_IDENTIFIER_COLUMN, - INFO_TABLE_LAST_MODIFIED_COLUMN); + INFO_TABLE_LAST_MODIFIED_COLUMN, tableName, + INFO_TABLE_IDENTIFIER_COLUMN); PreparedStatement statement = getConnection().prepareStatement(sql); statement.setString(1, identifier.getValue()); - statement.setTimestamp(2, oldestDate); ResultSet resultSet = statement.executeQuery(); if (resultSet.next()) { - logger.debug("Hit for dimension: {}", identifier); - return new Dimension( - resultSet.getInt(INFO_TABLE_WIDTH_COLUMN), - resultSet.getInt(INFO_TABLE_HEIGHT_COLUMN)); - } else { - flushInfo(identifier); + if (resultSet.getTimestamp(3).after(oldestDate)) { + logger.debug("Hit for dimension: {}", identifier); + return new Dimension( + resultSet.getInt(INFO_TABLE_WIDTH_COLUMN), + resultSet.getInt(INFO_TABLE_HEIGHT_COLUMN)); + } else { + logger.debug("Miss for dimension: {}", identifier); + flushInfo(identifier); + } } } catch (SQLException e) { throw new IOException(e.getMessage(), e); @@ -453,19 +454,23 @@ public InputStream getImageInputStream(Parameters params) { try { Connection conn = getConnection(); String sql = String.format( - "SELECT %s FROM %s WHERE %s = ? AND %s > ?", - IMAGE_TABLE_IMAGE_COLUMN, tableName, - IMAGE_TABLE_PARAMS_COLUMN, - IMAGE_TABLE_LAST_MODIFIED_COLUMN); + "SELECT %s, %s FROM %s WHERE %s = ?", + IMAGE_TABLE_IMAGE_COLUMN, + IMAGE_TABLE_LAST_MODIFIED_COLUMN, tableName, + IMAGE_TABLE_PARAMS_COLUMN); PreparedStatement statement = conn.prepareStatement(sql); statement.setString(1, params.toString()); - statement.setTimestamp(2, oldestDate); ResultSet resultSet = statement.executeQuery(); if (resultSet.next()) { - logger.debug("Hit for image: {}", params); - inputStream = resultSet.getBinaryStream(1); + if (resultSet.getTimestamp(2).after(oldestDate)) { + logger.debug("Hit for image: {}", params); + inputStream = resultSet.getBinaryStream(1); + } else { + logger.debug("Miss for image: {}", params); + flushImage(params); + } } - } catch (SQLException e) { + } catch (IOException | SQLException e) { logger.error(e.getMessage(), e); } } else { diff --git a/src/main/java/edu/illinois/library/cantaloupe/resource/ImageResource.java b/src/main/java/edu/illinois/library/cantaloupe/resource/ImageResource.java index 68fb624be..60cb9361c 100644 --- a/src/main/java/edu/illinois/library/cantaloupe/resource/ImageResource.java +++ b/src/main/java/edu/illinois/library/cantaloupe/resource/ImageResource.java @@ -6,7 +6,6 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.util.List; import java.util.Map; import java.util.Set; @@ -27,7 +26,6 @@ import edu.illinois.library.cantaloupe.resolver.StreamResolver; import org.apache.commons.io.IOUtils; import org.apache.commons.io.output.TeeOutputStream; -import org.restlet.data.CacheDirective; import org.restlet.data.MediaType; import org.restlet.representation.OutputRepresentation; import org.restlet.resource.Get; @@ -102,28 +100,67 @@ public ImageRepresentation(MediaType mediaType, * @param outputStream Response body output stream supplied by Restlet * @throws IOException */ + @Override public void write(OutputStream outputStream) throws IOException { Cache cache = CacheFactory.getInstance(); - if (cache != null) { - try (InputStream cacheStream = cache.getImageInputStream(this.params)) { - if (cacheStream != null) { - IOUtils.copy(cacheStream, outputStream); - } else { - TeeOutputStream tos = new TeeOutputStream(outputStream, - cache.getImageOutputStream(this.params)); - doWrite(tos, cache); + try { + if (cache != null) { + OutputStream cacheOutputStream = null; + try (InputStream cacheInputStream = + cache.getImageInputStream(this.params)) { + if (cacheInputStream != null) { + IOUtils.copy(cacheInputStream, outputStream); + } else { + cacheOutputStream = cache. + getImageOutputStream(this.params); + TeeOutputStream tos = new TeeOutputStream( + outputStream, cacheOutputStream); + doCacheAwareWrite(tos, cache); + } + } catch (Exception e) { + throw new IOException(e); + } finally { + if (cacheOutputStream != null) { + cacheOutputStream.close(); + } } - } catch (Exception e) { - throw new IOException(e); + } else { + doWrite(outputStream); } - } else { + } finally { + /* + TODO: doesn't work with Java2dProcessor.process() - try in release()? + try { + if (this.inputStream != null) { + this.inputStream.close(); + } + } catch (IOException e) { + logger.error(e.getMessage(), e); + } */ + } + } + + /** + * Variant of doWrite() that cleans up incomplete cached images when + * the connection has been interrupted. + * + * @param outputStream + * @param cache + * @throws IOException + */ + private void doCacheAwareWrite(TeeOutputStream outputStream, + Cache cache) throws IOException { + try { doWrite(outputStream); + } catch (IOException e) { + logger.error(e.getMessage(), e); + cache.flush(this.params); } } private void doWrite(OutputStream outputStream) throws IOException { try { - long msec = System.currentTimeMillis(); + final long msec = System.currentTimeMillis(); // if the parameters request an unmodified source image, it can // be streamed right through if (this.params.isRequestingUnmodifiedSource()) { @@ -144,7 +181,7 @@ private void doWrite(OutputStream outputStream) throws IOException { this.sourceFormat); fproc.process(this.params, this.sourceFormat, size, this.file, outputStream); - } else if (this.inputStream != null) { + } else { StreamProcessor sproc = (StreamProcessor) proc; sproc.process(this.params, this.sourceFormat, this.fullSize, this.inputStream, outputStream); @@ -155,33 +192,6 @@ private void doWrite(OutputStream outputStream) throws IOException { } } catch (Exception e) { throw new IOException(e); - } /*finally { - TODO: doesn't work with Java2dProcessor.process() - try { - if (this.inputStream != null) { - this.inputStream.close(); - } - } catch (IOException e) { - logger.error(e.getMessage(), e); - } - }*/ - } - - /** - * Variant of doWrite() that cleans up incomplete cached images when - * the connection has been interrupted. - * - * @param outputStream - * @param cache - * @throws IOException - */ - private void doWrite(OutputStream outputStream, Cache cache) - throws IOException { - try { - doWrite(outputStream); - } catch (IOException e) { - logger.error(e.getMessage(), e); - cache.flush(this.params); } } diff --git a/src/test/java/edu/illinois/library/cantaloupe/cache/JdbcCacheTest.java b/src/test/java/edu/illinois/library/cantaloupe/cache/JdbcCacheTest.java index 3e3827ab7..dc75f9e36 100644 --- a/src/test/java/edu/illinois/library/cantaloupe/cache/JdbcCacheTest.java +++ b/src/test/java/edu/illinois/library/cantaloupe/cache/JdbcCacheTest.java @@ -42,19 +42,19 @@ public void setUp() throws Exception { "default", "jpg"); OutputStream os = instance.getImageOutputStream(params); IOUtils.copy(new FileInputStream(TestUtil.getFixture("jpg")), os); - os.flush(); + os.close(); params = new Parameters("dogs", "50,50,50,50", "pct:90", "0", "default", "jpg"); os = instance.getImageOutputStream(params); IOUtils.copy(new FileInputStream(TestUtil.getFixture("jpg")), os); - os.flush(); + os.close(); params = new Parameters("bunnies", "10,20,50,90", "40,", "15", "color", "png"); os = instance.getImageOutputStream(params); IOUtils.copy(new FileInputStream(TestUtil.getFixture("jpg")), os); - os.flush(); + os.close(); // persist some corresponding dimensions instance.putDimension(new Identifier("cats"), new Dimension(50, 40)); @@ -151,7 +151,7 @@ public void testFlushExpired() throws Exception { "default", "jpg"); OutputStream os = instance.getImageOutputStream(params); IOUtils.copy(new FileInputStream(TestUtil.getFixture("jpg")), os); - os.flush(); + os.close(); instance.putDimension(new Identifier("bees"), new Dimension(50, 40)); instance.flushExpired(); @@ -232,7 +232,7 @@ public void testGetImageInputStreamWithNonzeroTtl() throws Exception { "default", "jpg"); OutputStream os = instance.getImageOutputStream(params); IOUtils.copy(new FileInputStream(TestUtil.getFixture("jpg")), os); - os.flush(); + os.close(); instance.putDimension(new Identifier("bees"), new Dimension(50, 40)); // existing, non-expired image From 1c455dfe478c6d1486fa049bf4fe3ee0c8e03968 Mon Sep 17 00:00:00 2001 From: Alex Dolskicache.client.enabled
key to the config file.cache.client.enabled
key to the config file.The Jekyll website compiler transforms the HTML pages in the website folder into a working static website. The build/deploy_website.rb script takes care of building the website, adding the current Javadoc to it, committing it, and deploying it to GitHub Pages.
-To merely preview the website without releasing it, cd
into the website folder and run jekyll serve
, then go to http://localhost:4000/ in a web browser.
To merely preview the website without releasing it, cd
into the website folder and run jekyll serve
, then go to http://localhost:4000/cantaloupe/ in a web browser.
Cantaloupe roughly uses semantic versioning. Major releases (n) break backwards compatibility in a major way. Minor releases (n.n) either do not break it, or only in a minor/trivial way. Patch releases (n.n.n) are for bugfixes only.
+Cantaloupe roughly uses semantic versioning. Major releases (n) break backwards compatibility in a significant way. Minor releases (n.n) either do not break compatibility, or only in a trivial way. Patch releases (n.n.n) are for bugfixes only.
-Note that the above statement covers public API (the HTTP endpoints) only. Internals may change significantly from release to release (though this is not really likely.)
- -Because Cantaloupe is generally intended to provide stable APIs, major version increments should be expected to be rare.
+Note that the above statement applies only to the HTTP endpoints. Internal public API may change significantly from release to release (though this is not really likely.)
Currently, the release process is mostly manual. The steps involved are:
+Currently, the release process is mostly manual, consisting of the following steps: