Skip to content

Commit

Permalink
Update to new checkstyle rules, including code update
Browse files Browse the repository at this point in the history
  • Loading branch information
ksclarke committed Sep 6, 2017
1 parent 26f8418 commit 7d2bb49
Show file tree
Hide file tree
Showing 70 changed files with 1,549 additions and 659 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

### Introduction

Jiiify is an experimental Java-based IIIF (Version 2, Level 0) image server built with [Vert.x](http://vertx.io/) (an event-driven, non-blocking, reactive tool-kit). Jiiify is still in active development and does not yet have a stable release.
Jiiify is an experimental Java-based IIIF (Version 2, Level 0) tile server built with [Vert.x](http://vertx.io/) (an event-driven, non-blocking, reactive tool-kit). Jiiify is still in active development and does not yet have a stable release.

As a "Level 0" IIIF image server, Jiiify does not generate images on-the-fly; instead it pre-generates the tiles and thumbnails necessary to use [Mirador](http://projectmirador.org/) and [OpenSeadragon](https://openseadragon.github.io/) (and perhaps other IIIF tiling clients). Archival images should be ingested into Jiiify so that tiles can be generated. Jiiify does not store the archival images, just the derivatives that are created. The archival images should continue to live in their repositories or on their separate archival file systems.
As a "Level 0" IIIF tile server, Jiiify does not generate images on-the-fly; instead, it pre-generates the tiles and thumbnails necessary to use [Mirador](http://projectmirador.org/) and [OpenSeadragon](https://openseadragon.github.io/) (and perhaps other IIIF tiling clients). Archival images should be ingested into Jiiify so that tiles can be generated. Jiiify does not store the archival images, just the derivatives that are created. The archival images should continue to live in their repositories or on their separate archival file systems.

Note that in order to use Jiiify with Mirador, or other similar viewers, one must create IIIF Presentation API manifests and upload them into Jiiify using its Web-based administrative interface. There is not, currently, any mechanism for creating or editing IIIF presentation manifests within Jiiify itself. Currently, at my place of work, we use a script that builds a IIIF manifest from files on the file system and a CSV document with metadata.

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -962,7 +962,7 @@
<parent>
<groupId>info.freelibrary</groupId>
<artifactId>freelib-parent</artifactId>
<version>0.1.15</version>
<version>0.1.17-SNAPSHOT</version>
</parent>

</project>
52 changes: 29 additions & 23 deletions src/main/java/info/freelibrary/jiiify/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import static info.freelibrary.jiiify.Constants.OAUTH_USERS;
import static info.freelibrary.jiiify.Constants.SERVICE_PREFIX_PROP;
import static info.freelibrary.jiiify.Constants.SHARED_DATA_KEY;
import static info.freelibrary.jiiify.Constants.SLASH;
import static info.freelibrary.jiiify.Constants.SOLR_SERVER_PROP;
import static info.freelibrary.jiiify.Constants.TILE_SIZE_PROP;
import static info.freelibrary.jiiify.Constants.UPLOADS_DIR_PROP;
Expand Down Expand Up @@ -78,11 +79,13 @@ public class Configuration implements Shareable {

public static final long DEFAULT_SESSION_TIMEOUT = 7200000L; // two hours

public static final String DEFAULT_UPLOADS_DIR = Paths.get(System.getProperty("java.io.tmpdir"),
"jiiify-file-uploads").toString();
public static final String TMP_DIR_PROPERTY = "java.io.tmpdir";

public static final String DEFAULT_WATCH_FOLDER = Paths.get(System.getProperty("java.io.tmpdir"),
"jiiify-watch-folder").toString();
public static final String TMP_DIR = System.getProperty(TMP_DIR_PROPERTY);

public static final String DEFAULT_UPLOADS_DIR = Paths.get(TMP_DIR, "jiiify-file-uploads").toString();

public static final String DEFAULT_WATCH_FOLDER = Paths.get(TMP_DIR, "jiiify-watch-folder").toString();

public static final File DEFAULT_DATA_DIR = new File("jiiify_data");

Expand All @@ -92,7 +95,11 @@ public class Configuration implements Shareable {

private static final String DEFAULT_SOLR_SERVER = "http://localhost:8983/solr/jiiify";

private final Logger LOGGER = LoggerFactory.getLogger(Configuration.class, MESSAGES);
private static final Logger LOGGER = LoggerFactory.getLogger(Configuration.class, MESSAGES);

private static final String HTTPS = "https";

private static final String HTTP = "http";

private final int myPort;

Expand Down Expand Up @@ -286,7 +293,7 @@ public String getOAuthClientID(final String aService) {
}

// FIXME: With something better than a RuntimeException
throw new RuntimeException("Unsupported OAuth service");
throw new RuntimeException(LOGGER.getMessage(MessageCodes.EXC_087));
}

/**
Expand All @@ -305,7 +312,7 @@ public String getOAuthClientSecretKey(final String aService) {
}

// FIXME: With something better than a RuntimeException
throw new RuntimeException("Unsupported OAuth service");
throw new RuntimeException(LOGGER.getMessage(MessageCodes.EXC_087));
}

/**
Expand Down Expand Up @@ -369,17 +376,18 @@ public String getScheme() {
* @return True if the server is using HTTPS; else, false
*/
public boolean usesHttps() {
return myURLScheme.equals("https");
return HTTPS.equals(myURLScheme);
}

/**
* Returns the base URL of the Jiiify image server, including: scheme, host, and port (if something other than 80).
* Returns the base URL of the Jiiify image server, including: scheme, host, and port (if something other than
* 80).
*
* @return The base URL of the Jiiify image server
*/
public String getServer() {
final int port = getPort();
return getScheme() + "://" + getHost() + (port != 80 && port != 443 ? ":" + getPort() : "");
return getScheme() + "://" + getHost() + ((port != 80) && (port != 443) ? ":" + getPort() : "");
}

/**
Expand Down Expand Up @@ -509,31 +517,29 @@ private boolean hasIDPrefixMatch(final String aID) {

private String setURLScheme(final JsonObject aConfig) {
final Properties properties = System.getProperties();
final String https = "https";
final String http = "http";

// We'll give command line properties first priority then fall back to our JSON configuration
if (properties.containsKey(URL_SCHEME_PROP)) {
final String scheme = properties.getProperty(URL_SCHEME_PROP);

if (LOGGER.isDebugEnabled()) {
if (scheme.equals(http)) {
LOGGER.debug(MessageCodes.DBG_112, URL_SCHEME_PROP, http);
} else if (scheme.equals(https)) {
LOGGER.debug(MessageCodes.DBG_112, URL_SCHEME_PROP, https);
if (HTTP.equals(scheme)) {
LOGGER.debug(MessageCodes.DBG_112, URL_SCHEME_PROP, HTTP);
} else if (HTTPS.equals(scheme)) {
LOGGER.debug(MessageCodes.DBG_112, URL_SCHEME_PROP, HTTPS);
}
}

if (!scheme.equals(http) && !scheme.equals(https)) {
LOGGER.warn(MessageCodes.WARN_016, URL_SCHEME_PROP, scheme, https);
if (!HTTP.equals(scheme) && !HTTPS.equals(scheme)) {
LOGGER.warn(MessageCodes.WARN_016, URL_SCHEME_PROP, scheme, HTTPS);

return https;
return HTTPS;
} else {
LOGGER.info(MessageCodes.INFO_008, scheme);
return scheme;
}
} else {
return https;
return HTTPS;
}
}

Expand Down Expand Up @@ -663,7 +669,7 @@ private String setServicePrefix(final JsonObject aConfig) {
}

try {
prefix = PathUtils.encodeServicePrefix(prefix.startsWith("/") ? prefix : "/" + prefix);
prefix = PathUtils.encodeServicePrefix(prefix.startsWith(SLASH) ? prefix : SLASH + prefix);
LOGGER.info(MessageCodes.INFO_013, prefix);
} catch (final URISyntaxException details) {
LOGGER.warn(MessageCodes.WARN_020, prefix, DEFAULT_SERVICE_PREFIX);
Expand Down Expand Up @@ -713,7 +719,7 @@ private void setUploadsDir(final JsonObject aConfig, final Handler<AsyncResult<C
uploadsDir = StringUtils.trimTo(aConfig.getString(UPLOADS_DIR_PROP), DEFAULT_UPLOADS_DIR);
}

if ("java.io.tmpdir".equalsIgnoreCase(uploadsDir)) {
if (TMP_DIR_PROPERTY.equalsIgnoreCase(uploadsDir)) {
uploadsDir = DEFAULT_UPLOADS_DIR;
LOGGER.debug(MessageCodes.DBG_113, uploadsDir);
}
Expand Down Expand Up @@ -753,7 +759,7 @@ private void setDataDirs(final JsonObject aConfig, final Handler<AsyncResult<Con
location = props.getProperty(DATA_DIR_PROP, aConfig.getString(DATA_DIR_PROP, DEFAULT_DATA_DIR
.getAbsolutePath()));

if (awsAccessKey != null && awsSecretKey != null) {
if ((awsAccessKey != null) && (awsSecretKey != null)) {
LOGGER.info(MessageCodes.INFO_015, awsAccessKey);

if (s3Endpoint == null) {
Expand Down
90 changes: 47 additions & 43 deletions src/main/java/info/freelibrary/jiiify/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,96 +10,100 @@
*/
public interface Constants {

public static final String UTF_8_ENCODING = Charset.forName("UTF-8").name();
String UTF_8_ENCODING = Charset.forName("UTF-8").name();

public static final String MESSAGES = "jiiify_messages";
String MESSAGES = "jiiify_messages";

/* The following are properties that can be set by the user */

public static final String HTTP_PORT_PROP = "jiiify.port";
String HTTP_PORT_PROP = "jiiify.port";

public static final String HTTP_PORT_REDIRECT_PROP = "jiiify.redirect.port";
String HTTP_PORT_REDIRECT_PROP = "jiiify.redirect.port";

public static final String HTTP_HOST_PROP = "jiiify.host";
String HTTP_HOST_PROP = "jiiify.host";

public static final String JIIIFY_CORES_PROP = "jiiify.cores";
String JIIIFY_CORES_PROP = "jiiify.cores";

public static final String URL_SCHEME_PROP = "jiiify.url.scheme";
String URL_SCHEME_PROP = "jiiify.url.scheme";

public static final String DATA_DIR_PROP = "jiiify.data.dir";
String DATA_DIR_PROP = "jiiify.data.dir";

public static final String UPLOADS_DIR_PROP = "jiiify.uploads.dir";
String UPLOADS_DIR_PROP = "jiiify.uploads.dir";

public static final String WATCH_FOLDER_PROP = "jiiify.watch.folder";
String WATCH_FOLDER_PROP = "jiiify.watch.folder";

public static final String SOLR_SERVER_PROP = "jiiify.solr.server";
String SOLR_SERVER_PROP = "jiiify.solr.server";

public static final String LOG_LEVEL_PROP = "jiiify.log.level";
String LOG_LEVEL_PROP = "jiiify.log.level";

public static final String SERVICE_PREFIX_PROP = "jiiify.service.prefix";
String SERVICE_PREFIX_PROP = "jiiify.service.prefix";

public static final String ID_PREFIXES_PROP = "jiiify.id.prefixes";
String ID_PREFIXES_PROP = "jiiify.id.prefixes";

public static final String TILE_SIZE_PROP = "jiiify.tile.size";
String TILE_SIZE_PROP = "jiiify.tile.size";

public static final String THUMBNAIL_SIZE_PROP = "jiiify.thumbnail.size";
String THUMBNAIL_SIZE_PROP = "jiiify.thumbnail.size";

public static final String KEY_PASS_PROP = "jiiify.key.pass";
String KEY_PASS_PROP = "jiiify.key.pass";

public static final String JCEKS_PROP = "jiiify.jceks";
String JCEKS_PROP = "jiiify.jceks";

public static final String JKS_PROP = "jiiify.jks";
String JKS_PROP = "jiiify.jks";

public static final String METRICS_REG_PROP = "jiiify.metrics";
String METRICS_REG_PROP = "jiiify.metrics";

public static final String FEDORA_IP_PROP = "fedora.ip";
String FEDORA_IP_PROP = "fedora.ip";

/* These config values are only used internally. */

public static final String JIIIFY_TESTING = "jiiify.ignore.failures";
String JIIIFY_TESTING = "jiiify.ignore.failures";

public static final String FILE_PATH_KEY = "jiiify.file.path";
String FILE_PATH_KEY = "jiiify.file.path";

public static final String IIIF_PATH_KEY = "jiiify.iiif.path";
String IIIF_PATH_KEY = "jiiify.iiif.path";

public static final String IMAGE_SOURCE_KEY = "jiiify.image.source";
String IMAGE_SOURCE_KEY = "jiiify.image.source";

public static final String IMAGE_CLEANUP_KEY = "jiiify.image.cleanup";
String IMAGE_CLEANUP_KEY = "jiiify.image.cleanup";

public static final String SHARED_DATA_KEY = "jiiify.shared.data";
String SHARED_DATA_KEY = "jiiify.shared.data";

public static final String SOLR_SERVICE_KEY = "jiiify.solr";
String SOLR_SERVICE_KEY = "jiiify.solr";

public static final String CONFIG_KEY = "jiiify.config";
String CONFIG_KEY = "jiiify.config";

public static final String HBS_DATA_KEY = "hbs.data";
String HBS_DATA_KEY = "hbs.data";

public static final String HBS_PATH_SKIP_KEY = "hbs.path.skip";
String HBS_PATH_SKIP_KEY = "hbs.path.skip";

public static final String ID_KEY = "id";
String ID_KEY = "id";

public static final String GOOGLE_OAUTH_CLIENT_ID = "jiiify.oauth.google.clientId";
String GOOGLE_OAUTH_CLIENT_ID = "jiiify.oauth.google.clientId";

public static final String FACEBOOK_OAUTH_CLIENT_ID = "jiiify.oauth.facebook.clientId";
String FACEBOOK_OAUTH_CLIENT_ID = "jiiify.oauth.facebook.clientId";

public static final String OAUTH_USERS = "jiiify.oauth.users";
String OAUTH_USERS = "jiiify.oauth.users";

public static final String OVERWRITE_KEY = "jiiify.file.overwrite";
String OVERWRITE_KEY = "jiiify.file.overwrite";

public static final String JIIIFY_ARRAY = "jiiify.json.array";
String JIIIFY_ARRAY = "jiiify.json.array";

public static final String TILE_REQUEST_KEY = "jiiify.tile.request.id";
String TILE_REQUEST_KEY = "jiiify.tile.request.id";

public static final String IMAGE_BUFFER_KEY = "jiiify.image.buffer";
String IMAGE_BUFFER_KEY = "jiiify.image.buffer";

public static final String IMAGE_COUNTER_KEY = "jiiify.image.counter";
String IMAGE_COUNTER_KEY = "jiiify.image.counter";

public static final String IMAGE_TILE_COUNT = "jiiify.tile.count";
String IMAGE_TILE_COUNT = "jiiify.tile.count";

/* Message values */

public static final String SUCCESS_RESPONSE = "success";
String SUCCESS_RESPONSE = "success";

public static final String FAILURE_RESPONSE = "failure";
String FAILURE_RESPONSE = "failure";

/* Commonly used values */

String SLASH = "/";

}
24 changes: 12 additions & 12 deletions src/main/java/info/freelibrary/jiiify/Metadata.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,28 @@
*/
public interface Metadata {

public static final String CONTENT_TYPE = "Content-Type";
String CONTENT_TYPE = "Content-Type";

public static final String CONTENT_LENGTH = "Content-Length";
String CONTENT_LENGTH = "Content-Length";

public static final String CACHE_CONTROL = "Cache-Control";
String CACHE_CONTROL = "Cache-Control";

public static final String CONTENT_DISPOSITION = "Content-Disposition";
String CONTENT_DISPOSITION = "Content-Disposition";

public static final String JSON_MIME_TYPE = "application/json";
String JSON_MIME_TYPE = "application/json";

public static final String TEXT_MIME_TYPE = "text/plain";
String TEXT_MIME_TYPE = "text/plain";

public static final String HTML_MIME_TYPE = "text/html";
String HTML_MIME_TYPE = "text/html";

public static final String ZIP_MIME_TYPE = "application/zip";
String ZIP_MIME_TYPE = "application/zip";

public static final String MANIFEST_FILE = "manifest.json";
String MANIFEST_FILE = "manifest.json";

public static final String PROPERTIES_FILE = "image.properties";
String PROPERTIES_FILE = "image.properties";

public static final String LOCATION_HEADER = "Location";
String LOCATION_HEADER = "Location";

public static final String DEFAULT_CACHE_CONTROL = "max-age=86400";
String DEFAULT_CACHE_CONTROL = "max-age=86400";

}
Loading

0 comments on commit 7d2bb49

Please sign in to comment.