Log every exception that occurs on image service calls

This commit is contained in:
Dominique Eifländer 2021-04-12 11:48:14 +02:00
parent 9696a421fc
commit cc3ad099ff

View File

@ -1,7 +1,6 @@
package com.iqser.red.service.redaction.v1.server.redaction.service;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import javax.imageio.ImageIO;
@ -32,14 +31,14 @@ public class ImageClassificationService {
classifiedDoc.getPages().forEach(page -> {
page.getImages().forEach(image -> {
if(settings.isEnableImageClassification()) {
if (settings.isEnableImageClassification()) {
try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
ImageIO.write(image.getImage(), "png", baos);
ImageClassificationResponse response = imageClassificationClient.classify(new MockMultipartFile("file", "Image.png", "image/png", baos
.toByteArray()));
image.setImageType(ImageType.valueOf(response.getCategory()));
} catch (IOException e) {
} catch (Exception e) {
log.error("Could not classify image", e);
}
} else {