diff --git a/PLUGIN-INF/metadata_SLUBStoragePlugin.xml b/PLUGIN-INF/metadata_SLUBStoragePlugin.xml index 74ad4bbd3396ca0fe9c19fa2a715e6fe776c44ef..499e7df2c769c0a2d80c91aa52cc3389c96dc8cc 100644 --- a/PLUGIN-INF/metadata_SLUBStoragePlugin.xml +++ b/PLUGIN-INF/metadata_SLUBStoragePlugin.xml @@ -70,7 +70,7 @@ </fr:x_form> </pl:initParameters> <pl:description>SLUB Storage Plugin</pl:description> - <pl:version>2.839</pl:version> + <pl:version>2.840</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 7430e6a0d66d1b3ba9b9429d3d97d02c3f43cdc3..a20604ea4d68207a62b85d9fac4fad5d6c63dc3c 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 @@ -45,6 +45,7 @@ import java.io.OutputStream; import java.io.RandomAccessFile; import java.nio.channels.FileChannel; import java.nio.file.Files; +import java.nio.file.Path; import java.nio.file.Paths; import java.security.NoSuchAlgorithmException; import java.text.SimpleDateFormat; @@ -119,7 +120,7 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { } private String throughput(long starttime_in_ms, long endtime_in_ms, long fsize) { long duration_in_ms = endtime_in_ms - starttime_in_ms; - log.info("SLUBStoragePlugin.throughput duration=" + duration_in_ms + " filesize=" + fsize); + //log.debug("SLUBStoragePlugin.throughput duration=" + duration_in_ms + " filesize=" + fsize); if ((fsize >= 0) && (duration_in_ms) > 0) { /* fsize in Bytes duration in ms = duration in s / 1000 @@ -147,12 +148,11 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { * @throws Exception */ public boolean checkFixity(List<Fixity> fixities, String storedEntityIdentifier) throws Exception { - log.info("SLUBStoragePlugin.checkFixity() storedEntityIdentifier='" + storedEntityIdentifier + "'"); + //log.debug("SLUBStoragePlugin.checkFixity() storedEntityIdentifier='" + storedEntityIdentifier + "'"); String absolute_storedEntityIdentifier = getFullFilePath(storedEntityIdentifier); contractAssertIsAbsolutePath(absolute_storedEntityIdentifier); - log.info("SLUBStoragePlugin.checkFixity() absolute_storedEntityIdentifier='" + absolute_storedEntityIdentifier + "'"); - // log.info("SLUBStoragePlugin.checkFixity() all fixities=" + fixities); - if (fixities == null) { + //log.debug("SLUBStoragePlugin.checkFixity() absolute_storedEntityIdentifier='" + absolute_storedEntityIdentifier + "'"); + if (null==fixities) { log.warn("SLUBStoragePlugin.checkFixity() No fixity list provided"); return true; } @@ -176,7 +176,7 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { String algorithm = fixity.getAlgorithm(); /* HINT: in past versions of Rosetta was a workaround for fixity.getAlgorithm() required, a lowercase string was returned instead of the correct fixity code table entry */ - log.info("SLUBStoragePlugin.checkSpecificFixity() absolute_storedEntityIdentifier='"+absolute_storedEntityIdentifier+"' getAlgorithm=" + algorithm); + //log.debug("SLUBStoragePlugin.checkSpecificFixity() absolute_storedEntityIdentifier='"+absolute_storedEntityIdentifier+"' getAlgorithm=" + algorithm); try { if ( (!Fixity.FixityAlgorithm.MD5.toString().equals(algorithm)) && @@ -184,12 +184,12 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { (!Fixity.FixityAlgorithm.SHA256.toString().equals(algorithm)) && (!Fixity.FixityAlgorithm.CRC32.toString().equals(algorithm)) ) { - log.info("SLUBStoragePlugin.checkSpecificFixity() call checkFixityByPlugin (" + fixity + "," + absolute_storedEntityIdentifier + ")"); + //log.debug("SLUBStoragePlugin.checkSpecificFixity() call checkFixityByPlugin (" + fixity + "," + absolute_storedEntityIdentifier + ")"); return checkFixityByPlugin(fixity, absolute_storedEntityIdentifier); } else { - log.info("SLUBStoragePlugin.checkSpecificFixity() calcMD5|calcSHA1|calcCRC32|calcSHA256=true"); + //log.debug("SLUBStoragePlugin.checkSpecificFixity() calcMD5|calcSHA1|calcCRC32|calcSHA256=true"); int checksummerAlgorithmIndex = getChecksummerAlgorithmIndex(algorithm); - log.info("SLUBStoragePlugin.checkSpecificFixity() checksummerAlgorithmIndex=" + checksummerAlgorithmIndex); + //log.debug("SLUBStoragePlugin.checkSpecificFixity() checksummerAlgorithmIndex=" + checksummerAlgorithmIndex); if (checksummerAlgorithmIndex != -1) { return checkFixityByBuiltin(fixity, absolute_storedEntityIdentifier, algorithm); } @@ -217,24 +217,31 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { * @throws IOException if I/O error */ private boolean checkFixityByBuiltin(Fixity fixity, String absolute_storedEntityIdentifier, String algorithm) throws NoSuchAlgorithmException, IOException { - log.info("SLUBStoragePlugin.checkFixityByBuiltin() absolute_storedEntityIdentifier='"+absolute_storedEntityIdentifier+"' algorithm=" + algorithm); + //log.debug("SLUBStoragePlugin.checkFixityByBuiltin() absolute_storedEntityIdentifier='"+absolute_storedEntityIdentifier+"' algorithm=" + algorithm); contractAssertIsAbsolutePath(absolute_storedEntityIdentifier); String oldValue = fixity.getValue(); - log.info("SLUBStoragePlugin.checkFixityByBuiltin() getAlgorithm (2)=" + algorithm); - log.info("SLUBStoragePlugin.checkFixityByBuiltin() oldvalue=" + oldValue); + //log.debug("SLUBStoragePlugin.checkFixityByBuiltin() getAlgorithm (2)=" + algorithm); + //log.debug("SLUBStoragePlugin.checkFixityByBuiltin() oldvalue=" + oldValue); long starttime = System.currentTimeMillis(); String storedEntityIdentifier = relativePath(absolute_storedEntityIdentifier); - log.info("SLUBStoragePlugin.checkFixityByBuiltin() calculated storedEntityIdentifier=" + storedEntityIdentifier); + //log.debug("SLUBStoragePlugin.checkFixityByBuiltin() calculated storedEntityIdentifier=" + storedEntityIdentifier); contractAssertIsRelativePath(storedEntityIdentifier); InputStream is = retrieveEntity(storedEntityIdentifier); Checksummer checksummer = new Checksummer(is, true, true, true, true); fixity.setValue(checksummer.getChecksum(algorithm)); - log.info("SLUBStoragePlugin.checkFixityByBuiltin() newvalue=" + fixity.getValue()); - fixity.setResult((oldValue == null) || (oldValue.equalsIgnoreCase(fixity.getValue()))); + var newValue = fixity.getValue(); + //log.debug("SLUBStoragePlugin.checkFixityByBuiltin() newvalue=" + newValue); + fixity.setResult((oldValue == null) || (oldValue.equalsIgnoreCase(newValue))); boolean result = fixity.getResult(); is.close(); long endtime = System.currentTimeMillis(); - log.info("SLUBStoragePlugin.checkFixityByBuiltin() pathname='"+ absolute_storedEntityIdentifier + "' result=" + result + " (" + throughput(starttime, endtime, absolute_storedEntityIdentifier)+ ")"); + log.info("SLUBStoragePlugin.checkFixityByBuiltin() pathname='" + absolute_storedEntityIdentifier + "'" + + " algorithm=" + algorithm + + " oldvalue=" + oldValue + + " newvalue=" + newValue + + " result=" + result + + " (" + throughput(starttime, endtime, absolute_storedEntityIdentifier)+ ")" + ); return result; } @@ -242,7 +249,7 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { var begin = getDirRoot().length(); var end = absolute_storedEntityIdentifier.length(); var rel = absolute_storedEntityIdentifier.substring(begin, end); - log.info("SLUBStoragePlugin.relativePath('"+ absolute_storedEntityIdentifier + "') -> DirRoot="+getDirRoot() + " begin=" + begin + " end=" + end + " rel='" + rel + "'"); + //log.debug("SLUBStoragePlugin.relativePath('"+ absolute_storedEntityIdentifier + "') -> DirRoot="+getDirRoot() + " begin=" + begin + " end=" + end + " rel='" + rel + "'"); assert(begin < end); return rel; } @@ -256,19 +263,20 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { * @throws Exception to inform rosetta */ private boolean checkFixityByPlugin(Fixity fixity, String absolute_storedEntityIdentifier) throws Exception { - log.info("SLUBStoragePlugin.checkFixityByPlugin() another fixity, root=" + getDirRoot() + " absolute_storedEntityIdentifier=" + absolute_storedEntityIdentifier); + //log.debug("SLUBStoragePlugin.checkFixityByPlugin() another fixity, root=" + getDirRoot() + " absolute_storedEntityIdentifier=" + absolute_storedEntityIdentifier); contractAssertIsAbsolutePath(absolute_storedEntityIdentifier); String pluginname = fixity.getPluginName(); - log.info("SLUBStoragePlugin.checkFixityByPlugin() pluginname=" + pluginname); + String algorithm = "should not occur"; + //log.debug("SLUBStoragePlugin.checkFixityByPlugin() pluginname=" + pluginname); // HINT: Workaround for Rosetta case 06472860 - Storage Plugin: Empty custom fixity plugin name breaks file updates [Rosetta 7.3.0.0] // -> use fallback names in case fixity plugin name is missing if (pluginname == null || pluginname.length() == 0) { log.warn("SLUBStoragePlugin.checkFixityByPlugin() 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(); + algorithm = fixity.getAlgorithm(); if ("SHA512".equals(algorithm)) { pluginname = "CustomFixitySHA512Plugin"; - log.info("SLUBStoragePlugin.checkFixityByPlugin() pluginname=" + pluginname); + //log.debug("SLUBStoragePlugin.checkFixityByPlugin() pluginname=" + pluginname); } else { log.error("SLUBStoragePlugin.checkFixityByPlugin() fallback table has no plugin name entry for algorithm '" + algorithm + "'"); } @@ -286,11 +294,16 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { /* 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()); + fixity.setResult((oldValue == null) || (oldValue.equals(newValue))); boolean result = fixity.getResult(); long endtime = System.currentTimeMillis(); - log.info("SLUBStoragePlugin.checkFixityByPlugin() pathname='" + absolute_storedEntityIdentifier + "' result=" + result + " (plugins " + throughput(starttime, endtime, absolute_storedEntityIdentifier)+ ")"); + log.info("SLUBStoragePlugin.checkFixityByPlugin() pathname='" + absolute_storedEntityIdentifier + "'" + + " algorithm=" + algorithm + + " oldvalue=" + oldValue + + " newvalue=" + newValue + + " result=" + result + + " (" + throughput(starttime, endtime, absolute_storedEntityIdentifier)+ ")" + ); return result; } @@ -303,7 +316,6 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { { log.info("SLUBStoragePlugin.deleteEntity() storedEntityIdentifier='" + relative_storedEntityIdentifier + "'"); var absolute_filename = getFullFilePath(relative_storedEntityIdentifier); - File file = new File(absolute_filename); try { @@ -316,10 +328,9 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { return true; } - public String getLocalFilePath(String storedEntityIdentifier) { - log.info("SLUBStoragePlugin.getLocalFilePath() with '" + storedEntityIdentifier + "'"); + //log.debug("SLUBStoragePlugin.getLocalFilePath() with '" + storedEntityIdentifier + "'"); return getFullFilePath(storedEntityIdentifier); } @@ -330,7 +341,7 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { */ public String getFullFilePath(String storedEntityIdentifier) { - log.info("SLUBStoragePlugin.getFullFilePath() with '" + storedEntityIdentifier + "'"); + //log.debug("SLUBStoragePlugin.getFullFilePath() with '" + storedEntityIdentifier + "'"); return getDirRoot() + storedEntityIdentifier; } @@ -384,8 +395,7 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { log.info("SLUBStoragePlugin.retrieveEntitybyRange() with storedEntityIdentifier='" + storedEntityIdentifier + "' start=" + start + " end=" + end); /* try-with-ressource block, no close if failed needed */ var absolute_filename = getFullFilePath(storedEntityIdentifier); - try (RandomAccessFile file = new RandomAccessFile(absolute_filename, "r")) - { + try (RandomAccessFile file = new RandomAccessFile(absolute_filename, "r")) { long starttime = System.currentTimeMillis(); file.seek(start); byte[] bytes = new byte[(int)(end - start + 1L)]; @@ -393,16 +403,13 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { long endtime = System.currentTimeMillis(); log.info("SLUBStoragePlugin.retrieveEntitybyRange() sucessfull (" + throughput(starttime, endtime, file.length())+ ")"); return bytes; - } - catch (FileNotFoundException e) { + } catch (FileNotFoundException e) { log.error("SLUBStoragePlugin.retrieveEntitybyRange(), file not found, " + e.getMessage()); throw e; - } - catch (IOException e) { + } catch (IOException e) { log.error("SLUBStoragePlugin.retrieveEntityByRange(), I/O error, " + e.getMessage()); throw e; - } - catch (Exception e) { + } catch (Exception e) { log.error("SLUBStoragePlugin.retrieveEntityByRange(), unknown problem, " + e.getMessage()); throw e; } @@ -420,7 +427,7 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { { log.info("SLUBStoragePlugin.storeEntity()"); String existsDescPath = getFilePathInDescIfExists(storedEntityMetadata); - log.debug("SLUBStoragePlugin.storeEntity() existsDescPath='" + existsDescPath + "'"); + //log.debug("SLUBStoragePlugin.storeEntity() existsDescPath='" + existsDescPath + "'"); String destFilePath = null; boolean isCopyFileNeeded = true; @@ -428,32 +435,32 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { { destFilePath = existsDescPath; /* destFilePath is relative, checkfixity expects absolute */ - log.info("SLUBStoragePlugin.storeEntity() calling checkFixity(storedEntityMetadata.getFixities(), '"+destFilePath+");"); + //log.debug("SLUBStoragePlugin.storeEntity() calling checkFixity(storedEntityMetadata.getFixities(), '"+destFilePath+");"); isCopyFileNeeded = !checkFixity(storedEntityMetadata.getFixities(), destFilePath); } - log.info("SLUBStoragePlugin.storeEntity() destFilePath='" + destFilePath + "'"); + //log.debug("SLUBStoragePlugin.storeEntity() destFilePath='" + destFilePath + "'"); Map<String, String> paths = getStoreEntityIdentifier(storedEntityMetadata, destFilePath); String storedEntityIdentifier = paths.get("relativeDirectoryPath"); contractAssertIsRelativePath(storedEntityIdentifier); - log.info("SLUBStoragePlugin.storeEntity() storedEntityIdentifier='" + storedEntityIdentifier + "'"); + //log.debug("SLUBStoragePlugin.storeEntity() storedEntityIdentifier='" + storedEntityIdentifier + "'"); String absolute_destFilePath = paths.get("destFilePath"); contractAssertIsAbsolutePath(absolute_destFilePath); - log.info("SLUBStoragePlugin.storeEntity() destFilePath (2)='" + absolute_destFilePath + "'"); - log.info("SLUBStoragePlugin.storeEntity() isCopyFileNeeded='" + isCopyFileNeeded + "'"); + //log.debug("SLUBStoragePlugin.storeEntity() destFilePath (2)='" + absolute_destFilePath + "'"); + //log.debug("SLUBStoragePlugin.storeEntity() isCopyFileNeeded='" + isCopyFileNeeded + "'"); if (isCopyFileNeeded) { if (canHandleSourcePath(storedEntityMetadata.getCurrentFilePath())) { - log.debug("SLUBStoragePlugin.storeEntity() absolute_destFilePath canhandle sourcepath"); + //log.debug("SLUBStoragePlugin.storeEntity() absolute_destFilePath canhandle sourcepath"); if (is != null) { is.close(); } copyStream(storedEntityMetadata, absolute_destFilePath); - log.info("SLUBStoragePlugin.storeEntity() try copy (copyStream(storedEntityMetadata, '" + absolute_destFilePath + "')) was successfull"); + //log.debug("SLUBStoragePlugin.storeEntity() try copy (copyStream(storedEntityMetadata, '" + absolute_destFilePath + "')) was successfull"); } else { - log.debug("SLUBStoragePlugin.storeEntity() Cannot handle source path: " + storedEntityMetadata.getCurrentFilePath()); + //log.debug("SLUBStoragePlugin.storeEntity() Cannot handle source path: " + storedEntityMetadata.getCurrentFilePath()); if (is == null) { log.warn("SLUBStoragePlugin.storeEntity() InputStream is null"); @@ -468,11 +475,11 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { } } if (!checkFixity(storedEntityMetadata.getFixities(), storedEntityIdentifier)) { - log.info("SLUBStoragePlugin.storeEntity() called checkFixity(fixities, '"+storedEntityIdentifier+"') failed"); + log.warn("SLUBStoragePlugin.storeEntity() called checkFixity(fixities, '"+storedEntityIdentifier+"') failed"); return null; } } - log.info("SLUBStoragePlugin.storeEntity() storedEntityIdentifier (2)='" + storedEntityIdentifier + "'"); + //log.debug("SLUBStoragePlugin.storeEntity() storedEntityIdentifier (2)='" + storedEntityIdentifier + "'"); return storedEntityIdentifier; } @@ -507,13 +514,13 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { log.info("SLUBStoragePlugin.copyStream()"); String filesHandlingMethod = getFilesHandlingMethod(); String srcPath = storedEntityMetadata.getCurrentFilePath(); - log.info("SLUBStoragePlugin.copyStream() destPath='" + destPath + "'"); - log.info("SLUBStoragePlugin.copyStream() srcPath='" + srcPath + "'"); - log.debug("SLUBStoragePlugin.copyStream() filesHandlingMethod='" + filesHandlingMethod + "'"); + //log.debug("SLUBStoragePlugin.copyStream() destPath='" + destPath + "'"); + //log.debug("SLUBStoragePlugin.copyStream() srcPath='" + srcPath + "'"); + //log.debug("SLUBStoragePlugin.copyStream() filesHandlingMethod='" + filesHandlingMethod + "'"); String pid = storedEntityMetadata.getEntityPid(); - log.debug("SLUBStoragePlugin.copyStream() pid='" + pid + "'"); + //log.debug("SLUBStoragePlugin.copyStream() pid='" + pid + "'"); String iePid = storedEntityMetadata.getIePid(); - log.debug("SLUBStoragePlugin.copyStream() iePid='" + iePid + "'"); + //log.debug("SLUBStoragePlugin.copyStream() iePid='" + iePid + "'"); String attr = "('\"+srcPath+\"','\" + destPath + \"')"; if ("copy".equalsIgnoreCase(filesHandlingMethod)) { // FileUtil.copyFile(srcPath, destPath); @@ -549,7 +556,7 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { } String tmpFilePath = getTempStorageDirectory(false) + "destPath"; String existsDescPath = StorageUtil.readDestPathFromTmpFile(storedEntityMetadata.getIePid(), tmpFilePath, storedEntityMetadata.getEntityPid()); - log.info("SLUBStoragePlugin.getFilePathInDescIfExists() existsDescPath='" + existsDescPath + "'"); + //log.debug("SLUBStoragePlugin.getFilePathInDescIfExists() existsDescPath='" + existsDescPath + "'"); return existsDescPath; } @@ -569,7 +576,7 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { /** copied from NFS Storage Plugin, enhanced with debugging info, {@inheritDoc} */ private int getChecksummerAlgorithmIndex(String algorithm) { - log.info("SLUBStoragePlugin.getChecksummerAlgorithm() algorithm='" + algorithm + "'"); + //log.debug("SLUBStoragePlugin.getChecksummerAlgorithm() algorithm='" + algorithm + "'"); try { Fixity.FixityAlgorithm fixityAlgorithm = Fixity.FixityAlgorithm.valueOf(algorithm); @@ -587,7 +594,7 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { /** copied from NFS Storage Plugin, enhanced with debugging info, {@inheritDoc} */ private File getCanonicalFile(String srcPath) { - log.info("SLUBStoragePlugin.getCanonicalFile() srcPath='"+ srcPath + "'"); + //log.debug("SLUBStoragePlugin.getCanonicalFile() srcPath='"+ srcPath + "'"); String backslash = "\\"; String fileName = srcPath.split(backslash + File.separator)[(srcPath.split(backslash + File.separator).length - 1)]; try @@ -606,12 +613,12 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { { log.info("SLUBStoragePlugin.getStoreEntityIdentifier() destFilePath='" + destFilePath +"'"); Map<String, String> paths = new HashMap<>(); - log.debug("(1) storedEntityMetadata is null?" + (null == storedEntityMetadata)); + //log.debug("(1) storedEntityMetadata is null?" + (null == storedEntityMetadata)); String fileName = createFileName(storedEntityMetadata); - log.debug("fileName='" + fileName + "'"); - log.debug("(2) storedEntityMetadata is null?" + (null == storedEntityMetadata)); + //log.debug("fileName='" + fileName + "'"); + //log.debug("(2) storedEntityMetadata is null?" + (null == storedEntityMetadata)); String relativeDirectoryPath = getStreamRelativePath(storedEntityMetadata); - log.debug("relativeDirectoryPath='" + relativeDirectoryPath + "'"); + //log.debug("relativeDirectoryPath='" + relativeDirectoryPath + "'"); if (destFilePath == null) { File destFile = getStreamDirectory(relativeDirectoryPath, fileName); @@ -619,11 +626,16 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { } contractAssertIsAbsolutePath(destFilePath); - log.info("destFilePath (2)='" + destFilePath + "'"); + //log.debug("destFilePath (2)='" + destFilePath + "'"); paths.put("destFilePath", destFilePath); String relativePath = relativeDirectoryPath + File.separator + fileName; contractAssertIsRelativePath(relativePath); paths.put("relativeDirectoryPath", relativePath); + log.info( + "SLUBStoragePlugin.getStoreEntityIdentifier() stored: " + + "destFilePath='" + destFilePath + "'" + + "relativeDirectoryPath='" + relativePath + "'" + ); return paths; } /** copied from NFS Storage Plugin, enhanced with debugging info, @@ -632,9 +644,9 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { File getStreamDirectory(String path, String fileName) { log.info("SLUBStoragePlugin.getStreamDirectory path='" + path + "' fileName='" + fileName + "'"); File newDir = new File(getDirRoot() + File.separator + path); - log.debug("SLUBStoragePlugin.getStreamDirectory newDir.getAbsolutePath()=" + newDir.getAbsolutePath()); + //log.debug("SLUBStoragePlugin.getStreamDirectory newDir.getAbsolutePath()=" + newDir.getAbsolutePath()); boolean arecreated = newDir.mkdirs(); - log.debug("SLUBStoragePlugin.getStreamDirectory newDir.mkdirs(), directories are created:" + arecreated); + //log.debug("SLUBStoragePlugin.getStreamDirectory newDir.mkdirs(), directories are created:" + arecreated); return new File(newDir.getAbsolutePath() + File.separator + fileName); } /** prepare right path @@ -649,27 +661,30 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { String getStreamRelativePath(StoredEntityMetaData storedEntityMetaData) throws Exception { log.info("SLUBStoragePlugin.getStreamRelativePath()"); - if ((null == storedEntityMetaData)) throw new AssertionError(); - log.debug("SLUBStoragePlugin.getStreamRelativePath() assert fine"); + if (null == storedEntityMetaData) { + log.fatal("SLUBStoragePlugin.getStreamRelativePath() with empty storedEntityMetaData called!"); + throw new AssertionError(); + } + //log.debug("SLUBStoragePlugin.getStreamRelativePath() assert fine"); String relativeDirectoryPath = File.separator; // get IE PID by calling IE-DNX record and search for ""internalIdentifierType" == "PID" DnxDocument iedoc = storedEntityMetaData.getIeDnx(); - log.debug("SLUBStoragePlugin.getStreamRelativePath() getIeDnx fine"); + //log.debug("SLUBStoragePlugin.getStreamRelativePath() getIeDnx fine"); if (null == iedoc) { log.error ("SLUBStoragePlugin.getStreamRelativePath no iedoc found, do you use plugin for others than permanent data (IE and filestream)? You should not! Also do not use it for SIPstoragePermanentGroup!"); throw new Exception("error, no iedoc found, do you use plugin for others than permanent data (IE and filestream)? You should not! Also do not use it for SIPstoragePermanentGroup!"); } StoredEntityMetaData.EntityType entityType = storedEntityMetaData.getEntityType(); - log.debug("SLUBStoragePlugin.getStreamRelativePath() getEntityType fine"); + //log.debug("SLUBStoragePlugin.getStreamRelativePath() getEntityType fine"); String entitytype = entityType.name(); - log.debug("entitytype='" + entitytype + "'"); + //log.debug("entitytype='" + entitytype + "'"); DnxSection iesec = iedoc.getSectionById("internalIdentifier"); if (null == iesec) { log.error ("SLUBStoragePlugin.getStreamRelativePath no section in entity of type "+entitytype +" with 'internalIdentfier' in associated iedoc found, do you use plugin for others than permanent data (IE and filestream)? You should not! Also do not use it for SIPstoragePermanentGroup!"); throw new Exception("error, no section in entity of type "+entitytype +" with 'internalIdentfier' in associated iedoc found, do you use plugin for others than permanent data (IE and filestream)? You should not! Also do not use it for SIPstoragePermanentGroup!"); } String iepid = null; - log.debug("SLUBStoragePlugin.getStreamRelativePath iesec=" + iesec); + //log.debug("SLUBStoragePlugin.getStreamRelativePath iesec=" + iesec); List<DnxSectionRecord> records = iesec.getRecordList(); for (DnxSectionRecord element : records) { if ("PID".equals(element.getKeyById("internalIdentifierType").getValue())) { @@ -682,7 +697,7 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { log.error ("SLUBStoragePlugin.getStreamRelativePath iesec="+iesec ); throw new Exception("error, could not get IEPID for storedEntityMetaData:"+storedEntityMetaData +" of type " + entitytype); } - log.debug("SLUBStoragePlugin.getStreamRelativePath iepid=" + iepid + " (entitytype=" + entitytype + ")"); + //log.debug("SLUBStoragePlugin.getStreamRelativePath iepid=" + iepid + " (entitytype=" + entitytype + ")"); // get creationDate of "objectCharacteristics" String datestring = iedoc.getSectionKeyValue("objectCharacteristics", "creationDate"); Calendar date = Calendar.getInstance(); @@ -692,7 +707,7 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { sdf.setLenient(false); /* if parse errors, do not guess about */ Date d = sdf.parse(datestring); date.setTime(d); - log.debug("SLUBStoragePlugin.getStreamRelativePath creation Date read=" + datestring + " parsed=" + date); + //log.debug("SLUBStoragePlugin.getStreamRelativePath creation Date read=" + datestring + " parsed=" + date); // now create path in format /yyyy/MM/dd/IEPID/ relativeDirectoryPath = relativeDirectoryPath + new SimpleDateFormat("yyyy").format(d); relativeDirectoryPath = relativeDirectoryPath + File.separator; @@ -706,35 +721,31 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { return relativeDirectoryPath; } - /** copied from NFS Storage Plugin, enhanced with debugging info, {@inheritDoc} */ - private void hardLink(String srcPath, String destPath) - throws IOException + private void softLink(String srcPath, String destPath) throws IOException + { + log.info("SLUBStoragePlugin.softLink srcPath='" + srcPath + "' destPath='" + destPath + "'"); + Files.createSymbolicLink(Path.of(srcPath), Path.of(destPath)); + } + + private void hardLink(String srcPath, String destPath) throws IOException { log.info("SLUBStoragePlugin.hardLink srcPath='" + srcPath + "' destPath='" + destPath + "'"); - String command = "ln"; - ExecExternalProcess proc = new ExecExternalProcess(); - List<String> args = new ArrayList<>(); - args.add(srcPath); - args.add(destPath); - int retValue = proc.execExternalProcess(command, args); - if (retValue != 0) { - throw new IOException("ln " + srcPath + " " + destPath + " failed " + proc.getErrorStream() + proc.getInputStream()); - } + Files.createLink(Path.of(srcPath), Path.of(destPath)); } - /** copied from NFS Storage Plugin, enhanced with debugging info, {@inheritDoc} */ + private void saveDestPathsTmpFile(String folder, String key, String path) { log.info("SLUBStoragePlugin.saveDestPathsTmpFile()"); - log.debug("SLUBStoragePlugin.saveDestPathsTmpFile folder='" + folder + "'"); - log.debug("SLUBStoragePlugin.saveDestPathsTmpFile key='" + key + "'"); - log.debug("SLUBStoragePlugin.saveDestPathsTmpFile path='" + path + "'"); + //log.debug("SLUBStoragePlugin.saveDestPathsTmpFile folder='" + folder + "'"); + //log.debug("SLUBStoragePlugin.saveDestPathsTmpFile key='" + key + "'"); + //log.debug("SLUBStoragePlugin.saveDestPathsTmpFile path='" + path + "'"); if (folder == null) { return; } String tmpFilePath = getTempStorageDirectory(false) + "destPath"; - log.debug("SLUBStoragePlugin.saveDestPathsTmpFile tmpFilePath='" + tmpFilePath + "'"); + //log.debug("SLUBStoragePlugin.saveDestPathsTmpFile tmpFilePath='" + tmpFilePath + "'"); File destPathDir = new File(getTempStorageDirectory(false) + "destPath" + File.separator); - log.debug("SLUBStoragePlugin.saveDestPathsTmpFile destPathDir='" + destPathDir + "'"); + //log.debug("SLUBStoragePlugin.saveDestPathsTmpFile destPathDir='" + destPathDir + "'"); if (!destPathDir.exists()) { boolean res = destPathDir.mkdirs(); if (!res) { @@ -743,25 +754,4 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { } StorageUtil.saveDestPathToTmpFile(folder, tmpFilePath, key, path); } - - /** copied from NFS Storage Plugin, enhanced with debugging info, {@inheritDoc} */ - private void softLink(String srcPath, String destPath) - throws IOException - { - log.info("SLUBStoragePlugin.softLink srcPath='" + srcPath + "' destPath='" + destPath + "'"); - File source = new File(srcPath); - if (!source.exists()) { - throw new IOException("File " + source + " does not exist"); - } - String command = "ln"; - ExecExternalProcess proc = new ExecExternalProcess(); - List<String> args = new ArrayList<>(); - args.add("-s"); - args.add(srcPath); - args.add(destPath); - int retValue = proc.execExternalProcess(command, args); - if (retValue != 0) { - throw new IOException("ln -s " + srcPath + " " + destPath + " failed " + proc.getErrorStream() + proc.getInputStream()); - } - } }