forked from D-Net/dnet-hadoop
added NPE checks
This commit is contained in:
parent
2f385b3ac6
commit
c42623f006
|
@ -48,8 +48,8 @@ public class OafMapperUtils {
|
||||||
|
|
||||||
public static Result mergeResults(Result left, Result right) {
|
public static Result mergeResults(Result left, Result right) {
|
||||||
|
|
||||||
final boolean leftFromDeletedAuthority = isFromDeletedAuthority(left);
|
final boolean leftFromDeletedAuthority = isFromDelegatedAuthority(left);
|
||||||
final boolean rightFromDeletedAuthority = isFromDeletedAuthority(right);
|
final boolean rightFromDeletedAuthority = isFromDelegatedAuthority(right);
|
||||||
|
|
||||||
if (leftFromDeletedAuthority && !rightFromDeletedAuthority) {
|
if (leftFromDeletedAuthority && !rightFromDeletedAuthority) {
|
||||||
return left;
|
return left;
|
||||||
|
@ -67,12 +67,16 @@ public class OafMapperUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isFromDeletedAuthority(Result r) {
|
private static boolean isFromDelegatedAuthority(Result r) {
|
||||||
return r
|
return Optional
|
||||||
.getInstance()
|
.ofNullable(r.getInstance())
|
||||||
.stream()
|
.map(
|
||||||
.map(i -> i.getCollectedfrom().getKey())
|
instance -> instance
|
||||||
.anyMatch(cfId -> IdentifierFactory.delegatedAuthorityDatasourceIds().contains(cfId));
|
.stream()
|
||||||
|
.filter(i -> Objects.nonNull(i.getCollectedfrom()))
|
||||||
|
.map(i -> i.getCollectedfrom().getKey())
|
||||||
|
.anyMatch(cfId -> IdentifierFactory.delegatedAuthorityDatasourceIds().contains(cfId)))
|
||||||
|
.orElse(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static KeyValue keyValue(final String k, final String v) {
|
public static KeyValue keyValue(final String k, final String v) {
|
||||||
|
|
Loading…
Reference in New Issue