Project

General

Profile

« Previous | Next » 

Revision 7591

naive version of SolrServerFactory - no reflection. It returns an EmbeddedSolrServer implementation based on the solr.homeDir set in Settings class. https://projects.ecoinformatics.org/ecoinfo/issues/5883

View differences:

SolrIndex.java
27 27
package edu.ucsb.nceas.metacat.index;
28 28

  
29 29
import java.io.ByteArrayInputStream;
30
import java.io.File;
31 30
import java.io.IOException;
32 31
import java.io.InputStream;
33 32
import java.util.ArrayList;
......
50 49
import org.apache.commons.logging.LogFactory;
51 50
import org.apache.solr.client.solrj.SolrServer;
52 51
import org.apache.solr.client.solrj.SolrServerException;
53
import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer;
54
//import org.apache.solr.client.solrj.impl.HttpSolrServer;
55 52
import org.apache.solr.client.solrj.response.UpdateResponse;
56 53
import org.apache.solr.common.SolrInputDocument;
57
import org.apache.solr.core.CoreContainer;
58 54
import org.dataone.cn.indexer.XMLNamespaceConfig;
59
import org.dataone.cn.indexer.XPathDocumentParser;
60 55
import org.dataone.cn.indexer.parser.IDocumentSubprocessor;
61 56
import org.dataone.cn.indexer.parser.SolrField;
62 57
import org.dataone.cn.indexer.solrhttp.SolrDoc;
63
import org.dataone.cn.indexer.solrhttp.SolrElementAdd;
64 58
import org.dataone.cn.indexer.solrhttp.SolrElementField;
65
import org.dataone.configuration.Settings;
66 59
import org.dataone.service.types.v1.Identifier;
67 60
import org.dataone.service.types.v1.SystemMetadata;
68 61
import org.dataone.service.util.TypeMarshaller;
......
76 69
 *
77 70
 */
78 71
public class SolrIndex {
79
    
80
    public static final String SOLRHOMEPROPERTYNAME = "solr.homeDir";
81
    
82
    //private static final String DEFAULTSOLRHOMEPATH = "/Users/tao/Downloads/apache-solr-3.4.0/example/solr";
83
    
72
            
84 73
    private List<IDocumentSubprocessor> subprocessors = null;
85 74
    private SolrServer solrServer = null;
86 75
    private XMLNamespaceConfig xmlNamespaceConfig = null;
......
114 103
                    throws XPathExpressionException, ParserConfigurationException, IOException, SAXException {
115 104
         this.xmlNamespaceConfig = xmlNamespaceConfig;
116 105
         this.sysmetaSolrFields = sysmetaSolrFields;
117
         initSolrServer();
118 106
         init();
119 107
    }
120 108
    
121
    private void initSolrServer() throws IOException, ParserConfigurationException, SAXException {
122
        String solrHomeDir = null;
123
        solrHomeDir = Settings.getConfiguration().getString(SOLRHOMEPROPERTYNAME);
124
        log.info("========================= the solr home from the metacat.properties is "+solrHomeDir);
125
        File configFile = new File(solrHomeDir, "solr.xml");
126
        CoreContainer c = new CoreContainer(solrHomeDir, configFile);
127
        c.load(solrHomeDir, configFile);
128
        solrServer = new EmbeddedSolrServer(c, "collection1");
129
    }
130
    
131 109
    private void init() throws ParserConfigurationException, XPathExpressionException {
132 110
        xpath.setNamespaceContext(xmlNamespaceConfig);
133 111
        initExpressions();

Also available in: Unified diff