Reusing Solr4 core name for upgrdaed Solr6 cores. Code cleanup

This commit is contained in:
Eugene Livis 2017-01-31 15:24:56 -05:00
parent 92d27e0838
commit 3a546b7a4e
4 changed files with 5 additions and 33 deletions

View File

@ -26,13 +26,11 @@ class Index {
private final String indexPath;
private final String schemaVersion;
private final String solrVersion;
private boolean newIndex;
Index(String indexPath, String solrVersion, String schemaVersion) {
this.indexPath = indexPath;
this.solrVersion = solrVersion;
this.schemaVersion = schemaVersion;
newIndex = false;
}
/**
@ -55,18 +53,4 @@ class Index {
String getSolrVersion() {
return solrVersion;
}
/**
* @return the newIndex
*/
boolean isNewIndex() {
return newIndex;
}
/**
* @param newIndex the newIndex to set
*/
void setNewIndex(boolean newIndex) {
this.newIndex = newIndex;
}
}

View File

@ -105,7 +105,6 @@ class IndexUpgrader {
// create upgraded index object
upgradedIndex = new Index(newIndexDir, Integer.toString(currentSolrVersion), indexToUpgrade.getSchemaVersion());
upgradedIndex.setNewIndex(true);
return upgradedIndex;
} catch (Exception ex) {

View File

@ -806,8 +806,6 @@ public class Server {
}
try {
String coreName = getCoreName(index, theCase);
File dataDir = new File(new File(index.getIndexPath()).getParent()); // "data dir" is the parent of the index directory
if (!dataDir.exists()) {
dataDir.mkdirs();
@ -818,6 +816,7 @@ public class Server {
throw new KeywordSearchModuleException(NbBundle.getMessage(this.getClass(), "Server.openCore.exception.msg"));
}
String coreName = getCoreName(theCase);
if (!coreIsLoaded(coreName)) {
/*
* The core either does not exist or it is not loaded. Make a
@ -861,27 +860,18 @@ public class Server {
/**
* Get or create a sanitized Solr core name. Stores the core name if needed.
*
* @param index Index object
* @param theCase Case object
*
* @return The sanitized Solr core name
*/
private String getCoreName(Index index, Case theCase) throws CaseMetadata.CaseMetadataException {
String coreName = "";
if (index.isNewIndex()) {
private String getCoreName(Case theCase) throws CaseMetadata.CaseMetadataException {
// get core name
String coreName = theCase.getTextIndexName();
if (coreName == null || coreName.isEmpty()) {
// come up with a new core name
coreName = createCoreName(theCase.getName());
// store the new core name
theCase.setTextIndexName(coreName);
} else {
// get core name
coreName = theCase.getTextIndexName();
if (coreName.isEmpty()) {
// come up with a new core name
coreName = createCoreName(theCase.getName());
// store the new core name
theCase.setTextIndexName(coreName);
}
}
return coreName;
}

View File

@ -196,7 +196,6 @@ public class SolrSearchService implements KeywordSearchService, AutopsyService {
progressUnitsCompleted++;
progress.progress(Bundle.SolrSearch_creatingNewIndex_msg(), progressUnitsCompleted);
currentVersionIndex = IndexFinder.createLatestVersionIndexDir(context.getCase());
currentVersionIndex.setNewIndex(true);
} else {
// check if one of the existing indexes is for latest Solr version and schema
progressUnitsCompleted++;