Search in sources :

Example 6 with OrcidIdentifier

use of org.orcid.jaxb.model.v3.dev1.common.OrcidIdentifier in project ORCID-Source by ORCID.

the class OrcidIdentifierUtils method buildOrcidIdentifier.

public OrcidIdentifier buildOrcidIdentifier(String orcid) {
    OrcidIdentifier identifier = new OrcidIdentifier();
    String correctedBaseUri = baseUri;
    if (!Features.HTTPS_IDS.isActive()) {
        correctedBaseUri = correctedBaseUri.replace("https", "http");
    }
    try {
        URI uri = new URI(correctedBaseUri);
        identifier.setHost(uri.getHost());
    } catch (URISyntaxException e) {
        throw new RuntimeException("Error parsing base uri", e);
    }
    identifier.setPath(orcid);
    identifier.setUri(correctedBaseUri + "/" + orcid);
    return identifier;
}
Also used : OrcidIdentifier(org.orcid.jaxb.model.v3.dev1.common.OrcidIdentifier) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI)

Example 7 with OrcidIdentifier

use of org.orcid.jaxb.model.v3.dev1.common.OrcidIdentifier in project ORCID-Source by ORCID.

the class PublicV3ApiServiceDelegatorTest method testSearchByQuery.

@Test
public void testSearchByQuery() {
    Search search = new Search();
    Result result = new Result();
    result.setOrcidIdentifier(new OrcidIdentifier("some-orcid-id"));
    search.getResults().add(result);
    OrcidSearchManager orcidSearchManager = Mockito.mock(OrcidSearchManagerImpl.class);
    Mockito.when(orcidSearchManager.findOrcidIds(Matchers.<Map<String, List<String>>>any())).thenReturn(search);
    PublicV3ApiServiceDelegatorImpl delegator = new PublicV3ApiServiceDelegatorImpl();
    ReflectionTestUtils.setField(delegator, "orcidSearchManager", orcidSearchManager);
    OrcidSecurityManager orcidSecurityManager = Mockito.mock(OrcidSecurityManagerImpl.class);
    Mockito.when(orcidSecurityManager.getClientIdFromAPIRequest()).thenReturn(null);
    ReflectionTestUtils.setField(delegator, "orcidSecurityManager", orcidSecurityManager);
    Response response = delegator.searchByQuery(new HashMap<String, List<String>>());
    assertNotNull(response);
    assertNotNull(response.getEntity());
    assertTrue(response.getEntity() instanceof Search);
    assertEquals(1, ((Search) response.getEntity()).getResults().size());
    assertEquals("some-orcid-id", ((Search) response.getEntity()).getResults().get(0).getOrcidIdentifier().getPath());
}
Also used : Response(javax.ws.rs.core.Response) OrcidIdentifier(org.orcid.jaxb.model.v3.dev1.common.OrcidIdentifier) PublicV3ApiServiceDelegatorImpl(org.orcid.api.publicV3.server.delegator.impl.PublicV3ApiServiceDelegatorImpl) Search(org.orcid.jaxb.model.v3.dev1.search.Search) OrcidSecurityManager(org.orcid.core.manager.v3.OrcidSecurityManager) ArrayList(java.util.ArrayList) List(java.util.List) OrcidSearchManager(org.orcid.core.manager.v3.OrcidSearchManager) Result(org.orcid.jaxb.model.v3.dev1.search.Result) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 8 with OrcidIdentifier

use of org.orcid.jaxb.model.v3.dev1.common.OrcidIdentifier in project ORCID-Source by ORCID.

the class RecordManagerReadOnlyImpl method getOrcidIdentifier.

@Override
public OrcidIdentifier getOrcidIdentifier(String orcid) {
    OrcidIdentifier orcidIdentifier = new OrcidIdentifier();
    orcidIdentifier.setPath(orcid);
    orcidIdentifier.setHost(orcidUrlManager.getBaseHost());
    orcidIdentifier.setUri(orcidUrlManager.getBaseUrl() + "/" + orcid);
    return orcidIdentifier;
}
Also used : OrcidIdentifier(org.orcid.jaxb.model.v3.dev1.common.OrcidIdentifier)

Aggregations

OrcidIdentifier (org.orcid.jaxb.model.v3.dev1.common.OrcidIdentifier)8 Test (org.junit.Test)5 Response (javax.ws.rs.core.Response)4 List (java.util.List)3 OrcidSecurityManager (org.orcid.core.manager.v3.OrcidSecurityManager)3 DBUnitTest (org.orcid.test.DBUnitTest)3 ArrayList (java.util.ArrayList)2 OrcidSearchManager (org.orcid.core.manager.v3.OrcidSearchManager)2 GroupIdRecord (org.orcid.jaxb.model.groupid_v2.GroupIdRecord)2 History (org.orcid.jaxb.model.v3.dev1.record.History)2 Record (org.orcid.jaxb.model.v3.dev1.record.Record)2 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 Arrays (java.util.Arrays)1 Date (java.util.Date)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 IntStream (java.util.stream.IntStream)1 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)1 StringUtils (org.apache.commons.lang3.StringUtils)1