SOLR-6194: Allow access to DataImporter and DIHConfiguration from DataImportHandler

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1605972 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Shalin Shekhar Mangar 2014-06-27 07:26:36 +00:00
parent d91568be77
commit ac2e3998a3
3 changed files with 18 additions and 9 deletions

View File

@ -121,6 +121,9 @@ Other Changes
* SOLR-5902: Corecontainer level mbeans are not exposed (noble)
* SOLR-6194: Allow access to DataImporter and DIHConfiguration from DataImportHandler.
(Aaron LaBella via shalin)
================== 4.9.0 ==================
Versions of Major Components

View File

@ -81,6 +81,10 @@ public class DataImportHandler extends RequestHandlerBase implements
private static final String PARAM_WRITER_IMPL = "writerImpl";
private static final String DEFAULT_WRITER_NAME = "SolrWriter";
public DataImporter getImporter() {
return this.importer;
}
@Override
@SuppressWarnings("unchecked")

View File

@ -127,7 +127,7 @@ public class DataImporter {
LOG.info("Loading DIH Configuration: " + dataconfigFile);
}
if(is!=null) {
loadDataConfig(is);
config = loadDataConfig(is);
success = true;
}
@ -174,16 +174,17 @@ public class DataImporter {
public IndexSchema getSchema() {
return schema;
}
/**
* Used by tests
*/
void loadAndInit(String configStr) {
loadDataConfig(new InputSource(new StringReader(configStr)));
}
public void loadAndInit(String configStr) {
config = loadDataConfig(new InputSource(new StringReader(configStr)));
}
private void loadDataConfig(InputSource configFile) {
public DIHConfiguration loadDataConfig(InputSource configFile) {
DIHConfiguration dihcfg = null;
try {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
@ -209,18 +210,19 @@ public class DataImporter {
IOUtils.closeQuietly(configFile.getByteStream());
}
config = readFromXml(document);
dihcfg = readFromXml(document);
LOG.info("Data Configuration loaded successfully");
} catch (Exception e) {
throw new DataImportHandlerException(SEVERE,
"Data Config problem: " + e.getMessage(), e);
}
for (Entity e : config.getEntities()) {
for (Entity e : dihcfg.getEntities()) {
if (e.getAllAttributes().containsKey(SqlEntityProcessor.DELTA_QUERY)) {
isDeltaImportSupported = true;
break;
}
}
return dihcfg;
}
public DIHConfiguration readFromXml(Document xmlDocument) {
@ -327,7 +329,7 @@ public class DataImporter {
return propWriter;
}
DIHConfiguration getConfig() {
public DIHConfiguration getConfig() {
return config;
}