From 59606ab346e505b280cc258192acfb2ec8afc436 Mon Sep 17 00:00:00 2001 From: Andreas Romeyke <andreas.romeyke@slub-dresden.de> Date: Tue, 21 Oct 2014 15:33:40 +0000 Subject: [PATCH] - cleanup, using log.debug() for debugging messages now, removed unused code --- .idea/inspectionProfiles/Project_Default.xml | 49 ++++++ .idea/workspace.xml | 160 ++++++++++-------- PLUGIN-INF/metadata_SLUBStoragepPlugin.xml | 2 +- .../plugin/storage/nfs/SLUBStoragePlugin.java | 112 ++++++------ 4 files changed, 189 insertions(+), 134 deletions(-) diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml index e859172..9da7f4d 100644 --- a/.idea/inspectionProfiles/Project_Default.xml +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -2,6 +2,55 @@ <profile version="1.0" is_locked="false"> <option name="myName" value="Project Default" /> <option name="myLocal" value="false" /> + <inspection_tool class="AutoUnboxing" enabled="true" level="WARNING" enabled_by_default="true" /> + <inspection_tool class="ClassWithMultipleLoggers" enabled="true" level="WARNING" enabled_by_default="true"> + <option name="loggerNamesString" value="java.util.logging.Logger,org.slf4j.Logger,org.apache.commons.logging.Log,org.apache.log4j.Logger" /> + </inspection_tool> + <inspection_tool class="ClassWithoutLogger" enabled="true" level="WARNING" enabled_by_default="true"> + <option name="loggerNamesString" value="java.util.logging.Logger,org.slf4j.Logger,org.apache.commons.logging.Log,org.apache.log4j.Logger" /> + <option name="ignoreSuperLoggers" value="false" /> + </inspection_tool> + <inspection_tool class="CyclomaticComplexity" enabled="true" level="WARNING" enabled_by_default="true"> + <option name="m_limit" value="10" /> + </inspection_tool> + <inspection_tool class="EqualsAndHashcode" enabled="true" level="WARNING" enabled_by_default="true" /> + <inspection_tool class="InstanceVariableUninitializedUse" enabled="true" level="WARNING" enabled_by_default="true"> + <option name="m_ignorePrimitives" value="false" /> + <option name="annotationNamesString" value="" /> + </inspection_tool> + <inspection_tool class="LoggerInitializedWithForeignClass" enabled="false" level="WARNING" enabled_by_default="false"> + <option name="loggerClassName" value="org.apache.log4j.Logger,org.slf4j.LoggerFactory,org.apache.commons.logging.LogFactory,java.util.logging.Logger" /> + <option name="loggerFactoryMethodName" value="getLogger,getLogger,getLog,getLogger" /> + </inspection_tool> + <inspection_tool class="LoggingConditionDisagreesWithLogStatement" enabled="true" level="WARNING" enabled_by_default="true" /> + <inspection_tool class="MethodCoupling" enabled="true" level="WARNING" enabled_by_default="true"> + <option name="m_includeJavaClasses" value="false" /> + <option name="m_includeLibraryClasses" value="false" /> + <option name="m_limit" value="10" /> + </inspection_tool> + <inspection_tool class="MethodWithMultipleLoops" enabled="true" level="WARNING" enabled_by_default="true" /> + <inspection_tool class="MultipleReturnPointsPerMethod" enabled="true" level="WARNING" enabled_by_default="true"> + <option name="ignoreGuardClauses" value="false" /> + <option name="ignoreEqualsMethod" value="false" /> + <option name="m_limit" value="1" /> + </inspection_tool> + <inspection_tool class="NestingDepth" enabled="true" level="WARNING" enabled_by_default="true"> + <option name="m_limit" value="5" /> + </inspection_tool> + <inspection_tool class="NonStaticFinalLogger" enabled="true" level="WARNING" enabled_by_default="true"> + <option name="loggerClassName" value="" /> + </inspection_tool> + <inspection_tool class="NonThreadSafeLazyInitialization" enabled="true" level="WARNING" enabled_by_default="true" /> + <inspection_tool class="PublicMethodWithoutLogging" enabled="true" level="WARNING" enabled_by_default="true"> + <option name="loggerClassName" value="" /> + </inspection_tool> + <inspection_tool class="StaticVariableUninitializedUse" enabled="true" level="WARNING" enabled_by_default="true"> + <option name="m_ignorePrimitives" value="false" /> + </inspection_tool> + <inspection_tool class="ThreeNegationsPerMethod" enabled="true" level="WARNING" enabled_by_default="true"> + <option name="m_ignoreInEquals" value="true" /> + <option name="ignoreInAssert" value="false" /> + </inspection_tool> <inspection_tool class="WrongPackageStatement" enabled="false" level="ERROR" enabled_by_default="false" /> </profile> </component> \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml index a0e8f88..cf6c0a1 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,5 +1,9 @@ <?xml version="1.0" encoding="UTF-8"?> <project version="4"> + <component name="AnalysisUIOptions"> + <option name="ANALYZE_TEST_SOURCES" value="false" /> + <option name="SCOPE_TYPE" value="3" /> + </component> <component name="ChangeListManager"> <list default="true" readonly="true" id="3ad7d15b-0167-4c60-a3f9-2d3c54aea812" name="Default" comment=""> <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/ant.xml" /> @@ -84,58 +88,16 @@ <file leaf-file-name="SLUBStoragePlugin.java" pinned="false" current="true" current-in-tab="true"> <entry file="file://$PROJECT_DIR$/java/org/slub/rosetta/dps/repository/plugin/storage/nfs/SLUBStoragePlugin.java"> <provider selected="true" editor-type-id="text-editor"> - <state vertical-scroll-proportion="0.33205375" vertical-offset="5302" max-vertical-offset="8025"> - <caret line="365" column="42" selection-start-line="365" selection-start-column="42" selection-end-line="365" selection-end-column="42" /> + <state vertical-scroll-proportion="1.248366" vertical-offset="1332" max-vertical-offset="7965"> + <caret line="127" column="25" selection-start-line="127" selection-start-column="25" selection-end-line="127" selection-end-column="25" /> <folding> - <element signature="e#0#24417#0" expanded="true" /> + <element signature="e#0#24439#0" expanded="true" /> <element signature="imports" expanded="true" /> <element signature="e#3017#3018#0" expanded="true" /> <element signature="e#3075#3076#0" expanded="true" /> - <element signature="e#15717#15733#0" expanded="true" /> - </folding> - </state> - </provider> - </entry> - </file> - <file leaf-file-name="StorageUtil.class" pinned="false" current="false" current-in-tab="false"> - <entry file="jar:///exlibris/dps/d4_1/system.dir/dps-sdk-4.0.0/lib/dps-sdk-4.0.0.jar!/com/exlibris/core/sdk/storage/handler/StorageUtil.class"> - <provider selected="true" editor-type-id="text-editor"> - <state vertical-scroll-proportion="-3.0" vertical-offset="0" max-vertical-offset="465"> - <caret line="6" column="13" selection-start-line="6" selection-start-column="13" selection-end-line="6" selection-end-column="13" /> - <folding /> - </state> - </provider> - </entry> - </file> - <file leaf-file-name="StoredEntityMetaData.class" pinned="false" current="false" current-in-tab="false"> - <entry file="jar:///exlibris/dps/d4_1/system.dir/dps-sdk-4.0.0/lib/dps-sdk-4.0.0.jar!/com/exlibris/core/sdk/storage/containers/StoredEntityMetaData.class"> - <provider selected="true" editor-type-id="text-editor"> - <state vertical-scroll-proportion="-7.16" vertical-offset="466" max-vertical-offset="1290"> - <caret line="44" column="56" selection-start-line="44" selection-start-column="56" selection-end-line="44" selection-end-column="56" /> - <folding /> - </state> - </provider> - </entry> - </file> - <file leaf-file-name="AbstractStorageHandler.class" pinned="false" current="false" current-in-tab="false"> - <entry file="jar:///exlibris/dps/d4_1/system.dir/dps-sdk-4.0.0/lib/dps-sdk-4.0.0.jar!/com/exlibris/core/sdk/storage/handler/AbstractStorageHandler.class"> - <provider selected="true" editor-type-id="text-editor"> - <state vertical-scroll-proportion="-3.0" vertical-offset="0" max-vertical-offset="720"> - <caret line="6" column="22" selection-start-line="6" selection-start-column="22" selection-end-line="6" selection-end-column="22" /> - <folding /> - </state> - </provider> - </entry> - </file> - <file leaf-file-name="NFSStoragePlugin.java" pinned="false" current="false" current-in-tab="false"> - <entry file="file://$PROJECT_DIR$/java/org/slub/rosetta/dps/repository/plugin/storage/nfs/NFSStoragePlugin.java"> - <provider selected="true" editor-type-id="text-editor"> - <state vertical-scroll-proportion="102.85185" vertical-offset="6362" max-vertical-offset="6885"> - <caret line="239" column="38" selection-start-line="239" selection-start-column="38" selection-end-line="239" selection-end-column="38" /> - <folding> - <element signature="imports" expanded="true" /> - <element signature="e#12505#12506#0" expanded="true" /> - <element signature="e#12561#12562#0" expanded="true" /> + <element signature="e#15518#15534#0" expanded="true" /> + <element signature="e#22145#22153#0" expanded="true" /> + <element signature="e#24094#24102#0" expanded="true" /> </folding> </state> </provider> @@ -175,10 +137,52 @@ <State> <id>General</id> </State> + <State> + <id>Imports</id> + </State> + <State> + <id>Initialization issues</id> + </State> + <State> + <id>J2ME issues</id> + </State> + <State> + <id>Java language level issues</id> + </State> + <State> + <id>Javadoc issues</id> + </State> + <State> + <id>Logging issues</id> + </State> + <State> + <id>Memory issues</id> + </State> + <State> + <id>Method metrics</id> + </State> + <State> + <id>Modularization issues</id> + </State> + <State> + <id>Naming conventions</id> + </State> + <State> + <id>Packaging issues</id> + </State> + <State> + <id>Performance issues</id> + </State> + <State> + <id>Portability issues</id> + </State> + <State> + <id>Probable bugs</id> + </State> </expanded-state> <selected-state> <State> - <id>WrongPackageStatement</id> + <id>StaticVariableUninitializedUse</id> </State> </selected-state> </profile-state> @@ -407,7 +411,7 @@ <window_info id="Problems" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32954547" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" /> <window_info id="Palette" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" /> <window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32954547" sideWeight="0.5" order="8" side_tool="false" content_ui="tabs" /> - <window_info id="Find" active="true" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.32954547" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" /> + <window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32954547" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" /> <window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" /> <window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" /> <window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="9" side_tool="true" content_ui="tabs" /> @@ -420,11 +424,11 @@ <window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="SLIDING" type="SLIDING" visible="false" weight="0.4" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" /> <window_info id="Application Servers" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="11" side_tool="false" content_ui="tabs" /> <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.21826425" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" /> + <window_info id="Inspection" active="true" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.4" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" /> <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32954547" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" /> <window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" /> <window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" /> <window_info id="Module Dependencies" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.06282383" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" /> - <window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" /> <window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="3" side_tool="false" content_ui="combo" /> </layout> </component> @@ -457,11 +461,13 @@ <state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="2775"> <caret line="23" column="0" selection-start-line="23" selection-start-column="0" selection-end-line="23" selection-end-column="0" /> <folding> - <element signature="e#0#24417#0" expanded="true" /> + <element signature="e#0#24439#0" expanded="true" /> <element signature="imports" expanded="true" /> <element signature="e#3017#3018#0" expanded="true" /> <element signature="e#3075#3076#0" expanded="true" /> - <element signature="e#15717#15733#0" expanded="true" /> + <element signature="e#15518#15534#0" expanded="true" /> + <element signature="e#22145#22153#0" expanded="true" /> + <element signature="e#24094#24102#0" expanded="true" /> </folding> </state> </provider> @@ -483,61 +489,65 @@ <state vertical-scroll-proportion="0.0" vertical-offset="675" max-vertical-offset="2370"> <caret line="45" column="2" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" /> <folding> - <element signature="e#0#24417#0" expanded="true" /> + <element signature="e#0#24439#0" expanded="true" /> <element signature="imports" expanded="true" /> <element signature="e#3017#3018#0" expanded="true" /> <element signature="e#3075#3076#0" expanded="true" /> - <element signature="e#15717#15733#0" expanded="true" /> + <element signature="e#15518#15534#0" expanded="true" /> + <element signature="e#22145#22153#0" expanded="true" /> + <element signature="e#24094#24102#0" expanded="true" /> </folding> </state> </provider> </entry> - <entry file="jar:///exlibris/dps/d4_1/system.dir/dps-sdk-4.0.0/lib/dps-sdk-4.0.0.jar!/com/exlibris/core/sdk/storage/containers/StoredEntityMetaData.class"> + <entry file="file://$PROJECT_DIR$/java/org/slub/rosetta/dps/repository/plugin/storage/nfs/NFSStoragePlugin.java"> <provider selected="true" editor-type-id="text-editor"> - <state vertical-scroll-proportion="-7.16" vertical-offset="466" max-vertical-offset="1290"> - <caret line="44" column="56" selection-start-line="44" selection-start-column="56" selection-end-line="44" selection-end-column="56" /> - <folding /> + <state vertical-scroll-proportion="-6.0238614" vertical-offset="6362" max-vertical-offset="6885"> + <caret line="239" column="38" selection-start-line="239" selection-start-column="38" selection-end-line="239" selection-end-column="38" /> + <folding> + <element signature="imports" expanded="true" /> + <element signature="e#12505#12506#0" expanded="true" /> + <element signature="e#12561#12562#0" expanded="true" /> + </folding> </state> </provider> </entry> <entry file="jar:///exlibris/dps/d4_1/system.dir/dps-sdk-4.0.0/lib/dps-sdk-4.0.0.jar!/com/exlibris/core/sdk/storage/handler/AbstractStorageHandler.class"> <provider selected="true" editor-type-id="text-editor"> - <state vertical-scroll-proportion="-3.0" vertical-offset="0" max-vertical-offset="720"> + <state vertical-scroll-proportion="0.16198704" vertical-offset="0" max-vertical-offset="720"> <caret line="6" column="22" selection-start-line="6" selection-start-column="22" selection-end-line="6" selection-end-column="22" /> <folding /> </state> </provider> </entry> - <entry file="jar:///exlibris/dps/d4_1/system.dir/dps-sdk-4.0.0/lib/dps-sdk-4.0.0.jar!/com/exlibris/core/sdk/storage/handler/StorageUtil.class"> + <entry file="jar:///exlibris/dps/d4_1/system.dir/dps-sdk-4.0.0/lib/dps-sdk-4.0.0.jar!/com/exlibris/core/sdk/storage/containers/StoredEntityMetaData.class"> <provider selected="true" editor-type-id="text-editor"> - <state vertical-scroll-proportion="-3.0" vertical-offset="0" max-vertical-offset="465"> - <caret line="6" column="13" selection-start-line="6" selection-start-column="13" selection-end-line="6" selection-end-column="13" /> + <state vertical-scroll-proportion="0.3760504" vertical-offset="466" max-vertical-offset="1290"> + <caret line="44" column="56" selection-start-line="44" selection-start-column="56" selection-end-line="44" selection-end-column="56" /> <folding /> </state> </provider> </entry> - <entry file="file://$PROJECT_DIR$/java/org/slub/rosetta/dps/repository/plugin/storage/nfs/NFSStoragePlugin.java"> + <entry file="jar:///exlibris/dps/d4_1/system.dir/dps-sdk-4.0.0/lib/dps-sdk-4.0.0.jar!/com/exlibris/core/sdk/storage/handler/StorageUtil.class"> <provider selected="true" editor-type-id="text-editor"> - <state vertical-scroll-proportion="102.85185" vertical-offset="6362" max-vertical-offset="6885"> - <caret line="239" column="38" selection-start-line="239" selection-start-column="38" selection-end-line="239" selection-end-column="38" /> - <folding> - <element signature="imports" expanded="true" /> - <element signature="e#12505#12506#0" expanded="true" /> - <element signature="e#12561#12562#0" expanded="true" /> - </folding> + <state vertical-scroll-proportion="0.16198704" vertical-offset="0" max-vertical-offset="465"> + <caret line="6" column="13" selection-start-line="6" selection-start-column="13" selection-end-line="6" selection-end-column="13" /> + <folding /> </state> </provider> </entry> <entry file="file://$PROJECT_DIR$/java/org/slub/rosetta/dps/repository/plugin/storage/nfs/SLUBStoragePlugin.java"> <provider selected="true" editor-type-id="text-editor"> - <state vertical-scroll-proportion="0.33205375" vertical-offset="5302" max-vertical-offset="8025"> - <caret line="365" column="42" selection-start-line="365" selection-start-column="42" selection-end-line="365" selection-end-column="42" /> + <state vertical-scroll-proportion="1.248366" vertical-offset="1332" max-vertical-offset="7965"> + <caret line="127" column="25" selection-start-line="127" selection-start-column="25" selection-end-line="127" selection-end-column="25" /> <folding> - <element signature="e#0#24417#0" expanded="true" /> + <element signature="e#0#24439#0" expanded="true" /> <element signature="imports" expanded="true" /> <element signature="e#3017#3018#0" expanded="true" /> <element signature="e#3075#3076#0" expanded="true" /> - <element signature="e#15717#15733#0" expanded="true" /> + <element signature="e#15518#15534#0" expanded="true" /> + <element signature="e#22145#22153#0" expanded="true" /> + <element signature="e#24094#24102#0" expanded="true" /> </folding> </state> </provider> diff --git a/PLUGIN-INF/metadata_SLUBStoragepPlugin.xml b/PLUGIN-INF/metadata_SLUBStoragepPlugin.xml index 21261c8..9a31a9d 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.4</pl:version> + <pl:version>2.5</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 a12b77c..ced4917 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 @@ -130,7 +130,6 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { } finally { - Checksummer checksummer; if (is != null) { is.close(); } @@ -142,8 +141,8 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { public boolean deleteEntity(String storedEntityIdentifier) { - log.info("SLUBStoragePlugin.deleteEntity()"); - File file = new File((String)this.parameters.get("DIR_ROOT") + storedEntityIdentifier); + log.info("SLUBStoragePlugin.deleteEntity() storedEntityIdentifier='" + storedEntityIdentifier + "'"); + File file = new File(this.parameters.get("DIR_ROOT") + storedEntityIdentifier); try { return file.delete(); @@ -164,7 +163,7 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { public String getFullFilePath(String storedEntityIdentifier) { log.info("SLUBStoragePlugin.getFullFilePath() with '" + storedEntityIdentifier + "'"); - return (String)this.parameters.get("DIR_ROOT") + storedEntityIdentifier; + return this.parameters.get("DIR_ROOT") + storedEntityIdentifier; } public InputStream retrieveEntity(String storedEntityIdentifier) @@ -177,7 +176,7 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { throws IOException { log.info("SLUBStoragePlugin.retrieveEntity() with '" + storedEntityIdentifier + "' isrelative=" + isRelative); - return new FileInputStream((isRelative ? (String)this.parameters.get("DIR_ROOT") : "") + storedEntityIdentifier); + return new FileInputStream((isRelative ? this.parameters.get("DIR_ROOT") : "") + storedEntityIdentifier); } public byte[] retrieveEntityByRange(String storedEntityIdentifier, long start, long end) throws Exception @@ -187,7 +186,7 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { RandomAccessFile file = null; try { - file = new RandomAccessFile((String)this.parameters.get("DIR_ROOT") + storedEntityIdentifier, "r"); + file = new RandomAccessFile(this.parameters.get("DIR_ROOT") + storedEntityIdentifier, "r"); file.seek(start); file.readFully(bytes, 0, (int)(end - start + 1L)); return bytes; @@ -211,7 +210,7 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { { log.info("SLUBStoragePlugin.storeEntity()"); String existsDescPath = getFilePathInDescIfExists(storedEntityMetadata); - log.info("SLUBStoragePlugin.storeEntity() existsDescPath='" + existsDescPath +"'"); + log.debug("SLUBStoragePlugin.storeEntity() existsDescPath='" + existsDescPath + "'"); String destFilePath = null; boolean isCopyFileNeeded = true; @@ -220,18 +219,18 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { destFilePath = existsDescPath; isCopyFileNeeded = !checkFixity(storedEntityMetadata.getFixities(), destFilePath, false); } - log.info("SLUBStoragePlugin.storeEntity() destFilePath='" + destFilePath +"'"); + log.debug("SLUBStoragePlugin.storeEntity() destFilePath='" + destFilePath + "'"); Map<String, String> paths = getStoreEntityIdentifier(storedEntityMetadata, destFilePath); - String storedEntityIdentifier = (String)paths.get("relativeDirectoryPath"); - log.info("SLUBStoragePlugin.storeEntity() storedEntityIdentifier='" + storedEntityIdentifier +"'"); - destFilePath = (String)paths.get("destFilePath"); - log.info("SLUBStoragePlugin.storeEntity() destFilePath (2)='" + destFilePath +"'"); - log.info("SLUBStoragePlugin.storeEntity() isCopyFileNeeded='" + isCopyFileNeeded +"'"); + String storedEntityIdentifier = paths.get("relativeDirectoryPath"); + log.debug("SLUBStoragePlugin.storeEntity() storedEntityIdentifier='" + storedEntityIdentifier + "'"); + destFilePath = paths.get("destFilePath"); + log.debug("SLUBStoragePlugin.storeEntity() destFilePath (2)='" + destFilePath + "'"); + log.debug("SLUBStoragePlugin.storeEntity() isCopyFileNeeded='" + isCopyFileNeeded + "'"); if (isCopyFileNeeded) { if (canHandleSourcePath(storedEntityMetadata.getCurrentFilePath())) { - log.info("SLUBStoragePlugin.storeEntity() destFilePath canhandle sourcepath"); + log.debug("SLUBStoragePlugin.storeEntity() destFilePath canhandle sourcepath"); if (is != null) { is.close(); } @@ -239,7 +238,7 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { } else { - log.info("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"); @@ -250,7 +249,7 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { { output = new FileOutputStream(new File(destFilePath)); IOUtil.copy(is, output); - log.info("SLUBStoragePlugin.storeEntity() try copy was successfull"); + log.debug("SLUBStoragePlugin.storeEntity() try copy was successfull"); } finally { @@ -262,22 +261,22 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { return null; } } - log.info("SLUBStoragePlugin.storeEntity() storedEntityIdentifier (2)='" + storedEntityIdentifier +"'"); + log.debug("SLUBStoragePlugin.storeEntity() storedEntityIdentifier (2)='" + storedEntityIdentifier + "'"); return storedEntityIdentifier; } protected void copyStream(StoredEntityMetaData storedEntityMetadata, String destPath) throws IOException { log.info("SLUBStoragePlugin.copyStream()"); - String filesHandlingMethod = (String)this.parameters.get("FILES_HANDLING_METHOD"); + String filesHandlingMethod = this.parameters.get("FILES_HANDLING_METHOD"); String srcPath = storedEntityMetadata.getCurrentFilePath(); - log.info("SLUBStoragePlugin.copyStream() destPath='" + destPath + "'"); - log.info("SLUBStoragePlugin.copyStream() srcPath='" + srcPath + "'"); - log.info("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.info("SLUBStoragePlugin.copyStream() pid='" + pid + "'"); + log.debug("SLUBStoragePlugin.copyStream() pid='" + pid + "'"); String iePid = storedEntityMetadata.getIePid(); - log.info("SLUBStoragePlugin.copyStream() iePid='" + iePid + "'"); + log.debug("SLUBStoragePlugin.copyStream() iePid='" + iePid + "'"); if ("move".equalsIgnoreCase(filesHandlingMethod)) { File canonicalSrcFile = getCanonicalFile(srcPath); @@ -306,6 +305,7 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { return null; } String existsDescPath = StorageUtil.readDestPathFromTmpFile(storedEntityMetadata.getIePid(), tmpFilePath, storedEntityMetadata.getEntityPid()); + log.debug("SLUBStoragePlugin.getFilePathInDescIfExists() existsDescPath='" + existsDescPath + "'"); return existsDescPath; } @@ -330,7 +330,9 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { Fixity.FixityAlgorithm fixityAlgorithm = Fixity.FixityAlgorithm.valueOf(algorithm); return fixityAlgorithm.ordinal(); } - catch (Exception e) {} + catch (Exception e) { + log.info("SLUBStoragePlugin.getChecksummerAlgorithm(), exception: " + e.getMessage()); + } return -1; } @@ -342,10 +344,9 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { { log.info("SLUBStoragePlugin.getCanonicalFile() srcPath='"+ srcPath + "'"); String fileName = srcPath.split("\\" + File.separator)[(srcPath.split("\\" + File.separator).length - 1)]; - File canonicalSrcDir = null; try { - canonicalSrcDir = new File(srcPath).getParentFile().getCanonicalFile(); + File canonicalSrcDir = new File(srcPath).getParentFile().getCanonicalFile(); return new File(canonicalSrcDir, fileName).getCanonicalFile(); } catch (IOException e) { @@ -354,32 +355,23 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { return null; } - private String getNextDir(String fullPath) - { - log.info("SLUBStoragePlugin.getNextDir() fullPath='"+ fullPath + "'"); - String[] dirs = fullPath.split("\\" + File.separator); - String dir = dirs[(dirs.length - 2)]; - log.info("SLUBStoragePlugin.getNextDir() dir='" + dir + "'"); - return dir; - } private Map<String, String> getStoreEntityIdentifier(StoredEntityMetaData storedEntityMetadata, String destFilePath) throws Exception { - log.info("SLUBStoragePlugin.getStoreEntityIdentifier()"); - log.info("destFilePath='" + destFilePath +"'"); + log.info("SLUBStoragePlugin.getStoreEntityIdentifier() destFilePath='" + destFilePath +"'"); Map<String, String> paths = new HashMap<String, String>(); - log.info( "(1) storedEntityMetadata is null?" + (null == storedEntityMetadata)); + log.debug("(1) storedEntityMetadata is null?" + (null == storedEntityMetadata)); String fileName = createFileName(storedEntityMetadata); - log.info("fileName='"+fileName +"'"); - log.info( "(2) storedEntityMetadata is null?" + (null == storedEntityMetadata)); + log.debug("fileName='" + fileName + "'"); + log.debug("(2) storedEntityMetadata is null?" + (null == storedEntityMetadata)); String relativeDirectoryPath = getStreamRelativePath(storedEntityMetadata); - log.info("relativeDirectoryPath='"+relativeDirectoryPath +"'"); + log.debug("relativeDirectoryPath='" + relativeDirectoryPath + "'"); if (destFilePath == null) { File destFile = getStreamDirectory(relativeDirectoryPath, fileName); destFilePath = destFile.getAbsolutePath(); } - log.info("destFilePath (2)='" + destFilePath +"'"); + log.debug("destFilePath (2)='" + destFilePath + "'"); paths.put("destFilePath", destFilePath); // paths.put("relativeDirectoryPath", (relativeDirectoryPath + getNextDir(destFilePath) + File.separator + fileName)); paths.put("relativeDirectoryPath", (relativeDirectoryPath + File.separator + fileName)); @@ -392,9 +384,9 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { private File getStreamDirectory(String path, String fileName) { log.info("SLUBStoragePlugin.getStreamDirectory path='" + path + "' fileName='" + fileName + "'"); File newDir = new File(parameters.get(DIR_ROOT) + File.separator + path); - log.info("SLUBStoragePlugin.getStreamDirectory newDir.getAbsolutePath()=" + newDir.getAbsolutePath()); + log.debug("SLUBStoragePlugin.getStreamDirectory newDir.getAbsolutePath()=" + newDir.getAbsolutePath()); boolean arecreated = newDir.mkdirs(); - log.info("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 @@ -409,26 +401,26 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { private String getStreamRelativePath(StoredEntityMetaData storedEntityMetaData ) throws Exception { log.info("SLUBStoragePlugin.getStreamRelativePath()"); if ((null == storedEntityMetaData)) throw new AssertionError(); - log.info("SLUBStoragePlugin.getStreamRelativePath() assert fine"); + 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.info("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? You should not!"); throw new Exception("error, no iedoc found, do you use plugin for others than permanent data? You should not!"); } StoredEntityMetaData.EntityType entityType = storedEntityMetaData.getEntityType(); - log.info("SLUBStoragePlugin.getStreamRelativePath() getEntityType fine"); + log.debug("SLUBStoragePlugin.getStreamRelativePath() getEntityType fine"); String entitytype = entityType.name(); - log.info("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? You should not!"); 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? You should not!"); } String iepid = null; - log.info ("SLUBStoragePlugin.getStreamRelativePath iesec="+iesec.toString() ); + log.debug("SLUBStoragePlugin.getStreamRelativePath iesec=" + iesec.toString()); List<DnxSectionRecord> records = iesec.getRecordList(); for (DnxSectionRecord element : records) { if (element.getKeyById("internalIdentifierType").getValue().equals("PID")) { @@ -441,7 +433,7 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { log.error ("SLUBStoragePlugin.getStreamRelativePath iesec="+iesec.toString() ); throw new Exception("error, could not get IEPID for storedEntityMetaData:"+storedEntityMetaData.toString() +" of type " + entitytype); } - log.info("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(); @@ -451,7 +443,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.info("SLUBStoragePlugin.getStreamRelativePath creation Date read=" + datestring + " parsed=" + date.toString()); + log.debug("SLUBStoragePlugin.getStreamRelativePath creation Date read=" + datestring + " parsed=" + date.toString()); // now create path in format /yyyy/MM/dd/IEPID/ relativeDirectoryPath = relativeDirectoryPath + new SimpleDateFormat("yyyy").format(d); relativeDirectoryPath = relativeDirectoryPath + File.separator; @@ -471,7 +463,7 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { log.info("SLUBStoragePlugin.hardLink srcPath='" + srcPath + "' destPath='" + destPath + "'"); String command = "ln"; ExecExternalProcess proc = new ExecExternalProcess(); - List<String> args = new LinkedList(); + List<String> args = new LinkedList<String>(); args.add(srcPath); args.add(destPath); int retValue = proc.execExternalProcess(command, args); @@ -482,21 +474,25 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { private void saveDestPathsTmpFile(String folder, String key, String path) { log.info("SLUBStoragePlugin.saveDestPathsTmpFile()"); - log.info("SLUBStoragePlugin.saveDestPathsTmpFile folder='" + folder + "'"); - log.info("SLUBStoragePlugin.saveDestPathsTmpFile key='" + key + "'"); - log.info("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.info("SLUBStoragePlugin.saveDestPathsTmpFile tmpFilePath='" + tmpFilePath + "'"); + log.debug("SLUBStoragePlugin.saveDestPathsTmpFile tmpFilePath='" + tmpFilePath + "'"); File destPathDir = new File(getTempStorageDirectory(false) + "destPath" + File.separator); - log.info("SLUBStoragePlugin.saveDestPathsTmpFile destPathDir='" + destPathDir + "'"); + log.debug("SLUBStoragePlugin.saveDestPathsTmpFile destPathDir='" + destPathDir + "'"); if (!destPathDir.exists()) { - destPathDir.mkdirs(); + boolean res = destPathDir.mkdirs(); + if (!res) { + log.error("SLUBStoragePlugin.saveDestPathsTmpFile() destPathdir='" + destPathDir + "' could not be created"); + } } StorageUtil.saveDestPathToTmpFile(folder, tmpFilePath, key, path); } + private void softLink(String srcPath, String destPath) throws IOException { @@ -507,7 +503,7 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { } String command = "ln"; ExecExternalProcess proc = new ExecExternalProcess(); - List<String> args = new ArrayList(); + List<String> args = new ArrayList<String>(); args.add("-s"); args.add(srcPath); args.add(destPath); -- GitLab