use of org.orcid.jaxb.model.v3.dev1.record.Membership in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegatorImpl method createMembership.
@Override
public Response createMembership(String orcid, Membership membership) {
orcidSecurityManager.checkClientAccessAndScopes(orcid, ScopePathType.AFFILIATIONS_CREATE, ScopePathType.AFFILIATIONS_UPDATE);
clearSource(membership);
Membership e = affiliationsManager.createMembershipAffiliation(orcid, membership, true);
sourceUtils.setSourceName(e);
try {
return Response.created(new URI(String.valueOf(e.getPutCode()))).build();
} catch (URISyntaxException ex) {
throw new RuntimeException(localeManager.resolveMessage("apiError.createdistinction_response.exception"), ex);
}
}
use of org.orcid.jaxb.model.v3.dev1.record.Membership in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegatorImpl method viewMembership.
@Override
public Response viewMembership(String orcid, Long putCode) {
Membership e = affiliationsManagerReadOnly.getMembershipAffiliation(orcid, putCode);
orcidSecurityManager.checkAndFilter(orcid, e, ScopePathType.AFFILIATIONS_READ_LIMITED);
ActivityUtils.setPathToActivity(e, orcid);
sourceUtils.setSourceName(e);
return Response.ok(e).build();
}
use of org.orcid.jaxb.model.v3.dev1.record.Membership in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegatorImpl method updateMembership.
@Override
public Response updateMembership(String orcid, Long putCode, Membership membership) {
orcidSecurityManager.checkClientAccessAndScopes(orcid, ScopePathType.AFFILIATIONS_UPDATE);
if (!putCode.equals(membership.getPutCode())) {
Map<String, String> params = new HashMap<String, String>();
params.put("urlPutCode", String.valueOf(putCode));
params.put("bodyPutCode", String.valueOf(membership.getPutCode()));
throw new MismatchedPutCodeException(params);
}
clearSource(membership);
Membership e = affiliationsManager.updateMembershipAffiliation(orcid, membership, true);
sourceUtils.setSourceName(e);
return Response.ok(e).build();
}
use of org.orcid.jaxb.model.v3.dev1.record.Membership in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_MembershipsTest method testViewMembershipSummaryReadPublic.
@Test
public void testViewMembershipSummaryReadPublic() {
SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555555", ScopePathType.READ_PUBLIC);
Response r = serviceDelegator.viewMembershipSummary(ORCID, 37L);
MembershipSummary element = (MembershipSummary) r.getEntity();
assertNotNull(element);
assertEquals("/0000-0000-0000-0003/membership/37", element.getPath());
Utils.assertIsPublicOrSource(element, "APP-5555555555555555");
}
use of org.orcid.jaxb.model.v3.dev1.record.Membership in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_MembershipsTest method testViewPublicMembership.
@Test
public void testViewPublicMembership() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
Response response = serviceDelegator.viewMembership(ORCID, 37L);
assertNotNull(response);
Membership membership = (Membership) response.getEntity();
assertNotNull(membership);
Utils.verifyLastModified(membership.getLastModifiedDate());
assertEquals(Long.valueOf(37L), membership.getPutCode());
assertEquals("/0000-0000-0000-0003/membership/37", membership.getPath());
assertEquals("PUBLIC Department", membership.getDepartmentName());
assertEquals(Visibility.PUBLIC.value(), membership.getVisibility().value());
}
Aggregations