use of org.orcid.jaxb.model.v3.dev1.record.Work in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegatorImpl method createWork.
@Override
public Response createWork(String orcid, Work work) {
orcidSecurityManager.checkClientAccessAndScopes(orcid, ScopePathType.ORCID_WORKS_CREATE, ScopePathType.ORCID_WORKS_UPDATE);
clearSource(work);
Work w = workManager.createWork(orcid, work, true);
sourceUtils.setSourceName(w);
try {
return Response.created(new URI(String.valueOf(w.getPutCode()))).build();
} catch (URISyntaxException e) {
throw new RuntimeException(localeManager.resolveMessage("apiError.creatework_response.exception"), e);
}
}
use of org.orcid.jaxb.model.v3.dev1.record.Work in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegatorImpl method updateWork.
@Override
public Response updateWork(String orcid, Long putCode, Work work) {
orcidSecurityManager.checkClientAccessAndScopes(orcid, ScopePathType.ORCID_WORKS_UPDATE);
if (!putCode.equals(work.getPutCode())) {
Map<String, String> params = new HashMap<String, String>();
params.put("urlPutCode", String.valueOf(putCode));
params.put("bodyPutCode", String.valueOf(work.getPutCode()));
throw new MismatchedPutCodeException(params);
}
clearSource(work);
Work w = workManager.updateWork(orcid, work, true);
sourceUtils.setSourceName(w);
return Response.ok(w).build();
}
use of org.orcid.jaxb.model.v3.dev1.record.Work in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegatorImpl method viewWork.
@Override
public Response viewWork(String orcid, Long putCode) {
Work w = workManagerReadOnly.getWork(orcid, putCode);
orcidSecurityManager.checkAndFilter(orcid, w, ScopePathType.ORCID_WORKS_READ_LIMITED);
contributorUtils.filterContributorPrivateData(w);
ActivityUtils.cleanEmptyFields(w);
ActivityUtils.setPathToActivity(w, orcid);
sourceUtils.setSourceName(w);
return Response.ok(w).build();
}
use of org.orcid.jaxb.model.v3.dev1.record.Work in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_DistinctionsTest method testReadPublicScope_Distinctions.
@Test
public void testReadPublicScope_Distinctions() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_PUBLIC);
Response r = serviceDelegator.viewDistinction(ORCID, 27L);
assertNotNull(r);
assertEquals(Distinction.class.getName(), r.getEntity().getClass().getName());
r = serviceDelegator.viewDistinctionSummary(ORCID, 27L);
assertNotNull(r);
assertEquals(DistinctionSummary.class.getName(), r.getEntity().getClass().getName());
// Limited that am the source of should work
serviceDelegator.viewDistinction(ORCID, 28L);
serviceDelegator.viewDistinctionSummary(ORCID, 28L);
// Limited that am not the source of should fail
try {
serviceDelegator.viewDistinction(ORCID, 30L);
fail();
} catch (OrcidAccessControlException e) {
} catch (Exception e) {
fail();
}
try {
serviceDelegator.viewDistinctionSummary(ORCID, 30L);
fail();
} catch (OrcidAccessControlException e) {
} catch (Exception e) {
fail();
}
// Private that am the source of should work
serviceDelegator.viewDistinction(ORCID, 29L);
serviceDelegator.viewDistinctionSummary(ORCID, 29L);
// Private that am not the source of should fails
try {
serviceDelegator.viewDistinction(ORCID, 31L);
fail();
} catch (OrcidAccessControlException e) {
} catch (Exception e) {
fail();
}
try {
serviceDelegator.viewDistinctionSummary(ORCID, 31L);
fail();
} catch (OrcidAccessControlException e) {
} catch (Exception e) {
fail();
}
}
use of org.orcid.jaxb.model.v3.dev1.record.Work in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_EmploymentsTest method testReadPublicScope_Employments.
@Test
public void testReadPublicScope_Employments() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_PUBLIC);
Response r = serviceDelegator.viewEmployment(ORCID, 17L);
assertNotNull(r);
assertEquals(Employment.class.getName(), r.getEntity().getClass().getName());
r = serviceDelegator.viewEmploymentSummary(ORCID, 17L);
assertNotNull(r);
assertEquals(EmploymentSummary.class.getName(), r.getEntity().getClass().getName());
// Limited that am the source of should work
serviceDelegator.viewEmployment(ORCID, 18L);
serviceDelegator.viewEmploymentSummary(ORCID, 18L);
// Limited that am not the source of should fail
try {
serviceDelegator.viewEmployment(ORCID, 23L);
fail();
} catch (OrcidAccessControlException e) {
} catch (Exception e) {
fail();
}
try {
serviceDelegator.viewEmploymentSummary(ORCID, 23L);
fail();
} catch (OrcidAccessControlException e) {
} catch (Exception e) {
fail();
}
// Private that am the source of should work
serviceDelegator.viewEmployment(ORCID, 19L);
serviceDelegator.viewEmploymentSummary(ORCID, 19L);
// Private that am not the source of should fail
try {
serviceDelegator.viewEmployment(ORCID, 24L);
fail();
} catch (OrcidAccessControlException e) {
} catch (Exception e) {
fail();
}
try {
serviceDelegator.viewEmploymentSummary(ORCID, 24L);
fail();
} catch (OrcidAccessControlException e) {
} catch (Exception e) {
fail();
}
}
Aggregations