Skip to content

Commit

Permalink
Merge pull request #6861 from ORCID/FixJacksonProblem
Browse files Browse the repository at this point in the history
Fix jackson problem
  • Loading branch information
leomendoza123 authored Aug 9, 2023
2 parents 3cfe1fe + 2a2a343 commit f60d7a4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package org.orcid.pojo.summary;


import com.fasterxml.jackson.annotation.JsonFilter;

import java.util.List;

@JsonFilter("nameFilter")
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;

public class RecordSummary {
@JsonInclude(Include.NON_NULL)
private String name;
private String orcid;
private List<AffiliationSummary> employmentAffiliations;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ PublicRecord getRecord(String orcid) {
}

@RequestMapping(value = "/{orcid:(?:\\d{4}-){3,}\\d{3}[\\dX]}/summary.json", method = RequestMethod.GET)
public @ResponseBody MappingJacksonValue getSummaryRecord(@PathVariable("orcid") String orcid) {
public @ResponseBody RecordSummary getSummaryRecord(@PathVariable("orcid") String orcid) {
RecordSummary recordSummary = new RecordSummary();
Boolean isDeprecated = false;

Expand All @@ -336,14 +336,14 @@ PublicRecord getRecord(String orcid) {
}
recordSummary.setName(localeManager.resolveMessage("public_profile.deactivated.given_names") + " "
+ localeManager.resolveMessage("public_profile.deactivated.family_name"));
return new MappingJacksonValue(recordSummary);
return recordSummary;
} catch (OrcidNotClaimedException e) {
recordSummary.setName(localeManager.resolveMessage("orcid.reserved_for_claim"));
return new MappingJacksonValue(recordSummary);
return recordSummary;
} catch (OrcidDeprecatedException e) {
isDeprecated = true;
} catch (OrcidNoResultException e) {
return new MappingJacksonValue(recordSummary);
return recordSummary;
}

if (isDeprecated) {
Expand All @@ -352,18 +352,11 @@ PublicRecord getRecord(String orcid) {
recordSummary.setProfessionalActivities(null);
recordSummary.setExternalIdentifiers(null);

return new MappingJacksonValue(recordSummary);
return recordSummary;
} else {
recordSummary = getSummary(orcid);
recordSummary.setStatus("active");

SimpleBeanPropertyFilter simpleBeanPropertyFilter = SimpleBeanPropertyFilter.serializeAllExcept("name");
FilterProvider filterProvider = new SimpleFilterProvider().addFilter("nameFilter", simpleBeanPropertyFilter);
MappingJacksonValue mappingJacksonValue = new MappingJacksonValue(recordSummary);
if (recordSummary.getName() == null) {
mappingJacksonValue.setFilters(filterProvider);
}
return mappingJacksonValue;
recordSummary.setStatus("active");
return recordSummary;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public void testGetPublicRecord() {

@Test
public void testGetRecordSummary() {
RecordSummary record = (RecordSummary) publicRecordController.getSummaryRecord(userOrcid).getValue();
RecordSummary record = publicRecordController.getSummaryRecord(userOrcid);

assertEquals("active", record.getStatus());
assertNotNull(record.getName());
Expand Down Expand Up @@ -184,7 +184,7 @@ public void testGetRecordSummary() {

@Test
public void testGetRecordSummaryDeactivated() {
RecordSummary record = (RecordSummary) publicRecordController.getSummaryRecord(deactivatedUserOrcid).getValue();
RecordSummary record = publicRecordController.getSummaryRecord(deactivatedUserOrcid);

assertEquals("Given Names Deactivated Family Name Deactivated", record.getName());

Expand All @@ -193,7 +193,7 @@ public void testGetRecordSummaryDeactivated() {

@Test
public void testGetRecordSummaryLocked() {
RecordSummary record = (RecordSummary) publicRecordController.getSummaryRecord(lockedUserOrcid).getValue();
RecordSummary record = publicRecordController.getSummaryRecord(lockedUserOrcid);

assertNotNull(record.getName());
assertEquals("Given Names Deactivated Family Name Deactivated", record.getName());
Expand All @@ -203,7 +203,7 @@ public void testGetRecordSummaryLocked() {

@Test
public void testGetRecordSummaryDeprecated() {
RecordSummary record = (RecordSummary) publicRecordController.getSummaryRecord(deprecatedUserOrcid).getValue();
RecordSummary record = publicRecordController.getSummaryRecord(deprecatedUserOrcid);

assertNull(record.getName());

Expand All @@ -212,7 +212,7 @@ public void testGetRecordSummaryDeprecated() {

@Test
public void testGetRecordSummaryPrivateName() {
RecordSummary record = (RecordSummary) publicRecordController.getSummaryRecord(unclaimedUserOrcid).getValue();
RecordSummary record = publicRecordController.getSummaryRecord(unclaimedUserOrcid);

assertNull(record.getName());
}
Expand Down

0 comments on commit f60d7a4

Please sign in to comment.