Project

General

Profile

« Previous | Next » 

Revision 53208

Reverted to revision 48064. Use solr7 branch for new solr

View differences:

OpenaireIdResolver.java
7 7
import org.apache.commons.logging.Log;
8 8
import org.apache.commons.logging.LogFactory;
9 9
import org.apache.solr.client.solrj.SolrQuery;
10
import org.apache.solr.client.solrj.impl.CloudSolrClient;
10
import org.apache.solr.client.solrj.impl.CloudSolrServer;
11 11
import org.apache.solr.client.solrj.response.QueryResponse;
12 12
import org.apache.solr.common.SolrDocument;
13 13
import org.apache.solr.common.SolrDocumentList;
......
47 47
	}
48 48

  
49 49
	protected List<String> findOriginalIds(final String id) {
50

  
50
		CloudSolrServer solrCore = null;
51 51
		final SolrQuery q = new SolrQuery("objidentifier:\"" + id + "\"");
52

  
53
		try (final CloudSolrClient solrCore = new CloudSolrClient.Builder().withZkHost(getIndexEndpoint()).build()) {
52
		QueryResponse response = null;
53
		try {
54
			solrCore = new CloudSolrServer(getIndexEndpoint());
54 55
			solrCore.setDefaultCollection(getPublicIndexCollection() + SOLR_COLLECTION_POSTFIX);
55
			final QueryResponse response = solrCore.query(q);
56
			response = solrCore.query(q);
56 57
			final SolrDocumentList results = response.getResults();
57 58
			if (results.isEmpty()) {
58 59
				log.debug("Query " + q + " returned 0 documents");
......
64 65
		} catch (final Exception e) {
65 66
			log.error("Can't get original ids for " + id + "\n ", e);
66 67
			throw new RuntimeException("Can't get original ids for " + id + "\n " + e);
68
		} finally {
69
			solrCore.shutdown();
67 70
		}
68 71
	}
69 72

  

Also available in: Unified diff