Search in sources :

Example 1 with Membership

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);
    }
}
Also used : Membership(org.orcid.jaxb.model.v3.dev1.record.Membership) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI)

Example 2 with Membership

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();
}
Also used : Membership(org.orcid.jaxb.model.v3.dev1.record.Membership)

Example 3 with Membership

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();
}
Also used : HashMap(java.util.HashMap) Membership(org.orcid.jaxb.model.v3.dev1.record.Membership) MismatchedPutCodeException(org.orcid.core.exception.MismatchedPutCodeException)

Example 4 with Membership

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");
}
Also used : Response(javax.ws.rs.core.Response) MembershipSummary(org.orcid.jaxb.model.v3.dev1.record.summary.MembershipSummary) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 5 with Membership

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());
}
Also used : Response(javax.ws.rs.core.Response) Membership(org.orcid.jaxb.model.v3.dev1.record.Membership) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Aggregations

Membership (org.orcid.jaxb.model.v3.dev1.record.Membership)41 Test (org.junit.Test)31 DBUnitTest (org.orcid.test.DBUnitTest)18 Response (javax.ws.rs.core.Response)17 Distinction (org.orcid.jaxb.model.v3.dev1.record.Distinction)11 Education (org.orcid.jaxb.model.v3.dev1.record.Education)11 Service (org.orcid.jaxb.model.v3.dev1.record.Service)11 Employment (org.orcid.jaxb.model.v3.dev1.record.Employment)10 InvitedPosition (org.orcid.jaxb.model.v3.dev1.record.InvitedPosition)10 Qualification (org.orcid.jaxb.model.v3.dev1.record.Qualification)10 Affiliation (org.orcid.jaxb.model.v3.dev1.record.Affiliation)8 MembershipSummary (org.orcid.jaxb.model.v3.dev1.record.summary.MembershipSummary)7 ResearcherUrl (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl)5 ActivitiesSummary (org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary)5 OrgAffiliationRelationEntity (org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity)5 ArrayList (java.util.ArrayList)4 List (java.util.List)4 Url (org.orcid.jaxb.model.v3.dev1.common.Url)4 ExternalID (org.orcid.jaxb.model.v3.dev1.record.ExternalID)4 Funding (org.orcid.jaxb.model.v3.dev1.record.Funding)4