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

- readded logger

- removed getAgentName()
- minor fixes
parent 532e99ae
No related branches found
No related tags found
No related merge requests found
...@@ -16,7 +16,9 @@ limitations under the License. ...@@ -16,7 +16,9 @@ limitations under the License.
package org.slub.rosetta.dps.repository.plugin; package org.slub.rosetta.dps.repository.plugin;
import com.exlibris.core.infra.common.exceptions.logging.ExLogger;
import com.exlibris.dps.sdk.techmd.FormatValidationPlugin; import com.exlibris.dps.sdk.techmd.FormatValidationPlugin;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
...@@ -31,12 +33,13 @@ import java.util.List; ...@@ -31,12 +33,13 @@ import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
* SLUBTechnicalMetadataExtractorMediaConchPlugin * SLUBMatroskaFFV1FormatValidationPlugin
* *
* @author andreas.romeyke@slub-dresden.de (Andreas Romeyke) * @author andreas.romeyke@slub-dresden.de (Andreas Romeyke)
* @see com.exlibris.dps.sdk.techmd.FormatValidationPlugin * @see com.exlibris.dps.sdk.techmd.FormatValidationPlugin
*/ */
public class SLUBMatroskaFFV1FormatValidationPlugin implements FormatValidationPlugin { public class SLUBMatroskaFFV1FormatValidationPlugin implements FormatValidationPlugin {
private static final ExLogger log = ExLogger.getExLogger(SLUBMatroskaFFV1FormatValidationPlugin.class);
private String mediaconch_binary_path; private String mediaconch_binary_path;
private String mediaconch_current_profile_path; private String mediaconch_current_profile_path;
private String mediaconch_upcoming_profile_path; private String mediaconch_upcoming_profile_path;
...@@ -50,8 +53,7 @@ public class SLUBMatroskaFFV1FormatValidationPlugin implements FormatValidationP ...@@ -50,8 +53,7 @@ public class SLUBMatroskaFFV1FormatValidationPlugin implements FormatValidationP
/** constructor */ /** constructor */
public SLUBMatroskaFFV1FormatValidationPlugin() { public SLUBMatroskaFFV1FormatValidationPlugin() {
//log.info("SLUBVirusCheckPlugin instantiated with host=" + host + " port=" + port + " timeout=" + timeout); log.info("SLUBTechnicalMetadataExtractorMediaConchPlugin instantiated");
System.out.println("SLUBTechnicalMetadataExtractorMediaConchPlugin instantiated");
} }
/** init params to configure the plugin via xml forms /** init params to configure the plugin via xml forms
...@@ -77,11 +79,12 @@ public class SLUBMatroskaFFV1FormatValidationPlugin implements FormatValidationP ...@@ -77,11 +79,12 @@ public class SLUBMatroskaFFV1FormatValidationPlugin implements FormatValidationP
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
// TODO: log.info();
} }
@Override @Override
// TODO: Pfadstring, Prüfsumme, modification date für beide Profile // TODO: Pfadstring, Prüfsumme, modification date für beide Profile
public String getProfile () { public final String getProfile () {
String modified_current = modificationDateOfFile( this.mediaconch_current_profile_path); String modified_current = modificationDateOfFile( this.mediaconch_current_profile_path);
String modified_upcoming = modificationDateOfFile( 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 */ /* there is no documentation in ExL API, therefore we use it to document the profile versions in a light way */
...@@ -131,11 +134,6 @@ public class SLUBMatroskaFFV1FormatValidationPlugin implements FormatValidationP ...@@ -131,11 +134,6 @@ public class SLUBMatroskaFFV1FormatValidationPlugin implements FormatValidationP
} }
} }
public String getAgentName()
{
return "mediaconch";
}
@Override @Override
public boolean validateFormat(String filePath) { public boolean validateFormat(String filePath) {
// mediaconch validation, first using upcoming profile, if invalid then retry with current profile // mediaconch validation, first using upcoming profile, if invalid then retry with current profile
...@@ -151,7 +149,7 @@ public class SLUBMatroskaFFV1FormatValidationPlugin implements FormatValidationP ...@@ -151,7 +149,7 @@ public class SLUBMatroskaFFV1FormatValidationPlugin implements FormatValidationP
* *
* @return string with version and signature version * @return string with version and signature version
*/ */
public String getAgent() { public final String getAgent() {
StringBuilder response = new StringBuilder(); StringBuilder response = new StringBuilder();
response.append("mediaconch:\n"); response.append("mediaconch:\n");
InputStreamReader process_out = null; InputStreamReader process_out = null;
...@@ -190,17 +188,17 @@ public class SLUBMatroskaFFV1FormatValidationPlugin implements FormatValidationP ...@@ -190,17 +188,17 @@ public class SLUBMatroskaFFV1FormatValidationPlugin implements FormatValidationP
} }
@Override @Override
public boolean isWellFormed() { public final boolean isWellFormed() {
return this.iswellformed; return this.iswellformed;
} }
@Override @Override
public List<String> getErrors() { public final List<String> getErrors() {
return List.copyOf(this.validationLog); return List.copyOf(this.validationLog);
} }
@Override @Override
public boolean isValid() { public final boolean isValid() {
//System.out.println("DEBUG: is valid=" + this.isvalid); //System.out.println("DEBUG: is valid=" + this.isvalid);
return this.isvalid; return this.isvalid;
} }
...@@ -218,8 +216,7 @@ public class SLUBMatroskaFFV1FormatValidationPlugin implements FormatValidationP ...@@ -218,8 +216,7 @@ public class SLUBMatroskaFFV1FormatValidationPlugin implements FormatValidationP
MessageDigest md = MessageDigest.getInstance("MD5"); MessageDigest md = MessageDigest.getInstance("MD5");
byte[] b = Files.readAllBytes(Paths.get(filename)); byte[] b = Files.readAllBytes(Paths.get(filename));
byte[] digest = md.digest(b); byte[] digest = md.digest(b);
String hexdigest = new BigInteger(1, digest).toString(16); return new BigInteger(1, digest).toString(16);
return hexdigest;
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -244,7 +241,6 @@ public class SLUBMatroskaFFV1FormatValidationPlugin implements FormatValidationP ...@@ -244,7 +241,6 @@ public class SLUBMatroskaFFV1FormatValidationPlugin implements FormatValidationP
initp.put( "mediaconch_binary_path", "/usr/bin/mediaconch"); initp.put( "mediaconch_binary_path", "/usr/bin/mediaconch");
initp.put( "mediaconch_current_profile_path", "/etc/mediaconch/profile.xml"); initp.put( "mediaconch_current_profile_path", "/etc/mediaconch/profile.xml");
initp.put( "mediaconch_upcoming_profile_path", "/etc/mediaconch/profile.xml"); initp.put( "mediaconch_upcoming_profile_path", "/etc/mediaconch/profile.xml");
initp.put( "mediainfo_binary_path", "/usr/bin/mediainfo");
plugin.initParams( initp ); plugin.initParams( initp );
System.out.println("----------------------------------"); System.out.println("----------------------------------");
System.out.println("Agent: '" + plugin.getAgent() + "'"); System.out.println("Agent: '" + plugin.getAgent() + "'");
...@@ -253,9 +249,6 @@ public class SLUBMatroskaFFV1FormatValidationPlugin implements FormatValidationP ...@@ -253,9 +249,6 @@ public class SLUBMatroskaFFV1FormatValidationPlugin implements FormatValidationP
System.out.println("Validation RESULT: " + plugin.isValid()); System.out.println("Validation RESULT: " + plugin.isValid());
} }
System.out.println("----------------------------------"); System.out.println("----------------------------------");
System.out.println("getAgentName:");
System.out.println( plugin.getAgentName());
System.out.println("----------------------------------");
System.out.println("getAgent:"); System.out.println("getAgent:");
System.out.println( plugin.getAgent()); System.out.println( plugin.getAgent());
System.out.println("----------------------------------"); System.out.println("----------------------------------");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment