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;
}
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());
}
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;
}
Aggregations