use of org.orcid.jaxb.model.v3.dev1.record.summary.Services in project ORCID-Source by ORCID.
the class ValidateV3_dev1SamplesTest method testMarshallServices.
@Test
public void testMarshallServices() throws JAXBException, SAXException, URISyntaxException {
Services object = (Services) unmarshallFromPath("/record_3.0_dev1/samples/read_samples/services-3.0_dev1.xml", Services.class);
marshall(object, "/record_3.0_dev1/activities-3.0_dev1.xsd");
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.Services in project ORCID-Source by ORCID.
the class PublicV3ApiServiceDelegatorImpl method viewServices.
@Override
public Response viewServices(String orcid) {
List<ServiceSummary> services = affiliationsManagerReadOnly.getServiceSummaryList(orcid);
Services publicServices = new Services();
for (ServiceSummary summary : services) {
if (Visibility.PUBLIC.equals(summary.getVisibility())) {
ActivityUtils.setPathToActivity(summary, orcid);
sourceUtilsReadOnly.setSourceName(summary);
publicServices.getSummaries().add(summary);
}
}
Api3_0_Dev1LastModifiedDatesHelper.calculateLastModified(publicServices);
ActivityUtils.setPathToAffiliations(publicServices, orcid);
return Response.ok(publicServices).build();
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.Services in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_ServicesTest method testViewServicesReadPublic.
@Test
public void testViewServicesReadPublic() {
SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555555", ScopePathType.READ_PUBLIC);
Response r = serviceDelegator.viewServices(ORCID);
Services element = (Services) r.getEntity();
assertNotNull(element);
assertEquals("/0000-0000-0000-0003/services", element.getPath());
Utils.assertIsPublicOrSource(element, "APP-5555555555555555");
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.Services in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_ServicesTest method testViewServices.
@Test
public void testViewServices() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
Response r = serviceDelegator.viewServices(ORCID);
assertNotNull(r);
Services services = (Services) r.getEntity();
assertNotNull(services);
assertEquals("/0000-0000-0000-0003/services", services.getPath());
Utils.verifyLastModified(services.getLastModifiedDate());
assertNotNull(services.getSummaries());
assertEquals(4, services.getSummaries().size());
boolean found1 = false, found2 = false, found3 = false, found4 = false;
for (ServiceSummary summary : services.getSummaries()) {
Utils.verifyLastModified(summary.getLastModifiedDate());
if (Long.valueOf(47).equals(summary.getPutCode())) {
assertEquals("PUBLIC Department", summary.getDepartmentName());
found1 = true;
} else if (Long.valueOf(48).equals(summary.getPutCode())) {
assertEquals("LIMITED Department", summary.getDepartmentName());
found2 = true;
} else if (Long.valueOf(49).equals(summary.getPutCode())) {
assertEquals("PRIVATE Department", summary.getDepartmentName());
found3 = true;
} else if (Long.valueOf(50).equals(summary.getPutCode())) {
assertEquals("SELF LIMITED Department", summary.getDepartmentName());
found4 = true;
} else {
fail("Invalid service found: " + summary.getPutCode());
}
}
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
assertTrue(found4);
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.Services in project ORCID-Source by ORCID.
the class OrcidSecurityManagerImpl method checkAndFilter.
@Override
public void checkAndFilter(String orcid, ActivitiesSummary activities) {
if (activities == null) {
return;
}
// Check the token
isMyToken(orcid);
// Distinctions
if (activities.getDistinctions() != null) {
checkAndFilter(orcid, activities.getDistinctions().getSummaries(), READ_AFFILIATIONS_REQUIRED_SCOPE, true);
}
// Educations
if (activities.getEducations() != null) {
checkAndFilter(orcid, activities.getEducations().getSummaries(), READ_AFFILIATIONS_REQUIRED_SCOPE, true);
}
// Employments
if (activities.getEmployments() != null) {
checkAndFilter(orcid, activities.getEmployments().getSummaries(), READ_AFFILIATIONS_REQUIRED_SCOPE, true);
}
// Invited positions
if (activities.getInvitedPositions() != null) {
checkAndFilter(orcid, activities.getInvitedPositions().getSummaries(), READ_AFFILIATIONS_REQUIRED_SCOPE, true);
}
// Memberships
if (activities.getMemberships() != null) {
checkAndFilter(orcid, activities.getMemberships().getSummaries(), READ_AFFILIATIONS_REQUIRED_SCOPE, true);
}
// Qualifications
if (activities.getQualifications() != null) {
checkAndFilter(orcid, activities.getQualifications().getSummaries(), READ_AFFILIATIONS_REQUIRED_SCOPE, true);
}
// Services
if (activities.getServices() != null) {
checkAndFilter(orcid, activities.getServices().getSummaries(), READ_AFFILIATIONS_REQUIRED_SCOPE, true);
}
// Funding
if (activities.getFundings() != null) {
Iterator<FundingGroup> groupIt = activities.getFundings().getFundingGroup().iterator();
while (groupIt.hasNext()) {
FundingGroup group = groupIt.next();
// Filter the list of elements
checkAndFilter(orcid, group.getFundingSummary(), READ_FUNDING_REQUIRED_SCOPE, true);
// Clean external identifiers
if (group.getFundingSummary().isEmpty()) {
groupIt.remove();
} else {
filterExternalIdentifiers(group);
}
}
}
// PeerReviews
if (activities.getPeerReviews() != null) {
Iterator<PeerReviewGroup> groupIt = activities.getPeerReviews().getPeerReviewGroup().iterator();
while (groupIt.hasNext()) {
PeerReviewGroup group = groupIt.next();
// Filter the list of elements
checkAndFilter(orcid, group.getPeerReviewSummary(), READ_PEER_REVIEWS_REQUIRED_SCOPE, true);
if (group.getPeerReviewSummary().isEmpty()) {
groupIt.remove();
}
}
}
// Works
if (activities.getWorks() != null) {
Iterator<WorkGroup> groupIt = activities.getWorks().getWorkGroup().iterator();
while (groupIt.hasNext()) {
WorkGroup group = groupIt.next();
// Filter the list of elements
checkAndFilter(orcid, group.getWorkSummary(), READ_WORKS_REQUIRED_SCOPE, true);
// Clean external identifiers
if (group.getWorkSummary().isEmpty()) {
groupIt.remove();
} else {
filterExternalIdentifiers(group);
}
}
}
}
Aggregations