From 817667992c73c0b1cf4bf8b7e3b18f80d92e1c6d Mon Sep 17 00:00:00 2001 From: pavel-stastny Date: Tue, 2 Apr 2024 13:24:05 +0200 Subject: [PATCH] IIIF characters ^ & ! --- .../rest/apiNew/client/v70/ItemsResource.java | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/rest/src/main/java/cz/incad/kramerius/rest/apiNew/client/v70/ItemsResource.java b/rest/src/main/java/cz/incad/kramerius/rest/apiNew/client/v70/ItemsResource.java index 4bc78f2dd..40625efe6 100644 --- a/rest/src/main/java/cz/incad/kramerius/rest/apiNew/client/v70/ItemsResource.java +++ b/rest/src/main/java/cz/incad/kramerius/rest/apiNew/client/v70/ItemsResource.java @@ -1171,16 +1171,12 @@ public Response tile(@PathParam("pid") String pid, String firstVal = split[0]; String secondVal = split[1]; - if (firstVal.startsWith("^")) { - firstVal = firstVal.substring(1); - } + firstVal = iiifPrefix(firstVal); + secondVal = iiifPrefix(secondVal); - if (firstVal.startsWith("!")) { - firstVal = firstVal.substring(1); - } try { - int width = Integer.parseInt(firstVal); - int height = Integer.parseInt(secondVal); + int width = StringUtils.isAnyString(firstVal) ? Integer.parseInt(firstVal) : 0; + int height = StringUtils.isAnyString(secondVal) ? Integer.parseInt(secondVal) :0; if (width > MAX_TIME_SIZE || height > MAX_TIME_SIZE) { checkUserIsAllowedToReadObject(pid); } @@ -1227,6 +1223,17 @@ public Response tile(@PathParam("pid") String pid, } } + private String iiifPrefix(String firstVal) { + if (firstVal.startsWith("^")) { + firstVal = firstVal.substring(1); + } + + if (firstVal.startsWith("!")) { + firstVal = firstVal.substring(1); + } + return firstVal; + } + @GET @Path("{pid}/introspect") @Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")