Commit 0588518111acb42870fa867ded03e7d21b5f2e51

Authored by Paulo Graça
1 parent 893c581c83
Exists in tests

NullpointerException fix when profile is empty

Showing 1 changed file with 7 additions and 2 deletions   Show diff stats
ptcrisync/src/pt/ptcris/ORCIDHelper.java
... ... @@ -9,6 +9,7 @@ import java.util.stream.Stream;
9 9 import org.um.dsi.gavea.orcid.model.work.Work;
10 10 import org.um.dsi.gavea.orcid.model.work.WorkSummary;
11 11 import org.um.dsi.gavea.orcid.model.activities.ActivitiesSummary;
  12 +import org.um.dsi.gavea.orcid.model.activities.ActivitiesSummary.Works;
12 13 import org.um.dsi.gavea.orcid.model.activities.WorkGroup;
13 14 import org.um.dsi.gavea.orcid.model.common.RelationshipType;
14 15 import org.um.dsi.gavea.orcid.model.work.WorkExternalIdentifiers;
... ... @@ -51,8 +52,12 @@ public class ORCIDHelper {
51 52 public List<WorkSummary> getSourcedWorkSummaries() throws OrcidClientException, NullPointerException {
52 53  
53 54 ActivitiesSummary activitiesSummary = client.getActivitiesSummary();
54   - String sourceClientID = client.getClientId();
55   - Stream<WorkGroup> workGroupList = activitiesSummary.getWorks().getGroup().stream();
  55 + String sourceClientID = client.getClientId();
  56 + Works works = activitiesSummary.getWorks();
  57 + if (works == null) {
  58 + return new LinkedList<WorkSummary>();
  59 + }
  60 + Stream<WorkGroup> workGroupList = works.getGroup().stream();
56 61  
57 62 Stream<WorkSummary> workSummaryList = workGroupList.map(WorkGroup::getWorkSummary)
58 63 .flatMap(List::stream)
... ...