From 3a546b7a4ecef983e35f6a4219e2e5f60442519c Mon Sep 17 00:00:00 2001 From: Eugene Livis Date: Tue, 31 Jan 2017 15:24:56 -0500 Subject: [PATCH] Reusing Solr4 core name for upgrdaed Solr6 cores. Code cleanup --- .../autopsy/keywordsearch/Index.java | 16 --------------- .../autopsy/keywordsearch/IndexUpgrader.java | 1 - .../autopsy/keywordsearch/Server.java | 20 +++++-------------- .../keywordsearch/SolrSearchService.java | 1 - 4 files changed, 5 insertions(+), 33 deletions(-) diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Index.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Index.java index e979474352..fd96a567cb 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Index.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Index.java @@ -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; - } } diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/IndexUpgrader.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/IndexUpgrader.java index 66c4b5fe90..eac2fc2212 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/IndexUpgrader.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/IndexUpgrader.java @@ -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) { diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Server.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Server.java index c924a95096..3787ef7da0 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Server.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Server.java @@ -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; } diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/SolrSearchService.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/SolrSearchService.java index ea5b20b10f..941590bec2 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/SolrSearchService.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/SolrSearchService.java @@ -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++;