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

- improved import

- updated Checksummer instantiation using fourth parameter
- added catch-blocks to get more descriptive logging
- more detailed log.info in checkFixityByPlugin()
parent 4fb6a8c8
No related branches found
No related tags found
No related merge requests found
...@@ -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>2.810</pl:version> <pl:version>2.813</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>
......
/* /*
2014-2016 by Andreas Romeyke (SLUB Dresden) 2014-2020 by Andreas Romeyke (SLUB Dresden)
The code contributed by SLUB is licensed under apache 2.0 and based partially The code contributed by SLUB is licensed under apache 2.0 and based partially
on NFS Storage Plugin, on NFS Storage Plugin,
...@@ -33,10 +33,22 @@ import com.exlibris.digitool.common.dnx.DnxSectionRecord; ...@@ -33,10 +33,22 @@ import com.exlibris.digitool.common.dnx.DnxSectionRecord;
import com.exlibris.digitool.common.storage.Fixity; import com.exlibris.digitool.common.storage.Fixity;
import com.exlibris.digitool.infrastructure.utils.Checksummer; import com.exlibris.digitool.infrastructure.utils.Checksummer;
import java.io.*; import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.RandomAccessFile;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
/** /**
* SLUBStoragePlugin * SLUBStoragePlugin
...@@ -87,7 +99,7 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { ...@@ -87,7 +99,7 @@ public class SLUBStoragePlugin extends AbstractStorageHandler {
InputStream is = null; InputStream is = null;
try { try {
is = retrieveEntity(storedEntityIdentifier, isRelativePath); is = retrieveEntity(storedEntityIdentifier, isRelativePath);
Checksummer checksummer = new Checksummer(is, true, true, true); Checksummer checksummer = new Checksummer(is, true, true, true,true);
for (Fixity fixity : fixities) { for (Fixity fixity : fixities) {
fixity.setResult(false); fixity.setResult(false);
log.info("SLUBStoragePlugin.checkFixity() getAlgorithm=" + fixity.getAlgorithm()); log.info("SLUBStoragePlugin.checkFixity() getAlgorithm=" + fixity.getAlgorithm());
...@@ -114,6 +126,15 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { ...@@ -114,6 +126,15 @@ public class SLUBStoragePlugin extends AbstractStorageHandler {
} }
} }
} }
catch (IOException e) {
log.error("SLUBStoragePlugin.checkFixity(), I/O error, " + e.getMessage());
}
catch (NoSuchAlgorithmException e) {
log.error( "SLUBStoragePlugin.checkFixity(), missed Algorithm, " + e.getMessage());
}
catch (Exception e) {
log.error( "SLUBStoragePlugin.checkFixity(), unknown problem, " + e.getMessage());
}
finally finally
{ {
log.info("SLUBStoragePlugin.checkFixity() finally called"); log.info("SLUBStoragePlugin.checkFixity() finally called");
...@@ -157,13 +178,19 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { ...@@ -157,13 +178,19 @@ public class SLUBStoragePlugin extends AbstractStorageHandler {
* @throws Exception * @throws Exception
*/ */
private boolean checkFixityByPlugin(Fixity fixity, String storedEntityIdentifier, boolean isRelativePath, boolean result) throws Exception { private boolean checkFixityByPlugin(Fixity fixity, String storedEntityIdentifier, boolean isRelativePath, boolean result) throws Exception {
log.info("SLUBStoragePlugin.checkFixity() another fixity"); log.info("SLUBStoragePlugin.checkFixityByPlugin() another fixity");
String pluginname;
try { try {
log.info("SLUBStoragePlugin.checkFixity() pluginname=" + fixity.getPluginName()); pluginname = fixity.getPluginName();
log.info("SLUBStoragePlugin.checkFixity() pluginname=" + pluginname);
} }
catch (Exception e) { catch (Exception e) {
log.warn("SLUBStoragePlugin failed to get pluginname ", e.getMessage()); pluginname = "";
} }
if (pluginname.isEmpty()) {
log.error("SLUBStoragePlugin failed to get pluginname, because it is empty. Possibly, there is no valid fixity typeused or a CustomFixityPlugin missed");
}
String oldValue = ""; String oldValue = "";
try { try {
oldValue = fixity.getValue(); oldValue = fixity.getValue();
...@@ -222,7 +249,7 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { ...@@ -222,7 +249,7 @@ public class SLUBStoragePlugin extends AbstractStorageHandler {
public byte[] retrieveEntityByRange(String storedEntityIdentifier, long start, long end) public byte[] retrieveEntityByRange(String storedEntityIdentifier, long start, long end)
throws Exception throws Exception
{ {
log.info("SLUBStoragePlugin.retrieveEntitybyRange() with '" + storedEntityIdentifier + "' start=" + start + "end=" + end); log.info("SLUBStoragePlugin.retrieveEntitybyRange() with '" + storedEntityIdentifier + "' start=" + start + " end=" + end);
byte[] bytes = new byte[(int)(end - start + 1L)]; byte[] bytes = new byte[(int)(end - start + 1L)];
RandomAccessFile file = null; RandomAccessFile file = null;
try try
...@@ -230,7 +257,13 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { ...@@ -230,7 +257,13 @@ public class SLUBStoragePlugin extends AbstractStorageHandler {
file = new RandomAccessFile(this.parameters.get("DIR_ROOT") + storedEntityIdentifier, "r"); file = new RandomAccessFile(this.parameters.get("DIR_ROOT") + storedEntityIdentifier, "r");
file.seek(start); file.seek(start);
file.readFully(bytes, 0, (int)(end - start + 1L)); file.readFully(bytes, 0, (int)(end - start + 1L));
return bytes;
}
catch (FileNotFoundException e) {
log.error("SLUBStoragePlugin.retrieveEntitybyRange(), file not found, " + e.getMessage());
}
catch (Exception e) {
log.error("SLUBStoragePlugin.retrieveEntityByRange(), I/O error, " + e.getMessage());
} }
finally finally
{ {
...@@ -241,11 +274,13 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { ...@@ -241,11 +274,13 @@ public class SLUBStoragePlugin extends AbstractStorageHandler {
} }
catch (Exception e) catch (Exception e)
{ {
log.warn("Failed closing file", e.getMessage()); log.error("Failed closing file", e.getMessage());
} }
} }
} }
return bytes;
} }
public String storeEntity(InputStream is, StoredEntityMetaData storedEntityMetadata) public String storeEntity(InputStream is, StoredEntityMetaData storedEntityMetadata)
throws Exception throws Exception
{ {
...@@ -305,6 +340,7 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { ...@@ -305,6 +340,7 @@ public class SLUBStoragePlugin extends AbstractStorageHandler {
log.debug("SLUBStoragePlugin.storeEntity() storedEntityIdentifier (2)='" + storedEntityIdentifier + "'"); log.debug("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
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment