diff --git a/dhp-workflows/dhp-broker-events/src/main/java/eu/dnetlib/dhp/broker/oa/util/ConversionUtils.java b/dhp-workflows/dhp-broker-events/src/main/java/eu/dnetlib/dhp/broker/oa/util/ConversionUtils.java index 9b5a5036d..4bf4d3341 100644 --- a/dhp-workflows/dhp-broker-events/src/main/java/eu/dnetlib/dhp/broker/oa/util/ConversionUtils.java +++ b/dhp-workflows/dhp-broker-events/src/main/java/eu/dnetlib/dhp/broker/oa/util/ConversionUtils.java @@ -128,13 +128,22 @@ public class ConversionUtils { protected static List allResultPids(final Result result) { final Map map = new HashMap<>(); - result.getPid().forEach(sp -> map.put(sp.getValue(), sp)); - result.getInstance().forEach(i -> { - i.getPid().forEach(sp -> map.put(sp.getValue(), sp)); - i.getAlternateIdentifier().forEach(sp -> map.put(sp.getValue(), sp)); - }); - final List pids = mappedList(map.values(), ConversionUtils::oafPidToBrokerPid); - return pids; + + if (result.getPid() != null) { + result.getPid().forEach(sp -> map.put(sp.getValue(), sp)); + } + + if (result.getInstance() != null) { + result.getInstance().forEach(i -> { + if (i.getPid() != null) { + i.getPid().forEach(sp -> map.put(sp.getValue(), sp)); + } + if (i.getAlternateIdentifier() != null) { + i.getAlternateIdentifier().forEach(sp -> map.put(sp.getValue(), sp)); + } + }); + } + return mappedList(map.values(), ConversionUtils::oafPidToBrokerPid); } public static String cleanOpenaireId(final String id) {