use of org.orcid.jaxb.model.v3.dev1.record.Distinction in project ORCID-Source by ORCID.
the class AffiliationsManagerTest method testAddDistinctionToUnclaimedRecordPreserveDistinctionVisibility.
@Test
public void testAddDistinctionToUnclaimedRecordPreserveDistinctionVisibility() {
when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID)));
Distinction element = getDistinction();
element = affiliationsManager.createDistinctionAffiliation(unclaimedOrcid, element, true);
element = affiliationsManager.getDistinctionAffiliation(unclaimedOrcid, element.getPutCode());
assertNotNull(element);
assertEquals(Visibility.PUBLIC, element.getVisibility());
}
use of org.orcid.jaxb.model.v3.dev1.record.Distinction in project ORCID-Source by ORCID.
the class AffiliationsManagerTest method getDistinction.
private Distinction getDistinction() {
Distinction element = new Distinction();
fillAffiliation(element);
return element;
}
use of org.orcid.jaxb.model.v3.dev1.record.Distinction in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegatorImpl method viewDistinction.
@Override
public Response viewDistinction(String orcid, Long putCode) {
Distinction e = affiliationsManagerReadOnly.getDistinctionAffiliation(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.Distinction in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegatorImpl method updateDistinction.
@Override
public Response updateDistinction(String orcid, Long putCode, Distinction distinction) {
orcidSecurityManager.checkClientAccessAndScopes(orcid, ScopePathType.AFFILIATIONS_UPDATE);
if (!putCode.equals(distinction.getPutCode())) {
Map<String, String> params = new HashMap<String, String>();
params.put("urlPutCode", String.valueOf(putCode));
params.put("bodyPutCode", String.valueOf(distinction.getPutCode()));
throw new MismatchedPutCodeException(params);
}
clearSource(distinction);
Distinction e = affiliationsManager.updateDistinctionAffiliation(orcid, distinction, true);
sourceUtils.setSourceName(e);
return Response.ok(e).build();
}
use of org.orcid.jaxb.model.v3.dev1.record.Distinction in project ORCID-Source by ORCID.
the class MemberV3Dev1Test method testUpdateDistinctionWithProfileCreationTokenWhenClaimedAndNotSource.
@Test
public void testUpdateDistinctionWithProfileCreationTokenWhenClaimedAndNotSource() throws JSONException, InterruptedException, URISyntaxException {
Distinction distinction = (Distinction) unmarshallFromPath("/record_3.0_dev1/samples/read_samples/distinction-3.0_dev1.xml", Distinction.class);
distinction.setPutCode(null);
distinction.setVisibility(Visibility.PUBLIC);
String accessToken = getAccessToken();
ClientResponse postResponse = memberV3Dev1ApiClientImpl.createDistinctionXml(this.getUser1OrcidId(), distinction, 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() + "/distinction/\\d+"));
ClientResponse getResponse = memberV3Dev1ApiClientImpl.viewLocationXml(postResponse.getLocation(), accessToken);
assertEquals(Response.Status.OK.getStatusCode(), getResponse.getStatus());
Distinction gotDistinction = getResponse.getEntity(Distinction.class);
assertEquals("department-name", gotDistinction.getDepartmentName());
assertEquals("role-title", gotDistinction.getRoleTitle());
gotDistinction.setDepartmentName("updated dept. name");
gotDistinction.setRoleTitle("updated role title");
String profileCreateToken = oauthHelper.getClientCredentialsAccessToken(this.getClient2ClientId(), this.getClient2ClientSecret(), ScopePathType.ORCID_PROFILE_CREATE);
ClientResponse putResponse = memberV3Dev1ApiClientImpl.updateLocationXml(postResponse.getLocation(), profileCreateToken, gotDistinction);
assertEquals(Response.Status.FORBIDDEN.getStatusCode(), putResponse.getStatus());
ClientResponse getAfterUpdateResponse = memberV3Dev1ApiClientImpl.viewLocationXml(postResponse.getLocation(), accessToken);
assertEquals(Response.Status.OK.getStatusCode(), getAfterUpdateResponse.getStatus());
Distinction gotAfterUpdateDistinction = getAfterUpdateResponse.getEntity(Distinction.class);
assertEquals("department-name", gotAfterUpdateDistinction.getDepartmentName());
assertEquals("role-title", gotAfterUpdateDistinction.getRoleTitle());
ClientResponse deleteResponse = memberV3Dev1ApiClientImpl.deleteDistinctionXml(this.getUser1OrcidId(), gotDistinction.getPutCode(), accessToken);
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), deleteResponse.getStatus());
}
Aggregations