Revision 7574
Added by Jing Tao over 11 years ago
metacat-index/src/main/java/edu/ucsb/nceas/metacat/index/SolrIndex.java | ||
---|---|---|
61 | 61 |
import org.dataone.cn.indexer.solrhttp.SolrDoc; |
62 | 62 |
import org.dataone.cn.indexer.solrhttp.SolrElementAdd; |
63 | 63 |
import org.dataone.cn.indexer.solrhttp.SolrElementField; |
64 |
import org.dataone.configuration.Settings; |
|
64 | 65 |
import org.dataone.service.types.v1.SystemMetadata; |
65 | 66 |
import org.dataone.service.util.TypeMarshaller; |
66 | 67 |
import org.jibx.runtime.JiBXException; |
... | ... | |
74 | 75 |
*/ |
75 | 76 |
public class SolrIndex { |
76 | 77 |
|
77 |
private static final String SOLRHOMEPATH = "/Users/tao/Downloads/apache-solr-3.4.0/example/solr"; |
|
78 | 78 |
|
79 |
|
|
79 | 80 |
public static final String SOLRHOME = "solr.solr.home"; |
81 |
public static final String SOLRHOMEPROPERTYNAME = "solr.homeDir"; |
|
82 |
|
|
83 |
private static final String SOLRINDEXWEBCONTEXT = "metacat-index"; |
|
80 | 84 |
private static final String SOLRSERVERNAME = "metacat-core"; |
85 |
//private static final String DEFAULTSOLRHOMEPATH = "/Users/tao/Downloads/apache-solr-3.4.0/example/solr"; |
|
81 | 86 |
|
82 |
|
|
83 | 87 |
private List<IDocumentSubprocessor> subprocessors = null; |
84 | 88 |
private SolrServer solrServer = null; |
85 | 89 |
private XMLNamespaceConfig xmlNamespaceConfig = null; |
... | ... | |
118 | 122 |
} |
119 | 123 |
|
120 | 124 |
private void initSolrServer() throws IOException, ParserConfigurationException, SAXException { |
121 |
System.setProperty(SOLRHOME, SOLRHOMEPATH); |
|
125 |
String solrHomeDir = null; |
|
126 |
solrHomeDir = Settings.getConfiguration().getString(SOLRHOMEPROPERTYNAME); |
|
127 |
log.info("========================= the solr home from the metacat.properties is "+solrHomeDir); |
|
128 |
if(solrHomeDir == null || solrHomeDir.trim().equals("")) { |
|
129 |
String deployDir = Settings.getConfiguration().getString("application.deployDir"); |
|
130 |
if(deployDir == null || deployDir.trim().equals("")) { |
|
131 |
solrHomeDir = SOLRINDEXWEBCONTEXT+"/WEB-INF/classes/solr-home"; |
|
132 |
} else { |
|
133 |
solrHomeDir = deployDir + "/" +SOLRINDEXWEBCONTEXT+"/WEB-INF/classes/solr-home"; |
|
134 |
} |
|
135 |
|
|
136 |
} |
|
137 |
log.info("==========================================final solr home is "+solrHomeDir); |
|
138 |
System.setProperty(SOLRHOME, solrHomeDir); |
|
122 | 139 |
CoreContainer.Initializer init = new CoreContainer.Initializer(); |
123 | 140 |
CoreContainer c = init.initialize(); |
124 | 141 |
solrServer = new EmbeddedSolrServer(c, "collection1"); |
... | ... | |
332 | 349 |
} |
333 | 350 |
|
334 | 351 |
/** |
335 |
* Set the solrServer |
|
352 |
* Set the solrServer. This method is only for setting a test solr server in the junit test.
|
|
336 | 353 |
* @param solrServer |
337 | 354 |
*/ |
338 | 355 |
void setSolrServer(SolrServer solrServer) { |
Also available in: Unified diff
Get the solr home dir from the metacat.properties.