From e99c043fe816e4fe7abdb9d87cc39e1d5769fafb Mon Sep 17 00:00:00 2001 From: Andreas Romeyke <art1@andreas-romeyke.de> Date: Thu, 22 Oct 2020 19:14:58 +0200 Subject: [PATCH] - fixed some spotifybugs warnings --- .../plugin/storage/nfs/SLUBStoragePlugin.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 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 89fc427..49907b8 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 @@ -34,11 +34,10 @@ import com.exlibris.digitool.common.storage.Fixity; import com.exlibris.digitool.infrastructure.utils.Checksummer; 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.OutputStream; import java.io.RandomAccessFile; import java.security.NoSuchAlgorithmException; import java.text.SimpleDateFormat; @@ -76,8 +75,8 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { private static final String DIR_ROOT = "DIR_ROOT"; /** {@inheritDoc} */ private static final String FILE_PER_DIR = "FILE_PER_DIR"; private static final String FILES_HANDLING_METHOD = "FILES_HANDLING_METHOD"; - private final String RELATIVE_DIRECTORY_PATH = "relativeDirectoryPath"; - private final String DEST_FILE_PATH = "destFilePath"; + final String RELATIVE_DIRECTORY_PATH = "relativeDirectoryPath"; + final String DEST_FILE_PATH = "destFilePath"; public SLUBStoragePlugin() { log.info("SLUBStoragePlugin instantiated"); @@ -244,7 +243,8 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { throws IOException { log.info("SLUBStoragePlugin.retrieveEntity() with '" + storedEntityIdentifier + "' isrelative=" + isRelative); - return new FileInputStream((isRelative ? this.parameters.get("DIR_ROOT") : "") + storedEntityIdentifier); + File file = new File((isRelative ? this.parameters.get("DIR_ROOT") : "") + storedEntityIdentifier); + return java.nio.file.Files.newInputStream( file.toPath()); } public byte[] retrieveEntityByRange(String storedEntityIdentifier, long start, long end) { @@ -319,10 +319,11 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { log.warn("SLUBStoragePlugin.storeEntity() InputStream is null"); return null; } - FileOutputStream output = null; + OutputStream output = null; try { - output = new FileOutputStream(new File(destFilePath)); + File file = new File(destFilePath); + output = java.nio.file.Files.newOutputStream( file.toPath()); IOUtil.copy(is, output); log.debug("SLUBStoragePlugin.storeEntity() try copy was successfull"); } @@ -476,6 +477,7 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { * @return calculated relative path as String * returns the path as string */ + String getStreamRelativePath(StoredEntityMetaData storedEntityMetaData) throws Exception { log.info("SLUBStoragePlugin.getStreamRelativePath()"); if ((null == storedEntityMetaData)) throw new AssertionError(); @@ -501,7 +503,7 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { log.debug("SLUBStoragePlugin.getStreamRelativePath iesec=" + iesec.toString()); List<DnxSectionRecord> records = iesec.getRecordList(); for (DnxSectionRecord element : records) { - if (element.getKeyById("internalIdentifierType").getValue().equals("PID")) { + if ("PID".equals(element.getKeyById("internalIdentifierType").getValue())) { iepid = element.getKeyById("internalIdentifierValue").getValue(); // found IEPID break; } -- GitLab