Skip to content
Snippets Groups Projects
Commit 7c384198 authored by Andreas Romeyke's avatar Andreas Romeyke
Browse files

- added explicite file checks

parent 8d02fe0c
Branches
Tags
No related merge requests found
...@@ -69,7 +69,7 @@ ...@@ -69,7 +69,7 @@
</fr:x_form> </fr:x_form>
</pl:initParameters> </pl:initParameters>
<pl:description>SLUB Technical Metadata Extractor Plugin, using check_it_tiff to validate tiff-files</pl:description> <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:materialType>DIGITAL</pl:materialType>
<pl:module>Preservation</pl:module> <pl:module>Preservation</pl:module>
<pl:generalType>TASK</pl:generalType> <pl:generalType>TASK</pl:generalType>
......
...@@ -29,6 +29,8 @@ import java.util.List; ...@@ -29,6 +29,8 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.nio.file.*;
/** /**
* SLUBTechnicalMetadataExtractorCheckItTiffPlugin * SLUBTechnicalMetadataExtractorCheckItTiffPlugin
...@@ -93,29 +95,27 @@ public class SLUBTechnicalMetadataExtractorCheckItTiffPlugin implements MDExtrac ...@@ -93,29 +95,27 @@ public class SLUBTechnicalMetadataExtractorCheckItTiffPlugin implements MDExtrac
} }
} }
@Override private void check_path(String filePath, String msgPath, boolean is_executable) throws Exception {
public void extract(String filePath) throws Exception { if (StringUtils.isEmptyString(filePath)) {
if (StringUtils.isEmptyString(current_checkit_tiff_binary_path)) {
//log.error("No checkit_tiff_binary_path defined. Please set the plugin parameter to hold your 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 (current) checkit_tiff_binary not found"); throw new Exception(msgPath + " is empty");
} }
if (StringUtils.isEmptyString(current_checkit_tiff_config_path)) { Path path = Paths.get(filePath);
//log.error("No checkit_tiff_config_path defined. Please set the plugin parameter to hold your checkit_tiff_config_path."); if (! Files.exists( path ) || !Files.isRegularFile(path)) {
throw new Exception("path for (current) checkit_tiff_config not found"); throw new Exception(msgPath + " does not exist (" + filePath + ")");
} }
if (StringUtils.isEmptyString(upcoming_checkit_tiff_binary_path)) { if (is_executable && ! Files.isExecutable(path)) {
//log.error("No checkit_tiff_binary_path defined. Please set the plugin parameter to hold your checkit_tiff_binary_path."); throw new Exception(msgPath + " not executable (" + filePath + ")");
throw new Exception("path for (upcoming) checkit_tiff_binary not found");
} }
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");
} }
@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) // checkit_tiff validation (upcoming)
try { try {
String execstring = this.upcoming_checkit_tiff_binary_path + " " + this.upcoming_checkit_tiff_config_path + " " + filePath ; String execstring = this.upcoming_checkit_tiff_binary_path + " " + this.upcoming_checkit_tiff_config_path + " " + filePath ;
...@@ -127,7 +127,7 @@ public class SLUBTechnicalMetadataExtractorCheckItTiffPlugin implements MDExtrac ...@@ -127,7 +127,7 @@ public class SLUBTechnicalMetadataExtractorCheckItTiffPlugin implements MDExtrac
while (line != null) { while (line != null) {
System.out.println(line); System.out.println(line);
validationLog.add(line); validationLog.add(line + System.lineSeparator());
line = reader.readLine(); line = reader.readLine();
} }
if (p.exitValue() == 0) { if (p.exitValue() == 0) {
...@@ -156,7 +156,7 @@ public class SLUBTechnicalMetadataExtractorCheckItTiffPlugin implements MDExtrac ...@@ -156,7 +156,7 @@ public class SLUBTechnicalMetadataExtractorCheckItTiffPlugin implements MDExtrac
while (line != null) { while (line != null) {
System.out.println(line); System.out.println(line);
validationLog.add(line); validationLog.add(line + System.lineSeparator());
line = reader.readLine(); line = reader.readLine();
} }
if (p.exitValue() == 0) { if (p.exitValue() == 0) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment