From 00b702b22784669a494bd04a5357814c17663b25 Mon Sep 17 00:00:00 2001 From: Robert Casties Date: Tue, 21 Nov 2017 17:57:34 +0100 Subject: [PATCH 1/6] updated version numbers. --- common/src/main/java/digilib/conf/DigilibConfiguration.java | 2 +- webapp/src/main/webapp/jquery/jquery.digilib.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/digilib/conf/DigilibConfiguration.java b/common/src/main/java/digilib/conf/DigilibConfiguration.java index afe7cadb..01165e53 100644 --- a/common/src/main/java/digilib/conf/DigilibConfiguration.java +++ b/common/src/main/java/digilib/conf/DigilibConfiguration.java @@ -57,7 +57,7 @@ public class DigilibConfiguration extends ParameterMap { /** digilib version */ public static String getClassVersion() { - return "2.5.4a"; + return "2.5.5a"; } /* non-static getVersion for Java inheritance */ diff --git a/webapp/src/main/webapp/jquery/jquery.digilib.js b/webapp/src/main/webapp/jquery/jquery.digilib.js index d3a335d7..fee3c1e6 100755 --- a/webapp/src/main/webapp/jquery/jquery.digilib.js +++ b/webapp/src/main/webapp/jquery/jquery.digilib.js @@ -45,7 +45,7 @@ function($) { var defaults = { // version of this script - 'version' : 'jquery.digilib.js 2.5.3a', + 'version' : 'jquery.digilib.js 2.5.5a', // logo url 'logoUrl' : 'img/digilib-logo-text1.png', // homepage url (behind logo) From 2bcb4e6fb53657cb5d1bab21d45ab2f51a678e45 Mon Sep 17 00:00:00 2001 From: Robert Casties Date: Tue, 21 Nov 2017 19:38:53 +0100 Subject: [PATCH 2/6] More documentation. Added Maven build profiles. Changed WAR download links to GitHub. --- README.md | 2 +- doc/src/site/markdown/build-maven.md | 60 +++++++++++++++++++++++- doc/src/site/markdown/install-digilib.md | 24 +++++----- 3 files changed, 71 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index a64ab79d..aa5586a4 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ A versatile image viewing environment for the internet. `digilib` documentation can be found on the [digilib documentation pages](https://robcast.github.io/digilib/) on GitHub -or on [SourceForge](http://digilib.sourceforge.net). +or on [SourceForge](https://sourceforge.net/projects/digilib/). ## How do I run digilib? diff --git a/doc/src/site/markdown/build-maven.md b/doc/src/site/markdown/build-maven.md index 513e6cd5..eb621cb0 100644 --- a/doc/src/site/markdown/build-maven.md +++ b/doc/src/site/markdown/build-maven.md @@ -86,10 +86,66 @@ http://localhost:8080/digilib/server/dlConfig.jsp ## Additional Maven build options +Some build options have to be activated as Maven profiles with the `-P` command line option +when building digilib. For example, to build digilib with the Manifester servlet ("iiif-presentation") +use: + + mvn -Piiif-presentation package + +You can add multiple profiles at the same time if necessary. + + ### servlet2 Digilib uses the Asynchronous Servlet API (3.0) by default. You will need Java version 6 or later and Tomcat version 7 or Jetty version 8 or later to use it. -If you want to use the old non-Asynchronous Servlet API (2.3) add `-Pservlet2` -to the Maven command line above. + +`-Pservlet2` builds a servlet with the the old non-Asynchronous Servlet API (2.3). + +This creates a WAR file with the postfix "-srv2". +The build process uses the file `webapp/src/main/webapp/WEB-INF/web-2.4.xml` as `web.xml` file. + +### servlet3 + +`-Pservlet3` builds digillib with the Asynchronous Servlet API (3.0). This is the default profile, it will be used +if you do not specify any profile. + +This creates a WAR file with the postfix "-srv3". +The build process uses the file `webapp/src/main/webapp/WEB-INF/web-3.0.xml` as `web.xml` file. + +### iiif-presentation + +`-Piiif-presentation` builds digilib with the "Manifester" servlet for IIIF Presentation API support +(see [digilib IIIF support documentation](iiif-api.html)). + +This creates a WAR file with the postfix "-srv3p". +The build process uses the file `webapp/src/main/webapp/WEB-INF/web-iiif-pres.xml` as `web.xml` file. + +### text + +`-Ptext` builds digilib with the "Texter" servlet to download plain text or XML files +(see [the source](https://github.com/robcast/digilib/tree/master/text)). You have +to add `-Pservlet3` or `-Pservlet2` as well. + +You also have to copy the mapping for the "Texter" servlet from `web-additional.xml` into the `web.xml` file +used by the selected servlet API like `web-3.0.xml`. + +### pdf + +`-Ppdf` builds digilib with the "PDFCache" servlet to generate and download PDF files from images. +(see [the source](https://github.com/robcast/digilib/tree/master/pdf)). + +You also have to copy the mapping for the "PDFCache" servlet from `web-additional.xml` into the `web.xml` file +used by the selected servlet API like `web-3.0.xml`. + +## create-sprites + +`-Pcreate-sprites` re-creates the image sprite file (`webapp/src/main/webapp/jquery/img/dl-buttons-full-32-sprite.png`) +from the separate icon image files. This option only needs to be used if you are a developer and you want to +change the icon images. + +## running tests + +`-DskipTests=false` enables some functional tests. The tests are run as part of the normal build process. +You can also run just the tests with `mvn -DskipTests=false test`. diff --git a/doc/src/site/markdown/install-digilib.md b/doc/src/site/markdown/install-digilib.md index 28e97c1a..85a2892b 100644 --- a/doc/src/site/markdown/install-digilib.md +++ b/doc/src/site/markdown/install-digilib.md @@ -10,8 +10,8 @@ later) or [Jetty](http://www.eclipse.org/jetty/) (version 8 or later) ## Start the Servlet Container Install and run the Servlet Container of your choice: -[Tomcat](http://tomcat.apache.org/tomcat-7.0-doc/setup.html) or -[Jetty](http://wiki.eclipse.org/Jetty/Howto/Run_Jetty). +[Tomcat](http://tomcat.apache.org/) or +[Jetty](http://wiki.eclipse.org/Jetty/). When the Servlet Container runs you should be able to access the start page on @@ -35,7 +35,7 @@ or web application directory any time you need. Also you get the chance to always use the latest digilib version by updating the source code. You can also download a digilib WAR file with a default configuration from the -[SourceForge download page](https://sourceforge.net/projects/digilib/files/) +[GitHub release page](https://github.com/robcast/digilib/releases) or the latest digilib build from the [daily build page](https://it-dev.mpiwg-berlin.mpg.de/downloads/digilib/daily-build/). The default configuration will only show a set of sample images. If you want to show your own images @@ -47,12 +47,12 @@ you will need to change the [digilib configuration](digilib-config.html) to poin 1. Get a digilib WAR file. 2. Rename the WAR file to `digilib.war`. 3. Deploy the WAR file by copying it into the `webapps` directory of your -Servlet Container. + Servlet Container. 4. Restart your Servlet Container (this may not be necessary). 5. Access your digilib instance at . You will now be able to see the sample images provided with the digilib -installation in the default configuration yor your own images +installation in the default configuration or your own images if you have updated the [configuration](digilib-config.html). In digilib you can view images by providing the directory and file @@ -68,14 +68,14 @@ Read more about the layout of image files and directories ## Install digilib as a web application directory 1. Get a digilib web application directory. -2. Rename the WAR file to `digilib.war`. -3. Deploy the WAR file by copying it into the `webapps` directory of your -Servlet Container. +2. Rename the directory to `digilib`. +3. Deploy the directory by copying it into the `webapps` directory of your + Servlet Container. 4. Restart your Servlet Container (this may not be necessary). 5. Access your digilib instance at You will now be able to see the sample images provided with the digilib -installation in the default configuration yor your own images +installation in the default configuration or your own images if you have updated the [configuration](digilib-config.html). In digilib you can view images by providing the directory and file @@ -98,6 +98,6 @@ Container (when its not running) to see if it created an unpacked web application directory called `digilib`. Then: 1. Make sure that your Servlet Container is not running and remove any -`digilib.war` files from the `webapps` directory. -2. Copy your `digilib` directory into the `webapps` directory of the -Servlet Container. + `digilib.war` files from the `webapps` directory. +2. Keep the `digilib` directory in the `webapps` directory of the + Servlet Container. From 9cd1a322d4c79605dbb14fa22fc5905a13af3287 Mon Sep 17 00:00:00 2001 From: Robert Casties Date: Tue, 21 Nov 2017 20:30:34 +0100 Subject: [PATCH 3/6] More documentation. --- doc/src/site/markdown/digilib-config.md | 62 ++++++++++++++----------- 1 file changed, 34 insertions(+), 28 deletions(-) diff --git a/doc/src/site/markdown/digilib-config.md b/doc/src/site/markdown/digilib-config.md index 6cd68bd8..114e7ccd 100644 --- a/doc/src/site/markdown/digilib-config.md +++ b/doc/src/site/markdown/digilib-config.md @@ -35,7 +35,7 @@ If relative paths are provided as file locations, these will be resolved with the web application's directory as base. You can inspect a summary of your running digilib configuration at the URL -`/server/dlConfig.jsp`. +`/server/dlConfig.jsp` e.g. . ### Image locations @@ -44,7 +44,7 @@ You can inspect a summary of your running digilib configuration at the URL ``` A list of directories where images are searched. See -[this document](image-directories.html) for details. +[this document](image-directories.html) for details (**required**). ```xml @@ -79,7 +79,7 @@ The location of the mapping file. Refer to [digilib-map.xml.template](https://github.com/robcast/digilib/blob/master/webapp/src/main/webapp/WEB-INF/digilib-map.xml.template) for an example. -The file contains `mapping` elements with a `link` attribute containing a 'virtual directory' name that is mapped to the +The file contains `mapping` elements with a `link` attribute containing a 'virtual directory' name that is redirected to the directory given in the `dir` attribute. @@ -121,6 +121,13 @@ subsampling, i.e. by skipping pixels. Details are provided in the [documentation on authentication and authorization](auth.html). +```xml + +``` + +Enables or disables all authorization. If `use-authorization` is `true` you also have to configure +`authnops-class`, `authzops-class` and the `auth-file` and its contents. + ```xml ``` @@ -146,13 +153,6 @@ The class to handle authentication. The class to handle authorization. -```xml - -``` - -Enable or disable all authorization. If `use-authorization` is `true` it also needs to be configured -using `authnops-class` and `authzops-class` and the `auth-file`. - ### IIIF API options @@ -195,7 +195,7 @@ The character that replaces a slash in the identifier of IIIF requests. ``` -The maximum number of requests waiting in the queue before sending "service unavailable". +The maximum number of requests waiting in the queue before new requests get "service unavailable". ```xml @@ -210,7 +210,7 @@ The maximum number of concurrently working threads. Timeout for worker threads in milliseconds. -### Assorted options +### Other options ```xml @@ -234,39 +234,45 @@ and lead to resource issues if digilib runs for a long time. ``` -Location of the logging configuration file. The current logger is +Location of the logging configuration file. The current logging library is [Log4J 1.2](https://logging.apache.org/log4j/1.2/manual.html). +### Options for developers -### Unknown category - -**TODO** move items to appropriate sections +Using these options you can replace default classes used by digilib with your own implementations +to change the behaviour of digilib. ```xml - + ``` -Class for **TODO**. + +Class of the `DocuImage` instance. You can replace the `digilib.image.DocuImage` implementation to use a different image +toolkit than Java ImageIO. (There are deprecated alternative implementations in the `common-jai`, +`common-imagej` and `common-bioformats` modules.) ```xml - + ``` -Class for **TODO**. +Text string to selectively enable specific `Hacks` in the `DocuImage` implementation +(see [the source](https://github.com/robcast/digilib/blob/master/common/src/main/java/digilib/image/ImageLoaderDocuImage.java)) ```xml - + + ``` -Class for the `DocuImage` instance, **TODO** elaborate intended use +Classes of the `digilib.meta.FileMeta` and `digilib.meta.DirMeta` implementations. You can change these implementations +to change the way digilib finds metadata about image files. + +`IndexMetaFileMeta` and `IndexMetaDirMeta` read metadata from `index.meta` and `*.meta` XML files according to +the [index meta standard](http://intern.mpiwg-berlin.mpg.de/digitalhumanities/mpiwg-metadata-documentation/formate/indexmeta-standard). ```xml - + ``` -**TODO** elaborate +Class of the `digilib.io.DocuDirectory` implementation. You can change this implementation to change the way +digilib finds image files (including different resolutions). -```xml - -``` -Class for **TODO**. From acaa50dff2410e9acc8177dd19ea1aa119206570 Mon Sep 17 00:00:00 2001 From: Robert Casties Date: Tue, 21 Nov 2017 20:48:54 +0100 Subject: [PATCH 4/6] Still more documentation fixes. --- doc/src/site/markdown/digilib-config.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/src/site/markdown/digilib-config.md b/doc/src/site/markdown/digilib-config.md index 114e7ccd..bffa4800 100644 --- a/doc/src/site/markdown/digilib-config.md +++ b/doc/src/site/markdown/digilib-config.md @@ -168,13 +168,15 @@ The IIIF API version for the generated `info.json` information response. ``` -Enables the `Cross-Origin Resource Sharing` header in IIIF info requests. +Enables the [Cross-Origin Resource Sharing](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) +header in IIIF info requests (`Access-Control-Allow-Origin: *`). ```xml ``` -Enables the `Cross-Origin Resource Sharing` header in IIIF image requests. +Enables the [Cross-Origin Resource Sharing](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) +header in IIIF image requests (`Access-Control-Allow-Origin: *`). ```xml From 06935f4e9958969f0df52e447f441e128b9e7b12 Mon Sep 17 00:00:00 2001 From: Robert Casties Date: Thu, 23 Nov 2017 13:12:35 +0100 Subject: [PATCH 5/6] Changed IIIF info.json generation to JsonGenerator. Should fix missing comma bug in sizes list. Updated javax.json implementation to 1.0.4. --- iiif-presentation/pom.xml | 2 +- servlet/pom.xml | 11 ++ .../main/java/digilib/servlet/ServletOps.java | 113 ++++++++++++------ 3 files changed, 91 insertions(+), 35 deletions(-) diff --git a/iiif-presentation/pom.xml b/iiif-presentation/pom.xml index a8fe6005..fc3b3175 100644 --- a/iiif-presentation/pom.xml +++ b/iiif-presentation/pom.xml @@ -35,7 +35,7 @@ org.glassfish javax.json - 1.0 + 1.0.4 diff --git a/servlet/pom.xml b/servlet/pom.xml index bba661c9..bc8da3ae 100644 --- a/servlet/pom.xml +++ b/servlet/pom.xml @@ -27,9 +27,20 @@ provided + org.bitbucket.b_c jose4j 0.5.0 + + javax.json + javax.json-api + 1.0 + + + org.glassfish + javax.json + 1.0.4 + diff --git a/servlet/src/main/java/digilib/servlet/ServletOps.java b/servlet/src/main/java/digilib/servlet/ServletOps.java index 94f88b0a..f205d92d 100644 --- a/servlet/src/main/java/digilib/servlet/ServletOps.java +++ b/servlet/src/main/java/digilib/servlet/ServletOps.java @@ -34,8 +34,11 @@ import java.util.Enumeration; import java.util.StringTokenizer; +import javax.json.Json; +import javax.json.stream.JsonGenerator; import javax.servlet.ServletContext; import javax.servlet.ServletException; +import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -482,7 +485,6 @@ public static void sendIiifInfo(DigilibServletRequest dlReq, HttpServletResponse } } - PrintWriter writer; if (dlConfig.getAsString("iiif-api-version").startsWith("2.")) { /* * IIIF Image API version 2 image information @@ -498,54 +500,97 @@ public static void sendIiifInfo(DigilibServletRequest dlReq, HttpServletResponse +"; type=\"application/ld+json\""); } // write info.json - writer = response.getWriter(); - writer.println("{"); - writer.println("\"@context\" : \"http://iiif.io/api/image/2/context.json\","); - writer.println("\"@id\" : \"" + url + "\","); - writer.println("\"protocol\" : \"http://iiif.io/api/image\","); - writer.println("\"width\" : " + size.width + ","); - writer.println("\"height\" : " + size.height + ","); - writer.println("\"profile\" : ["); - writer.println(" \"http://iiif.io/api/image/2/level2.json\","); - writer.println(" {"); - writer.println(" \"formats\" : [\"jpg\", \"png\"],"); - writer.println(" \"qualities\" : [\"color\", \"gray\"],"); + ServletOutputStream out = response.getOutputStream(); + JsonGenerator info = Json.createGenerator(out); + // top level object + info.writeStartObject() + .write("@context", "http://iiif.io/api/image/2/context.json") + .write("@id", url) + .write("protocol", "http://iiif.io/api/image") + .write("width", size.width) + .write("height", size.height); + // profile[ array + info.writeStartArray("profile") + // profile[ level + .write("http://iiif.io/api/image/2/level2.json"); + // profile[{ object + info.writeStartObject(); + // profile[{formats[ + info.writeStartArray("formats") + .write("jpg") + .write("png") + .writeEnd(); + // profile[{qualities[ + info.writeStartArray("qualities") + .write("color") + .write("gray") + .writeEnd(); + // profile[{maxArea if (dlConfig.getAsInt("max-image-size") > 0) { - writer.println(" \"maxArea\" : " + dlConfig.getAsInt("max-image-size") + ","); + info.write("maxArea", dlConfig.getAsInt("max-image-size")); } - writer.println(" \"supports\" : [" - + "\"mirroring\", \"rotationArbitrary\", \"sizeAboveFull\", \"regionSquare\"" - + "]"); - writer.println(" }]"); + // profile[{supports[ + info.writeStartArray("supports") + .write("mirroring") + .write("rotationArbitrary") + .write("sizeAboveFull") + .write("regionSquare") + .writeEnd(); + // profile[{} + info.writeEnd(); + // profile[] + info.writeEnd(); // add size of original and prescaled images int numImgs = imageSet.size(); if (numImgs > 0) { - writer.println(", \"sizes\" : ["); + // sizes[ + info.writeStartArray("sizes"); for (int i = numImgs - 1; i >= 0; --i) { ImageInput ii = imageSet.get(i); ImageSize is = ii.getSize(); - writer.println(" {\"width\" : "+is.getWidth()+", \"height\" : "+is.getHeight()+"}" - +((i > 1)?",":"")); + // sizes[{ + info.writeStartObject() + .write("width", is.getWidth()) + .write("height", is.getHeight()) + .writeEnd(); } - writer.println("]"); + // sizes[] + info.writeEnd(); } - writer.println("}"); - + // end info.json + info.writeEnd(); + info.close(); + } else { /* * IIIF Image API version 1 image information */ response.setContentType("application/json,application/ld+json"); - writer = response.getWriter(); - writer.println("{"); - writer.println("\"@context\" : \"http://library.stanford.edu/iiif/image-api/1.1/context.json\","); - writer.println("\"@id\" : \"" + url + "\","); - writer.println("\"width\" : " + size.width + ","); - writer.println("\"height\" : " + size.height + ","); - writer.println("\"formats\" : [\"jpg\", \"png\"],"); - writer.println("\"qualities\" : [\"native\", \"color\", \"grey\"],"); - writer.println("\"profile\" : \"http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level2\""); - writer.println("}"); + // write info.json + ServletOutputStream out = response.getOutputStream(); + JsonGenerator info = Json.createGenerator(out); + // top level object + info.writeStartObject() + .write("@context", "http://library.stanford.edu/iiif/image-api/1.1/context.json") + .write("@id", url) + .write("width", size.width) + .write("height", size.height); + // formats[ + info.writeStartArray("formats") + .write("jpg") + .write("png") + .writeEnd(); + // qualities[ + info.writeStartArray("qualities") + .write("native") + .write("color") + .write("gray") + .writeEnd(); + // profile + info.write("profile", "http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level2"); + // end info.json + info.writeEnd(); + info.close(); } } catch (IOException e) { throw new ServletException("Unable to write response!", e); From 9b4d666fde56313edcb5fb797e46f6600e66d22d Mon Sep 17 00:00:00 2001 From: Robert Casties Date: Thu, 23 Nov 2017 14:59:09 +0100 Subject: [PATCH 6/6] Remove context link header for IIIF image info response. --- servlet/src/main/java/digilib/servlet/ServletOps.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/servlet/src/main/java/digilib/servlet/ServletOps.java b/servlet/src/main/java/digilib/servlet/ServletOps.java index f205d92d..9250b3af 100644 --- a/servlet/src/main/java/digilib/servlet/ServletOps.java +++ b/servlet/src/main/java/digilib/servlet/ServletOps.java @@ -495,9 +495,6 @@ public static void sendIiifInfo(DigilibServletRequest dlReq, HttpServletResponse response.setContentType("application/ld+json"); } else { response.setContentType("application/json"); - response.setHeader("Link", "" - +"; rel=\"http://www.w3.org/ns/json-ld#context\"" - +"; type=\"application/ld+json\""); } // write info.json ServletOutputStream out = response.getOutputStream();