diff --git a/PLUGIN-INF/metadata_SLUBStoragepPlugin.xml b/PLUGIN-INF/metadata_SLUBStoragepPlugin.xml index 58af2808060a09f270f01f8f64f43a914edcb140..541500cc4ecbaac7e8a572494757eee36b8c387b 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.810</pl:version> + <pl:version>2.813</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 8258602f8cec7741a0154a90a0a1b63a9b0440d6..7ca020c6b0611f74046b386fbf9fcee4cc44cdb8 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 @@ -1,6 +1,6 @@ /* -2014-2016 by Andreas Romeyke (SLUB Dresden) +2014-2020 by Andreas Romeyke (SLUB Dresden) The code contributed by SLUB is licensed under apache 2.0 and based partially on NFS Storage Plugin, @@ -33,10 +33,22 @@ import com.exlibris.digitool.common.dnx.DnxSectionRecord; import com.exlibris.digitool.common.storage.Fixity; import com.exlibris.digitool.infrastructure.utils.Checksummer; -import java.io.*; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.RandomAccessFile; import java.security.NoSuchAlgorithmException; import java.text.SimpleDateFormat; -import java.util.*; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; /** * SLUBStoragePlugin @@ -87,7 +99,7 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { InputStream is = null; try { is = retrieveEntity(storedEntityIdentifier, isRelativePath); - Checksummer checksummer = new Checksummer(is, true, true, true); + Checksummer checksummer = new Checksummer(is, true, true, true,true); for (Fixity fixity : fixities) { fixity.setResult(false); log.info("SLUBStoragePlugin.checkFixity() getAlgorithm=" + fixity.getAlgorithm()); @@ -114,6 +126,15 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { } } } + catch (IOException e) { + log.error("SLUBStoragePlugin.checkFixity(), I/O error, " + e.getMessage()); + } + catch (NoSuchAlgorithmException e) { + log.error( "SLUBStoragePlugin.checkFixity(), missed Algorithm, " + e.getMessage()); + } + catch (Exception e) { + log.error( "SLUBStoragePlugin.checkFixity(), unknown problem, " + e.getMessage()); + } finally { log.info("SLUBStoragePlugin.checkFixity() finally called"); @@ -157,13 +178,19 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { * @throws Exception */ private boolean checkFixityByPlugin(Fixity fixity, String storedEntityIdentifier, boolean isRelativePath, boolean result) throws Exception { - log.info("SLUBStoragePlugin.checkFixity() another fixity"); + log.info("SLUBStoragePlugin.checkFixityByPlugin() another fixity"); + String pluginname; try { - log.info("SLUBStoragePlugin.checkFixity() pluginname=" + fixity.getPluginName()); + pluginname = fixity.getPluginName(); + log.info("SLUBStoragePlugin.checkFixity() pluginname=" + pluginname); } catch (Exception e) { - log.warn("SLUBStoragePlugin failed to get pluginname ", e.getMessage()); + pluginname = ""; } + if (pluginname.isEmpty()) { + log.error("SLUBStoragePlugin failed to get pluginname, because it is empty. Possibly, there is no valid fixity typeused or a CustomFixityPlugin missed"); + } + String oldValue = ""; try { oldValue = fixity.getValue(); @@ -222,7 +249,7 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { public byte[] retrieveEntityByRange(String storedEntityIdentifier, long start, long end) throws Exception { - log.info("SLUBStoragePlugin.retrieveEntitybyRange() with '" + storedEntityIdentifier + "' start=" + start + "end=" + end); + log.info("SLUBStoragePlugin.retrieveEntitybyRange() with '" + storedEntityIdentifier + "' start=" + start + " end=" + end); byte[] bytes = new byte[(int)(end - start + 1L)]; RandomAccessFile file = null; try @@ -230,7 +257,13 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { file = new RandomAccessFile(this.parameters.get("DIR_ROOT") + storedEntityIdentifier, "r"); file.seek(start); file.readFully(bytes, 0, (int)(end - start + 1L)); - return bytes; + + } + catch (FileNotFoundException e) { + log.error("SLUBStoragePlugin.retrieveEntitybyRange(), file not found, " + e.getMessage()); + } + catch (Exception e) { + log.error("SLUBStoragePlugin.retrieveEntityByRange(), I/O error, " + e.getMessage()); } finally { @@ -241,11 +274,13 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { } catch (Exception e) { - log.warn("Failed closing file", e.getMessage()); + log.error("Failed closing file", e.getMessage()); } } } + return bytes; } + public String storeEntity(InputStream is, StoredEntityMetaData storedEntityMetadata) throws Exception { @@ -305,6 +340,7 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { log.debug("SLUBStoragePlugin.storeEntity() storedEntityIdentifier (2)='" + storedEntityIdentifier + "'"); return storedEntityIdentifier; } + protected void copyStream(StoredEntityMetaData storedEntityMetadata, String destPath) throws IOException {