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

- implemented dual profile validation

- the md5 of profile is used to minimize calls
parent 5776ef6f
No related branches found
No related tags found
No related merge requests found
......@@ -63,6 +63,9 @@ public class SLUBTechnicalMetadataExtractorMediaConchPlugin implements MDExtract
private final List<String> validationLog = new ArrayList<>();
private boolean isvalid = false;
private boolean iswellformed = false;
private String md5CurrentProfile;
private String md5UpcomingProfile;
private boolean isDifferentProfile = true;
private final Map<String,String> attributes = new HashMap<>();
//static final ExLogger log = ExLogger.getExLogger(SLUBTechnicalMetadataExtractorMediaConchPlugin.class, ExLogger.VALIDATIONSTACK);
......@@ -87,6 +90,9 @@ public class SLUBTechnicalMetadataExtractorMediaConchPlugin implements MDExtract
checkFileExists(this.xsltproc_binary_path);
checkFileExists(this.mediaconch_current_profile_path);
checkFileExists(this.mediaconch_upcoming_profile_path);
this.md5CurrentProfile = md5SumOfFile( this.mediaconch_current_profile_path);
this.md5UpcomingProfile = md5SumOfFile( this.mediaconch_upcoming_profile_path);
this.isDifferentProfile = ! this.md5UpcomingProfile.equals(this.md5CurrentProfile);
System.out.println("SLUBTechnicalMetadataExtractorMediaConchPlugin instantiated with "
+ " mediaconch_binary_path=" + mediaconch_binary_path
+ " mediaconch_current_profile_path=" + mediaconch_current_profile_path
......@@ -102,19 +108,17 @@ public class SLUBTechnicalMetadataExtractorMediaConchPlugin implements MDExtract
@Override
// TODO: Pfadstring, Prüfsumme, modification date für beide Profile
public String getProfile () {
String md5_current = md5SumOfFile( this.mediaconch_current_profile_path);
String modified_current = modificationDateOfFile( this.mediaconch_current_profile_path);
String md5_upcoming = md5SumOfFile( this.mediaconch_upcoming_profile_path);
String modified_upcoming = modificationDateOfFile( this.mediaconch_upcoming_profile_path);
/* there is no documentation in ExL API, therefore we use it to document the profile versions in a light way */
return (
"current profile:\n"
+ " path=" + this.mediaconch_current_profile_path + "\n"
+ " md5sum=" + md5_current + "\n"
+ " md5sum=" + this.md5CurrentProfile + "\n"
+ " modification date=" + modified_current + "\n"
+ "upcoming profile:\n"
+ " path=" + this.mediaconch_upcoming_profile_path + "\n"
+ " md5sum=" + md5_upcoming + "\n"
+ " md5sum=" + this.md5UpcomingProfile + "\n"
+ " modification date=" +modified_upcoming + "\n"
);
}
......@@ -133,9 +137,12 @@ public class SLUBTechnicalMetadataExtractorMediaConchPlugin implements MDExtract
checkFileExists(this.mediaconch_binary_path);
checkFileExists(this.mediaconch_current_profile_path);
checkFileExists(this.mediainfo_binary_path);
//checkFileExists(xsltproc_binary_path);
// mediaconch validation
callMediaconch(filePath);
checkFileExists(this.xsltproc_binary_path);
// mediaconch validation, first using upcoming profile, if invalid then retry with current profile
callMediaconch(filePath, this.mediaconch_upcoming_profile_path);
if (isDifferentProfile && !isvalid) {
callMediaconch(filePath, this.mediaconch_current_profile_path);
}
// mediainfo metadata extraction
callMediainfoAndResultProcessing(filePath);
}
......@@ -254,8 +261,8 @@ public class SLUBTechnicalMetadataExtractorMediaConchPlugin implements MDExtract
}
}
private void callMediaconch(String filePath) throws Exception {
String execstring = this.mediaconch_binary_path + " " + filePath + " -p " + this.mediaconch_current_profile_path;
private void callMediaconch(String filePath, String profilePath) throws Exception {
String execstring = this.mediaconch_binary_path + " " + filePath + " -p " + profilePath;
System.out.println("executing: " + execstring);
InputStreamReader process_out;
try {
......@@ -479,7 +486,7 @@ public class SLUBTechnicalMetadataExtractorMediaConchPlugin implements MDExtract
e.printStackTrace();
return;
}
System.out.println("RESULT: " + plugin.isValid());
System.out.println("Validation RESULT: " + plugin.isValid());
System.out.println("ERRORMESSAGE: " + plugin.getExtractionErrors());
}
System.out.println("----------------------------------");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment