use of org.apache.solr.client.solrj.SolrServerException in project ORCID-Source by ORCID.
the class SolrIndexUpdater method retrieveLastModified.
public Date retrieveLastModified(String orcid) {
SolrQuery query = new SolrQuery();
query.setQuery(ORCID + ":\"" + orcid + "\"");
query.setFields(PROFILE_LAST_MODIFIED_DATE);
try {
QueryResponse response = solrServer.query(query);
List<SolrDocument> results = response.getResults();
if (results.isEmpty()) {
return null;
} else {
return (Date) results.get(0).getFieldValue(PROFILE_LAST_MODIFIED_DATE);
}
} catch (SolrServerException e) {
throw new NonTransientDataAccessResourceException("Error retrieving last modified date from SOLR Server", e);
}
}
use of org.apache.solr.client.solrj.SolrServerException in project ORCID-Source by ORCID.
the class OrgDisambiguatedSolrDaoImpl method findById.
@Override
public OrgDisambiguatedSolrDocument findById(Long id) {
SolrQuery query = new SolrQuery();
query.setQuery(ORG_DISAMBIGUATED_ID + ":" + id).setFields("*");
try {
QueryResponse queryResponse = solrServerReadOnly.query(query);
if (!queryResponse.getResults().isEmpty()) {
OrgDisambiguatedSolrDocument document = queryResponse.getBeans(OrgDisambiguatedSolrDocument.class).get(0);
return document;
}
} catch (SolrServerException se) {
String errorMessage = MessageFormat.format("Error when attempting to retrieve org {0}", new Object[] { id });
throw new NonTransientDataAccessResourceException(errorMessage, se);
}
return null;
}
use of org.apache.solr.client.solrj.SolrServerException in project ORCID-Source by ORCID.
the class SolrDaoImpl method persist.
@Override
public void persist(OrcidSolrDocument orcidSolrDocument) {
try {
solrServer.addBean(orcidSolrDocument);
solrServer.commit();
} catch (SolrServerException se) {
throw new NonTransientDataAccessResourceException("Error persisting to SOLR Server", se);
} catch (IOException ioe) {
throw new NonTransientDataAccessResourceException("IOException when persisting to SOLR", ioe);
}
}
use of org.apache.solr.client.solrj.SolrServerException in project ORCID-Source by ORCID.
the class SolrDaoImpl method findByOrcidAsReader.
@Override
public Reader findByOrcidAsReader(String orcid) {
SolrQuery query = new SolrQuery();
query.setQuery(ORCID + ":\"" + orcid + "\"").setFields(SCORE, ORCID, PUBLIC_PROFILE);
query.add("wt", "orcidProfile");
try {
QueryResponse queryResponse = solrServerForStreaming.query(query);
InputStream inputStream = (InputStream) queryResponse.getResponse().get("stream");
return new InputStreamReader(inputStream, "UTF-8");
} catch (SolrServerException | SolrException e) {
String errorMessage = MessageFormat.format("Error when attempting to retrieve stream for orcid {0}", new Object[] { orcid });
throw new NonTransientDataAccessResourceException(errorMessage, e);
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
}
use of org.apache.solr.client.solrj.SolrServerException in project ORCID-Source by ORCID.
the class SolrDaoImpl method retrieveLastModified.
@Override
public Date retrieveLastModified(String orcid) {
SolrQuery query = new SolrQuery();
query.setQuery(ORCID + ":\"" + orcid + "\"");
query.setFields(PROFILE_LAST_MODIFIED_DATE);
try {
QueryResponse response = solrServer.query(query);
List<SolrDocument> results = response.getResults();
if (results.isEmpty()) {
return null;
} else {
return (Date) results.get(0).getFieldValue(PROFILE_LAST_MODIFIED_DATE);
}
} catch (SolrServerException e) {
throw new NonTransientDataAccessResourceException("Error retrieving last modified date from SOLR Server", e);
}
}
Aggregations