fixed null pointer exceptions

This commit is contained in:
Konstantinos Spyrou 2022-08-04 14:13:02 +00:00
parent 36aa53273e
commit 54f3ad2bd2
1 changed files with 9 additions and 2 deletions

View File

@ -1,6 +1,7 @@
package eu.dnetlib.repo.manager.domain; package eu.dnetlib.repo.manager.domain;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class RepositoryInterface extends ApiDetails { public class RepositoryInterface extends ApiDetails {
@ -29,7 +30,10 @@ public class RepositoryInterface extends ApiDetails {
public String getAccessSet() { public String getAccessSet() {
Map<String, String> map; Map<String, String> map;
if (apiParams != null) { if (apiParams != null) {
map = apiParams.stream().collect(Collectors.toMap(ApiParamDetails::getParam, ApiParamDetails::getValue)); map = apiParams.stream()
.filter(Objects::nonNull)
.filter(k -> k.getParam() == null && k.getValue() == null)
.collect(Collectors.toMap(ApiParamDetails::getParam, ApiParamDetails::getValue));
return map.get("set"); return map.get("set");
} }
return null; return null;
@ -42,7 +46,10 @@ public class RepositoryInterface extends ApiDetails {
public String getAccessFormat() { public String getAccessFormat() {
Map<String, String> map; Map<String, String> map;
if (apiParams != null) { if (apiParams != null) {
map = apiParams.stream().collect(Collectors.toMap(ApiParamDetails::getParam, ApiParamDetails::getValue)); map = apiParams.stream()
.filter(Objects::nonNull)
.filter(k -> k.getParam() == null && k.getValue() == null)
.collect(Collectors.toMap(ApiParamDetails::getParam, ApiParamDetails::getValue));
return map.get("format"); return map.get("format");
} }
return null; return null;