diff --git a/PLUGIN-INF/metadata_SLUBStoragePlugin.xml b/PLUGIN-INF/metadata_SLUBStoragePlugin.xml index f7ee169fa64d8d32cc94d1cfbec71d670860b560..8b2322b14d3bf2c8daffd43c092c37e19a0f9e97 100644 --- a/PLUGIN-INF/metadata_SLUBStoragePlugin.xml +++ b/PLUGIN-INF/metadata_SLUBStoragePlugin.xml @@ -83,7 +83,7 @@ </fr:x_form> </pl:initParameters> <pl:description>SLUB Storage Plugin</pl:description> - <pl:version>2.96</pl:version> + <pl:version>2.97</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 c021c590891f317b70e489bf6e062fb8474df534..981cfe509fe73519f2c9b9380f0c273aa352b326 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 @@ -198,10 +198,10 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { /** * checkFixity - * @param fixities - * @param absolutePath + * @param fixities checksummer list + * @param absolutePath path of checked file * @return true if valid, otherwise false - * @throws Exception + * @throws IOException if I/O error occurs */ public boolean checkFixityAbs(List<Fixity> fixities, AbsolutePath absolutePath) throws IOException{ //log.debug("SLUBStoragePlugin.checkFixity() storedEntityIdentifier='" + storedEntityIdentifier + "'"); @@ -265,9 +265,10 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { /** * checkSpecificFixity * @param absolute_storedEntityIdentifier absolute file path - * @param fixity + * @param fixity checksummer object * @return true if valid otherwise false - * @throws Exception + * @throws IOException if I/O errors occure + * @throws NoSuchAlgorithmException if checksummer object does not match expected algorithm */ private boolean checkSpecificFixity(AbsolutePath absolute_storedEntityIdentifier, Fixity fixity) throws IOException, NoSuchAlgorithmException { String algorithm = fixity.getAlgorithm(); @@ -363,7 +364,6 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { * @param fixity concrete fixity object * @param absolute_storedEntityIdentifier absolute filepath to file which should be checked * @return true if valid, otherwise false - * @throws Exception to inform rosetta */ private boolean checkFixityByPlugin(Fixity fixity, AbsolutePath absolute_storedEntityIdentifier) { //log.debug("SLUBStoragePlugin.checkFixityByPlugin() another fixity, root=" + getDirRoot() + " absolute_storedEntityIdentifier=" + absolute_storedEntityIdentifier); @@ -417,7 +417,7 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { /** * deleteEntity - * @param relative_storedEntityIdentifier + * @param relative_storedEntityIdentifier file object to delete * @return true if successful */ public boolean deleteEntity(String relative_storedEntityIdentifier) @@ -470,7 +470,7 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { * retrieveEntity * @param storedEntityIdentifier as relative filepath * @return Buffered InputStream - * @throws IOException + * @throws IOException if I/O error occur */ public InputStream retrieveEntity(String storedEntityIdentifier) throws IOException @@ -479,8 +479,13 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { contractAssertIsRelativePath(storedEntityIdentifier); var absolute_filename = getFullFilePath(storedEntityIdentifier); var absolute_path = Paths.get(absolute_filename); - var is = java.nio.file.Files.newInputStream( absolute_path ); - return new BufferedInputStream( is , getBlockSize()); + try (InputStream is = Files.newInputStream(absolute_path)) { + return new BufferedInputStream(is, getBlockSize()); + } catch (IOException e) { + log.error("SLUBStoragePlugin.retrieveEntity() with storedEntityIdentifier '" + storedEntityIdentifier + + "', I/O error, file=" + absolute_filename + " " + e.getMessage()); + throw e; + } } /** @@ -489,7 +494,7 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { * @param start offset to begin * @param end offset to end * @return byte array of size end-begin - * @throws Exception + * @throws Exception if any error occur */ public byte[] retrieveEntityByRange(String storedEntityIdentifier, long start, long end) throws Exception { @@ -520,9 +525,9 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { /** * storeEntity * @param is - InputStream - * @param storedEntityMetadata + * @param storedEntityMetadata rosetta specific metadata object * @return relative path to storedEntity - * @throws Exception + * @throws IOException if I/O error occur */ public String storeEntity(InputStream is, StoredEntityMetaData storedEntityMetadata) throws IOException @@ -586,21 +591,21 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { /** * copyFile, specialised function derived from FileUtil.copyFile using improved filecopy - * @param source - * @param destination - * @throws IOException + * @param source sourcefile string + * @param destination destination path + * @throws IOException if I/O error occur */ private void copyFile(String source, AbsolutePath destination) throws IOException { long starttime = System.currentTimeMillis(); log.info("SLUBStoragePlugin.copyFile (" + source + ", " + destination.filestring() + "), begin copying…"); - OutputStream output = java.nio.file.Files.newOutputStream(Path.of(destination.filestring())); + OutputStream output = Files.newOutputStream(Path.of(destination.filestring())); InputStream input; if (source.toLowerCase().trim().startsWith("http")) { log.info("SLUBStoragePlugin.copyFile (\" + source + \", \" + destination.filestring() + \"), using getUrlContent()\");"); input = FileTransferUtil.getUrlContent(source); } else { /* simpleFilecopy, see https://www.digitalocean.com/community/tutorials/java-copy-file */ log.info("SLUBStoragePlugin.copyFile (\" + source + \", \" + destination.filestring() + \"), using FileInputStream()\");"); - input = java.nio.file.Files.newInputStream(Path.of(source)); + input = Files.newInputStream(Path.of(source)); } copyStreamFast(input, output); input.close(); @@ -817,8 +822,8 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { /** * - * @param storedEntityMetadata - * @param absolutePath + * @param storedEntityMetadata rosetta specific metadata object + * @param absolutePath filepath object */ private void saveAbsoluteDestPathsTmpFile(StoredEntityMetaData storedEntityMetadata, AbsolutePath absolutePath) { log.info("SLUBStoragePlugin.saveAbsoluteDestPathsTmpFile()");