use of org.orcid.jaxb.model.v3.dev1.record.WorkBulk in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegatorImpl method viewBulkWorks.
@Override
public Response viewBulkWorks(String orcid, String putCodes) {
ProfileEntity profileEntity = profileEntityManager.findByOrcid(orcid);
if (profileEntity == null) {
throw new OrcidNoResultException("No such profile: " + orcid);
}
WorkBulk workBulk = workManagerReadOnly.findWorkBulk(orcid, putCodes);
orcidSecurityManager.checkAndFilter(orcid, workBulk, ScopePathType.ORCID_WORKS_READ_LIMITED);
contributorUtils.filterContributorPrivateData(workBulk);
ActivityUtils.cleanEmptyFields(workBulk);
sourceUtils.setSourceName(workBulk);
return Response.ok(workBulk).build();
}
use of org.orcid.jaxb.model.v3.dev1.record.WorkBulk in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_WorksTest method testViewBulkWorksWithBadPutCode.
@Test
public void testViewBulkWorksWithBadPutCode() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
Response response = serviceDelegator.viewBulkWorks(ORCID, "11,12,13,bad");
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
assertTrue(workBulk.getBulk().get(2) instanceof Work);
// bad put code
assertTrue(workBulk.getBulk().get(3) instanceof OrcidError);
}
use of org.orcid.jaxb.model.v3.dev1.record.WorkBulk in project ORCID-Source by ORCID.
the class PublicV3ApiServiceDelegatorTest method testViewBulkWorks.
@Test
public void testViewBulkWorks() {
Response response = serviceDelegator.viewBulkWorks(ORCID, "11,12,13");
assertNotNull(response);
WorkBulk workBulk = (WorkBulk) response.getEntity();
assertNotNull(workBulk);
assertNotNull(workBulk.getBulk());
assertEquals(3, workBulk.getBulk().size());
assertTrue(workBulk.getBulk().get(0) instanceof Work);
assertTrue(workBulk.getBulk().get(1) instanceof OrcidError);
assertTrue(workBulk.getBulk().get(2) instanceof OrcidError);
Work work = (Work) workBulk.getBulk().get(0);
assertNotNull(work);
assertNotNull(work.getLastModifiedDate());
assertNotNull(work.getLastModifiedDate().getValue());
assertNotNull(work.getWorkTitle());
assertNotNull(work.getWorkTitle().getTitle());
assertEquals("PUBLIC", work.getWorkTitle().getTitle().getContent());
assertEquals(Long.valueOf(11), work.getPutCode());
assertEquals("/0000-0000-0000-0003/work/11", work.getPath());
assertEquals(WorkType.JOURNAL_ARTICLE, work.getWorkType());
assertEquals("APP-5555555555555555", work.getSource().retrieveSourcePath());
assertNotNull(work.getWorkContributors());
assertNotNull(work.getWorkContributors().getContributor());
assertEquals(1, work.getWorkContributors().getContributor().size());
assertNotNull(work.getWorkContributors().getContributor().get(0).getContributorOrcid());
assertEquals("0000-0000-0000-0000", work.getWorkContributors().getContributor().get(0).getContributorOrcid().getPath());
assertNull(work.getWorkContributors().getContributor().get(0).getCreditName());
}
use of org.orcid.jaxb.model.v3.dev1.record.WorkBulk in project ORCID-Source by ORCID.
the class WorkManagerReadOnlyImpl method findWorkBulk.
@Override
public WorkBulk findWorkBulk(String orcid, String putCodesAsString) {
List<BulkElement> works = new ArrayList<>();
String[] putCodes = getPutCodeArray(putCodesAsString);
for (String putCode : putCodes) {
try {
Long id = Long.valueOf(putCode);
WorkEntity workEntity = workEntityCacheManager.retrieveFullWork(orcid, id, getLastModified(orcid));
works.add(jpaJaxbWorkAdapter.toWork(workEntity));
} catch (Exception e) {
works.add(orcidCoreExceptionMapper.getV3OrcidError(new PutCodeFormatException("'" + putCode + "' is not a valid put code")));
}
}
WorkBulk bulk = new WorkBulk();
bulk.setBulk(works);
return bulk;
}
use of org.orcid.jaxb.model.v3.dev1.record.WorkBulk in project ORCID-Source by ORCID.
the class WorksTest method testCantAddMoreThan1000WorksAtATime.
@Test
public void testCantAddMoreThan1000WorksAtATime() throws InterruptedException, JSONException {
String accessToken = getAccessToken();
WorkBulk bulk = createBulk(1001, null);
ClientResponse postResponse = memberV3Dev1ApiClient.createWorksJson(this.getUser1OrcidId(), bulk, accessToken);
assertNotNull(postResponse);
assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), postResponse.getStatus());
OrcidError error = postResponse.getEntity(OrcidError.class);
assertNotNull(error);
assertEquals(Integer.valueOf(9006), error.getErrorCode());
}
Aggregations