mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-17 10:17:41 +00:00
Reusing Solr4 core name for upgrdaed Solr6 cores. Code cleanup
This commit is contained in:
parent
92d27e0838
commit
3a546b7a4e
@ -26,13 +26,11 @@ class Index {
|
|||||||
private final String indexPath;
|
private final String indexPath;
|
||||||
private final String schemaVersion;
|
private final String schemaVersion;
|
||||||
private final String solrVersion;
|
private final String solrVersion;
|
||||||
private boolean newIndex;
|
|
||||||
|
|
||||||
Index(String indexPath, String solrVersion, String schemaVersion) {
|
Index(String indexPath, String solrVersion, String schemaVersion) {
|
||||||
this.indexPath = indexPath;
|
this.indexPath = indexPath;
|
||||||
this.solrVersion = solrVersion;
|
this.solrVersion = solrVersion;
|
||||||
this.schemaVersion = schemaVersion;
|
this.schemaVersion = schemaVersion;
|
||||||
newIndex = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -55,18 +53,4 @@ class Index {
|
|||||||
String getSolrVersion() {
|
String getSolrVersion() {
|
||||||
return solrVersion;
|
return solrVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the newIndex
|
|
||||||
*/
|
|
||||||
boolean isNewIndex() {
|
|
||||||
return newIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param newIndex the newIndex to set
|
|
||||||
*/
|
|
||||||
void setNewIndex(boolean newIndex) {
|
|
||||||
this.newIndex = newIndex;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,6 @@ class IndexUpgrader {
|
|||||||
|
|
||||||
// create upgraded index object
|
// create upgraded index object
|
||||||
upgradedIndex = new Index(newIndexDir, Integer.toString(currentSolrVersion), indexToUpgrade.getSchemaVersion());
|
upgradedIndex = new Index(newIndexDir, Integer.toString(currentSolrVersion), indexToUpgrade.getSchemaVersion());
|
||||||
upgradedIndex.setNewIndex(true);
|
|
||||||
return upgradedIndex;
|
return upgradedIndex;
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
@ -806,8 +806,6 @@ public class Server {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String coreName = getCoreName(index, theCase);
|
|
||||||
|
|
||||||
File dataDir = new File(new File(index.getIndexPath()).getParent()); // "data dir" is the parent of the index directory
|
File dataDir = new File(new File(index.getIndexPath()).getParent()); // "data dir" is the parent of the index directory
|
||||||
if (!dataDir.exists()) {
|
if (!dataDir.exists()) {
|
||||||
dataDir.mkdirs();
|
dataDir.mkdirs();
|
||||||
@ -818,6 +816,7 @@ public class Server {
|
|||||||
throw new KeywordSearchModuleException(NbBundle.getMessage(this.getClass(), "Server.openCore.exception.msg"));
|
throw new KeywordSearchModuleException(NbBundle.getMessage(this.getClass(), "Server.openCore.exception.msg"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String coreName = getCoreName(theCase);
|
||||||
if (!coreIsLoaded(coreName)) {
|
if (!coreIsLoaded(coreName)) {
|
||||||
/*
|
/*
|
||||||
* The core either does not exist or it is not loaded. Make a
|
* 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.
|
* Get or create a sanitized Solr core name. Stores the core name if needed.
|
||||||
*
|
*
|
||||||
* @param index Index object
|
|
||||||
* @param theCase Case object
|
* @param theCase Case object
|
||||||
*
|
*
|
||||||
* @return The sanitized Solr core name
|
* @return The sanitized Solr core name
|
||||||
*/
|
*/
|
||||||
private String getCoreName(Index index, Case theCase) throws CaseMetadata.CaseMetadataException {
|
private String getCoreName(Case theCase) throws CaseMetadata.CaseMetadataException {
|
||||||
String coreName = "";
|
// get core name
|
||||||
if (index.isNewIndex()) {
|
String coreName = theCase.getTextIndexName();
|
||||||
|
if (coreName == null || coreName.isEmpty()) {
|
||||||
// come up with a new core name
|
// come up with a new core name
|
||||||
coreName = createCoreName(theCase.getName());
|
coreName = createCoreName(theCase.getName());
|
||||||
// store the new core name
|
// store the new core name
|
||||||
theCase.setTextIndexName(coreName);
|
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;
|
return coreName;
|
||||||
}
|
}
|
||||||
|
@ -196,7 +196,6 @@ public class SolrSearchService implements KeywordSearchService, AutopsyService {
|
|||||||
progressUnitsCompleted++;
|
progressUnitsCompleted++;
|
||||||
progress.progress(Bundle.SolrSearch_creatingNewIndex_msg(), progressUnitsCompleted);
|
progress.progress(Bundle.SolrSearch_creatingNewIndex_msg(), progressUnitsCompleted);
|
||||||
currentVersionIndex = IndexFinder.createLatestVersionIndexDir(context.getCase());
|
currentVersionIndex = IndexFinder.createLatestVersionIndexDir(context.getCase());
|
||||||
currentVersionIndex.setNewIndex(true);
|
|
||||||
} else {
|
} else {
|
||||||
// check if one of the existing indexes is for latest Solr version and schema
|
// check if one of the existing indexes is for latest Solr version and schema
|
||||||
progressUnitsCompleted++;
|
progressUnitsCompleted++;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user