Skip to content

Commit cc1e76a

Browse files
committed
Use go-iiif v7 from original repo
Therefore the image-id has to be url-encoded which the indexer has to do when generating the manifest. So indexer update is necessarry
1 parent e7ce20e commit cc1e76a

File tree

5 files changed

+46
-13
lines changed

5 files changed

+46
-13
lines changed

docker-compose.cluster.yaml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -107,24 +107,19 @@ services:
107107
- es
108108
- search
109109

110-
go-iiif:
111-
image: ghcr.io/subugoe/go-iiif:develop
110+
olahds_image_server:
112111
container_name: olahds_image_server
113-
command: /go/iiif-server -server-uri http://0.0.0.0:8080 -config-source file:///etc/iiif-server
114-
working_dir: /go
115-
volumes:
116-
- ./cfg/go-iiif/config.json:/etc/iiif-server/config.json
117-
- ./cfg/go-iiif/instructions.json:/etc/iiif-server/instructions.json
118-
env_file:
119-
- .env
112+
build:
113+
context: https://github.com/go-iiif/go-iiif.git#v7.0.2
114+
command: /bin/iiif-server -server-uri "http://0.0.0.0:8090" -config-images-source-uri "rfc6570://?template=http://backend:8080/download-image?id={id}"
120115
labels:
121116
- "traefik.enable=true"
122117
- "traefik.http.routers.go-iiif.entrypoints=web"
123118
- "traefik.http.routers.go-iiif.rule=PathPrefix(`/images`)"
124119
- "traefik.http.routers.go-iiif.middlewares=stripprefix_images"
125120
- "traefik.http.middlewares.stripprefix_images.stripprefix.prefixes=/images"
126121
ports:
127-
- "6701:8080"
122+
- "6701:8090"
128123
networks:
129124
olahd:
130125
aliases:

docker-compose.localdev.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,18 @@ services:
120120
- olahds_s3
121121
- s3
122122

123+
olahds_image_server:
124+
container_name: olahds_image_server
125+
build:
126+
context: https://github.com/go-iiif/go-iiif.git#v7.0.2
127+
command: /bin/iiif-server -server-uri "http://0.0.0.0:8090" -config-images-source-uri "rfc6570://?template=http://172.17.0.1:8080/download-image?id={id}"
128+
ports:
129+
- "8090:8090"
130+
networks:
131+
olahd:
132+
aliases:
133+
- images
134+
- image-server
123135

124136
volumes:
125137
redisdata:

src/main/java/de/ocrd/olahd/config/SecurityConfig.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ protected void configure(HttpSecurity http) throws Exception {
4545
.authorizeRequests()
4646
.antMatchers("/export/**",
4747
"/export-full/**",
48-
"/download",
49-
"/download-file/**",
48+
"/download*",
5049
"/login",
5150
"/search*/**",
5251
"/iiif/**",

src/main/java/de/ocrd/olahd/controller/ExportController.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,33 @@ public ResponseEntity<Resource> downloadFile(
191191
.header(HttpHeaders.CONTENT_LENGTH, contentLength + "").body(resource);
192192
}
193193

194+
static final String REGEX_IMAGE_ID = "^(.*?)&.*?path=([^\\s]+)$";
195+
static final java.util.regex.Pattern PATTERN_IMAGE_ID = java.util.regex.Pattern.compile(REGEX_IMAGE_ID);
196+
197+
@ApiOperation(value = "Endpoint for go-iiif to get images")
198+
@ApiResponses({
199+
@ApiResponse(code = 200, message = "File successfully transfered.", response = byte[].class),
200+
@ApiResponse(code = 404, message = "File or archive not found.", response = byte[].class),
201+
@ApiResponse(code = 409, message = "File only available on tape.", response = byte[].class),
202+
})
203+
@GetMapping(value = "/download-image", produces = { MediaType.APPLICATION_XML_VALUE,
204+
MediaType.TEXT_PLAIN_VALUE, MediaType.APPLICATION_OCTET_STREAM_VALUE })
205+
public ResponseEntity<Resource> downloadImage(
206+
@ApiParam(value = "Image id used by go-iiif image server", required = true) @RequestParam("id")
207+
String imageId
208+
) throws IOException {
209+
String pid = null;
210+
String path = null;
211+
java.util.regex.Matcher matcher = PATTERN_IMAGE_ID.matcher(imageId);
212+
if (matcher.find()) {
213+
pid = matcher.group(1);
214+
path = matcher.group(2);
215+
} else {
216+
throw new HttpClientErrorException(HttpStatus.UNPROCESSABLE_ENTITY, ErrMsg.CANNOT_PARSE_IMAGE_ID);
217+
}
218+
return this.downloadFile(pid, false, path);
219+
}
220+
194221
/**
195222
* Export data using {@linkplain ArchiveManagerService}
196223
*

src/main/java/de/ocrd/olahd/msg/ErrMsg.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ private ErrMsg() {
2828
public static final String FILE_NOT_A_TIFF = "Given file is not a tiff image";
2929
public static final String TIFF_CONVERT_ERROR = "Error converting tiff to jpeg";
3030
public static final String IIIF_MANIFEST_NOT_FOUND = "IIIF-Manifest not found";
31-
31+
public static final String CANNOT_PARSE_IMAGE_ID = "Cannot parse PID and filepath from image-id";
3232

3333
}

0 commit comments

Comments
 (0)