Merge pull request #4148 from esaunders/4253_solr_schema_compatibility

Added Index.isCompatible() method to determine whether a particular S…
This commit is contained in:
Richard Cordovano 2018-09-28 10:50:43 -04:00 committed by GitHub
commit 70daddc76f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 6 deletions

View File

@ -189,10 +189,10 @@ class DropdownToolbar extends javax.swing.JPanel {
* schema version and selectively enable the ad
* hoc search UI components.
*/
boolean schemaIsCurrent = IndexFinder.getCurrentSchemaVersion().equals(indexInfo.getSchemaVersion());
listsButton.setEnabled(schemaIsCurrent);
boolean schemaIsCompatible = indexInfo.isCompatible(IndexFinder.getCurrentSchemaVersion());
listsButton.setEnabled(schemaIsCompatible);
searchDropButton.setEnabled(true);
dropPanel.setRegexSearchEnabled(schemaIsCurrent);
dropPanel.setRegexSearchEnabled(schemaIsCompatible);
active = true;
} else {
/*

View File

@ -20,6 +20,7 @@ package org.sleuthkit.autopsy.keywordsearch;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.apache.commons.lang.math.NumberUtils;
import org.sleuthkit.autopsy.coreutils.UNCPathUtilities;
/**
@ -133,4 +134,20 @@ final class Index {
String getIndexName() {
return indexName;
}
/**
* Is the current Index instance compatible with the given version number
*
* @param version The version number to compare the current Index against
*
* @return true if the current major version number is equal to the given
* major version number, otherwise false
*/
boolean isCompatible(String version) {
// Versions are compatible if they have the same major version no
int currentMajorVersion = NumberUtils.toInt(schemaVersion.substring(0, schemaVersion.indexOf('.')));
int givenMajorVersion = NumberUtils.toInt(version.substring(0, version.indexOf('.')));
return currentMajorVersion == givenMajorVersion;
}
}

View File

@ -164,7 +164,7 @@ public final class KeywordSearchIngestModule implements FileIngestModule {
if (!IndexFinder.getCurrentSolrVersion().equals(indexInfo.getSolrVersion())) {
throw new IngestModuleException(Bundle.KeywordSearchIngestModule_startupException_indexSolrVersionNotSupported(indexInfo.getSolrVersion()));
}
if (!IndexFinder.getCurrentSchemaVersion().equals(indexInfo.getSchemaVersion())) {
if (!indexInfo.isCompatible(IndexFinder.getCurrentSchemaVersion())) {
throw new IngestModuleException(Bundle.KeywordSearchIngestModule_startupException_indexSchemaNotSupported(indexInfo.getSchemaVersion()));
}
} catch (NoOpenCoreException ex) {

View File

@ -325,8 +325,8 @@ public class SolrSearchService implements KeywordSearchService, AutopsyService {
double currentSolrVersion = NumberUtils.toDouble(IndexFinder.getCurrentSolrVersion());
double indexSolrVersion = NumberUtils.toDouble(indexToUse.getSolrVersion());
if (indexSolrVersion == currentSolrVersion) {
// latest Solr version but not latest schema. index should be used in read-only mode
if (RuntimeProperties.runningWithGUI()) {
// latest Solr version but schema not compatible. index should be used in read-only mode
if (!indexToUse.isCompatible(IndexFinder.getCurrentSchemaVersion()) && RuntimeProperties.runningWithGUI()) {
// pop up a message box to indicate the read-only restrictions.
JOptionPane optionPane = new JOptionPane(
NbBundle.getMessage(this.getClass(), "SolrSearchService.IndexReadOnlyDialog.msg"),