Skip to content

Commit

Permalink
Merge branch 'release/1.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Dolski committed Nov 25, 2015
2 parents a3ffe51 + 7ce1853 commit 7360cf5
Show file tree
Hide file tree
Showing 45 changed files with 1,647 additions and 206 deletions.
66 changes: 52 additions & 14 deletions cantaloupe.properties.sample
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,14 @@ http.port = 8182
#http.auth.basic.username = myself
#http.auth.basic.secret = password

# Whether to generate all internal links with `https://` URLs, i.e. for when
# running behind an HTTPS reverse proxy.
generate_https_links = false
# Controls the response Content-Disposition header for images. Allowed values
# are `inline`, `attachment`, and `none`.
http.content_disposition = inline

# The base URI to use for internal links, such as Link headers and JSON-LD @id
# values. This is mainly needed in reverse-proxy scenarios, where a public base
# URI needs to override the local URI. Leave blank to use the default.
base_uri =

# Helpful in development
print_stack_trace_on_error_pages = true
Expand All @@ -27,7 +32,8 @@ print_stack_trace_on_error_pages = true
###############

# The resolver that translates the identifier in the URL to an image source.
# Available values are `FilesystemResolver` and `HttpResolver`.
# Available values are `FilesystemResolver`, `HttpResolver`, `JdbcResolver`,
# and `AmazonS3Resolver`.
resolver = FilesystemResolver

###
Expand Down Expand Up @@ -65,7 +71,7 @@ HttpResolver.url_suffix =
#HttpResolver.path_separator =

# Used for HTTP Basic authentication.
HttpResolver.auto.basic.username =
HttpResolver.auth.basic.username =
HttpResolver.auth.basic.secret =

###
Expand All @@ -77,8 +83,7 @@ JdbcResolver.user = postgres
JdbcResolver.password = postgres

# JavaScript function that takes in an unencoded identifier and returns the
# value that will be used in the prepared statement returned by lookup() and
# identify().
# value that will be used in prepared statements.
JdbcResolver.function.identifier = function getDatabaseIdentifier(url_identifier) {\
// return the un-altered identifier\
return url_identifier;\
Expand All @@ -90,7 +95,7 @@ JdbcResolver.function.identifier = function getDatabaseIdentifier(url_identifier
# JavaScript function that returns a media (MIME) type. If the media type is
# stored in the database, this can return an SQL statement to retrieve it, in
# which case the "SELECT" and "FROM" clauses should be in uppercase in order
# to be autodetected. Comment out to force Cantaloupe to infer the media type
# to be autodetected. If commented out, Cantaloupe will infer the media type
# from the identifier extension (if present).
JdbcResolver.function.media_type = function getMediaType() {\
return "SELECT media_type " +\
Expand All @@ -99,27 +104,55 @@ JdbcResolver.function.media_type = function getMediaType() {\
}

# SQL statement that selects the BLOB corresponding to the value returned by
# the function.lookup.statement_value function.
# the getDatabaseIdentifier() function above.
JdbcResolver.lookup_sql = SELECT image \
FROM item \
WHERE filename = ?

###
# AmazonS3Resolver
###

# See: http://aws.amazon.com/security-credentials
# Access key ID associated with your AWS account.
AmazonS3Resolver.access_key_id =
# Secret key associated with your AWS account.
AmazonS3Resolver.secret_key =

# Name of a bucket containing images.
AmazonS3Resolver.bucket.name =

# See: http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region
# Can be commented out or left blank.
#AmazonS3Resolver.bucket.region = us-east-1

###############
# PROCESSORS
###############

# Image processors to use for various source formats. Available values are
# `Java2dProcessor`, `GraphicsMagickProcessor`, `ImageMagickProcessor`,
# `KakaduProcessor`, and `JaiProcessor`.
# `KakaduProcessor`, `JaiProcessor`, and `FfmpegProcessor`.

# These extension-specific definitions are optional.
processor.avi = FfmpegProcessor
#processor.jpg = ImageMagickProcessor
#processor.jp2 = KakaduProcessor
processor.mov = FfmpegProcessor
processor.mp4 = FfmpegProcessor
#processor.tif = GraphicsMagickProcessor
processor.webm = FfmpegProcessor

# Fall back to this processor for any formats not assigned above.
processor.fallback = Java2dProcessor

###
# FfmpegProcessor
###

# Optional; overrides the PATH
#FfmpegProcessor.path_to_binaries = /usr/local/bin

###
# GraphicsMagickProcessor
###
Expand All @@ -142,8 +175,8 @@ processor.fallback = Java2dProcessor
Java2dProcessor.jpg.quality = 0.7f

# Available values are `TIFFImageReader` and `TIFFImageDecoder`.
# TIFFImageReader is optimized for pyramidal TIFFs, but if you notice any
# issues, try switching.
# TIFFImageReader is optimized for pyramidal TIFFs, but both are flaky in
# their own ways. If you notice any issues, try switching.
Java2dProcessor.tif.reader = TIFFImageReader

###
Expand All @@ -156,7 +189,7 @@ Java2dProcessor.tif.reader = TIFFImageReader
# Due to a quirk of kdu_expand, you will need to create a symbolic link to
# /dev/stdout somewhere called `stdout.ppm`, like this:
# `ln -s /dev/stdout /path/to/stdout.ppm`
KakaduProcessor.path_to_stdout_symlink = /some/path/to/stdout.ppm
KakaduProcessor.path_to_stdout_symlink = /path/to/stdout.ppm

# Available values are `jai` and `java2d`.
KakaduProcessor.post_processor = java2d
Expand Down Expand Up @@ -184,6 +217,11 @@ cache.client.no_transform = true
# to disable caching.
#cache.server = FilesystemCache

# If true, the source image will be checked to make sure it exists before a
# cached copy is returned. If false, the cached copy will be returned without
# any checking. Resolving first is safer but slower.
cache.server.resolve_first = true

###
# FilesystemCache
###
Expand All @@ -200,7 +238,7 @@ FilesystemCache.ttl_seconds = 2592000
###

JdbcCache.connection_string = jdbc:postgresql://localhost:5432/cantaloupe
JdbcCache.user = alexd
JdbcCache.user = postgres
JdbcCache.password =

# These will be created automatically.
Expand Down
11 changes: 9 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
<groupId>edu.illinois.library.cantaloupe</groupId>
<artifactId>Cantaloupe</artifactId>
<packaging>jar</packaging>
<version>1.1</version>
<version>1.2</version>
<name>Cantaloupe</name>
<url>https://medusa-project.github.io/cantaloupe/</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<cantaloupe.version>1.1</cantaloupe.version>
<cantaloupe.version>1.2</cantaloupe.version>
<amazon-s3.version>1.9.0</amazon-s3.version>
<commons-io.version>2.4</commons-io.version>
<commons-lang3.version>3.4</commons-lang3.version>
<h2.version>1.4.190</h2.version>
Expand All @@ -34,6 +35,12 @@
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
</dependency>
<!-- Used by AmazonS3Resolver -->
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-s3</artifactId>
<version>${amazon-s3.version}</version>
</dependency>
<!-- Used by JdbcResolverTest -->
<dependency>
<groupId>com.h2database</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import edu.illinois.library.cantaloupe.resource.InformationResource;
import edu.illinois.library.cantaloupe.resource.LandingResource;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.lang3.StringUtils;
import org.apache.velocity.app.Velocity;
import org.restlet.Application;
import org.restlet.Request;
Expand Down Expand Up @@ -80,6 +81,10 @@ public Representation toRepresentation(Status status, Request request,
status.getReasonPhrase());
templateVars.put("message", message);
templateVars.put("stackTrace", stackTrace);
String baseUri = edu.illinois.library.cantaloupe.Application.
getConfiguration().getString("base_uri", "");
baseUri = StringUtils.stripEnd(baseUri, "/");
templateVars.put("baseUri", baseUri);

org.apache.velocity.Template template = Velocity.getTemplate("error.vm");
return new TemplateRepresentation(template, templateVars,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,33 @@
import java.util.List;

/**
* Should contain constants for every source format that anyone could possibly
* ever want to read.
* Should contain constants for every source format that any processor could
* possibly consider supporting.
*/
public enum SourceFormat {

BMP("bmp", "BMP"),
GIF("gif", "GIF"),
JP2("jp2", "JPEG2000"),
JPG("jpg", "JPEG"),
PDF("pdf", "PDF"),
PNG("png", "PNG"),
TIF("tif", "TIFF"),
WEBP("webp", "WebP"),
UNKNOWN("unknown", "Unknown");
AVI("avi", "AVI", Type.VIDEO),
BMP("bmp", "BMP", Type.IMAGE),
GIF("gif", "GIF", Type.IMAGE),
JP2("jp2", "JPEG2000", Type.IMAGE),
JPG("jpg", "JPEG", Type.IMAGE),
MOV("mov", "QuickTime", Type.VIDEO),
MP4("mp4", "MPEG-4", Type.VIDEO),
MPG("mpg", "MPEG", Type.VIDEO),
PDF("pdf", "PDF", Type.IMAGE),
PNG("png", "PNG", Type.IMAGE),
TIF("tif", "TIFF", Type.IMAGE),
WEBM("webm", "WebM", Type.VIDEO),
WEBP("webp", "WebP", Type.IMAGE),
UNKNOWN("unknown", "Unknown", null);

public enum Type {
IMAGE, VIDEO
}

private String id;
private String name;
private Type type;

/**
* @param identifier IIIF identifier.
Expand Down Expand Up @@ -58,15 +68,18 @@ public static SourceFormat getSourceFormat(MediaType mediaType) {
return SourceFormat.UNKNOWN;
}

SourceFormat(String internalId, String name) {
SourceFormat(String internalId, String name, Type type) {
this.id = internalId;
this.name = name;
this.type = type;
}

public List<String> getExtensions() {
List<String> extensions = new ArrayList<>();
// the first extension will be the preferred extension
if (this.id.equals("bmp")) {
if (this.id.equals("avi")) {
extensions.add("avi");
} else if (this.id.equals("bmp")) {
extensions.add("bmp");
} else if (this.id.equals("gif")) {
extensions.add("gif");
Expand All @@ -75,6 +88,12 @@ public List<String> getExtensions() {
} else if (this.id.equals("jpg")) {
extensions.add("jpg");
extensions.add("jpeg");
} else if (this.id.equals("mov")) {
extensions.add("mov");
} else if (this.id.equals("mp4")) {
extensions.add("mp4");
} else if (this.id.equals("mpg")) {
extensions.add("mpg");
} else if (this.id.equals("pdf")) {
extensions.add("pdf");
} else if (this.id.equals("png")) {
Expand All @@ -83,6 +102,8 @@ public List<String> getExtensions() {
extensions.add("tif");
extensions.add("ptif");
extensions.add("tiff");
} else if (this.id.equals("webm")) {
extensions.add("webm");
} else if (this.id.equals("webp")) {
extensions.add("webp");
} else if (this.id.equals("unknown")) {
Expand All @@ -94,7 +115,11 @@ public List<String> getExtensions() {
public List<MediaType> getMediaTypes() {
List<MediaType> types = new ArrayList<>();
// the first type will be the preferred extension
if (this.id.equals("bmp")) {
if (this.id.equals("avi")) {
types.add(new MediaType("video/avi"));
types.add(new MediaType("video/msvideo"));
types.add(new MediaType("video/x-msvideo"));
} if (this.id.equals("bmp")) {
types.add(new MediaType("image/bmp"));
types.add(new MediaType("image/x-ms-bmp"));
} else if (this.id.equals("gif")) {
Expand All @@ -103,12 +128,21 @@ public List<MediaType> getMediaTypes() {
types.add(new MediaType("image/jp2"));
} else if (this.id.equals("jpg")) {
types.add(new MediaType("image/jpeg"));
} else if (this.id.equals("mov")) {
types.add(new MediaType("video/quicktime"));
types.add(new MediaType("video/x-quicktime"));
} else if (this.id.equals("mp4")) {
types.add(new MediaType("video/mp4"));
} else if (this.id.equals("mpg")) {
types.add(new MediaType("video/mpeg"));
} else if (this.id.equals("pdf")) {
types.add(new MediaType("application/pdf"));
} else if (this.id.equals("png")) {
types.add(new MediaType("image/png"));
} else if (this.id.equals("tif")) {
types.add(new MediaType("image/tiff"));
} else if (this.id.equals("webm")) {
types.add(new MediaType("video/webm"));
} else if (this.id.equals("webp")) {
types.add(new MediaType("image/webp"));
} else if (this.id.equals("unknown")) {
Expand All @@ -132,6 +166,14 @@ public MediaType getPreferredMediaType() {
return this.getMediaTypes().get(0);
}

public Type getType() {
return this.type;
}

public boolean isImage() {
return (this.getType() != null && this.getType().equals(Type.IMAGE));
}

/**
* @return Extension.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ public class ApplicationLogFilter extends Filter<ILoggingEvent> {
* Filters out useless log messages.
*/
public FilterReply decide(ILoggingEvent event) {
if (event.getLoggerName().equals("org.restlet") &&
// stop the Amazon S3 client from logging HTTP responses
if (event.getLoggerName().startsWith("org.apache.http.") &&
event.getLevel().equals(Level.DEBUG)) {
return FilterReply.DENY;
} else if (event.getLoggerName().equals("org.restlet") &&
event.getLevel().equals(Level.INFO) &&
event.getMessage().contains("ing the internal HTTP client")) {
return FilterReply.DENY;
Expand Down
Loading

0 comments on commit 7360cf5

Please sign in to comment.