From b2dab0f332e4c047b517cf78547237b882007155 Mon Sep 17 00:00:00 2001
From: Jens Steidl <Jens.Steidl@slub-dresden.de>
Date: Wed, 17 Aug 2022 11:42:14 +0200
Subject: [PATCH] - workaround: added fallback for empty custom fixity plugin
 names

---
 .../plugin/storage/nfs/SLUBStoragePlugin.java     | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

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 f498708..b3e159b 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
@@ -187,7 +187,15 @@ public class SLUBStoragePlugin extends AbstractStorageHandler {
         }
         finally {
             if (pluginname == null || pluginname.length() == 0) {
-                log.error("SLUBStoragePlugin failed to get pluginname, because it is empty. Possibly, there is no valid fixity type used or a CustomFixityPlugin missed");
+                log.warn("SLUBStoragePlugin failed to get pluginname, because it is empty. Possibly, there is no valid fixity type used or a CustomFixityPlugin missed");
+                log.warn("SLUBStoragePlugin.checkFixityByPlugin() trying to use fallback table to determine plugin name");
+                String algorithm = fixity.getAlgorithm();
+                if (algorithm == "SHA512") {
+                    pluginname = "CustomFixitySHA512Plugin";
+                    log.info("SLUBStoragePlugin.checkFixityByPlugin() pluginname=" + pluginname);
+                } else {
+                    log.error("SLUBStoragePlugin.checkFixityByPlugin() fallback table has no plugin name entry for algorithm '" + algorithm + "'");
+                }
             }
         }
 
@@ -199,7 +207,10 @@ public class SLUBStoragePlugin extends AbstractStorageHandler {
         catch (Exception e) {
             log.warn("SLUBStoragePlugin.checkFixityByPlugin() hard error getting previous fixity value, ", e.getMessage());
         }
-        fixity.setValue(getChecksumUsingPlugin(isRelativePath ? getLocalFilePath(storedEntityIdentifier) : storedEntityIdentifier, fixity.getPluginName(), oldValue));
+        fixity.setValue(getChecksumUsingPlugin(isRelativePath ? getLocalFilePath(storedEntityIdentifier) : storedEntityIdentifier, pluginname, oldValue));
+        /* HINT: if plugin name is still empty a java.lang.NullPointerException gets thrown
+                 Rosetta will handle it and let us know (creates technical issue in workbench)
+         */
         fixity.setResult((oldValue == null) || (oldValue.equals(fixity.getValue())));
         log.info("SLUBStoragePlugin.checkFixityByPlugin() newvalue=" + fixity.getValue());
         result &= fixity.getResult();
-- 
GitLab