Skip to content
Snippets Groups Projects
Commit 9fc0e3d3 authored by Andreas Romeyke's avatar Andreas Romeyke
Browse files

- works with Rosetta 4.0 again (using stuff from nfsstorage plugin by

ExLibris), needs more code cleanup
parent 381f3966
No related branches found
No related tags found
No related merge requests found
...@@ -84,26 +84,54 @@ ...@@ -84,26 +84,54 @@
<file leaf-file-name="SLUBStoragePlugin.java" pinned="false" current="true" current-in-tab="true"> <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"> <entry file="file://$PROJECT_DIR$/java/org/slub/rosetta/dps/repository/plugin/storage/nfs/SLUBStoragePlugin.java">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.6167883" vertical-offset="6457" max-vertical-offset="7005"> <state vertical-scroll-proportion="0.33205375" vertical-offset="5302" max-vertical-offset="8025">
<caret line="453" column="5" selection-start-line="453" selection-start-column="5" selection-end-line="453" selection-end-column="5" /> <caret line="365" column="42" selection-start-line="365" selection-start-column="42" selection-end-line="365" selection-end-column="42" />
<folding> <folding>
<element signature="e#0#19071#0" expanded="true" /> <element signature="e#0#24417#0" expanded="true" />
<element signature="imports" expanded="true" /> <element signature="imports" expanded="true" />
<element signature="e#2675#2676#0" expanded="true" /> <element signature="e#3017#3018#0" expanded="true" />
<element signature="e#2727#2728#0" expanded="true" /> <element signature="e#3075#3076#0" expanded="true" />
<element signature="e#3607#3608#0" expanded="true" /> <element signature="e#15717#15733#0" expanded="true" />
<element signature="e#3669#3670#0" expanded="true" />
<element signature="e#18552#18568#0" expanded="true" />
</folding> </folding>
</state> </state>
</provider> </provider>
</entry> </entry>
</file> </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"> <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"> <entry file="file://$PROJECT_DIR$/java/org/slub/rosetta/dps/repository/plugin/storage/nfs/NFSStoragePlugin.java">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-12.555555" vertical-offset="2586" max-vertical-offset="6885"> <state vertical-scroll-proportion="102.85185" vertical-offset="6362" max-vertical-offset="6885">
<caret line="195" column="0" selection-start-line="185" selection-start-column="2" selection-end-line="195" selection-end-column="0" /> <caret line="239" column="38" selection-start-line="239" selection-start-column="38" selection-end-line="239" selection-end-column="38" />
<folding> <folding>
<element signature="imports" expanded="true" /> <element signature="imports" expanded="true" />
<element signature="e#12505#12506#0" expanded="true" /> <element signature="e#12505#12506#0" expanded="true" />
...@@ -132,8 +160,8 @@ ...@@ -132,8 +160,8 @@
<treeState /> <treeState />
</component> </component>
<component name="ProjectFrameBounds"> <component name="ProjectFrameBounds">
<option name="x" value="88" /> <option name="x" value="92" />
<option name="y" value="68" /> <option name="y" value="93" />
<option name="width" value="1594" /> <option name="width" value="1594" />
<option name="height" value="1000" /> <option name="height" value="1000" />
</component> </component>
...@@ -372,14 +400,14 @@ ...@@ -372,14 +400,14 @@
</todo-panel> </todo-panel>
</component> </component>
<component name="ToolWindowManager"> <component name="ToolWindowManager">
<frame x="88" y="68" width="1594" height="1000" extended-state="0" /> <frame x="92" y="93" width="1594" height="1000" extended-state="0" />
<editor active="true" /> <editor active="false" />
<layout> <layout>
<window_info id="Changes" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32954547" sideWeight="0.5" order="12" side_tool="false" content_ui="tabs" /> <window_info id="Changes" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32954547" sideWeight="0.5" order="12" side_tool="false" content_ui="tabs" />
<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="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="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="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="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="2" 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="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="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="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" /> <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" />
...@@ -392,7 +420,7 @@ ...@@ -392,7 +420,7 @@
<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="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="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="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="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.32954547" sideWeight="0.5" order="3" 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="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="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="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" />
...@@ -429,13 +457,11 @@ ...@@ -429,13 +457,11 @@
<state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="2775"> <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" /> <caret line="23" column="0" selection-start-line="23" selection-start-column="0" selection-end-line="23" selection-end-column="0" />
<folding> <folding>
<element signature="e#0#19071#0" expanded="true" /> <element signature="e#0#24417#0" expanded="true" />
<element signature="imports" expanded="true" /> <element signature="imports" expanded="true" />
<element signature="e#2675#2676#0" expanded="true" /> <element signature="e#3017#3018#0" expanded="true" />
<element signature="e#2727#2728#0" expanded="true" /> <element signature="e#3075#3076#0" expanded="true" />
<element signature="e#3607#3608#0" expanded="true" /> <element signature="e#15717#15733#0" expanded="true" />
<element signature="e#3669#3670#0" expanded="true" />
<element signature="e#18552#18568#0" expanded="true" />
</folding> </folding>
</state> </state>
</provider> </provider>
...@@ -457,29 +483,43 @@ ...@@ -457,29 +483,43 @@
<state vertical-scroll-proportion="0.0" vertical-offset="675" max-vertical-offset="2370"> <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" /> <caret line="45" column="2" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding> <folding>
<element signature="e#0#19071#0" expanded="true" /> <element signature="e#0#24417#0" expanded="true" />
<element signature="imports" expanded="true" /> <element signature="imports" expanded="true" />
<element signature="e#2675#2676#0" expanded="true" /> <element signature="e#3017#3018#0" expanded="true" />
<element signature="e#2727#2728#0" expanded="true" /> <element signature="e#3075#3076#0" expanded="true" />
<element signature="e#3607#3608#0" expanded="true" /> <element signature="e#15717#15733#0" expanded="true" />
<element signature="e#3669#3670#0" expanded="true" />
<element signature="e#18552#18568#0" expanded="true" />
</folding> </folding>
</state> </state>
</provider> </provider>
</entry> </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">
<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>
<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"> <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"> <provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.14285715" vertical-offset="0" max-vertical-offset="720"> <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" /> <caret line="6" column="22" selection-start-line="6" selection-start-column="22" selection-end-line="6" selection-end-column="22" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </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">
<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>
<entry file="file://$PROJECT_DIR$/java/org/slub/rosetta/dps/repository/plugin/storage/nfs/NFSStoragePlugin.java"> <entry file="file://$PROJECT_DIR$/java/org/slub/rosetta/dps/repository/plugin/storage/nfs/NFSStoragePlugin.java">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-12.555555" vertical-offset="2586" max-vertical-offset="6885"> <state vertical-scroll-proportion="102.85185" vertical-offset="6362" max-vertical-offset="6885">
<caret line="195" column="0" selection-start-line="185" selection-start-column="2" selection-end-line="195" selection-end-column="0" /> <caret line="239" column="38" selection-start-line="239" selection-start-column="38" selection-end-line="239" selection-end-column="38" />
<folding> <folding>
<element signature="imports" expanded="true" /> <element signature="imports" expanded="true" />
<element signature="e#12505#12506#0" expanded="true" /> <element signature="e#12505#12506#0" expanded="true" />
...@@ -490,16 +530,14 @@ ...@@ -490,16 +530,14 @@
</entry> </entry>
<entry file="file://$PROJECT_DIR$/java/org/slub/rosetta/dps/repository/plugin/storage/nfs/SLUBStoragePlugin.java"> <entry file="file://$PROJECT_DIR$/java/org/slub/rosetta/dps/repository/plugin/storage/nfs/SLUBStoragePlugin.java">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.6167883" vertical-offset="6457" max-vertical-offset="7005"> <state vertical-scroll-proportion="0.33205375" vertical-offset="5302" max-vertical-offset="8025">
<caret line="453" column="5" selection-start-line="453" selection-start-column="5" selection-end-line="453" selection-end-column="5" /> <caret line="365" column="42" selection-start-line="365" selection-start-column="42" selection-end-line="365" selection-end-column="42" />
<folding> <folding>
<element signature="e#0#19071#0" expanded="true" /> <element signature="e#0#24417#0" expanded="true" />
<element signature="imports" expanded="true" /> <element signature="imports" expanded="true" />
<element signature="e#2675#2676#0" expanded="true" /> <element signature="e#3017#3018#0" expanded="true" />
<element signature="e#2727#2728#0" expanded="true" /> <element signature="e#3075#3076#0" expanded="true" />
<element signature="e#3607#3608#0" expanded="true" /> <element signature="e#15717#15733#0" expanded="true" />
<element signature="e#3669#3670#0" expanded="true" />
<element signature="e#18552#18568#0" expanded="true" />
</folding> </folding>
</state> </state>
</provider> </provider>
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<fr:x_form xmlns:fr="http://com/exlibris/digitool/common/forms/xmlbeans"> <fr:x_form xmlns:fr="http://com/exlibris/digitool/common/forms/xmlbeans">
<form_name>SLUBStoragePlugin_Params</form_name> <form_name>SLUBStoragePlugin_Params</form_name>
<description>SLUBTreeStoragePlugin_parameters_form</description> <description>SLUBTreeStoragePlugin_parameters_form</description>
<version>0.1</version> <version>0.2</version>
<grid_x>1</grid_x> <grid_x>1</grid_x>
<md_format>1</md_format> <md_format>1</md_format>
<x_fields> <x_fields>
...@@ -70,7 +70,7 @@ ...@@ -70,7 +70,7 @@
</fr:x_form> </fr:x_form>
</pl:initParameters> </pl:initParameters>
<pl:description>SLUB Storage Plugin</pl:description> <pl:description>SLUB Storage Plugin</pl:description>
<pl:version>1.6</pl:version> <pl:version>2.4</pl:version>
<pl:materialType>DIGITAL</pl:materialType> <pl:materialType>DIGITAL</pl:materialType>
<pl:module>Repository</pl:module> <pl:module>Repository</pl:module>
<pl:generalType>TASK</pl:generalType> <pl:generalType>TASK</pl:generalType>
......
...@@ -58,56 +58,28 @@ import java.util.*; ...@@ -58,56 +58,28 @@ import java.util.*;
* @ see com.exlibris.dps.repository.plugin.storage.nfs.NFSStoragePlugin * @ see com.exlibris.dps.repository.plugin.storage.nfs.NFSStoragePlugin
*/ */
public class SLUBStoragePlugin extends AbstractStorageHandler { public class SLUBStoragePlugin extends AbstractStorageHandler {
private static final String DIR_ROOT = "DIR_ROOT"; /** {@inheritDoc} */
private static final ExLogger log = ExLogger.getExLogger(SLUBStoragePlugin.class); private static final ExLogger log = ExLogger.getExLogger(SLUBStoragePlugin.class);
private static final String DIR_PREFIX = "DIR_PREFIX";
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";
public SLUBStoragePlugin() { public SLUBStoragePlugin() {
log.info("SLUBStoragePlugin instantiated"); log.info("SLUBStoragePlugin instantiated");
} }
public byte[] retrieveEntityByRange(String storedEntityIdentifier, long start, long end)
throws Exception
{
byte[] bytes = new byte[(int)(end - start + 1L)];
RandomAccessFile file = null;
try
{
file = new RandomAccessFile((String)this.parameters.get("DIR_ROOT") + storedEntityIdentifier, "r");
file.seek(start);
file.readFully(bytes, 0, (int)(end - start + 1L));
return bytes;
}
finally
{
if (file != null) {
try
{
file.close();
}
catch (Exception e)
{
log.warn("Failed closing file", e.getMessage());
}
}
}
}
public String getLocalFilePath(String storedEntityIdentifier)
{
return getFullFilePath(storedEntityIdentifier);
}
public String getFullFilePath(String storedEntityIdentifier)
{
return (String)this.parameters.get("DIR_ROOT") + storedEntityIdentifier;
}
public boolean checkFixity(List<Fixity> fixities, String storedEntityIdentifier) public boolean checkFixity(List<Fixity> fixities, String storedEntityIdentifier)
throws Exception throws Exception
{ {
log.info("SLUBStoragePlugin.checkFixity()");
return checkFixity(fixities, storedEntityIdentifier, true); return checkFixity(fixities, storedEntityIdentifier, true);
} }
public boolean checkFixity(List<Fixity> fixities, String storedEntityIdentifier, boolean isRelativePath) public boolean checkFixity(List<Fixity> fixities, String storedEntityIdentifier, boolean isRelativePath)
throws Exception throws Exception
{ {
log.info("SLUBStoragePlugin.checkFixity() storedEntityIdentifier='" + storedEntityIdentifier + "' isRelativePath=" + isRelativePath);
boolean result = true; boolean result = true;
if (fixities != null) if (fixities != null)
{ {
...@@ -167,19 +139,10 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { ...@@ -167,19 +139,10 @@ public class SLUBStoragePlugin extends AbstractStorageHandler {
} }
return result; return result;
} }
private int getChecksummerAlgorithmIndex(String algorithm)
{
try
{
Fixity.FixityAlgorithm fixityAlgorithm = Fixity.FixityAlgorithm.valueOf(algorithm);
return fixityAlgorithm.ordinal();
}
catch (Exception e) {}
return -1;
}
public boolean deleteEntity(String storedEntityIdentifier) public boolean deleteEntity(String storedEntityIdentifier)
{ {
log.info("SLUBStoragePlugin.deleteEntity()");
File file = new File((String)this.parameters.get("DIR_ROOT") + storedEntityIdentifier); File file = new File((String)this.parameters.get("DIR_ROOT") + storedEntityIdentifier);
try try
{ {
...@@ -187,25 +150,68 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { ...@@ -187,25 +150,68 @@ public class SLUBStoragePlugin extends AbstractStorageHandler {
} }
catch (Exception e) catch (Exception e)
{ {
log.warn("failed to delete entity with path: " + file.getPath(), e.getMessage()); log.warn("SLUBStoragePlugin failed to delete entity with path: " + file.getPath(), e.getMessage());
} }
return true; return true;
} }
public String getLocalFilePath(String storedEntityIdentifier)
{
log.info("SLUBStoragePlugin.getLocalFilePath() with '" + storedEntityIdentifier + "'");
return getFullFilePath(storedEntityIdentifier);
}
public String getFullFilePath(String storedEntityIdentifier)
{
log.info("SLUBStoragePlugin.getFullFilePath() with '" + storedEntityIdentifier + "'");
return (String)this.parameters.get("DIR_ROOT") + storedEntityIdentifier;
}
public InputStream retrieveEntity(String storedEntityIdentifier) public InputStream retrieveEntity(String storedEntityIdentifier)
throws IOException throws IOException
{ {
log.info("SLUBStoragePlugin.retrieveEntity() with '" + storedEntityIdentifier + "'");
return retrieveEntity(storedEntityIdentifier, true); return retrieveEntity(storedEntityIdentifier, true);
} }
public InputStream retrieveEntity(String storedEntityIdentifier, boolean isRelative) public InputStream retrieveEntity(String storedEntityIdentifier, boolean isRelative)
throws IOException 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 ? (String)this.parameters.get("DIR_ROOT") : "") + storedEntityIdentifier);
} }
public byte[] retrieveEntityByRange(String storedEntityIdentifier, long start, long end)
throws Exception
{
log.info("SLUBStoragePlugin.retrieveEntitybyRange() with '" + storedEntityIdentifier + "' start=" + start + "end=" + end);
byte[] bytes = new byte[(int)(end - start + 1L)];
RandomAccessFile file = null;
try
{
file = new RandomAccessFile((String)this.parameters.get("DIR_ROOT") + storedEntityIdentifier, "r");
file.seek(start);
file.readFully(bytes, 0, (int)(end - start + 1L));
return bytes;
}
finally
{
if (file != null) {
try
{
file.close();
}
catch (Exception e)
{
log.warn("Failed closing file", e.getMessage());
}
}
}
}
public String storeEntity(InputStream is, StoredEntityMetaData storedEntityMetadata) public String storeEntity(InputStream is, StoredEntityMetaData storedEntityMetadata)
throws Exception throws Exception
{ {
log.info("SLUBStoragePlugin.storeEntity()");
String existsDescPath = getFilePathInDescIfExists(storedEntityMetadata); String existsDescPath = getFilePathInDescIfExists(storedEntityMetadata);
log.info("SLUBStoragePlugin.storeEntity() existsDescPath='" + existsDescPath +"'");
String destFilePath = null; String destFilePath = null;
boolean isCopyFileNeeded = true; boolean isCopyFileNeeded = true;
...@@ -214,13 +220,18 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { ...@@ -214,13 +220,18 @@ public class SLUBStoragePlugin extends AbstractStorageHandler {
destFilePath = existsDescPath; destFilePath = existsDescPath;
isCopyFileNeeded = !checkFixity(storedEntityMetadata.getFixities(), destFilePath, false); isCopyFileNeeded = !checkFixity(storedEntityMetadata.getFixities(), destFilePath, false);
} }
log.info("SLUBStoragePlugin.storeEntity() destFilePath='" + destFilePath +"'");
Map<String, String> paths = getStoreEntityIdentifier(storedEntityMetadata, destFilePath); Map<String, String> paths = getStoreEntityIdentifier(storedEntityMetadata, destFilePath);
String storedEntityIdentifier = (String)paths.get("relativeDirectoryPath"); String storedEntityIdentifier = (String)paths.get("relativeDirectoryPath");
log.info("SLUBStoragePlugin.storeEntity() storedEntityIdentifier='" + storedEntityIdentifier +"'");
destFilePath = (String)paths.get("destFilePath"); destFilePath = (String)paths.get("destFilePath");
log.info("SLUBStoragePlugin.storeEntity() destFilePath (2)='" + destFilePath +"'");
log.info("SLUBStoragePlugin.storeEntity() isCopyFileNeeded='" + isCopyFileNeeded +"'");
if (isCopyFileNeeded) if (isCopyFileNeeded)
{ {
if (canHandleSourcePath(storedEntityMetadata.getCurrentFilePath())) if (canHandleSourcePath(storedEntityMetadata.getCurrentFilePath()))
{ {
log.info("SLUBStoragePlugin.storeEntity() destFilePath canhandle sourcepath");
if (is != null) { if (is != null) {
is.close(); is.close();
} }
...@@ -228,10 +239,10 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { ...@@ -228,10 +239,10 @@ public class SLUBStoragePlugin extends AbstractStorageHandler {
} }
else else
{ {
log.info("Cannot handle source path: " + storedEntityMetadata.getCurrentFilePath()); log.info("SLUBStoragePlugin.storeEntity() Cannot handle source path: " + storedEntityMetadata.getCurrentFilePath());
if (is == null) if (is == null)
{ {
log.warn("InputStream is null"); log.warn("SLUBStoragePlugin.storeEntity() InputStream is null");
return null; return null;
} }
FileOutputStream output = null; FileOutputStream output = null;
...@@ -239,6 +250,7 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { ...@@ -239,6 +250,7 @@ public class SLUBStoragePlugin extends AbstractStorageHandler {
{ {
output = new FileOutputStream(new File(destFilePath)); output = new FileOutputStream(new File(destFilePath));
IOUtil.copy(is, output); IOUtil.copy(is, output);
log.info("SLUBStoragePlugin.storeEntity() try copy was successfull");
} }
finally finally
{ {
...@@ -246,19 +258,26 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { ...@@ -246,19 +258,26 @@ public class SLUBStoragePlugin extends AbstractStorageHandler {
} }
} }
if (!checkFixity(storedEntityMetadata.getFixities(), storedEntityIdentifier)) { if (!checkFixity(storedEntityMetadata.getFixities(), storedEntityIdentifier)) {
log.info("SLUBStoragePlugin.storeEntity() checkFixity failed");
return null; return null;
} }
} }
log.info("SLUBStoragePlugin.storeEntity() storedEntityIdentifier (2)='" + storedEntityIdentifier +"'");
return storedEntityIdentifier; return storedEntityIdentifier;
} }
protected void copyStream(StoredEntityMetaData storedEntityMetadata, String destPath) protected void copyStream(StoredEntityMetaData storedEntityMetadata, String destPath)
throws IOException throws IOException
{ {
log.info("SLUBStoragePlugin.copyStream()");
String filesHandlingMethod = (String)this.parameters.get("FILES_HANDLING_METHOD"); String filesHandlingMethod = (String)this.parameters.get("FILES_HANDLING_METHOD");
String srcPath = storedEntityMetadata.getCurrentFilePath(); String srcPath = storedEntityMetadata.getCurrentFilePath();
log.info("SLUBStoragePlugin.copyStream() destPath='" + destPath + "'");
log.info("SLUBStoragePlugin.copyStream() srcPath='" + srcPath + "'");
log.info("SLUBStoragePlugin.copyStream() filesHandlingMethod='" + filesHandlingMethod + "'");
String pid = storedEntityMetadata.getEntityPid(); String pid = storedEntityMetadata.getEntityPid();
log.info("SLUBStoragePlugin.copyStream() pid='" + pid + "'");
String iePid = storedEntityMetadata.getIePid(); String iePid = storedEntityMetadata.getIePid();
log.info("SLUBStoragePlugin.copyStream() iePid='" + iePid + "'");
if ("move".equalsIgnoreCase(filesHandlingMethod)) if ("move".equalsIgnoreCase(filesHandlingMethod))
{ {
File canonicalSrcFile = getCanonicalFile(srcPath); File canonicalSrcFile = getCanonicalFile(srcPath);
...@@ -279,22 +298,49 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { ...@@ -279,22 +298,49 @@ public class SLUBStoragePlugin extends AbstractStorageHandler {
saveDestPathsTmpFile(iePid, pid, destPath); saveDestPathsTmpFile(iePid, pid, destPath);
} }
} }
private void saveDestPathsTmpFile(String folder, String key, String path) protected String getFilePathInDescIfExists(StoredEntityMetaData storedEntityMetadata)
{ {
if (folder == null) { log.info("SLUBStoragePlugin.getFilePathInDescIfExists()");
return;
}
String tmpFilePath = getTempStorageDirectory(false) + "destPath"; String tmpFilePath = getTempStorageDirectory(false) + "destPath";
if (storedEntityMetadata.getIePid() == null) {
return null;
}
String existsDescPath = StorageUtil.readDestPathFromTmpFile(storedEntityMetadata.getIePid(), tmpFilePath, storedEntityMetadata.getEntityPid());
return existsDescPath;
}
/** copied from NFS Storage Plugin, enhanced with debugging info, {@inheritDoc} */
private boolean canHandleSourcePath(String srcPath) {
log.info("SLUBStoragePlugin.canHandleSourcePath path=" + srcPath);
try {
File file = new File(srcPath);
return file.canRead();
}
catch (Exception e) {
log.warn("SLUBStoragePlugin.canHandleSourcePath exception=" + e.getMessage());
return false;
}
}
File destPathDir = new File(getTempStorageDirectory(false) + "destPath" + File.separator); private int getChecksummerAlgorithmIndex(String algorithm)
if (!destPathDir.exists()) { {
destPathDir.mkdirs(); log.info("SLUBStoragePlugin.getChecksummerAlgorithm() algorithm='" + algorithm + "'");
try
{
Fixity.FixityAlgorithm fixityAlgorithm = Fixity.FixityAlgorithm.valueOf(algorithm);
return fixityAlgorithm.ordinal();
} }
StorageUtil.saveDestPathToTmpFile(folder, tmpFilePath, key, path); catch (Exception e) {}
return -1;
} }
private File getCanonicalFile(String srcPath) private File getCanonicalFile(String srcPath)
{ {
log.info("SLUBStoragePlugin.getCanonicalFile() srcPath='"+ srcPath + "'");
String fileName = srcPath.split("\\" + File.separator)[(srcPath.split("\\" + File.separator).length - 1)]; String fileName = srcPath.split("\\" + File.separator)[(srcPath.split("\\" + File.separator).length - 1)];
File canonicalSrcDir = null; File canonicalSrcDir = null;
try try
...@@ -308,49 +354,49 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { ...@@ -308,49 +354,49 @@ public class SLUBStoragePlugin extends AbstractStorageHandler {
return null; return null;
} }
private void hardLink(String srcPath, String destPath) private String getNextDir(String fullPath)
throws IOException
{ {
String command = "ln"; log.info("SLUBStoragePlugin.getNextDir() fullPath='"+ fullPath + "'");
ExecExternalProcess proc = new ExecExternalProcess();
List<String> args = new LinkedList();
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());
}
}
private void softLink(String srcPath, String destPath) String[] dirs = fullPath.split("\\" + File.separator);
throws IOException String dir = dirs[(dirs.length - 2)];
{ log.info("SLUBStoragePlugin.getNextDir() dir='" + dir + "'");
File source = new File(srcPath); return dir;
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());
} }
private Map<String, String> getStoreEntityIdentifier(StoredEntityMetaData storedEntityMetadata, String destFilePath) throws Exception
{
log.info("SLUBStoragePlugin.getStoreEntityIdentifier()");
log.info("destFilePath='" + destFilePath +"'");
Map<String, String> paths = new HashMap<String, String>();
log.info( "(1) storedEntityMetadata is null?" + (null == storedEntityMetadata));
String fileName = createFileName(storedEntityMetadata);
log.info("fileName='"+fileName +"'");
log.info( "(2) storedEntityMetadata is null?" + (null == storedEntityMetadata));
String relativeDirectoryPath = getStreamRelativePath(storedEntityMetadata);
log.info("relativeDirectoryPath='"+relativeDirectoryPath +"'");
if (destFilePath == null)
{
File destFile = getStreamDirectory(relativeDirectoryPath, fileName);
destFilePath = destFile.getAbsolutePath();
} }
log.info("destFilePath (2)='" + destFilePath +"'");
paths.put("destFilePath", destFilePath);
// paths.put("relativeDirectoryPath", (relativeDirectoryPath + getNextDir(destFilePath) + File.separator + fileName));
paths.put("relativeDirectoryPath", (relativeDirectoryPath + File.separator + fileName));
return paths;
protected String getFilePathInDescIfExists(StoredEntityMetaData storedEntityMetadata)
{
String tmpFilePath = getTempStorageDirectory(false) + "destPath";
if (storedEntityMetadata.getIePid() == null) {
return null;
} }
String existsDescPath = StorageUtil.readDestPathFromTmpFile(storedEntityMetadata.getIePid(), tmpFilePath, storedEntityMetadata.getEntityPid()); /** copied from NFS Storage Plugin, enhanced with debugging info,
return existsDescPath; * this combines full file path and creates parent directories if needed {@inheritDoc}
*/
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());
boolean arecreated = newDir.mkdirs();
log.info("SLUBStoragePlugin.getStreamDirectory newDir.mkdirs(), directories are created:" + arecreated);
return new File(newDir.getAbsolutePath() + File.separator + fileName);
} }
/** prepare right path /** prepare right path
* path should be of form yyyy/MM/dd/IE-PID/ * path should be of form yyyy/MM/dd/IE-PID/
* we need to findout the associated dnx document (IE), * we need to findout the associated dnx document (IE),
...@@ -361,11 +407,21 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { ...@@ -361,11 +407,21 @@ public class SLUBStoragePlugin extends AbstractStorageHandler {
* returns the path as string * returns the path as string
*/ */
private String getStreamRelativePath(StoredEntityMetaData storedEntityMetaData ) throws Exception { private String getStreamRelativePath(StoredEntityMetaData storedEntityMetaData ) throws Exception {
log.info("SLUBStoragePlugin AAB"); log.info("SLUBStoragePlugin.getStreamRelativePath()");
if ((null == storedEntityMetaData)) throw new AssertionError();
log.info("SLUBStoragePlugin.getStreamRelativePath() assert fine");
String relativeDirectoryPath = File.separator; String relativeDirectoryPath = File.separator;
// get IE PID by calling IE-DNX record and search for ""internalIdentifierType" == "PID" // get IE PID by calling IE-DNX record and search for ""internalIdentifierType" == "PID"
DnxDocument iedoc = storedEntityMetaData.getIeDnx(); DnxDocument iedoc = storedEntityMetaData.getIeDnx();
String entitytype = storedEntityMetaData.getEntityType().name(); log.info("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");
String entitytype = entityType.name();
log.info("entitytype='" + entitytype + "'");
DnxSection iesec = iedoc.getSectionById("internalIdentifier"); DnxSection iesec = iedoc.getSectionById("internalIdentifier");
if (null == iesec) { 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!"); 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!");
...@@ -409,53 +465,65 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { ...@@ -409,53 +465,65 @@ public class SLUBStoragePlugin extends AbstractStorageHandler {
return relativeDirectoryPath; return relativeDirectoryPath;
} }
/** copied from NFS Storage Plugin, enhanced with debugging info, private void hardLink(String srcPath, String destPath)
* this combines full file path and creates parent directories if needed {@inheritDoc} throws IOException
*/ {
private File getStreamDirectory(String path, String fileName) { log.info("SLUBStoragePlugin.hardLink srcPath='" + srcPath + "' destPath='" + destPath + "'");
File newDir = new File(parameters.get(DIR_ROOT) + File.separator + path); String command = "ln";
log.info("SLUBStoragePlugin.getStreamDirectory path=" + path); ExecExternalProcess proc = new ExecExternalProcess();
log.info("SLUBStoragePlugin.getStreamDirectory fileName=" + fileName); List<String> args = new LinkedList();
log.info("SLUBStoragePlugin.getStreamDirectory newDir.getAbsolutePath()=" + newDir.getAbsolutePath()); args.add(srcPath);
boolean arecreated = newDir.mkdirs(); args.add(destPath);
log.info("SLUBStoragePlugin.getStreamDirectory newDir.mkdirs(), directories are created:" + arecreated); int retValue = proc.execExternalProcess(command, args);
return new File(newDir.getAbsolutePath() + File.separator + fileName); if (retValue != 0) {
throw new IOException("ln " + srcPath + " " + destPath + " failed " + proc.getErrorStream() + proc.getInputStream());
} }
/** copied from NFS Storage Plugin, enhanced with debugging info, {@inheritDoc} */
private boolean canHandleSourcePath(String srcPath) {
log.info("SLUBStoragePlugin.canHandleSourcePath path=" + srcPath);
try {
File file = new File(srcPath);
return file.canRead();
} }
catch (Exception e) { private void saveDestPathsTmpFile(String folder, String key, String path)
log.warn("SLUBStoragePlugin.canHandleSourcePath exception=" + e.getMessage()); {
return false; log.info("SLUBStoragePlugin.saveDestPathsTmpFile()");
log.info("SLUBStoragePlugin.saveDestPathsTmpFile folder='" + folder + "'");
log.info("SLUBStoragePlugin.saveDestPathsTmpFile key='" + key + "'");
log.info("SLUBStoragePlugin.saveDestPathsTmpFile path='" + path + "'");
if (folder == null) {
return;
}
String tmpFilePath = getTempStorageDirectory(false) + "destPath";
log.info("SLUBStoragePlugin.saveDestPathsTmpFile tmpFilePath='" + tmpFilePath + "'");
File destPathDir = new File(getTempStorageDirectory(false) + "destPath" + File.separator);
log.info("SLUBStoragePlugin.saveDestPathsTmpFile destPathDir='" + destPathDir + "'");
if (!destPathDir.exists()) {
destPathDir.mkdirs();
} }
StorageUtil.saveDestPathToTmpFile(folder, tmpFilePath, key, path);
} }
private String getNextDir(String fullPath) private void softLink(String srcPath, String destPath)
throws IOException
{ {
String[] dirs = fullPath.split("\\" + File.separator); log.info("SLUBStoragePlugin.softLink srcPath='" + srcPath + "' destPath='" + destPath + "'");
return dirs[(dirs.length - 2)]; 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());
}
} }
private Map<String, String> getStoreEntityIdentifier(StoredEntityMetaData storedEntityMetadata, String destFilePath) throws Exception
{
Map<String, String> paths = new HashMap<String, String>();
String fileName = createFileName(storedEntityMetadata);
String relativeDirectoryPath = getStreamRelativePath(storedEntityMetadata);
if (destFilePath == null)
{
File destFile = getStreamDirectory(relativeDirectoryPath, fileName);
destFilePath = destFile.getAbsolutePath();
}
paths.put("destFilePath", destFilePath);
paths.put("relativeDirectoryPath", (relativeDirectoryPath + getNextDir(destFilePath) + File.separator + fileName));
return paths;
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment