Skip to content
Snippets Groups Projects
Commit b2f89ddd authored by Greg DiCristofaro's avatar Greg DiCristofaro
Browse files

upgrade from solr4

parent 556c89f0
No related branches found
No related tags found
No related merge requests found
...@@ -263,4 +263,11 @@ private void displayDialog() { ...@@ -263,4 +263,11 @@ private void displayDialog() {
dialog.setLocationRelativeTo(parent); dialog.setLocationRelativeTo(parent);
this.dialog.setVisible(true); this.dialog.setVisible(true);
} }
/**
* @return The GUI dialog presenting the progress. Possibly null.
*/
public Dialog getDialog() {
return this.dialog;
}
} }
...@@ -52,7 +52,7 @@ KeywordSearchResultFactory.createNodeForKey.noResultsFound.text=No results found ...@@ -52,7 +52,7 @@ KeywordSearchResultFactory.createNodeForKey.noResultsFound.text=No results found
KeywordSearchResultFactory.query.exception.msg=Could not perform the query KeywordSearchResultFactory.query.exception.msg=Could not perform the query
OpenIDE-Module-Display-Category=Ingest Module OpenIDE-Module-Display-Category=Ingest Module
OpenIDE-Module-Long-Description=Keyword Search ingest module.\n\nThe module indexes files found in the disk image at ingest time.\nIt then periodically runs the search on the indexed files using one or more keyword lists (containing pure words and/or regular expressions) and posts results.\n\n\The module also contains additional tools integrated in the main GUI, such as keyword list configuration, keyword search bar in the top-right corner, extracted text viewer and search results viewer showing highlighted keywords found. OpenIDE-Module-Long-Description=Keyword Search ingest module.\n\nThe module indexes files found in the disk image at ingest time.\nIt then periodically runs the search on the indexed files using one or more keyword lists (containing pure words and/or regular expressions) and posts results.\n\nThe module also contains additional tools integrated in the main GUI, such as keyword list configuration, keyword search bar in the top-right corner, extracted text viewer and search results viewer showing highlighted keywords found.
OpenIDE-Module-Name=KeywordSearch OpenIDE-Module-Name=KeywordSearch
OptionsCategory_Name_KeywordSearchOptions=Keyword Search OptionsCategory_Name_KeywordSearchOptions=Keyword Search
OptionsCategory_Keywords_KeywordSearchOptions=Keyword Search OptionsCategory_Keywords_KeywordSearchOptions=Keyword Search
...@@ -306,6 +306,14 @@ KeywordSearchModuleFactory.getIngestJobSettingsPanel.exception.msg=Expected sett ...@@ -306,6 +306,14 @@ KeywordSearchModuleFactory.getIngestJobSettingsPanel.exception.msg=Expected sett
KeywordSearchModuleFactory.createFileIngestModule.exception.msg=Expected settings argument to be instanceof KeywordSearchJobSettings KeywordSearchModuleFactory.createFileIngestModule.exception.msg=Expected settings argument to be instanceof KeywordSearchJobSettings
SearchRunner.Searcher.done.err.msg=Error performing keyword search SearchRunner.Searcher.done.err.msg=Error performing keyword search
Server.status.failed.msg=Local Solr server did not respond to status request. This may be because the server failed to start or is taking too long to initialize. Server.status.failed.msg=Local Solr server did not respond to status request. This may be because the server failed to start or is taking too long to initialize.
# {0} - indexVersion
Server_configureSolrConnection_illegalSolrVersion=The solr version in the case: {0}, is not supported.
# {0} - solrVersion
# {1} - caseName
Server_configureSolrConnection_unsupportedSolrDesc=<html><body><p style="width: 400px">The current Solr version: {0} in the case: {1} is no longer supported. You can continue without upgrading, but Solr will not be usable while the case is open, and you will encounter errors. You can also choose to upgrade the Solr version for the case. If you choose to do this, you will need to run Keyword Search with Solr indexing selected in order to use Solr features like ad hoc search with images in the case.</p></body></html>
Server_configureSolrConnection_unsupportedSolrDisableOpt=Continue
Server_configureSolrConnection_unsupportedSolrTitle=Unsupported Solr Version
Server_configureSolrConnection_unsupportedSolrUpgradeOpt=Upgrade Solr Core
SolrConnectionCheck.HostnameOrPort=Invalid hostname and/or port number. SolrConnectionCheck.HostnameOrPort=Invalid hostname and/or port number.
SolrConnectionCheck.Hostname=Invalid hostname. SolrConnectionCheck.Hostname=Invalid hostname.
SolrConnectionCheck.MissingHostname=Missing hostname. SolrConnectionCheck.MissingHostname=Missing hostname.
......
...@@ -57,6 +57,7 @@ ...@@ -57,6 +57,7 @@
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static java.util.stream.Collectors.toList; import static java.util.stream.Collectors.toList;
import javax.swing.JOptionPane;
import org.apache.solr.client.solrj.SolrQuery; import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrRequest; import org.apache.solr.client.solrj.SolrRequest;
import org.apache.solr.client.solrj.SolrServerException; import org.apache.solr.client.solrj.SolrServerException;
...@@ -82,6 +83,7 @@ ...@@ -82,6 +83,7 @@
import org.openide.modules.InstalledFileLocator; import org.openide.modules.InstalledFileLocator;
import org.openide.modules.Places; import org.openide.modules.Places;
import org.openide.util.NbBundle; import org.openide.util.NbBundle;
import org.openide.util.NbBundle.Messages;
import org.openide.windows.WindowManager; import org.openide.windows.WindowManager;
import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.Case.CaseType; import org.sleuthkit.autopsy.casemodule.Case.CaseType;
...@@ -611,18 +613,22 @@ void start() throws KeywordSearchModuleException, SolrServerNoPortException, Sol ...@@ -611,18 +613,22 @@ void start() throws KeywordSearchModuleException, SolrServerNoPortException, Sol
startLocalSolr(SOLR_VERSION.SOLR8); startLocalSolr(SOLR_VERSION.SOLR8);
} }
@Messages({
"# {0} - indexVersion",
"Server_configureSolrConnection_illegalSolrVersion=The solr version in the case: {0}, is not supported."
})
private void configureSolrConnection(Case theCase, Index index) throws KeywordSearchModuleException, SolrServerNoPortException { private void configureSolrConnection(Case theCase, Index index) throws KeywordSearchModuleException, SolrServerNoPortException {
try { try {
if (theCase.getCaseType() == CaseType.SINGLE_USER_CASE) { if (theCase.getCaseType() == CaseType.SINGLE_USER_CASE) {
// makes sure the proper local Solr server is running // makes sure the proper local Solr server is running
if (IndexFinder.getCurrentSolrVersion().equals(index.getSolrVersion())) { if (!IndexFinder.getCurrentSolrVersion().equals(index.getSolrVersion())) {
startLocalSolr(SOLR_VERSION.SOLR8); throw new KeywordSearchModuleException(Bundle.Server_configureSolrConnection_illegalSolrVersion(index.getSolrVersion()));
} else {
startLocalSolr(SOLR_VERSION.SOLR4);
} }
startLocalSolr(SOLR_VERSION.SOLR8);
// check if the local Solr server is running // check if the local Solr server is running
if (!this.isLocalSolrRunning()) { if (!this.isLocalSolrRunning()) {
logger.log(Level.SEVERE, "Local Solr server is not running"); //NON-NLS logger.log(Level.SEVERE, "Local Solr server is not running"); //NON-NLS
...@@ -684,8 +690,7 @@ synchronized void startLocalSolr(SOLR_VERSION version) throws KeywordSearchModul ...@@ -684,8 +690,7 @@ synchronized void startLocalSolr(SOLR_VERSION version) throws KeywordSearchModul
if (version == SOLR_VERSION.SOLR8) { if (version == SOLR_VERSION.SOLR8) {
localSolrFolder = InstalledFileLocator.getDefault().locate("solr", Server.class.getPackage().getName(), false); //NON-NLS localSolrFolder = InstalledFileLocator.getDefault().locate("solr", Server.class.getPackage().getName(), false); //NON-NLS
} else { } else {
// solr4 throw new KeywordSearchModuleException(Bundle.Server_configureSolrConnection_illegalSolrVersion(version.name()));
localSolrFolder = InstalledFileLocator.getDefault().locate("solr4", Server.class.getPackage().getName(), false); //NON-NLS
} }
if (isLocalSolrRunning()) { if (isLocalSolrRunning()) {
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
*/ */
package org.sleuthkit.autopsy.keywordsearch; package org.sleuthkit.autopsy.keywordsearch;
import java.awt.Component;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.Reader; import java.io.Reader;
...@@ -26,18 +27,22 @@ ...@@ -26,18 +27,22 @@
import java.util.List; import java.util.List;
import java.util.MissingResourceException; import java.util.MissingResourceException;
import java.util.logging.Level; import java.util.logging.Level;
import javax.swing.JOptionPane;
import org.apache.solr.client.solrj.SolrServerException; import org.apache.solr.client.solrj.SolrServerException;
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.openide.windows.WindowManager;
import org.sleuthkit.autopsy.appservices.AutopsyService; import org.sleuthkit.autopsy.appservices.AutopsyService;
import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.CaseMetadata; import org.sleuthkit.autopsy.casemodule.CaseMetadata;
import org.sleuthkit.autopsy.core.RuntimeProperties;
import org.sleuthkit.autopsy.coreutils.FileUtil; import org.sleuthkit.autopsy.coreutils.FileUtil;
import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.ingest.IngestManager; import org.sleuthkit.autopsy.ingest.IngestManager;
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.autopsy.progress.ModalDialogProgressIndicator;
import org.sleuthkit.autopsy.progress.ProgressIndicator; import org.sleuthkit.autopsy.progress.ProgressIndicator;
import org.sleuthkit.autopsy.textextractors.TextExtractor; import org.sleuthkit.autopsy.textextractors.TextExtractor;
import org.sleuthkit.autopsy.textextractors.TextExtractorFactory; import org.sleuthkit.autopsy.textextractors.TextExtractorFactory;
...@@ -315,11 +320,25 @@ public void openCaseResources(CaseContext context) throws AutopsyServiceExceptio ...@@ -315,11 +320,25 @@ public void openCaseResources(CaseContext context) throws AutopsyServiceExceptio
} }
throw new AutopsyServiceException(Bundle.SolrSearch_unableToFindIndex_msg()); throw new AutopsyServiceException(Bundle.SolrSearch_unableToFindIndex_msg());
} }
if (context.cancelRequested()) { if (context.cancelRequested()) {
return; return;
} }
if (!IndexFinder.getCurrentSolrVersion().equals(indexToUse.getSolrVersion())) {
Index prevIndex = indexToUse;
indexToUse = tryUpgradeSolrVersion(context, indexToUse);
if (indexToUse != prevIndex) {
indexes.add(indexToUse);
}
}
if (context.cancelRequested()) {
return;
}
// check if schema is compatible // check if schema is compatible
if (!indexToUse.isCompatible(IndexFinder.getCurrentSchemaVersion())) { if (!indexToUse.isCompatible(IndexFinder.getCurrentSchemaVersion())) {
String msg = "Text index schema version " + indexToUse.getSchemaVersion() + " is not compatible with current schema"; String msg = "Text index schema version " + indexToUse.getSchemaVersion() + " is not compatible with current schema";
...@@ -355,6 +374,71 @@ public void openCaseResources(CaseContext context) throws AutopsyServiceExceptio ...@@ -355,6 +374,71 @@ public void openCaseResources(CaseContext context) throws AutopsyServiceExceptio
progress.progress(Bundle.SolrSearch_complete_msg(), totalNumProgressUnits); progress.progress(Bundle.SolrSearch_complete_msg(), totalNumProgressUnits);
} }
private static final long WAIT_TIME_MILLIS = 2000;
/**
* Attempts to upgrade the solr version to most recent version first prompting the user.
* @param context The case context.
* @param index The current index.
* @return The new index.
* @throws org.sleuthkit.autopsy.appservices.AutopsyService.AutopsyServiceException
*/
@NbBundle.Messages({
"Server_configureSolrConnection_unsupportedSolrTitle=Unsupported Solr Version",
"# {0} - solrVersion",
"# {1} - caseName",
"Server_configureSolrConnection_unsupportedSolrDesc=<html><body><p style=\"width: 400px\">The current Solr version: {0} in the case: {1} is no longer supported. You can continue without upgrading, but Solr will not be usable while the case is open, and you will encounter errors. You can also choose to upgrade the Solr version for the case. If you choose to do this, you will need to run Keyword Search with Solr indexing selected in order to use Solr features like ad hoc search with images in the case.</p></body></html>",
"Server_configureSolrConnection_unsupportedSolrDisableOpt=Continue",
"Server_configureSolrConnection_unsupportedSolrUpgradeOpt=Upgrade Solr Core"
})
private Index tryUpgradeSolrVersion(CaseContext context, Index index) throws AutopsyServiceException {
// if not, attempt to fix issue
if (RuntimeProperties.runningWithGUI()) {
Component parentComponent = WindowManager.getDefault().getMainWindow();
if (context.getProgressIndicator() instanceof ModalDialogProgressIndicator progInd && progInd.getDialog() != null) {
parentComponent = progInd.getDialog();
}
if (context.cancelRequested()) {
return index;
}
try {
// progress updates occur right before this in the same window, so there is the possibility that
// the progress window will update just after the option pane is shown causing the option pane to
// not be visible or selectable. This sleep is added to give the window enough time to finish
Thread.sleep(WAIT_TIME_MILLIS);
} catch (InterruptedException ex) {
// just proceed if interrupted
}
if (context.cancelRequested()) {
return index;
}
int selection = JOptionPane.showOptionDialog(
parentComponent,
Bundle.Server_configureSolrConnection_unsupportedSolrDesc(index.getSolrVersion(), context.getCase().getDisplayName()),
Bundle.Server_configureSolrConnection_unsupportedSolrTitle(),
JOptionPane.YES_NO_OPTION,
JOptionPane.WARNING_MESSAGE,
null,
new Object[]{
Bundle.Server_configureSolrConnection_unsupportedSolrDisableOpt(),
Bundle.Server_configureSolrConnection_unsupportedSolrUpgradeOpt()
},
Bundle.Server_configureSolrConnection_unsupportedSolrDisableOpt());
if (selection == 1) {
return IndexFinder.createLatestVersionIndex(context.getCase());
}
}
throw new AutopsyServiceException("Unsupported Solr version: " + index.getSolrVersion());
}
/** /**
* Closes the open core. * Closes the open core.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment