From a2d6095e034325a9d50b790da95a77d8d7212316 Mon Sep 17 00:00:00 2001 From: Matthias Ronge Date: Thu, 25 Jan 2024 15:10:37 +0100 Subject: [PATCH 1/2] Catch IOException in indexing processes --- .../production/services/data/ProcessService.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Kitodo/src/main/java/org/kitodo/production/services/data/ProcessService.java b/Kitodo/src/main/java/org/kitodo/production/services/data/ProcessService.java index 4da7c8f6657..3a7ae8582f4 100644 --- a/Kitodo/src/main/java/org/kitodo/production/services/data/ProcessService.java +++ b/Kitodo/src/main/java/org/kitodo/production/services/data/ProcessService.java @@ -73,6 +73,7 @@ import org.apache.commons.configuration.ConfigurationException; import org.apache.commons.io.IOUtils; +import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.lucene.search.join.ScoreMode; @@ -352,11 +353,16 @@ private void enrichProcessData(Process process, boolean forIndexingAll) throws I if (!fileService.fileExist(metadataFilePath)) { logger.info("No metadata file for indexing: {}", metadataFilePath); } else { - Workpiece workpiece = ServiceManager.getMetsService().loadWorkpiece(metadataFilePath); - process.setNumberOfImages(getNumberOfImagesForIndex(workpiece)); - process.setNumberOfMetadata(getNumberOfMetadata(workpiece)); - process.setNumberOfStructures(getNumberOfStructures(workpiece)); - process.setBaseType(getBaseType(workpiece)); + try { + Workpiece workpiece = ServiceManager.getMetsService().loadWorkpiece(metadataFilePath); + process.setNumberOfImages(getNumberOfImagesForIndex(workpiece)); + process.setNumberOfMetadata(getNumberOfMetadata(workpiece)); + process.setNumberOfStructures(getNumberOfStructures(workpiece)); + process.setBaseType(getBaseType(workpiece)); + } catch (IOException e) { + logger.warn("Cannot read metadata file for indexing: {}", metadataFilePath); + logger.catching(Level.DEBUG, e); + } } } From b0d52f70ed83d369e1bd9583c73160c93d7e04a4 Mon Sep 17 00:00:00 2001 From: Matthias Ronge Date: Thu, 25 Jan 2024 15:49:17 +0100 Subject: [PATCH 2/2] Also catch IllegalArgumentException --- .../org/kitodo/production/services/data/ProcessService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Kitodo/src/main/java/org/kitodo/production/services/data/ProcessService.java b/Kitodo/src/main/java/org/kitodo/production/services/data/ProcessService.java index 3a7ae8582f4..27808aa5712 100644 --- a/Kitodo/src/main/java/org/kitodo/production/services/data/ProcessService.java +++ b/Kitodo/src/main/java/org/kitodo/production/services/data/ProcessService.java @@ -359,7 +359,7 @@ private void enrichProcessData(Process process, boolean forIndexingAll) throws I process.setNumberOfMetadata(getNumberOfMetadata(workpiece)); process.setNumberOfStructures(getNumberOfStructures(workpiece)); process.setBaseType(getBaseType(workpiece)); - } catch (IOException e) { + } catch (IllegalArgumentException | IOException e) { logger.warn("Cannot read metadata file for indexing: {}", metadataFilePath); logger.catching(Level.DEBUG, e); }