Skip to content

Commit 147d8e1

Browse files
committed
Merge branch 'develop' of [email protected]:goobi-workflow/goobi-workflow-core.git into develop
2 parents ccf18d1 + 36aab1d commit 147d8e1

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/main/java/org/goobi/api/rest/process/thumbnail/GoobiThumbnailResource.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
*/
2525
package org.goobi.api.rest.process.thumbnail;
2626

27+
import java.io.UnsupportedEncodingException;
2728
import java.net.URI;
2829
import java.net.URISyntaxException;
2930
import java.net.URLEncoder;
@@ -42,6 +43,7 @@
4243
import jakarta.ws.rs.PathParam;
4344
import jakarta.ws.rs.container.ContainerRequestContext;
4445
import jakarta.ws.rs.core.Context;
46+
import jakarta.ws.rs.core.UriBuilder;
4547
import lombok.extern.log4j.Log4j2;
4648

4749
@jakarta.ws.rs.Path("process/thumbs/{processId}/{foldername}/{filename}")
@@ -91,4 +93,20 @@ public void createResourceURI(HttpServletRequest request, String processId, Stri
9193
public String getGoobiURIPrefix() {
9294
return GoobiThumbnailResource.class.getAnnotation(jakarta.ws.rs.Path.class).value();
9395
}
96+
97+
/**
98+
* This needs to override the createResourceURI method of the ImageResource class which otherwise throws an error due to different number of path
99+
* variables The actual value of the URI is created in {@link #createResourceURI(HttpServletRequest, String, String, String)
100+
*/
101+
@Override
102+
protected URI createResourceURI(URI baseURI, String directory, String filename) throws IllegalRequestException {
103+
try {
104+
return UriBuilder.fromUri(baseURI)
105+
.path(getURIPrefix())
106+
.build("", URLEncoder.encode(directory, "utf-8"), URLEncoder.encode(filename, "utf-8"));
107+
} catch (UnsupportedEncodingException e) {
108+
log.error("Failed to create image request uri");
109+
throw new IllegalRequestException("Unable to evaluate request to '" + directory + "', '" + filename + "'");
110+
}
111+
}
94112
}

0 commit comments

Comments
 (0)