use of org.orcid.jaxb.model.message.OrcidMessage in project ORCID-Source by ORCID.
the class LastModifiedMessageProcessorTest method recordStatusMarkAsSentFor12Test.
@Test
public void recordStatusMarkAsSentFor12Test() throws LockedRecordException, DeprecatedRecordException {
when(mock_orcid12ApiClient.fetchPublicProfile(Matchers.anyString())).thenReturn(new OrcidMessage());
when(mock_orcid20ApiClient.fetchPublicProfile(Matchers.anyString())).thenReturn(null);
String orcid = "0000-0000-0000-0000";
execute(orcid);
verify(mock_recordStatusManager, times(1)).markAsSent(orcid, AvailableBroker.DUMP_STATUS_1_2_API);
verify(mock_recordStatusManager, times(0)).markAsFailed(orcid, AvailableBroker.DUMP_STATUS_1_2_API);
verify(mock_recordStatusManager, times(0)).markAsSent(orcid, AvailableBroker.DUMP_STATUS_2_0_API);
verify(mock_recordStatusManager, times(0)).markAsFailed(orcid, AvailableBroker.DUMP_STATUS_2_0_API);
}
use of org.orcid.jaxb.model.message.OrcidMessage in project ORCID-Source by ORCID.
the class S3MessageProcessor method update_1_2_API.
private void update_1_2_API(String orcid) {
if (is12IndexingEnabled) {
try {
OrcidMessage profile = orcid12ApiClient.fetchPublicProfile(orcid);
// Update API 1.2
if (profile != null) {
s3Updater.updateS3(orcid, profile);
recordStatusManager.markAsSent(orcid, AvailableBroker.DUMP_STATUS_1_2_API);
}
} catch (LockedRecordException | DeprecatedRecordException e) {
try {
if (e instanceof LockedRecordException) {
LOG.error("Record " + orcid + " is locked");
exceptionHandler.handle12LockedRecordException(orcid, ((LockedRecordException) e).getOrcidMessage());
} else {
LOG.error("Record " + orcid + " is deprecated");
exceptionHandler.handle12DeprecatedRecordException(orcid, ((DeprecatedRecordException) e).getOrcidDeprecated());
}
recordStatusManager.markAsSent(orcid, AvailableBroker.DUMP_STATUS_1_2_API);
} catch (JsonProcessingException | AmazonClientException | JAXBException e1) {
LOG.error("Unable to handle LockedRecordException for record " + orcid, e1);
recordStatusManager.markAsFailed(orcid, AvailableBroker.DUMP_STATUS_1_2_API);
}
} catch (Exception e) {
// something else went wrong fetching record from ORCID and
// threw a
// runtime exception
LOG.error("Unable to fetch record " + orcid + " for 1.2 API");
LOG.error(e.getMessage(), e);
recordStatusManager.markAsFailed(orcid, AvailableBroker.DUMP_STATUS_1_2_API);
}
}
}
use of org.orcid.jaxb.model.message.OrcidMessage in project ORCID-Source by ORCID.
the class VisibilityFilterImplTest method testFilterStripWithVisibilities.
@Test
public void testFilterStripWithVisibilities() throws Exception {
protectedOrcidMessage = getOrcidMessage("/orcid-protected-full-message-latest.xml");
publicOrcidMessage = getOrcidMessage("/orcid-stripped-with-visibility-message-latest.xml");
OrcidMessage orcidMessage = visibilityFilter.filter(cascadeSectionPrivacyToItems(protectedOrcidMessage), Visibility.PUBLIC);
Diff myDiff = new Diff(publicOrcidMessage.toString(), orcidMessage.toString());
assertEquals(publicOrcidMessage.toString(), orcidMessage.toString());
assertTrue(myDiff.toString(), myDiff.similar());
}
use of org.orcid.jaxb.model.message.OrcidMessage in project ORCID-Source by ORCID.
the class VisibilityFilterImplTest method testOrcidMessageWithNullOrcidProfile.
@Test
public void testOrcidMessageWithNullOrcidProfile() throws JAXBException {
OrcidMessage orcidMessage = getOrcidMessage("/orcid-search-result-message.xml");
OrcidMessage filteredMessage = visibilityFilter.filter(orcidMessage, Visibility.PUBLIC);
assertNotNull(filteredMessage);
assertNull(filteredMessage.getOrcidProfile());
assertEquals(2, filteredMessage.getOrcidSearchResults().getNumFound());
for (int i = 0; i < filteredMessage.getOrcidSearchResults().getNumFound(); i++) {
OrcidSearchResult searchResult = filteredMessage.getOrcidSearchResults().getOrcidSearchResult().get(i);
OrcidBio orcidBio = searchResult.getOrcidProfile().getOrcidBio();
// check private emails stripped out
assertEquals(1, orcidBio.getContactDetails().getEmail().size());
}
}
use of org.orcid.jaxb.model.message.OrcidMessage in project ORCID-Source by ORCID.
the class RDFWriterTest method missingCreditName.
@Test
public void missingCreditName() throws Exception {
ByteArrayOutputStream entityStream = new ByteArrayOutputStream(1024);
OrcidMessage fakeBio = fakeBio();
// empty creditName
fakeBio.getOrcidProfile().getOrcidBio().getPersonalDetails().setCreditName(null);
rdfWriter.writeTo(fakeBio, OrcidMessage.class, null, null, new MediaType("text", "turtle"), null, entityStream);
String str = entityStream.toString("utf-8");
System.out.println(str);
// Should NOT include a foaf:name
assertFalse(str.contains("foaf:name"));
// but do include a concatenation as a label
assertTrue(str.contains("rdfs:label"));
assertTrue(str.contains("\"John Doe\""));
// And family/given
assertTrue(str.contains("foaf:familyName"));
assertTrue(str.contains("\"Doe\""));
assertTrue(str.contains("foaf:givenName"));
assertTrue(str.contains("\"John\""));
}
Aggregations