use of org.orcid.jaxb.model.v3.dev1.record.summary.Memberships in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegatorImpl method viewMemberships.
@Override
public Response viewMemberships(String orcid) {
List<MembershipSummary> membershipsList = affiliationsManagerReadOnly.getMembershipSummaryList(orcid);
// Lets copy the list so we don't modify the cached collection
List<MembershipSummary> filteredList = null;
if (membershipsList != null) {
filteredList = new ArrayList<MembershipSummary>(membershipsList);
}
membershipsList = filteredList;
orcidSecurityManager.checkAndFilter(orcid, membershipsList, ScopePathType.AFFILIATIONS_READ_LIMITED);
Memberships memberships = new Memberships(membershipsList);
ActivityUtils.setPathToAffiliations(memberships, orcid);
sourceUtils.setSourceName(memberships);
Api3_0_Dev1LastModifiedDatesHelper.calculateLastModified(memberships);
return Response.ok(memberships).build();
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.Memberships in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_MembershipsTest method testViewMembershipsReadPublic.
@Test
public void testViewMembershipsReadPublic() {
SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555555", ScopePathType.READ_PUBLIC);
Response r = serviceDelegator.viewMemberships(ORCID);
Memberships element = (Memberships) r.getEntity();
assertNotNull(element);
assertEquals("/0000-0000-0000-0003/memberships", element.getPath());
Utils.assertIsPublicOrSource(element, "APP-5555555555555555");
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.Memberships in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_MembershipsTest method testViewMemberships.
@Test
public void testViewMemberships() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
Response r = serviceDelegator.viewMemberships(ORCID);
assertNotNull(r);
Memberships memberships = (Memberships) r.getEntity();
assertNotNull(memberships);
assertEquals("/0000-0000-0000-0003/memberships", memberships.getPath());
Utils.verifyLastModified(memberships.getLastModifiedDate());
assertNotNull(memberships.getSummaries());
assertEquals(4, memberships.getSummaries().size());
boolean found1 = false, found2 = false, found3 = false, found4 = false;
for (MembershipSummary summary : memberships.getSummaries()) {
Utils.verifyLastModified(summary.getLastModifiedDate());
if (Long.valueOf(37).equals(summary.getPutCode())) {
assertEquals("PUBLIC Department", summary.getDepartmentName());
found1 = true;
} else if (Long.valueOf(38).equals(summary.getPutCode())) {
assertEquals("LIMITED Department", summary.getDepartmentName());
found2 = true;
} else if (Long.valueOf(39).equals(summary.getPutCode())) {
assertEquals("PRIVATE Department", summary.getDepartmentName());
found3 = true;
} else if (Long.valueOf(40).equals(summary.getPutCode())) {
assertEquals("SELF LIMITED Department", summary.getDepartmentName());
found4 = true;
} else {
fail("Invalid membership found: " + summary.getPutCode());
}
}
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
assertTrue(found4);
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.Memberships in project ORCID-Source by ORCID.
the class PublicV3ApiServiceDelegatorTest method testGetPublicMembershipsUsingToken.
@Test
public void testGetPublicMembershipsUsingToken() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
Response r = serviceDelegator.viewMemberships(ORCID);
assertNotNull(r);
Memberships memberships = (Memberships) r.getEntity();
assertNotNull(memberships);
assertNotNull(memberships.getLastModifiedDate());
assertNotNull(memberships.getLastModifiedDate().getValue());
assertNotNull(memberships.getSummaries());
assertEquals(1, memberships.getSummaries().size());
assertEquals(Long.valueOf(37), memberships.getSummaries().get(0).getPutCode());
assertEquals(Visibility.PUBLIC, memberships.getSummaries().get(0).getVisibility());
assertNotNull(memberships.getSummaries().get(0).getLastModifiedDate());
assertNotNull(memberships.getSummaries().get(0).getLastModifiedDate().getValue());
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.Memberships in project ORCID-Source by ORCID.
the class PublicAPISecurityManagerV3Test method filterMembershipsTest.
@Test
public void filterMembershipsTest() {
Memberships e = getMemberships(Visibility.PUBLIC, Visibility.PUBLIC, Visibility.PUBLIC);
assertEquals(3, e.getSummaries().size());
publicAPISecurityManagerV3.filter(e);
assertEquals(3, e.getSummaries().size());
assertContainerContainsOnlyPublicElements(e);
e = getMemberships(Visibility.PUBLIC, Visibility.PUBLIC, Visibility.LIMITED);
assertEquals(3, e.getSummaries().size());
publicAPISecurityManagerV3.filter(e);
assertEquals(2, e.getSummaries().size());
assertContainerContainsOnlyPublicElements(e);
e = getMemberships(Visibility.PUBLIC, Visibility.LIMITED, Visibility.PRIVATE);
assertEquals(3, e.getSummaries().size());
publicAPISecurityManagerV3.filter(e);
assertEquals(1, e.getSummaries().size());
assertContainerContainsOnlyPublicElements(e);
e = getMemberships(Visibility.PRIVATE, Visibility.LIMITED, Visibility.PRIVATE);
assertEquals(3, e.getSummaries().size());
publicAPISecurityManagerV3.filter(e);
assertTrue(e.getSummaries().isEmpty());
}
Aggregations