From ccd755524f207b9843ac591772d49b56ab83ae88 Mon Sep 17 00:00:00 2001 From: Eugene Livis Date: Fri, 15 May 2020 20:23:11 -0400 Subject: [PATCH] Fixes to SolrSearchService --- .../keywordsearch/Bundle.properties-MERGED | 6 ++-- .../keywordsearch/SolrSearchService.java | 36 +++++-------------- 2 files changed, 12 insertions(+), 30 deletions(-) diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Bundle.properties-MERGED b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Bundle.properties-MERGED index 49c6eaf73f..9a7e3e484e 100755 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Bundle.properties-MERGED +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Bundle.properties-MERGED @@ -36,7 +36,7 @@ KeywordSearchResultFactory.createNodeForKey.noResultsFound.text=No results found KeywordSearchResultFactory.query.exception.msg=Could not perform the query 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 OptionsCategory_Name_KeywordSearchOptions=Keyword Search OptionsCategory_Keywords_KeywordSearchOptions=Keyword Search @@ -212,8 +212,8 @@ KeywordSearchSettings.propertiesNSRL.text={0}_NSRL KeywordSearchSettings.propertiesScripts.text={0}_Scripts NoOpenCoreException.err.noOpenSorlCore.msg=No currently open Solr core. SearchRunner.query.exception.msg=Error performing query: -# {0} - core name -Server.deleteCore.exception.msg=Failed to delete Solr core {0} +# {0} - colelction name +Server.deleteCore.exception.msg=Failed to delete Solr colelction {0} Server.exceptionMessage.unableToCreateCollection=Unable to create Solr collection Server.start.exception.cantStartSolr.msg=Could not start Solr server process Server.start.exception.cantStartSolr.msg2=Could not start Solr server process diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/SolrSearchService.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/SolrSearchService.java index 1372e2e73f..23e72c73b4 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/SolrSearchService.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/SolrSearchService.java @@ -27,7 +27,6 @@ import java.net.InetAddress; import java.util.ArrayList; import java.util.List; import java.util.MissingResourceException; -import java.util.concurrent.TimeUnit; import java.util.logging.Level; import javax.swing.JDialog; import javax.swing.JOptionPane; @@ -35,8 +34,7 @@ import javax.swing.SwingUtilities; import org.apache.commons.io.FileUtils; import org.apache.commons.lang.math.NumberUtils; import org.apache.solr.client.solrj.SolrServerException; -import org.apache.solr.client.solrj.impl.CloudSolrClient; -import org.apache.solr.client.solrj.impl.HttpSolrClient; +import org.apache.solr.client.solrj.impl.ConcurrentUpdateSolrClient; import org.openide.util.NbBundle; import org.openide.util.lookup.ServiceProvider; import org.openide.util.lookup.ServiceProviders; @@ -44,11 +42,9 @@ import org.sleuthkit.autopsy.appservices.AutopsyService; import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.casemodule.CaseMetadata; import org.sleuthkit.autopsy.core.RuntimeProperties; -import org.sleuthkit.autopsy.core.UserPreferences; import org.sleuthkit.autopsy.coreutils.FileUtil; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil; -import static org.sleuthkit.autopsy.keywordsearch.Server.getMultiUserServerProperties; import org.sleuthkit.autopsy.keywordsearchservice.KeywordSearchService; import org.sleuthkit.autopsy.keywordsearchservice.KeywordSearchServiceException; import org.sleuthkit.autopsy.progress.ProgressIndicator; @@ -158,26 +154,16 @@ public class SolrSearchService implements KeywordSearchService, AutopsyService { */ @Override public void tryConnect(String host, int port) throws KeywordSearchServiceException { - // ELTODO HttpSolrClient solrServer = null; - CloudSolrClient solrServer = null; + ConcurrentUpdateSolrClient solrServer = null; if (host == null || host.isEmpty()) { throw new KeywordSearchServiceException(NbBundle.getMessage(SolrSearchService.class, "SolrConnectionCheck.MissingHostname")); //NON-NLS } try { - // ELTODO solrServer = new HttpSolrClient.Builder("http://" + host + ":" + Integer.toString(port) + "/solr").build(); //NON-NLS - List solrServerList = UserPreferences.getAllIndexingServers(); - List solrUrls = new ArrayList<>(); - for (String server : solrServerList) { - solrUrls.add("http://" + server + "/solr"); - } - if (solrUrls.isEmpty()) { - solrUrls.add("http://" + host + ":" + port + "/solr"); - } - // ELTODO UNCOMMENT solrServer = new CloudSolrClient.Builder(solrUrls).build(); - // ELTODO UNCOMMENT solrServer.connect(10, TimeUnit.SECONDS); - /* ELTODO } catch (SolrServerException ex) { + solrServer = new ConcurrentUpdateSolrClient.Builder("http://" + host + ":" + Integer.toString(port) + "/solr").build(); //NON-NLS + KeywordSearch.getServer().connectToSolrServer(solrServer); + } catch (SolrServerException ex) { throw new KeywordSearchServiceException(NbBundle.getMessage(SolrSearchService.class, "SolrConnectionCheck.HostnameOrPort")); //NON-NLS*/ - } catch (/*ELTODO IOException*/ Exception ex) { + } catch (IOException ex) { String result = NbBundle.getMessage(SolrSearchService.class, "SolrConnectionCheck.HostnameOrPort"); //NON-NLS String message = ex.getCause().getMessage().toLowerCase(); if (message.startsWith(SERVER_REFUSED_CONNECTION)) { @@ -196,17 +182,13 @@ public class SolrSearchService implements KeywordSearchService, AutopsyService { result = NbBundle.getMessage(SolrSearchService.class, "SolrConnectionCheck.Hostname"); //NON-NLS } throw new KeywordSearchServiceException(result); - /* ELTODO} catch (NumberFormatException ex) { + } catch (NumberFormatException ex) { throw new KeywordSearchServiceException(Bundle.SolrConnectionCheck_Port()); } catch (IllegalArgumentException ex) { - throw new KeywordSearchServiceException(ex.getMessage());*/ + throw new KeywordSearchServiceException(ex.getMessage()); } finally { if (null != solrServer) { - try { - solrServer.close(); - } catch (IOException ex) { - throw new KeywordSearchServiceException(ex.getMessage()); - } + solrServer.close(); } } }