use of org.orcid.jaxb.model.error_rc4.OrcidError in project ORCID-Source by ORCID.
the class S3MessageProcessor method update_2_0_API.
private void update_2_0_API(String orcid) {
if (is20IndexingEnabled) {
// Update API 2.0
try {
Record record = orcid20ApiClient.fetchPublicProfile(orcid);
if (record != null) {
s3Updater.updateS3(orcid, record);
recordStatusManager.markAsSent(orcid, AvailableBroker.DUMP_STATUS_2_0_API);
}
} catch (LockedRecordException | DeprecatedRecordException e) {
try {
OrcidError error = null;
if (e instanceof LockedRecordException) {
LOG.error("Record " + orcid + " is locked");
error = ((LockedRecordException) e).getOrcidError();
} else {
LOG.error("Record " + orcid + " is deprecated");
error = ((DeprecatedRecordException) e).getOrcidError();
}
exceptionHandler.handle20Exception(orcid, error);
recordStatusManager.markAsSent(orcid, AvailableBroker.DUMP_STATUS_2_0_API);
} catch (JsonProcessingException | AmazonClientException | JAXBException e1) {
LOG.error("Unable to handle LockedRecordException for record " + orcid, e1);
recordStatusManager.markAsFailed(orcid, AvailableBroker.DUMP_STATUS_2_0_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 2.0 API");
LOG.error(e.getMessage(), e);
recordStatusManager.markAsFailed(orcid, AvailableBroker.DUMP_STATUS_2_0_API);
}
}
}
use of org.orcid.jaxb.model.error_rc4.OrcidError in project ORCID-Source by ORCID.
the class LastModifiedMessageProcessorTest method recordLocked20LockedExceptionTest.
@Test
public void recordLocked20LockedExceptionTest() throws LockedRecordException, JsonProcessingException, AmazonClientException, JAXBException, DeprecatedRecordException {
when(mock_orcid12ApiClient.fetchPublicProfile(Matchers.anyString())).thenReturn(null);
when(mock_orcid20ApiClient.fetchPublicProfile(Matchers.anyString())).thenThrow(new LockedRecordException(new OrcidError()));
String orcid = "0000-0000-0000-0000";
execute(orcid);
verify(mock_exceptionHandler, times(1)).handle20Exception(Matchers.any(), Matchers.any());
}
use of org.orcid.jaxb.model.error_rc4.OrcidError in project ORCID-Source by ORCID.
the class PublicAPISecurityManagerV2Impl method filter.
@Override
public void filter(WorkBulk workBulk) {
if (workBulk != null && workBulk.getBulk() != null) {
List<BulkElement> filtered = new ArrayList<>();
for (int i = 0; i < workBulk.getBulk().size(); i++) {
BulkElement bulkElement = workBulk.getBulk().get(i);
if (bulkElement instanceof OrcidError) {
filtered.add(bulkElement);
} else {
try {
checkIsPublic((Work) bulkElement);
filtered.add(bulkElement);
} catch (OrcidNonPublicElementException e) {
filtered.add(orcidCoreExceptionMapper.getOrcidError(e));
}
}
}
workBulk.setBulk(filtered);
}
}
use of org.orcid.jaxb.model.error_rc4.OrcidError in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_WorksTest method testViewBulkWorks.
@Test
public void testViewBulkWorks() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
Response response = serviceDelegator.viewBulkWorks(ORCID, "11,12,13,16");
WorkBulk workBulk = (WorkBulk) response.getEntity();
assertNotNull(workBulk);
assertNotNull(workBulk.getBulk());
assertEquals(4, workBulk.getBulk().size());
assertTrue(workBulk.getBulk().get(0) instanceof Work);
assertTrue(workBulk.getBulk().get(1) instanceof Work);
// private work but matching source
assertTrue(workBulk.getBulk().get(2) instanceof Work);
// private work not matching source
assertTrue(workBulk.getBulk().get(3) instanceof OrcidError);
}
use of org.orcid.jaxb.model.error_rc4.OrcidError in project ORCID-Source by ORCID.
the class OrcidSecurityManager_WorkBulkTest method testPrivateWorkBulkReadLimitedToken.
@Test
public void testPrivateWorkBulkReadLimitedToken() {
WorkBulk workBulk = new WorkBulk();
workBulk.setBulk(Arrays.asList(createWork(Visibility.PRIVATE, CLIENT_2)));
SecurityContextTestUtils.setUpSecurityContext(ORCID_1, CLIENT_1, ScopePathType.READ_LIMITED);
orcidSecurityManager.checkAndFilter(ORCID_1, workBulk, ScopePathType.ORCID_WORKS_READ_LIMITED);
assertNotNull(workBulk);
assertEquals(1, workBulk.getBulk().size());
assertTrue(workBulk.getBulk().get(0) instanceof OrcidError);
}
Aggregations