use of org.orcid.jaxb.model.v3.dev1.record.Service in project ORCID-Source by ORCID.
the class MapperFacadeFactory method getServiceMapperFacade.
public MapperFacade getServiceMapperFacade() {
MapperFactory mapperFactory = new DefaultMapperFactory.Builder().build();
ClassMapBuilder<Service, OrgAffiliationRelationEntity> classMap = mapperFactory.classMap(Service.class, OrgAffiliationRelationEntity.class);
ClassMapBuilder<ServiceSummary, OrgAffiliationRelationEntity> summaryClassMap = mapperFactory.classMap(ServiceSummary.class, OrgAffiliationRelationEntity.class);
return generateMapperFacadeForAffiliation(mapperFactory, classMap, summaryClassMap);
}
use of org.orcid.jaxb.model.v3.dev1.record.Service in project ORCID-Source by ORCID.
the class AffiliationsManagerTest method testAddServiceToUnclaimedRecordPreserveServiceVisibility.
@Test
public void testAddServiceToUnclaimedRecordPreserveServiceVisibility() {
when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID)));
Service element = getService();
element = affiliationsManager.createServiceAffiliation(unclaimedOrcid, element, true);
element = affiliationsManager.getServiceAffiliation(unclaimedOrcid, element.getPutCode());
assertNotNull(element);
assertEquals(Visibility.PUBLIC, element.getVisibility());
}
use of org.orcid.jaxb.model.v3.dev1.record.Service in project ORCID-Source by ORCID.
the class ActivityUtilsTest method setPathToServicesTest.
@Test
public void setPathToServicesTest() {
Services x = getServices();
ActivityUtils.setPathToAffiliations(x, ORCID);
assertEquals("/" + ORCID + "/service/123", x.getSummaries().get(0).getPath());
}
use of org.orcid.jaxb.model.v3.dev1.record.Service in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegatorImpl method viewService.
@Override
public Response viewService(String orcid, Long putCode) {
Service e = affiliationsManagerReadOnly.getServiceAffiliation(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.Service in project ORCID-Source by ORCID.
the class MemberV3Dev1Test method testUpdateServiceWithProfileCreationTokenWhenClaimedAndNotSource.
@Test
public void testUpdateServiceWithProfileCreationTokenWhenClaimedAndNotSource() throws JSONException, InterruptedException, URISyntaxException {
Service service = (Service) unmarshallFromPath("/record_3.0_dev1/samples/read_samples/service-3.0_dev1.xml", Service.class);
service.setPutCode(null);
service.setVisibility(Visibility.PUBLIC);
String accessToken = getAccessToken();
ClientResponse postResponse = memberV3Dev1ApiClientImpl.createServiceXml(this.getUser1OrcidId(), service, accessToken);
assertNotNull(postResponse);
assertEquals(Response.Status.CREATED.getStatusCode(), postResponse.getStatus());
String locationPath = postResponse.getLocation().getPath();
assertTrue("Location header path should match pattern, but was " + locationPath, locationPath.matches(".*/v3.0_dev1/" + this.getUser1OrcidId() + "/service/\\d+"));
ClientResponse getResponse = memberV3Dev1ApiClientImpl.viewLocationXml(postResponse.getLocation(), accessToken);
assertEquals(Response.Status.OK.getStatusCode(), getResponse.getStatus());
Service gotService = getResponse.getEntity(Service.class);
assertEquals("department-name", gotService.getDepartmentName());
assertEquals("role-title", gotService.getRoleTitle());
gotService.setDepartmentName("updated dept. name");
gotService.setRoleTitle("updated role title");
String profileCreateToken = oauthHelper.getClientCredentialsAccessToken(this.getClient2ClientId(), this.getClient2ClientSecret(), ScopePathType.ORCID_PROFILE_CREATE);
ClientResponse putResponse = memberV3Dev1ApiClientImpl.updateLocationXml(postResponse.getLocation(), profileCreateToken, gotService);
assertEquals(Response.Status.FORBIDDEN.getStatusCode(), putResponse.getStatus());
ClientResponse getAfterUpdateResponse = memberV3Dev1ApiClientImpl.viewLocationXml(postResponse.getLocation(), accessToken);
assertEquals(Response.Status.OK.getStatusCode(), getAfterUpdateResponse.getStatus());
Service gotAfterUpdateService = getAfterUpdateResponse.getEntity(Service.class);
assertEquals("department-name", gotAfterUpdateService.getDepartmentName());
assertEquals("role-title", gotAfterUpdateService.getRoleTitle());
ClientResponse deleteResponse = memberV3Dev1ApiClientImpl.deleteServiceXml(this.getUser1OrcidId(), gotService.getPutCode(), accessToken);
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), deleteResponse.getStatus());
}
Aggregations