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 f8c5a4a44113c4c41d02375ea164f18ccaed6c88..b7a718f778ed284fed1286ff7c0db11d8a281ea0 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 @@ -55,6 +55,7 @@ import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Optional; /** * SLUBStoragePlugin @@ -683,20 +684,18 @@ public class SLUBStoragePlugin extends AbstractStorageHandler { 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); List<DnxSectionRecord> records = iesec.getRecordList(); - for (DnxSectionRecord element : records) { - if ("PID".equals(element.getKeyById("internalIdentifierType").getValue())) { - iepid = element.getKeyById("internalIdentifierValue").getValue(); // found IEPID - break; - } - } + Optional<DnxSectionRecord> match = records.parallelStream().filter( + element -> "PID".equals( element.getKeyById("internalIdentifierType").getValue() ) + ).findFirst(); + if (match.isEmpty()) { // raise Exception if IEPID is null - if (null == iepid) { log.error ("SLUBStoragePlugin.getStreamRelativePath iesec="+iesec ); throw new Exception("error, could not get IEPID for storedEntityMetaData:"+storedEntityMetaData +" of type " + entitytype); } + String iepid = match.get().getKeyById("internalIdentifierValue").getValue(); // found IEPID //log.debug("SLUBStoragePlugin.getStreamRelativePath iepid=" + iepid + " (entitytype=" + entitytype + ")"); // get creationDate of "objectCharacteristics" String datestring = iedoc.getSectionKeyValue("objectCharacteristics", "creationDate");