From a6fdfb19561bba0fc8574586440ea036d6a1ec7e Mon Sep 17 00:00:00 2001 From: "Kevin S. Clarke" Date: Thu, 6 Feb 2025 14:21:45 -0500 Subject: [PATCH] [SERV-1218] Update GA build(s) (#231) --- .github/workflows/build.yml | 2 +- .github/workflows/nightly.yml | 1 + .github/workflows/release.yml | 2 +- src/main/docker/kakadu | 2 +- .../docker/patches/issue-574-v5.0.5.patch | 202 ------------------ .../docker/patches/issue-581-v5.0.5.patch | 143 ------------- 6 files changed, 4 insertions(+), 348 deletions(-) delete mode 100644 src/main/docker/patches/issue-574-v5.0.5.patch delete mode 100644 src/main/docker/patches/issue-581-v5.0.5.patch diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9b43f3d..d16fbd5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -41,5 +41,5 @@ jobs: with: maven_goals_phases: "clean verify" maven_args: > - -V -ntp -DlogLevel=DEBUG -DtestLogLevel=DEBUG + -V -ntp -DlogLevel=DEBUG -DtestLogLevel=DEBUG -Ddocker.noCache -D${{ matrix.build_property }}=${{ secrets.KAKADU_VERSION }} diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 92198e1..9481670 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -58,3 +58,4 @@ jobs: -Ddocker.registry.username=${{ secrets.DOCKER_USERNAME }} -Ddocker.registry.account=${{ secrets.DOCKER_REGISTRY_ACCOUNT}} -Ddocker.registry.password=${{ secrets.DOCKER_PASSWORD }} + -Ddocker.noCache diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ded51ec..7dd11f1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -66,7 +66,7 @@ jobs: -Drevision=${{ github.event.release.tag_name }} -ntp -Dorg.slf4j.simpleLogger.log.net.sourceforge.pmd=error -D${{ matrix.build_property }}=${{ secrets.KAKADU_VERSION }} - -DskipNexusStagingDeployMojo=true + -DskipNexusStagingDeployMojo=true -Ddocker.noCache -Ddocker.image=${{ secrets.DOCKER_REGISTRY_ACCOUNT}}cantaloupe${{ env.ARTIFACT_QUALIFIER }}:${{ github.event.release.tag_name }} -Ddocker.registry.username=${{ secrets.DOCKER_USERNAME }} -Ddocker.registry.account=${{ secrets.DOCKER_REGISTRY_ACCOUNT}} diff --git a/src/main/docker/kakadu b/src/main/docker/kakadu index cdf0536..62cfd5f 160000 --- a/src/main/docker/kakadu +++ b/src/main/docker/kakadu @@ -1 +1 @@ -Subproject commit cdf0536312d9fd720fbe2def6e35959322f0fcd4 +Subproject commit 62cfd5fd1079601fe621d0b8cc2be0fe009e291e diff --git a/src/main/docker/patches/issue-574-v5.0.5.patch b/src/main/docker/patches/issue-574-v5.0.5.patch deleted file mode 100644 index f7e4826..0000000 --- a/src/main/docker/patches/issue-574-v5.0.5.patch +++ /dev/null @@ -1,202 +0,0 @@ -diff --git a/src/main/java/edu/illinois/library/cantaloupe/resource/AbstractResource.java b/src/main/java/edu/illinois/library/cantaloupe/resource/AbstractResource.java -index 20181b298..b479e2e29 100644 ---- a/src/main/java/edu/illinois/library/cantaloupe/resource/AbstractResource.java -+++ b/src/main/java/edu/illinois/library/cantaloupe/resource/AbstractResource.java -@@ -198,7 +198,10 @@ public abstract class AbstractResource { - doGET(); - } - -- final void doOPTIONS() { -+ /** -+ * May be overridden by implementations that support {@literal OPTIONS}. -+ */ -+ protected void doOPTIONS() { - Method[] methods = getSupportedMethods(); - if (methods.length > 0) { - response.setStatus(Status.NO_CONTENT.getCode()); -diff --git a/src/main/java/edu/illinois/library/cantaloupe/resource/iiif/v1/InformationResource.java b/src/main/java/edu/illinois/library/cantaloupe/resource/iiif/v1/InformationResource.java -index c0842269c..537c6dbad 100644 ---- a/src/main/java/edu/illinois/library/cantaloupe/resource/iiif/v1/InformationResource.java -+++ b/src/main/java/edu/illinois/library/cantaloupe/resource/iiif/v1/InformationResource.java -@@ -1,8 +1,10 @@ - package edu.illinois.library.cantaloupe.resource.iiif.v1; - -+import java.util.Arrays; - import java.util.HashSet; - import java.util.List; - import java.util.Set; -+import java.util.stream.Collectors; - - import edu.illinois.library.cantaloupe.http.Method; - import edu.illinois.library.cantaloupe.http.Status; -@@ -15,6 +17,8 @@ import edu.illinois.library.cantaloupe.resource.InformationRequestHandler; - import org.slf4j.Logger; - import org.slf4j.LoggerFactory; - -+import javax.servlet.http.HttpServletResponse; -+ - /** - * Handles IIIF Image API 1.x information requests. - * -@@ -39,6 +43,21 @@ public class InformationResource extends IIIF1Resource { - return SUPPORTED_METHODS; - } - -+ @Override -+ protected final void doOPTIONS() { -+ HttpServletResponse response = getResponse(); -+ Method[] methods = getSupportedMethods(); -+ if (methods.length > 0) { -+ response.setStatus(Status.NO_CONTENT.getCode()); -+ response.setHeader("Access-Control-Allow-Headers", "Authorization"); -+ response.setHeader("Allow", Arrays.stream(methods) -+ .map(Method::toString) -+ .collect(Collectors.joining(","))); -+ } else { -+ response.setStatus(Status.METHOD_NOT_ALLOWED.getCode()); -+ } -+ } -+ - /** - * Writes a JSON-serialized {@link ImageInfo} instance to the response. - */ -diff --git a/src/main/java/edu/illinois/library/cantaloupe/resource/iiif/v2/InformationResource.java b/src/main/java/edu/illinois/library/cantaloupe/resource/iiif/v2/InformationResource.java -index bc3658f7f..78051e72a 100644 ---- a/src/main/java/edu/illinois/library/cantaloupe/resource/iiif/v2/InformationResource.java -+++ b/src/main/java/edu/illinois/library/cantaloupe/resource/iiif/v2/InformationResource.java -@@ -1,8 +1,10 @@ - package edu.illinois.library.cantaloupe.resource.iiif.v2; - -+import java.util.Arrays; - import java.util.HashSet; - import java.util.List; - import java.util.Set; -+import java.util.stream.Collectors; - - import edu.illinois.library.cantaloupe.http.Method; - import edu.illinois.library.cantaloupe.http.Status; -@@ -16,6 +18,8 @@ import edu.illinois.library.cantaloupe.resource.InformationRequestHandler; - import org.slf4j.Logger; - import org.slf4j.LoggerFactory; - -+import javax.servlet.http.HttpServletResponse; -+ - /** - * Handles IIIF Image API 2.x information requests. - * -@@ -40,6 +44,21 @@ public class InformationResource extends IIIF2Resource { - return SUPPORTED_METHODS; - } - -+ @Override -+ protected final void doOPTIONS() { -+ HttpServletResponse response = getResponse(); -+ Method[] methods = getSupportedMethods(); -+ if (methods.length > 0) { -+ response.setStatus(Status.NO_CONTENT.getCode()); -+ response.setHeader("Access-Control-Allow-Headers", "Authorization"); -+ response.setHeader("Allow", Arrays.stream(methods) -+ .map(Method::toString) -+ .collect(Collectors.joining(","))); -+ } else { -+ response.setStatus(Status.METHOD_NOT_ALLOWED.getCode()); -+ } -+ } -+ - /** - * Writes a JSON-serialized {@link ImageInfo} instance to the response. - */ -diff --git a/src/main/java/edu/illinois/library/cantaloupe/resource/iiif/v3/InformationResource.java b/src/main/java/edu/illinois/library/cantaloupe/resource/iiif/v3/InformationResource.java -index 113883d08..aed0e896d 100644 ---- a/src/main/java/edu/illinois/library/cantaloupe/resource/iiif/v3/InformationResource.java -+++ b/src/main/java/edu/illinois/library/cantaloupe/resource/iiif/v3/InformationResource.java -@@ -1,8 +1,10 @@ - package edu.illinois.library.cantaloupe.resource.iiif.v3; - -+import java.util.Arrays; - import java.util.HashSet; - import java.util.List; - import java.util.Set; -+import java.util.stream.Collectors; - - import edu.illinois.library.cantaloupe.http.Method; - import edu.illinois.library.cantaloupe.http.Status; -@@ -16,6 +18,8 @@ import edu.illinois.library.cantaloupe.resource.InformationRequestHandler; - import org.slf4j.Logger; - import org.slf4j.LoggerFactory; - -+import javax.servlet.http.HttpServletResponse; -+ - /** - * Handles IIIF Image API 3.x information requests. - * -@@ -40,6 +44,21 @@ public class InformationResource extends IIIF3Resource { - return SUPPORTED_METHODS; - } - -+ @Override -+ protected final void doOPTIONS() { -+ HttpServletResponse response = getResponse(); -+ Method[] methods = getSupportedMethods(); -+ if (methods.length > 0) { -+ response.setStatus(Status.NO_CONTENT.getCode()); -+ response.setHeader("Access-Control-Allow-Headers", "Authorization"); -+ response.setHeader("Allow", Arrays.stream(methods) -+ .map(Method::toString) -+ .collect(Collectors.joining(","))); -+ } else { -+ response.setStatus(Status.METHOD_NOT_ALLOWED.getCode()); -+ } -+ } -+ - /** - * Writes a JSON-serialized {@link ImageInfo} instance to the response. - */ -diff --git a/src/test/java/edu/illinois/library/cantaloupe/resource/iiif/v1/InformationResourceTest.java b/src/test/java/edu/illinois/library/cantaloupe/resource/iiif/v1/InformationResourceTest.java -index a37df660a..885af5b4b 100644 ---- a/src/test/java/edu/illinois/library/cantaloupe/resource/iiif/v1/InformationResourceTest.java -+++ b/src/test/java/edu/illinois/library/cantaloupe/resource/iiif/v1/InformationResourceTest.java -@@ -586,6 +586,11 @@ public class InformationResourceTest extends ResourceTest { - assertEquals(2, methods.size()); - assertTrue(methods.contains("GET")); - assertTrue(methods.contains("OPTIONS")); -+ -+ List allowedHeaders = -+ List.of(StringUtils.split(headers.getFirstValue("Access-Control-Allow-Headers"), ", ")); -+ assertEquals(1, allowedHeaders.size()); -+ assertTrue(allowedHeaders.contains("Authorization")); - } - - @Test -diff --git a/src/test/java/edu/illinois/library/cantaloupe/resource/iiif/v2/InformationResourceTest.java b/src/test/java/edu/illinois/library/cantaloupe/resource/iiif/v2/InformationResourceTest.java -index c8f879830..405db7088 100644 ---- a/src/test/java/edu/illinois/library/cantaloupe/resource/iiif/v2/InformationResourceTest.java -+++ b/src/test/java/edu/illinois/library/cantaloupe/resource/iiif/v2/InformationResourceTest.java -@@ -599,6 +599,11 @@ public class InformationResourceTest extends ResourceTest { - assertEquals(2, methods.size()); - assertTrue(methods.contains("GET")); - assertTrue(methods.contains("OPTIONS")); -+ -+ List allowedHeaders = -+ List.of(StringUtils.split(headers.getFirstValue("Access-Control-Allow-Headers"), ", ")); -+ assertEquals(1, allowedHeaders.size()); -+ assertTrue(allowedHeaders.contains("Authorization")); - } - - @Test -diff --git a/src/test/java/edu/illinois/library/cantaloupe/resource/iiif/v3/InformationResourceTest.java b/src/test/java/edu/illinois/library/cantaloupe/resource/iiif/v3/InformationResourceTest.java -index e3bfc5d53..a99f2ad53 100644 ---- a/src/test/java/edu/illinois/library/cantaloupe/resource/iiif/v3/InformationResourceTest.java -+++ b/src/test/java/edu/illinois/library/cantaloupe/resource/iiif/v3/InformationResourceTest.java -@@ -574,6 +574,11 @@ public class InformationResourceTest extends ResourceTest { - assertEquals(2, methods.size()); - assertTrue(methods.contains("GET")); - assertTrue(methods.contains("OPTIONS")); -+ -+ List allowedHeaders = -+ List.of(StringUtils.split(headers.getFirstValue("Access-Control-Allow-Headers"), ", ")); -+ assertEquals(1, allowedHeaders.size()); -+ assertTrue(allowedHeaders.contains("Authorization")); - } - - @Test diff --git a/src/main/docker/patches/issue-581-v5.0.5.patch b/src/main/docker/patches/issue-581-v5.0.5.patch deleted file mode 100644 index d4bf75b..0000000 --- a/src/main/docker/patches/issue-581-v5.0.5.patch +++ /dev/null @@ -1,143 +0,0 @@ -diff --git a/src/main/java/edu/illinois/library/cantaloupe/image/MetaIdentifier.java b/src/main/java/edu/illinois/library/cantaloupe/image/MetaIdentifier.java -index 35493f3c4..bbc2aa3ab 100644 ---- a/src/main/java/edu/illinois/library/cantaloupe/image/MetaIdentifier.java -+++ b/src/main/java/edu/illinois/library/cantaloupe/image/MetaIdentifier.java -@@ -259,6 +259,34 @@ public final class MetaIdentifier { - } - } - -+ /** -+ * Translates the meta-identifier into a URI path component. -+ * -+ * Reverses {@link #fromURIPathComponent(String, DelegateProxy)}. -+ * -+ * @param delegateProxy Delegate proxy. -+ */ -+ public String toURIPathComponent(DelegateProxy delegateProxy) { -+ // Encode just the identifier part. -+ final Identifier originalIdentifier = getIdentifier(); -+ final String slashedIdentifier = originalIdentifier.toString(); -+ final String deSlashedIdentifier = StringUtils.encodeSlashes(slashedIdentifier); -+ final String encodedIdentifier = Reference.encode(deSlashedIdentifier); -+ final MetaIdentifierTransformer xformer = -+ new MetaIdentifierTransformerFactory().newInstance(delegateProxy); -+ final String serializedMetaIdentifier; -+ -+ setIdentifier(new Identifier(encodedIdentifier)); -+ serializedMetaIdentifier = xformer.serialize(this); -+ // Now that we've serialized the encoded meta-identifier, put it back to how it was before -+ setIdentifier(originalIdentifier); -+ -+ LOGGER.debug("[Slash-substituted identifier: {}] -> [de-slashed identifier: {}] -> " + -+ "[percent-encoded identifier: {}] -> [raw path component: {}]", -+ slashedIdentifier, deSlashedIdentifier, encodedIdentifier, serializedMetaIdentifier); -+ return serializedMetaIdentifier; -+ } -+ - @Override - public String toString() { - return new StandardMetaIdentifierTransformer().serialize(this); -diff --git a/src/main/java/edu/illinois/library/cantaloupe/resource/AbstractResource.java b/src/main/java/edu/illinois/library/cantaloupe/resource/AbstractResource.java -index 20181b298..ecc8484b1 100644 ---- a/src/main/java/edu/illinois/library/cantaloupe/resource/AbstractResource.java -+++ b/src/main/java/edu/illinois/library/cantaloupe/resource/AbstractResource.java -@@ -13,8 +13,6 @@ import edu.illinois.library.cantaloupe.http.Status; - import edu.illinois.library.cantaloupe.image.Format; - import edu.illinois.library.cantaloupe.image.Identifier; - import edu.illinois.library.cantaloupe.image.MetaIdentifier; --import edu.illinois.library.cantaloupe.image.MetaIdentifierTransformer; --import edu.illinois.library.cantaloupe.image.MetaIdentifierTransformerFactory; - import edu.illinois.library.cantaloupe.delegate.DelegateProxy; - import edu.illinois.library.cantaloupe.delegate.DelegateProxyService; - import edu.illinois.library.cantaloupe.delegate.UnavailableException; -@@ -594,9 +592,8 @@ public abstract class AbstractResource { - final int identifierIndex = pathComponents.indexOf( - getIdentifierPathComponent()); - -- final MetaIdentifierTransformer xformer = -- new MetaIdentifierTransformerFactory().newInstance(getDelegateProxy()); -- final String newMetaIdentifierString = xformer.serialize(newMetaIdentifier); -+ final String newMetaIdentifierString = -+ newMetaIdentifier.toURIPathComponent(getDelegateProxy()); - publicRef.setPathComponent(identifierIndex, newMetaIdentifierString); - return publicRef; - } -diff --git a/src/main/java/edu/illinois/library/cantaloupe/util/StringUtils.java b/src/main/java/edu/illinois/library/cantaloupe/util/StringUtils.java -index c8e4c38c5..4a20f05a8 100644 ---- a/src/main/java/edu/illinois/library/cantaloupe/util/StringUtils.java -+++ b/src/main/java/edu/illinois/library/cantaloupe/util/StringUtils.java -@@ -41,6 +41,22 @@ public final class StringUtils { - return uriPathComponent; - } - -+ /** -+ * Reverses {@link #decodeSlashes(String)}. -+ * -+ * @param slashedIdentifier Identifier with slashes to be substituted. -+ * @return Identifier with slashes substituted. -+ */ -+ public static String encodeSlashes(final String slashedIdentifier) { -+ final String substitute = Configuration.getInstance(). -+ getString(Key.SLASH_SUBSTITUTE, ""); -+ if (!substitute.isEmpty()) { -+ return org.apache.commons.lang3.StringUtils.replace( -+ slashedIdentifier, "/", substitute); -+ } -+ return slashedIdentifier; -+ } -+ - public static String escapeHTML(String html) { - StringBuilder out = new StringBuilder(Math.max(16, html.length())); - for (int i = 0, length = html.length(); i < length; i++) { -diff --git a/src/test/java/edu/illinois/library/cantaloupe/image/MetaIdentifierTest.java b/src/test/java/edu/illinois/library/cantaloupe/image/MetaIdentifierTest.java -index 13b519d46..b9a318de3 100644 ---- a/src/test/java/edu/illinois/library/cantaloupe/image/MetaIdentifierTest.java -+++ b/src/test/java/edu/illinois/library/cantaloupe/image/MetaIdentifierTest.java -@@ -264,6 +264,29 @@ class MetaIdentifierTest extends BaseTest { - () -> instance.setScaleConstraint(scaleConstraint)); - } - -+ /* toURIPathComponent() */ -+ -+ @Test -+ void testToURIPathComponent() { -+ final Configuration config = Configuration.getInstance(); -+ config.setProperty(Key.SLASH_SUBSTITUTE, "BUG"); -+ config.setProperty(Key.META_IDENTIFIER_TRANSFORMER, -+ StandardMetaIdentifierTransformer.class.getSimpleName()); -+ -+ DelegateProxy delegateProxy = TestUtil.newDelegateProxy(); -+ MetaIdentifier metaIdentifier = MetaIdentifier.builder() -+ .withIdentifier("cats/:dogs") -+ .withPageNumber(2) -+ .withScaleConstraint(2, 3) -+ .build(); -+ MetaIdentifier beforeMethodCall = new MetaIdentifier(metaIdentifier); -+ String actual = metaIdentifier.toURIPathComponent(delegateProxy); -+ String expected = "catsBUG%3Adogs;2;2:3"; -+ assertEquals(expected, actual); -+ // Make sure the call to toURIPathComponent didn't change the meta-identifier. -+ assertEquals(beforeMethodCall, metaIdentifier); -+ } -+ - /* toString() */ - - @Test -diff --git a/src/test/java/edu/illinois/library/cantaloupe/util/StringUtilsTest.java b/src/test/java/edu/illinois/library/cantaloupe/util/StringUtilsTest.java -index e6b5f00b1..704966bf9 100644 ---- a/src/test/java/edu/illinois/library/cantaloupe/util/StringUtilsTest.java -+++ b/src/test/java/edu/illinois/library/cantaloupe/util/StringUtilsTest.java -@@ -25,6 +25,13 @@ class StringUtilsTest extends BaseTest { - assertEquals("ca/ts", StringUtils.decodeSlashes("ca$$ts")); - } - -+ @Test -+ void testEncodeSlashes() { -+ Configuration.getInstance().setProperty(Key.SLASH_SUBSTITUTE, "$$"); -+ assertEquals("cats", StringUtils.encodeSlashes("cats")); -+ assertEquals("ca$$ts", StringUtils.encodeSlashes("ca/ts")); -+ } -+ - @Test - void testEscapeHTML() { - String html = "the quick brown fox";