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