diff --git a/PLUGIN-INF/metadata_SLUBTechnicalMetadataExtractorCheckItTiffPlugin.xml b/PLUGIN-INF/metadata_SLUBTechnicalMetadataExtractorCheckItTiffPlugin.xml index fc3742a9748e62f60fd1e6a927512e32ba08660a..b423a4e1d3e299c6661f9eb2a3c02f12e48c1bd8 100644 --- a/PLUGIN-INF/metadata_SLUBTechnicalMetadataExtractorCheckItTiffPlugin.xml +++ b/PLUGIN-INF/metadata_SLUBTechnicalMetadataExtractorCheckItTiffPlugin.xml @@ -69,7 +69,7 @@ </fr:x_form> </pl:initParameters> <pl:description>SLUB Technical Metadata Extractor Plugin, using check_it_tiff to validate tiff-files</pl:description> - <pl:version>1.96</pl:version> + <pl:version>1.99</pl:version> <pl:materialType>DIGITAL</pl:materialType> <pl:module>Preservation</pl:module> <pl:generalType>TASK</pl:generalType> diff --git a/java/org/slub/rosetta/dps/repository/plugin/SLUBTechnicalMetadataExtractorCheckItTiffPlugin.java b/java/org/slub/rosetta/dps/repository/plugin/SLUBTechnicalMetadataExtractorCheckItTiffPlugin.java index 16ddd1a4018219a2022e0dde36e23c9443d439a9..1a5338ba73485b48f451c68cc3e3266ce157000a 100644 --- a/java/org/slub/rosetta/dps/repository/plugin/SLUBTechnicalMetadataExtractorCheckItTiffPlugin.java +++ b/java/org/slub/rosetta/dps/repository/plugin/SLUBTechnicalMetadataExtractorCheckItTiffPlugin.java @@ -29,6 +29,8 @@ import java.util.List; import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; +import java.nio.file.*; + /** * SLUBTechnicalMetadataExtractorCheckItTiffPlugin @@ -93,29 +95,27 @@ public class SLUBTechnicalMetadataExtractorCheckItTiffPlugin implements MDExtrac } } - @Override - public void extract(String filePath) throws Exception { - if (StringUtils.isEmptyString(current_checkit_tiff_binary_path)) { + private void check_path(String filePath, String msgPath, boolean is_executable) throws Exception { + if (StringUtils.isEmptyString(filePath)) { //log.error("No checkit_tiff_binary_path defined. Please set the plugin parameter to hold your checkit_tiff_binary_path."); - throw new Exception("path for (current) checkit_tiff_binary not found"); + throw new Exception(msgPath + " is empty"); } - if (StringUtils.isEmptyString(current_checkit_tiff_config_path)) { - //log.error("No checkit_tiff_config_path defined. Please set the plugin parameter to hold your checkit_tiff_config_path."); - throw new Exception("path for (current) checkit_tiff_config not found"); - } - if (StringUtils.isEmptyString(upcoming_checkit_tiff_binary_path)) { - //log.error("No checkit_tiff_binary_path defined. Please set the plugin parameter to hold your checkit_tiff_binary_path."); - throw new Exception("path for (upcoming) checkit_tiff_binary not found"); + Path path = Paths.get(filePath); + if (! Files.exists( path ) || !Files.isRegularFile(path)) { + throw new Exception(msgPath + " does not exist (" + filePath + ")"); } - if (StringUtils.isEmptyString(upcoming_checkit_tiff_config_path)) { - //log.error("No checkit_tiff_config_path defined. Please set the plugin parameter to hold your checkit_tiff_config_path."); - throw new Exception("path for (upcoming) checkit_tiff_config not found"); - } - if (StringUtils.isEmptyString(exiftool_binary_path)) { - //log.error("No checkit_tiff_config_path defined. Please set the plugin parameter to hold your checkit_tiff_config_path."); - throw new Exception("path for exiftool_binary not found"); + if (is_executable && ! Files.isExecutable(path)) { + throw new Exception(msgPath + " not executable (" + filePath + ")"); } + } + @Override + public void extract(String filePath) throws Exception { + check_path( current_checkit_tiff_binary_path, "path for (current) checkit_tiff_binary", true); + check_path( current_checkit_tiff_config_path, "path for (current) checkit_tiff_config", false); + check_path(upcoming_checkit_tiff_binary_path, "path for (upcoming) checkit_tiff_binary", true); + check_path(upcoming_checkit_tiff_config_path, "path for (upcoming) checkit_tiff_config", false); + check_path(exiftool_binary_path, "path for exiftool_binary", true); // checkit_tiff validation (upcoming) try { String execstring = this.upcoming_checkit_tiff_binary_path + " " + this.upcoming_checkit_tiff_config_path + " " + filePath ; @@ -127,7 +127,7 @@ public class SLUBTechnicalMetadataExtractorCheckItTiffPlugin implements MDExtrac while (line != null) { System.out.println(line); - validationLog.add(line); + validationLog.add(line + System.lineSeparator()); line = reader.readLine(); } if (p.exitValue() == 0) { @@ -156,7 +156,7 @@ public class SLUBTechnicalMetadataExtractorCheckItTiffPlugin implements MDExtrac while (line != null) { System.out.println(line); - validationLog.add(line); + validationLog.add(line + System.lineSeparator()); line = reader.readLine(); } if (p.exitValue() == 0) {