From c4cf05770d54b0c016fb3e75cce140f767a590eb Mon Sep 17 00:00:00 2001 From: Andreas Romeyke <andreas.romeyke@slub-dresden.de> Date: Mon, 27 Oct 2014 15:41:34 +0000 Subject: [PATCH] - because the fixity.getAlgorithm() (which was broken in Rosetta4.0 because results in lowercase instead of uppercase) was used on different parts of code, the workaround is rewritten to fix all occurences --- PLUGIN-INF/metadata_SLUBStoragepPlugin.xml | 2 +- .../plugin/storage/nfs/SLUBStoragePlugin.java | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/PLUGIN-INF/metadata_SLUBStoragepPlugin.xml b/PLUGIN-INF/metadata_SLUBStoragepPlugin.xml index 86465e2..c143da1 100644 --- a/PLUGIN-INF/metadata_SLUBStoragepPlugin.xml +++ b/PLUGIN-INF/metadata_SLUBStoragepPlugin.xml @@ -70,7 +70,7 @@ </fr:x_form> </pl:initParameters> <pl:description>SLUB Storage Plugin</pl:description> - <pl:version>2.803</pl:version> + <pl:version>2.804</pl:version> <pl:materialType>DIGITAL</pl:materialType> <pl:module>Repository</pl:module> <pl:generalType>TASK</pl:generalType> diff --git a/java/org/slub/rosetta/dps/repository/plugin/storage/nfs/SLUBStoragePlugin.java b/java/org/slub/rosetta/dps/repository/plugin/storage/nfs/SLUBStoragePlugin.java index bc8b4e6..2f94f3c 100644 --- a/java/org/slub/rosetta/dps/repository/plugin/storage/nfs/SLUBStoragePlugin.java +++ b/java/org/slub/rosetta/dps/repository/plugin/storage/nfs/SLUBStoragePlugin.java @@ -93,17 +93,20 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { log.info("SLUBStoragePlugin.checkFixity() FixityAlgorithm.MD5=" + Fixity.FixityAlgorithm.MD5.toString()); log.info("SLUBStoragePlugin.checkFixity() FixityAlgorithm.SHA1=" + Fixity.FixityAlgorithm.SHA1.toString()); log.info("SLUBStoragePlugin.checkFixity() FixityAlgorithm.CRC32=" + Fixity.FixityAlgorithm.CRC32.toString()); - if (Fixity.FixityAlgorithm.MD5.toString().toLowerCase().equals(fixity.getAlgorithm().toLowerCase())) + /* TODO: with upcoming versions of Rosetta, recheck need of + * Workaround for fixity.getAlgorithm() */ + String algorithm = fixity.getAlgorithm().toUpperCase(); // workaround, because fixity.getAlgorithm() returns lowercase string + if (Fixity.FixityAlgorithm.MD5.toString().equals(algorithm)) { log.info("SLUBStoragePlugin.checkFixity() calcMD5=true"); calcMD5 = true; } - else if (Fixity.FixityAlgorithm.SHA1.toString().toLowerCase().equals(fixity.getAlgorithm().toLowerCase())) + else if (Fixity.FixityAlgorithm.SHA1.toString().equals(algorithm)) { log.info("SLUBStoragePlugin.checkFixity() calcSHA1=true"); calcSHA1 = true; } - else if (Fixity.FixityAlgorithm.CRC32.toString().toLowerCase().equals(fixity.getAlgorithm().toLowerCase())) + else if (Fixity.FixityAlgorithm.CRC32.toString().equals(algorithm)) { log.info("SLUBStoragePlugin.checkFixity() calcCRC32=true"); calcCRC32 = true; @@ -131,14 +134,17 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { Checksummer checksummer = new Checksummer(is, calcMD5, calcSHA1, calcCRC32); for (Fixity fixity : fixities) { - int checksummerAlgorithmIndex = getChecksummerAlgorithmIndex(fixity.getAlgorithm()); + /* TODO: with upcoming versions of Rosetta, recheck need of + * Workaround for fixity.getAlgorithm() */ + String algorithm = fixity.getAlgorithm().toUpperCase(); // workaround, because fixity.getAlgorithm() returns lowercase string + int checksummerAlgorithmIndex = getChecksummerAlgorithmIndex(algorithm); if (checksummerAlgorithmIndex != -1) { log.info("SLUBStoragePlugin.checkFixity() checksummerAlgorithmIndex=" + checksummerAlgorithmIndex); String oldValue = fixity.getValue(); - log.info("SLUBStoragePlugin.checkFixity() getAlgorithm (2)=" + fixity.getAlgorithm()); + log.info("SLUBStoragePlugin.checkFixity() getAlgorithm (2)=" + algorithm); log.info("SLUBStoragePlugin.checkFixity() oldvalue=" + oldValue); - fixity.setValue(checksummer.getChecksum(fixity.getAlgorithm())); + fixity.setValue(checksummer.getChecksum(algorithm)); log.info("SLUBStoragePlugin.checkFixity() newvalue=" + fixity.getValue()); fixity.setResult(Boolean.valueOf((oldValue == null) || (oldValue.equalsIgnoreCase(fixity.getValue())))); result &= fixity.getResult().booleanValue(); -- GitLab