use of org.orcid.jaxb.model.v3.dev1.record.summary.ServiceSummary in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegatorImpl method viewServices.
@Override
public Response viewServices(String orcid) {
List<ServiceSummary> servicesList = affiliationsManagerReadOnly.getServiceSummaryList(orcid);
// Lets copy the list so we don't modify the cached collection
List<ServiceSummary> filteredList = null;
if (servicesList != null) {
filteredList = new ArrayList<ServiceSummary>(servicesList);
}
servicesList = filteredList;
orcidSecurityManager.checkAndFilter(orcid, servicesList, ScopePathType.AFFILIATIONS_READ_LIMITED);
Services services = new Services(servicesList);
ActivityUtils.setPathToAffiliations(services, orcid);
sourceUtils.setSourceName(services);
Api3_0_Dev1LastModifiedDatesHelper.calculateLastModified(services);
return Response.ok(services).build();
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.ServiceSummary in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegatorImpl method viewServiceSummary.
@Override
public Response viewServiceSummary(String orcid, Long putCode) {
ServiceSummary es = affiliationsManagerReadOnly.getServiceSummary(orcid, putCode);
orcidSecurityManager.checkAndFilter(orcid, es, ScopePathType.AFFILIATIONS_READ_LIMITED);
ActivityUtils.setPathToActivity(es, orcid);
sourceUtils.setSourceName(es);
return Response.ok(es).build();
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.ServiceSummary in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_ServicesTest method testAddService.
@Test
public void testAddService() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
Response response = serviceDelegator.viewActivities(ORCID);
assertNotNull(response);
ActivitiesSummary originalSummary = (ActivitiesSummary) response.getEntity();
assertNotNull(originalSummary);
Utils.verifyLastModified(originalSummary.getLastModifiedDate());
assertNotNull(originalSummary.getServices());
Utils.verifyLastModified(originalSummary.getServices().getLastModifiedDate());
assertNotNull(originalSummary.getServices().getSummaries());
assertNotNull(originalSummary.getServices().getSummaries().get(0));
Utils.verifyLastModified(originalSummary.getServices().getSummaries().get(0).getLastModifiedDate());
assertEquals(4, originalSummary.getServices().getSummaries().size());
response = serviceDelegator.createService(ORCID, (Service) Utils.getAffiliation(AffiliationType.SERVICE));
assertNotNull(response);
assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
Map<?, ?> map = response.getMetadata();
assertNotNull(map);
assertTrue(map.containsKey("Location"));
List<?> resultWithPutCode = (List<?>) map.get("Location");
Long putCode = Long.valueOf(String.valueOf(resultWithPutCode.get(0)));
response = serviceDelegator.viewActivities(ORCID);
assertNotNull(response);
ActivitiesSummary summaryWithNewElement = (ActivitiesSummary) response.getEntity();
assertNotNull(summaryWithNewElement);
Utils.verifyLastModified(summaryWithNewElement.getLastModifiedDate());
assertNotNull(summaryWithNewElement.getServices());
Utils.verifyLastModified(summaryWithNewElement.getServices().getLastModifiedDate());
assertNotNull(summaryWithNewElement.getServices().getSummaries());
assertEquals(5, summaryWithNewElement.getServices().getSummaries().size());
boolean haveNew = false;
for (ServiceSummary serviceSummary : summaryWithNewElement.getServices().getSummaries()) {
assertNotNull(serviceSummary.getPutCode());
Utils.verifyLastModified(serviceSummary.getLastModifiedDate());
if (serviceSummary.getPutCode().equals(putCode)) {
assertEquals("My department name", serviceSummary.getDepartmentName());
haveNew = true;
} else {
assertTrue(originalSummary.getServices().getSummaries().contains(serviceSummary));
}
}
assertTrue(haveNew);
// Remove new element
serviceDelegator.deleteAffiliation(ORCID, putCode);
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.ServiceSummary in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_ServicesTest method testViewServiceSummaryReadPublic.
@Test
public void testViewServiceSummaryReadPublic() {
SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555555", ScopePathType.READ_PUBLIC);
Response r = serviceDelegator.viewServiceSummary(ORCID, 47L);
ServiceSummary element = (ServiceSummary) r.getEntity();
assertNotNull(element);
assertEquals("/0000-0000-0000-0003/service/47", element.getPath());
Utils.assertIsPublicOrSource(element, "APP-5555555555555555");
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.ServiceSummary in project ORCID-Source by ORCID.
the class PublicV3ApiServiceDelegatorTest method testViewServices.
@Test
public void testViewServices() {
Response response = serviceDelegator.viewServices(ORCID);
assertNotNull(response);
Services services = (Services) response.getEntity();
assertNotNull(services);
assertEquals("/0000-0000-0000-0003/services", services.getPath());
assertNotNull(services.getLastModifiedDate());
assertNotNull(services.getLastModifiedDate().getValue());
assertEquals(1, services.getSummaries().size());
ServiceSummary service = services.getSummaries().get(0);
assertEquals(Long.valueOf(47), service.getPutCode());
assertNotNull(service.getLastModifiedDate());
assertNotNull(service.getLastModifiedDate().getValue());
assertEquals("/0000-0000-0000-0003/service/47", service.getPath());
assertEquals("PUBLIC Department", service.getDepartmentName());
assertEquals(Visibility.PUBLIC.value(), service.getVisibility().value());
assertEquals("APP-5555555555555555", service.getSource().retrieveSourcePath());
}
Aggregations