Fixes to SolrSearchService

This commit is contained in:
Eugene Livis 2020-05-15 20:23:11 -04:00
parent d777d630e9
commit ccd755524f
2 changed files with 12 additions and 30 deletions

View File

@ -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

View File

@ -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<String> solrServerList = UserPreferences.getAllIndexingServers();
List<String> 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();
}
}
}