Search in sources :

Example 96 with OtherName

use of org.orcid.jaxb.model.record_rc3.OtherName in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegatorImpl method viewOtherName.

@Override
public Response viewOtherName(String orcid, Long putCode) {
    OtherName otherName = otherNameManagerReadOnly.getOtherName(orcid, putCode);
    orcidSecurityManager.checkAndFilter(orcid, otherName, ScopePathType.ORCID_BIO_READ_LIMITED);
    ElementUtils.setPathToOtherName(otherName, orcid);
    sourceUtils.setSourceName(otherName);
    return Response.ok(otherName).build();
}
Also used : OtherName(org.orcid.jaxb.model.record_v2.OtherName)

Example 97 with OtherName

use of org.orcid.jaxb.model.record_rc3.OtherName in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_OtherNamesTest method testUpdateOtherNameLeavingVisibilityNullTest.

@Test
public void testUpdateOtherNameLeavingVisibilityNullTest() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4443", ScopePathType.PERSON_READ_LIMITED, ScopePathType.PERSON_UPDATE);
    Response response = serviceDelegator.viewOtherName("4444-4444-4444-4443", 1L);
    assertNotNull(response);
    OtherName otherName = (OtherName) response.getEntity();
    assertNotNull(otherName);
    assertEquals(Visibility.PUBLIC, otherName.getVisibility());
    otherName.setVisibility(null);
    response = serviceDelegator.updateOtherName("4444-4444-4444-4443", 1L, otherName);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    otherName = (OtherName) response.getEntity();
    assertNotNull(otherName);
    assertEquals(Visibility.PUBLIC, otherName.getVisibility());
}
Also used : Response(javax.ws.rs.core.Response) OtherName(org.orcid.jaxb.model.record_v2.OtherName) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 98 with OtherName

use of org.orcid.jaxb.model.record_rc3.OtherName in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_OtherNamesTest method testUpdateOtherNameYouAreNotTheSourceOf.

@Test(expected = WrongSourceException.class)
public void testUpdateOtherNameYouAreNotTheSourceOf() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4443", ScopePathType.PERSON_READ_LIMITED, ScopePathType.PERSON_UPDATE);
    Response response = serviceDelegator.viewOtherName("4444-4444-4444-4443", 2L);
    assertNotNull(response);
    OtherName otherName = (OtherName) response.getEntity();
    assertNotNull(otherName);
    assertEquals("Flibberdy Flabinah", otherName.getContent());
    assertEquals(Visibility.PUBLIC, otherName.getVisibility());
    otherName.setContent("Updated Other Name " + System.currentTimeMillis());
    serviceDelegator.updateOtherName("4444-4444-4444-4443", 2L, otherName);
    fail();
}
Also used : Response(javax.ws.rs.core.Response) OtherName(org.orcid.jaxb.model.record_v2.OtherName) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 99 with OtherName

use of org.orcid.jaxb.model.record_rc3.OtherName in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_OtherNamesTest method testViewLimitedOtherName.

@Test
public void testViewLimitedOtherName() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4446", ScopePathType.PERSON_READ_LIMITED);
    Response response = serviceDelegator.viewOtherName("4444-4444-4444-4446", 6L);
    assertNotNull(response);
    OtherName otherName = (OtherName) response.getEntity();
    assertNotNull(otherName);
    assertEquals("/4444-4444-4444-4446/other-names/6", otherName.getPath());
    Utils.verifyLastModified(otherName.getLastModifiedDate());
    assertEquals("Other Name # 2", otherName.getContent());
    assertEquals(Visibility.LIMITED, otherName.getVisibility());
    assertEquals("4444-4444-4444-4446", otherName.getSource().retrieveSourcePath());
}
Also used : Response(javax.ws.rs.core.Response) OtherName(org.orcid.jaxb.model.record_v2.OtherName) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 100 with OtherName

use of org.orcid.jaxb.model.record_rc3.OtherName in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_OtherNamesTest method testViewPrivateOtherName.

@Test
public void testViewPrivateOtherName() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4446", ScopePathType.PERSON_READ_LIMITED);
    Response response = serviceDelegator.viewOtherName("4444-4444-4444-4446", 8L);
    assertNotNull(response);
    OtherName otherName = (OtherName) response.getEntity();
    assertNotNull(otherName);
    assertEquals("/4444-4444-4444-4446/other-names/8", otherName.getPath());
    Utils.verifyLastModified(otherName.getLastModifiedDate());
    assertEquals("Other Name # 4", otherName.getContent());
    assertEquals(Visibility.PRIVATE, otherName.getVisibility());
    assertEquals("APP-5555555555555555", otherName.getSource().retrieveSourcePath());
}
Also used : Response(javax.ws.rs.core.Response) OtherName(org.orcid.jaxb.model.record_v2.OtherName) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Aggregations

OtherName (org.orcid.jaxb.model.record_v2.OtherName)114 Test (org.junit.Test)99 OtherNames (org.orcid.jaxb.model.record_v2.OtherNames)55 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)45 Biography (org.orcid.jaxb.model.record_v2.Biography)44 Address (org.orcid.jaxb.model.record_v2.Address)43 Keyword (org.orcid.jaxb.model.record_v2.Keyword)42 Name (org.orcid.jaxb.model.record_v2.Name)42 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)42 Email (org.orcid.jaxb.model.record_v2.Email)39 Addresses (org.orcid.jaxb.model.record_v2.Addresses)32 Emails (org.orcid.jaxb.model.record_v2.Emails)32 Keywords (org.orcid.jaxb.model.record_v2.Keywords)32 PersonExternalIdentifiers (org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers)32 ResearcherUrls (org.orcid.jaxb.model.record_v2.ResearcherUrls)32 Person (org.orcid.jaxb.model.record_v2.Person)30 ArrayList (java.util.ArrayList)23 DBUnitTest (org.orcid.test.DBUnitTest)22 Response (javax.ws.rs.core.Response)20 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)18