mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-12 16:06:15 +00:00
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:
commit
70daddc76f
@ -189,10 +189,10 @@ class DropdownToolbar extends javax.swing.JPanel {
|
|||||||
* schema version and selectively enable the ad
|
* schema version and selectively enable the ad
|
||||||
* hoc search UI components.
|
* hoc search UI components.
|
||||||
*/
|
*/
|
||||||
boolean schemaIsCurrent = IndexFinder.getCurrentSchemaVersion().equals(indexInfo.getSchemaVersion());
|
boolean schemaIsCompatible = indexInfo.isCompatible(IndexFinder.getCurrentSchemaVersion());
|
||||||
listsButton.setEnabled(schemaIsCurrent);
|
listsButton.setEnabled(schemaIsCompatible);
|
||||||
searchDropButton.setEnabled(true);
|
searchDropButton.setEnabled(true);
|
||||||
dropPanel.setRegexSearchEnabled(schemaIsCurrent);
|
dropPanel.setRegexSearchEnabled(schemaIsCompatible);
|
||||||
active = true;
|
active = true;
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
|
@ -20,6 +20,7 @@ package org.sleuthkit.autopsy.keywordsearch;
|
|||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import org.apache.commons.lang.math.NumberUtils;
|
||||||
import org.sleuthkit.autopsy.coreutils.UNCPathUtilities;
|
import org.sleuthkit.autopsy.coreutils.UNCPathUtilities;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -133,4 +134,20 @@ final class Index {
|
|||||||
String getIndexName() {
|
String getIndexName() {
|
||||||
return indexName;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -164,7 +164,7 @@ public final class KeywordSearchIngestModule implements FileIngestModule {
|
|||||||
if (!IndexFinder.getCurrentSolrVersion().equals(indexInfo.getSolrVersion())) {
|
if (!IndexFinder.getCurrentSolrVersion().equals(indexInfo.getSolrVersion())) {
|
||||||
throw new IngestModuleException(Bundle.KeywordSearchIngestModule_startupException_indexSolrVersionNotSupported(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()));
|
throw new IngestModuleException(Bundle.KeywordSearchIngestModule_startupException_indexSchemaNotSupported(indexInfo.getSchemaVersion()));
|
||||||
}
|
}
|
||||||
} catch (NoOpenCoreException ex) {
|
} catch (NoOpenCoreException ex) {
|
||||||
|
@ -325,8 +325,8 @@ public class SolrSearchService implements KeywordSearchService, AutopsyService {
|
|||||||
double currentSolrVersion = NumberUtils.toDouble(IndexFinder.getCurrentSolrVersion());
|
double currentSolrVersion = NumberUtils.toDouble(IndexFinder.getCurrentSolrVersion());
|
||||||
double indexSolrVersion = NumberUtils.toDouble(indexToUse.getSolrVersion());
|
double indexSolrVersion = NumberUtils.toDouble(indexToUse.getSolrVersion());
|
||||||
if (indexSolrVersion == currentSolrVersion) {
|
if (indexSolrVersion == currentSolrVersion) {
|
||||||
// latest Solr version but not latest schema. index should be used in read-only mode
|
// latest Solr version but schema not compatible. index should be used in read-only mode
|
||||||
if (RuntimeProperties.runningWithGUI()) {
|
if (!indexToUse.isCompatible(IndexFinder.getCurrentSchemaVersion()) && RuntimeProperties.runningWithGUI()) {
|
||||||
// pop up a message box to indicate the read-only restrictions.
|
// pop up a message box to indicate the read-only restrictions.
|
||||||
JOptionPane optionPane = new JOptionPane(
|
JOptionPane optionPane = new JOptionPane(
|
||||||
NbBundle.getMessage(this.getClass(), "SolrSearchService.IndexReadOnlyDialog.msg"),
|
NbBundle.getMessage(this.getClass(), "SolrSearchService.IndexReadOnlyDialog.msg"),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user