Search in sources :

Example 1 with OrcidMessage

use of org.orcid.jaxb.model.message.OrcidMessage in project ORCID-Source by ORCID.

the class OrcidApiServiceDelegatorImpl method searchByQuery.

/**
     * See {@link OrcidApiServiceDelegator}{@link #searchByQuery(Map)}
     */
@Override
@VisibilityControl
public Response searchByQuery(Map<String, List<String>> queryMap) {
    validateSearchParams(queryMap);
    OrcidMessage orcidMessage = orcidSearchManager.findOrcidsByQuery(queryMap);
    List<OrcidSearchResult> searchResults = orcidMessage.getOrcidSearchResults() != null ? orcidMessage.getOrcidSearchResults().getOrcidSearchResult() : null;
    List<OrcidSearchResult> filteredResults = new ArrayList<OrcidSearchResult>();
    OrcidSearchResults orcidSearchResults = new OrcidSearchResults();
    if (searchResults != null) {
        orcidSearchResults.setNumFound(orcidMessage.getOrcidSearchResults().getNumFound());
        if (searchResults.size() > 0) {
            for (OrcidSearchResult searchResult : searchResults) {
                OrcidSearchResult filteredSearchResult = new OrcidSearchResult();
                OrcidProfile filteredProfile = new OrcidProfile();
                filteredSearchResult.setRelevancyScore(searchResult.getRelevancyScore());
                filteredProfile.setOrcid(searchResult.getOrcidProfile().getOrcid());
                filteredProfile.setOrcidId(searchResult.getOrcidProfile().getOrcidId());
                filteredProfile.setOrcidIdentifier(searchResult.getOrcidProfile().getOrcidIdentifier());
                filteredProfile.setOrcidBio(searchResult.getOrcidProfile().getOrcidBio());
                filteredSearchResult.setOrcidProfile(filteredProfile);
                filteredResults.add(filteredSearchResult);
            }
        }
    }
    orcidSearchResults.getOrcidSearchResult().addAll(filteredResults);
    return getOrcidSearchResultsResponse(orcidSearchResults, queryMap.toString());
}
Also used : OrcidSearchResult(org.orcid.jaxb.model.message.OrcidSearchResult) OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) OrcidSearchResults(org.orcid.jaxb.model.message.OrcidSearchResults) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) ArrayList(java.util.ArrayList) VisibilityControl(org.orcid.core.security.visibility.aop.VisibilityControl)

Example 2 with OrcidMessage

use of org.orcid.jaxb.model.message.OrcidMessage in project ORCID-Source by ORCID.

the class OrcidExceptionMapper method getLegacyOrcidEntity.

private OrcidMessage getLegacyOrcidEntity(String prefix, Throwable e) {
    OrcidMessage entity = new OrcidMessage();
    entity.setMessageVersion(OrcidMessage.DEFAULT_VERSION);
    if (e != null && !PojoUtil.isEmpty(e.getMessage()))
        entity.setErrorDesc(new ErrorDesc(prefix + e.getMessage()));
    else
        entity.setErrorDesc(new ErrorDesc(prefix));
    return entity;
}
Also used : ErrorDesc(org.orcid.jaxb.model.message.ErrorDesc) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage)

Example 3 with OrcidMessage

use of org.orcid.jaxb.model.message.OrcidMessage in project ORCID-Source by ORCID.

the class OrcidExceptionMapper method getLegacy500OrcidEntity.

private OrcidMessage getLegacy500OrcidEntity(Throwable e) {
    OrcidMessage entity = new OrcidMessage();
    entity.setMessageVersion(OrcidMessage.DEFAULT_VERSION);
    entity.setErrorDesc(new ErrorDesc(StringUtils.isNotBlank(e.getMessage()) ? e.getMessage() : messageSource.getMessage("apiError.unknown.exception", null, localeManager.getLocale())));
    return entity;
}
Also used : ErrorDesc(org.orcid.jaxb.model.message.ErrorDesc) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage)

Example 4 with OrcidMessage

use of org.orcid.jaxb.model.message.OrcidMessage in project ORCID-Source by ORCID.

the class OrcidApiServiceVersionedDelegatorImpl method validateOutgoingResponse.

private void validateOutgoingResponse(Response response) {
    OrcidMessage orcidMessage = (OrcidMessage) response.getEntity();
    outgoingValidationManager.validateMessage(orcidMessage);
}
Also used : OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage)

Example 5 with OrcidMessage

use of org.orcid.jaxb.model.message.OrcidMessage in project ORCID-Source by ORCID.

the class OrcidValidationJaxbContextResolver method getResponse.

private Response getResponse(Throwable e) {
    OrcidMessage entity = new OrcidMessage();
    entity.setErrorDesc(new ErrorDesc(e.getMessage()));
    return Response.serverError().entity(entity).build();
}
Also used : ErrorDesc(org.orcid.jaxb.model.message.ErrorDesc) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage)

Aggregations

OrcidMessage (org.orcid.jaxb.model.message.OrcidMessage)173 Test (org.junit.Test)108 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)64 DBUnitTest (org.orcid.test.DBUnitTest)49 ClientResponse (com.sun.jersey.api.client.ClientResponse)36 Response (javax.ws.rs.core.Response)26 OrcidWork (org.orcid.jaxb.model.message.OrcidWork)22 Transactional (org.springframework.transaction.annotation.Transactional)22 OrcidActivities (org.orcid.jaxb.model.message.OrcidActivities)20 OrcidBio (org.orcid.jaxb.model.message.OrcidBio)19 Email (org.orcid.jaxb.model.message.Email)18 BaseTest (org.orcid.core.BaseTest)17 OrcidIdentifier (org.orcid.jaxb.model.message.OrcidIdentifier)16 Affiliation (org.orcid.jaxb.model.message.Affiliation)13 OrcidSearchResult (org.orcid.jaxb.model.message.OrcidSearchResult)12 WorkExternalIdentifier (org.orcid.jaxb.model.message.WorkExternalIdentifier)12 JAXBContext (javax.xml.bind.JAXBContext)11 Unmarshaller (javax.xml.bind.Unmarshaller)11 Organization (org.orcid.jaxb.model.message.Organization)11 OrganizationAddress (org.orcid.jaxb.model.message.OrganizationAddress)11