mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-17 10:17:41 +00:00
More work
This commit is contained in:
parent
fc0fcfc3f1
commit
247b3c96aa
@ -28,7 +28,6 @@ import java.util.logging.Level;
|
|||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.openide.util.NbBundle;
|
|
||||||
import org.sleuthkit.autopsy.casemodule.Case;
|
import org.sleuthkit.autopsy.casemodule.Case;
|
||||||
import org.sleuthkit.autopsy.corecomponentinterfaces.AutopsyService;
|
import org.sleuthkit.autopsy.corecomponentinterfaces.AutopsyService;
|
||||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||||
@ -73,6 +72,14 @@ class IndexFinder {
|
|||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static String createLatestVersionIndexDir(Case theCase) {
|
||||||
|
String indexFolderName = "solr" + CURRENT_SOLR_VERSION + "_schema_" + CURRENT_SOLR_SCHEMA_VERSION;
|
||||||
|
// new index should be stored in "\ModuleOutput\keywordsearch\data\solrX_schema_Y\index"
|
||||||
|
File targetDirPath = Paths.get(theCase.getModuleDirectory(), KWS_OUTPUT_FOLDER_NAME, KWS_DATA_FOLDER_NAME, indexFolderName, INDEX_FOLDER_NAME).toFile(); //NON-NLS
|
||||||
|
targetDirPath.mkdirs();
|
||||||
|
return targetDirPath.getAbsolutePath();
|
||||||
|
}
|
||||||
|
|
||||||
String copyIndexAndConfigSet(Case theCase, String oldIndexDir) throws AutopsyService.AutopsyServiceException {
|
String copyIndexAndConfigSet(Case theCase, String oldIndexDir) throws AutopsyService.AutopsyServiceException {
|
||||||
// Copy the "old" index into ModuleOutput/keywordsearch/data/solrX_schema_Y/index
|
// Copy the "old" index into ModuleOutput/keywordsearch/data/solrX_schema_Y/index
|
||||||
|
@ -45,8 +45,6 @@ class Installer extends ModuleInstall {
|
|||||||
//Setup the default KeywordSearch configuration files
|
//Setup the default KeywordSearch configuration files
|
||||||
KeywordSearchSettings.setDefaults();
|
KeywordSearchSettings.setDefaults();
|
||||||
|
|
||||||
Case.addEventSubscriber(Case.Events.CURRENT_CASE.toString(), new KeywordSearch.CaseChangeListener());
|
|
||||||
|
|
||||||
final Server server = KeywordSearch.getServer();
|
final Server server = KeywordSearch.getServer();
|
||||||
try {
|
try {
|
||||||
server.start();
|
server.start();
|
||||||
|
@ -30,9 +30,11 @@ import org.apache.solr.client.solrj.impl.HttpSolrClient;
|
|||||||
import org.openide.util.NbBundle;
|
import org.openide.util.NbBundle;
|
||||||
import org.openide.util.lookup.ServiceProvider;
|
import org.openide.util.lookup.ServiceProvider;
|
||||||
import org.openide.util.lookup.ServiceProviders;
|
import org.openide.util.lookup.ServiceProviders;
|
||||||
|
import org.sleuthkit.autopsy.casemodule.Case;
|
||||||
import org.sleuthkit.autopsy.core.RuntimeProperties;
|
import org.sleuthkit.autopsy.core.RuntimeProperties;
|
||||||
import org.sleuthkit.autopsy.corecomponentinterfaces.AutopsyService;
|
import org.sleuthkit.autopsy.corecomponentinterfaces.AutopsyService;
|
||||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||||
|
import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil;
|
||||||
import org.sleuthkit.autopsy.keywordsearchservice.KeywordSearchService;
|
import org.sleuthkit.autopsy.keywordsearchservice.KeywordSearchService;
|
||||||
import org.sleuthkit.autopsy.keywordsearchservice.KeywordSearchServiceException;
|
import org.sleuthkit.autopsy.keywordsearchservice.KeywordSearchServiceException;
|
||||||
import org.sleuthkit.datamodel.BlackboardArtifact;
|
import org.sleuthkit.datamodel.BlackboardArtifact;
|
||||||
@ -161,40 +163,62 @@ public class SolrSearchService implements KeywordSearchService, AutopsyService
|
|||||||
List<String> indexDirs = indexFinder.findAllIndexDirs(context.getCase());
|
List<String> indexDirs = indexFinder.findAllIndexDirs(context.getCase());
|
||||||
|
|
||||||
// check if index needs upgrade
|
// check if index needs upgrade
|
||||||
|
String schemaVer;
|
||||||
String currentVersionIndexDir = IndexFinder.findLatestVersionIndexDir(indexDirs);
|
String currentVersionIndexDir = IndexFinder.findLatestVersionIndexDir(indexDirs);
|
||||||
if (currentVersionIndexDir.isEmpty()) {
|
if (currentVersionIndexDir.isEmpty()) {
|
||||||
|
if (indexDirs.isEmpty()) {
|
||||||
// ELTODO not sure what to do when there are multiple old indexes. grab the first one?
|
// new case that doesn't have an existing index. create new index folder
|
||||||
String oldIndexDir = indexDirs.get(0);
|
currentVersionIndexDir = IndexFinder.createLatestVersionIndexDir(context.getCase());
|
||||||
|
schemaVer = IndexFinder.getCurrentSchemaVersion();
|
||||||
|
} else {
|
||||||
|
// ELTODO not sure what to do when there are multiple old indexes. grab the first one?
|
||||||
|
// ELTODO need to handle here a case where it is Solr 6 index but not latest schema
|
||||||
|
// ELTODO figure out the schema version of the "old" index
|
||||||
|
String oldIndexDir = indexDirs.get(0);
|
||||||
|
|
||||||
if (RuntimeProperties.coreComponentsAreActive()) {
|
if (RuntimeProperties.coreComponentsAreActive()) {
|
||||||
//pop up a message box to indicate the restrictions on adding additional
|
//pop up a message box to indicate the restrictions on adding additional
|
||||||
//text and performing regex searches and give the user the option to decline the upgrade
|
//text and performing regex searches and give the user the option to decline the upgrade
|
||||||
if (!KeywordSearchUtil.displayConfirmDialog(NbBundle.getMessage(this.getClass(), "SolrSearchService.IndexUpgradeDialog.title"),
|
if (!KeywordSearchUtil.displayConfirmDialog(NbBundle.getMessage(this.getClass(), "SolrSearchService.IndexUpgradeDialog.title"),
|
||||||
NbBundle.getMessage(this.getClass(), "SolrSearchService.IndexUpgradeDialog.msg"),
|
NbBundle.getMessage(this.getClass(), "SolrSearchService.IndexUpgradeDialog.msg"),
|
||||||
KeywordSearchUtil.DIALOG_MESSAGE_TYPE.WARN)) {
|
KeywordSearchUtil.DIALOG_MESSAGE_TYPE.WARN)) {
|
||||||
// upgrade declined - throw exception
|
// upgrade declined - throw exception
|
||||||
throw new AutopsyServiceException("Index upgrade was declined by user");
|
throw new AutopsyServiceException("Index upgrade was declined by user");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ELTODO Check for cancellation at whatever points are feasible
|
||||||
|
|
||||||
|
// Copy the "old" index and config set into ModuleOutput/keywordsearch/data/solrX_schema_Y/
|
||||||
|
String newIndexDir = indexFinder.copyIndexAndConfigSet(context.getCase(), oldIndexDir);
|
||||||
|
|
||||||
|
// upgrade the "old" index to the latest supported Solr version
|
||||||
|
IndexUpgrader indexUpgrader = new IndexUpgrader();
|
||||||
|
indexUpgrader.performIndexUpgrade(newIndexDir, context.getCase().getTempDirectory());
|
||||||
|
|
||||||
|
// set the upgraded reference index as the index to be used for this case
|
||||||
|
currentVersionIndexDir = newIndexDir;
|
||||||
|
// schemaVer = ; // ELTODO
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
// ELTODO Check for cancellation at whatever points are feasible
|
// found index that is latest version of Solr and schema
|
||||||
|
schemaVer = IndexFinder.getCurrentSchemaVersion();
|
||||||
// Copy the "old" index and config set into ModuleOutput/keywordsearch/data/solrX_schema_Y/
|
|
||||||
String newIndexDir = indexFinder.copyIndexAndConfigSet(context.getCase(), oldIndexDir);
|
|
||||||
|
|
||||||
// upgrade the "old" index to the latest supported Solr version
|
|
||||||
IndexUpgrader indexUpgrader = new IndexUpgrader();
|
|
||||||
indexUpgrader.performIndexUpgrade(newIndexDir, context.getCase().getTempDirectory());
|
|
||||||
|
|
||||||
// set the upgraded reference index as the index to be used for this case
|
|
||||||
currentVersionIndexDir = newIndexDir;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// open currentVersionIndexDir index
|
// open core
|
||||||
|
try {
|
||||||
// execute a test query
|
// ELTODO figure out the schema version of the core that's being opened
|
||||||
// if failed, close the upgraded index?
|
//KeywordSearch.getServer().openCoreForCase(context.getCase(), currentVersionIndexDir, schemaVer);
|
||||||
|
KeywordSearch.getServer().openCoreForCase(context.getCase());
|
||||||
|
} catch (Exception ex) {
|
||||||
|
logger.log(Level.SEVERE, String.format("Failed to open or create core for %s", context.getCase().getCaseDirectory()), ex); //NON-NLS
|
||||||
|
if (RuntimeProperties.coreComponentsAreActive()) {
|
||||||
|
MessageNotifyUtil.Notify.error(NbBundle.getMessage(KeywordSearch.class, "KeywordSearch.openCore.notification.msg"), ex.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ELTODO execute a test query
|
||||||
|
// ELTODO if failed, close the upgraded index?
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -209,6 +233,22 @@ public class SolrSearchService implements KeywordSearchService, AutopsyService
|
|||||||
/*
|
/*
|
||||||
* Autopsy service providers may not have case-level resources.
|
* Autopsy service providers may not have case-level resources.
|
||||||
*/
|
*/
|
||||||
|
try {
|
||||||
|
KeywordSearchResultFactory.BlackboardResultWriter.stopAllWriters();
|
||||||
|
/*
|
||||||
|
* TODO (AUT-2084): The following code
|
||||||
|
* KeywordSearch.CaseChangeListener gambles that any
|
||||||
|
* BlackboardResultWriters (SwingWorkers) will complete
|
||||||
|
* in less than roughly two seconds
|
||||||
|
*/
|
||||||
|
Thread.sleep(2000);
|
||||||
|
KeywordSearch.getServer().closeCore();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
logger.log(Level.SEVERE, String.format("Failed to close core for %s", context.getCase().getCaseDirectory()), ex); //NON-NLS
|
||||||
|
if (RuntimeProperties.coreComponentsAreActive()) {
|
||||||
|
MessageNotifyUtil.Notify.error(NbBundle.getMessage(KeywordSearch.class, "KeywordSearch.closeCore.notification.msg"), ex.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user