mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-17 02:07:42 +00:00
Code review
This commit is contained in:
parent
d1c91b0089
commit
8cb276c9d5
@ -66,7 +66,7 @@ public final class MultiUserSettingsPanel extends javax.swing.JPanel {
|
|||||||
private static final String INVALID_INDEXING_SERVER_PORT_MSG = NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.validationErrMsg.invalidIndexingServerPort");
|
private static final String INVALID_INDEXING_SERVER_PORT_MSG = NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.validationErrMsg.invalidIndexingServerPort");
|
||||||
private static final String INVALID_SOLR4_SERVER_PORT_MSG = NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.validationErrMsg.invalidSolr4ServerPort");
|
private static final String INVALID_SOLR4_SERVER_PORT_MSG = NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.validationErrMsg.invalidSolr4ServerPort");
|
||||||
private static final String SOLR_SERVER_NOT_CONFIGURED_MSG = NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.validationErrMsg.solrNotConfigured");
|
private static final String SOLR_SERVER_NOT_CONFIGURED_MSG = NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.validationErrMsg.solrNotConfigured");
|
||||||
private static final String INVALID_ZK_SERVER_HOST_MSG = NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.validationErrMsg.invalidZkServerHostName");
|
private static final String INVALID_ZK_SERVER_HOST_MSG = NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.validationErrMsg.invalidZkServerHostName");
|
||||||
private static final String INVALID_ZK_SERVER_PORT_MSG = NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.validationErrMsg.invalidZkServerPort");
|
private static final String INVALID_ZK_SERVER_PORT_MSG = NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.validationErrMsg.invalidZkServerPort");
|
||||||
private static final String SOLR8_HOST_NAME_OR_IP_PROMPT = NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbSolr8Hostname.toolTipText");
|
private static final String SOLR8_HOST_NAME_OR_IP_PROMPT = NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbSolr8Hostname.toolTipText");
|
||||||
private static final String SOLR8_PORT_PROMPT = NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbSolr8Port.toolTipText");
|
private static final String SOLR8_PORT_PROMPT = NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbSolr8Port.toolTipText");
|
||||||
@ -129,7 +129,7 @@ public final class MultiUserSettingsPanel extends javax.swing.JPanel {
|
|||||||
tbSolr4Port.getDocument().putProperty("statusIcon", lbTestSolr);
|
tbSolr4Port.getDocument().putProperty("statusIcon", lbTestSolr);
|
||||||
tbZkHostname.getDocument().putProperty("statusIcon", lbTestSolr);
|
tbZkHostname.getDocument().putProperty("statusIcon", lbTestSolr);
|
||||||
tbZkPort.getDocument().putProperty("statusIcon", lbTestSolr);
|
tbZkPort.getDocument().putProperty("statusIcon", lbTestSolr);
|
||||||
|
|
||||||
tbMsgHostname.getDocument().putProperty("statusIcon", lbTestMessageService);
|
tbMsgHostname.getDocument().putProperty("statusIcon", lbTestMessageService);
|
||||||
tbMsgPort.getDocument().putProperty("statusIcon", lbTestMessageService);
|
tbMsgPort.getDocument().putProperty("statusIcon", lbTestMessageService);
|
||||||
tbMsgUsername.getDocument().putProperty("statusIcon", lbTestMessageService);
|
tbMsgUsername.getDocument().putProperty("statusIcon", lbTestMessageService);
|
||||||
@ -151,10 +151,10 @@ public final class MultiUserSettingsPanel extends javax.swing.JPanel {
|
|||||||
textBoxes.add(tbSolr4Port);
|
textBoxes.add(tbSolr4Port);
|
||||||
textBoxes.add(tbZkHostname);
|
textBoxes.add(tbZkHostname);
|
||||||
textBoxes.add(tbZkPort);
|
textBoxes.add(tbZkPort);
|
||||||
|
|
||||||
// as the user enters Solr 8 settings, we fill in the ZK settings with the embedded Solr 8 ZK connection info.
|
// as the user enters Solr 8 settings, we fill in the ZK settings with the embedded Solr 8 ZK connection info.
|
||||||
tbSolr8Hostname.getDocument().addDocumentListener(new MyDocumentListener());
|
tbSolr8Hostname.getDocument().addDocumentListener(new MyDocumentListener());
|
||||||
|
|
||||||
addDocumentListeners(textBoxes, textBoxChangedListener);
|
addDocumentListeners(textBoxes, textBoxChangedListener);
|
||||||
goodIcon = new ImageIcon(ImageUtilities.loadImage("org/sleuthkit/autopsy/images/good.png", false));
|
goodIcon = new ImageIcon(ImageUtilities.loadImage("org/sleuthkit/autopsy/images/good.png", false));
|
||||||
badIcon = new ImageIcon(ImageUtilities.loadImage("org/sleuthkit/autopsy/images/bad.png", false));
|
badIcon = new ImageIcon(ImageUtilities.loadImage("org/sleuthkit/autopsy/images/bad.png", false));
|
||||||
@ -570,7 +570,7 @@ public final class MultiUserSettingsPanel extends javax.swing.JPanel {
|
|||||||
* Enables/disables the multi-user settings, based upon input provided
|
* Enables/disables the multi-user settings, based upon input provided
|
||||||
*
|
*
|
||||||
* @param textFields The text fields to enable/disable.
|
* @param textFields The text fields to enable/disable.
|
||||||
* @param enabled True means enable, false means disable.
|
* @param enabled True means enable, false means disable.
|
||||||
*/
|
*/
|
||||||
private static void enableMultiUserComponents(Collection<JTextField> textFields, boolean enabled) {
|
private static void enableMultiUserComponents(Collection<JTextField> textFields, boolean enabled) {
|
||||||
for (JTextField textField : textFields) {
|
for (JTextField textField : textFields) {
|
||||||
@ -668,13 +668,13 @@ public final class MultiUserSettingsPanel extends javax.swing.JPanel {
|
|||||||
int port = Integer.parseInt(tbSolr8Port.getText().trim());
|
int port = Integer.parseInt(tbSolr8Port.getText().trim());
|
||||||
kwsService.tryConnect(tbSolr8Hostname.getText().trim(), port);
|
kwsService.tryConnect(tbSolr8Hostname.getText().trim(), port);
|
||||||
}
|
}
|
||||||
|
|
||||||
// test Solr 4 conenctivity
|
// test Solr 4 conenctivity
|
||||||
if (!tbSolr4Port.getText().trim().isEmpty() && !tbSolr4Hostname.getText().trim().isEmpty()) {
|
if (!tbSolr4Port.getText().trim().isEmpty() && !tbSolr4Hostname.getText().trim().isEmpty()) {
|
||||||
int port = Integer.parseInt(tbSolr4Port.getText().trim());
|
int port = Integer.parseInt(tbSolr4Port.getText().trim());
|
||||||
kwsService.tryConnect(tbSolr4Hostname.getText().trim(), port);
|
kwsService.tryConnect(tbSolr4Hostname.getText().trim(), port);
|
||||||
}
|
}
|
||||||
|
|
||||||
// test ZooKeeper connectivity (ZK settings are mandatory)
|
// test ZooKeeper connectivity (ZK settings are mandatory)
|
||||||
if (tbZkPort.getText().trim().isEmpty() || tbZkHostname.getText().trim().isEmpty()) {
|
if (tbZkPort.getText().trim().isEmpty() || tbZkHostname.getText().trim().isEmpty()) {
|
||||||
lbTestSolr.setIcon(badIcon);
|
lbTestSolr.setIcon(badIcon);
|
||||||
@ -770,7 +770,7 @@ public final class MultiUserSettingsPanel extends javax.swing.JPanel {
|
|||||||
if (portNumberIsValid(solr4ServerPort)) {
|
if (portNumberIsValid(solr4ServerPort)) {
|
||||||
tbSolr4Port.setText(solr4ServerPort);
|
tbSolr4Port.setText(solr4ServerPort);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if there are existing valid ZK settings, use those
|
// if there are existing valid ZK settings, use those
|
||||||
String zkServerPort = UserPreferences.getZkServerPort().trim();
|
String zkServerPort = UserPreferences.getZkServerPort().trim();
|
||||||
if (portNumberIsValid(zkServerPort)) {
|
if (portNumberIsValid(zkServerPort)) {
|
||||||
@ -781,7 +781,7 @@ public final class MultiUserSettingsPanel extends javax.swing.JPanel {
|
|||||||
tbZkHostname.setText(zkServerHost);
|
tbZkHostname.setText(zkServerHost);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there are no previous Solr 4 settings, use Solr 8 settings
|
// If there are no previous Solr 4 settings, use Solr 8 settings
|
||||||
// to fill in the ZK settings with the embedded Solr 8 ZK connection info.
|
// to fill in the ZK settings with the embedded Solr 8 ZK connection info.
|
||||||
if (solr4ServerHost.isEmpty() && !indexingServerHost.isEmpty()) {
|
if (solr4ServerHost.isEmpty() && !indexingServerHost.isEmpty()) {
|
||||||
@ -789,14 +789,14 @@ public final class MultiUserSettingsPanel extends javax.swing.JPanel {
|
|||||||
tbZkPort.setText(zkServerPort); // gets default ZK port, which is Solr port number + 1000
|
tbZkPort.setText(zkServerPort); // gets default ZK port, which is Solr port number + 1000
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there are existing Solr 4 settings and no Solr 8 settings,
|
// If there are existing Solr 4 settings and no Solr 8 settings,
|
||||||
// pre-populate the ZK settings with the Solr 4 embedded ZK settings.
|
// pre-populate the ZK settings with the Solr 4 embedded ZK settings.
|
||||||
if (!solr4ServerHost.isEmpty() && indexingServerHost.isEmpty()) {
|
if (!solr4ServerHost.isEmpty() && indexingServerHost.isEmpty()) {
|
||||||
tbZkHostname.setText(solr4ServerHost);
|
tbZkHostname.setText(solr4ServerHost);
|
||||||
tbZkPort.setText(zkServerPort); // gets default ZK port, which is Solr port number + 1000
|
tbZkPort.setText(zkServerPort); // gets default ZK port, which is Solr port number + 1000
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -813,28 +813,28 @@ public final class MultiUserSettingsPanel extends javax.swing.JPanel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests whether or not values have been entered in all of the mandatory Solr settings
|
* Tests whether or not values have been entered in all of the mandatory
|
||||||
* text fields. Test optional settings for completeness.
|
* Solr settings text fields. Test optional settings for completeness.
|
||||||
*
|
*
|
||||||
* @return True or false.
|
* @return True or false.
|
||||||
*/
|
*/
|
||||||
private boolean solrFieldsArePopulated() {
|
private boolean solrFieldsArePopulated() {
|
||||||
|
|
||||||
// either Solr 8 or/and Solr 4 seetings must be specified
|
// either Solr 8 or/and Solr 4 seetings must be specified
|
||||||
boolean solrConfigured = false;
|
boolean solrConfigured = false;
|
||||||
|
|
||||||
// check if Solr 8 settings are set
|
// check if Solr 8 settings are set
|
||||||
if (!tbSolr8Hostname.getText().trim().isEmpty()
|
if (!tbSolr8Hostname.getText().trim().isEmpty()
|
||||||
&& !tbSolr8Port.getText().trim().isEmpty()) {
|
&& !tbSolr8Port.getText().trim().isEmpty()) {
|
||||||
solrConfigured = true;
|
solrConfigured = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if Solr 4 settings are set
|
// check if Solr 4 settings are set
|
||||||
if (!tbSolr4Hostname.getText().trim().isEmpty()
|
if (!tbSolr4Hostname.getText().trim().isEmpty()
|
||||||
&& !tbSolr4Port.getText().trim().isEmpty()) {
|
&& !tbSolr4Port.getText().trim().isEmpty()) {
|
||||||
solrConfigured = true;
|
solrConfigured = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ZK settings are mandatory
|
// ZK settings are mandatory
|
||||||
return (solrConfigured && !tbZkHostname.getText().trim().isEmpty()
|
return (solrConfigured && !tbZkHostname.getText().trim().isEmpty()
|
||||||
&& !tbZkPort.getText().trim().isEmpty());
|
&& !tbZkPort.getText().trim().isEmpty());
|
||||||
@ -858,8 +858,6 @@ public final class MultiUserSettingsPanel extends javax.swing.JPanel {
|
|||||||
boolean isPwSet = (tbMsgPassword.getPassword().length != 0);
|
boolean isPwSet = (tbMsgPassword.getPassword().length != 0);
|
||||||
return (isUserSet == isPwSet);
|
return (isUserSet == isPwSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void store() {
|
void store() {
|
||||||
boolean prevSelected = UserPreferences.getIsMultiUserModeEnabled();
|
boolean prevSelected = UserPreferences.getIsMultiUserModeEnabled();
|
||||||
@ -872,11 +870,11 @@ public final class MultiUserSettingsPanel extends javax.swing.JPanel {
|
|||||||
|
|
||||||
boolean multiUserCasesEnabled = cbEnableMultiUser.isSelected();
|
boolean multiUserCasesEnabled = cbEnableMultiUser.isSelected();
|
||||||
UserPreferences.setIsMultiUserModeEnabled(multiUserCasesEnabled);
|
UserPreferences.setIsMultiUserModeEnabled(multiUserCasesEnabled);
|
||||||
|
|
||||||
CaseDbConnectionInfo info = null;
|
CaseDbConnectionInfo info = null;
|
||||||
|
|
||||||
if (multiUserCasesEnabled == true) {
|
if (multiUserCasesEnabled == true) {
|
||||||
|
|
||||||
// Check if aplication restart is required.
|
// Check if aplication restart is required.
|
||||||
boolean needsRestart = false;
|
boolean needsRestart = false;
|
||||||
// don't check if entring multi user data for the first time
|
// don't check if entring multi user data for the first time
|
||||||
@ -918,7 +916,7 @@ public final class MultiUserSettingsPanel extends javax.swing.JPanel {
|
|||||||
UserPreferences.setMessageServiceConnectionInfo(msgServiceInfo);
|
UserPreferences.setMessageServiceConnectionInfo(msgServiceInfo);
|
||||||
} catch (UserPreferencesException ex) {
|
} catch (UserPreferencesException ex) {
|
||||||
logger.log(Level.SEVERE, "Error saving messaging service connection info", ex); //NON-NLS
|
logger.log(Level.SEVERE, "Error saving messaging service connection info", ex); //NON-NLS
|
||||||
}
|
}
|
||||||
|
|
||||||
UserPreferences.setIndexingServerHost(tbSolr8Hostname.getText().trim());
|
UserPreferences.setIndexingServerHost(tbSolr8Hostname.getText().trim());
|
||||||
String solr8port = tbSolr8Port.getText().trim();
|
String solr8port = tbSolr8Port.getText().trim();
|
||||||
@ -929,7 +927,7 @@ public final class MultiUserSettingsPanel extends javax.swing.JPanel {
|
|||||||
UserPreferences.setSolr4ServerPort(tbSolr4Port.getText().trim());
|
UserPreferences.setSolr4ServerPort(tbSolr4Port.getText().trim());
|
||||||
UserPreferences.setZkServerHost(tbZkHostname.getText().trim());
|
UserPreferences.setZkServerHost(tbZkHostname.getText().trim());
|
||||||
UserPreferences.setZkServerPort(tbZkPort.getText().trim());
|
UserPreferences.setZkServerPort(tbZkPort.getText().trim());
|
||||||
|
|
||||||
if (needsRestart) {
|
if (needsRestart) {
|
||||||
SwingUtilities.invokeLater(() -> {
|
SwingUtilities.invokeLater(() -> {
|
||||||
JOptionPane.showMessageDialog(this,
|
JOptionPane.showMessageDialog(this,
|
||||||
@ -941,10 +939,11 @@ public final class MultiUserSettingsPanel extends javax.swing.JPanel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// trigger changes to whether or not user can use multi user settings for central repository
|
// trigger changes to whether or not user can use multi user settings for central repository
|
||||||
if (prevSelected != multiUserCasesEnabled || !areCaseDbConnectionEqual(prevConn, info))
|
if (prevSelected != multiUserCasesEnabled || !areCaseDbConnectionEqual(prevConn, info)) {
|
||||||
GlobalSettingsPanel.onMultiUserChange(this, prevSelected, multiUserCasesEnabled);
|
GlobalSettingsPanel.onMultiUserChange(this, prevSelected, multiUserCasesEnabled);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isRestartRequired() {
|
private boolean isRestartRequired() {
|
||||||
// if ZK was previously configured
|
// if ZK was previously configured
|
||||||
if (!UserPreferences.getZkServerHost().isEmpty()) {
|
if (!UserPreferences.getZkServerHost().isEmpty()) {
|
||||||
@ -953,32 +952,29 @@ public final class MultiUserSettingsPanel extends javax.swing.JPanel {
|
|||||||
|| !(tbZkPort.getText().trim().equals(UserPreferences.getZkServerPort()))) {
|
|| !(tbZkPort.getText().trim().equals(UserPreferences.getZkServerPort()))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean arePropsEqual(Object a, Object b) {
|
private static boolean arePropsEqual(Object a, Object b) {
|
||||||
if (a == null || b == null) {
|
if (a == null || b == null) {
|
||||||
return (a == null && b == null);
|
return (a == null && b == null);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return a.equals(b);
|
return a.equals(b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean areCaseDbConnectionEqual(CaseDbConnectionInfo a, CaseDbConnectionInfo b) {
|
private static boolean areCaseDbConnectionEqual(CaseDbConnectionInfo a, CaseDbConnectionInfo b) {
|
||||||
if (a == null || b == null) {
|
if (a == null || b == null) {
|
||||||
return (a == null && b == null);
|
return (a == null && b == null);
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return arePropsEqual(a.getDbType(), b.getDbType())
|
||||||
arePropsEqual(a.getDbType(), b.getDbType()) &&
|
&& arePropsEqual(a.getHost(), b.getHost())
|
||||||
arePropsEqual(a.getHost(), b.getHost()) &&
|
&& arePropsEqual(a.getPassword(), b.getPassword())
|
||||||
arePropsEqual(a.getPassword(), b.getPassword()) &&
|
&& arePropsEqual(a.getPort(), b.getPort())
|
||||||
arePropsEqual(a.getPort(), b.getPort()) &&
|
&& arePropsEqual(a.getUserName(), b.getUserName());
|
||||||
arePropsEqual(a.getUserName(), b.getUserName());
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validates that the form is filled out correctly for our usage.
|
* Validates that the form is filled out correctly for our usage.
|
||||||
@ -1062,7 +1058,7 @@ public final class MultiUserSettingsPanel extends javax.swing.JPanel {
|
|||||||
* @return True or false.
|
* @return True or false.
|
||||||
*/
|
*/
|
||||||
boolean indexingServerSettingsAreValid() {
|
boolean indexingServerSettingsAreValid() {
|
||||||
|
|
||||||
String solr8Port = tbSolr8Port.getText().trim();
|
String solr8Port = tbSolr8Port.getText().trim();
|
||||||
if (!solr8Port.isEmpty() && !portNumberIsValid(solr8Port)) {
|
if (!solr8Port.isEmpty() && !portNumberIsValid(solr8Port)) {
|
||||||
// if the port is specified, it has to be valid
|
// if the port is specified, it has to be valid
|
||||||
@ -1075,34 +1071,34 @@ public final class MultiUserSettingsPanel extends javax.swing.JPanel {
|
|||||||
// if the port is specified, it has to be valid
|
// if the port is specified, it has to be valid
|
||||||
tbOops.setText(INVALID_SOLR4_SERVER_PORT_MSG);
|
tbOops.setText(INVALID_SOLR4_SERVER_PORT_MSG);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// either Solr 8 or/and Solr 4 seetings must be specified
|
// either Solr 8 or/and Solr 4 seetings must be specified
|
||||||
boolean solrConfigured = false;
|
boolean solrConfigured = false;
|
||||||
|
|
||||||
// check if Solr 8 settings are set
|
// check if Solr 8 settings are set
|
||||||
if (!tbSolr8Hostname.getText().trim().isEmpty()
|
if (!tbSolr8Hostname.getText().trim().isEmpty()
|
||||||
&& !tbSolr8Port.getText().trim().isEmpty()) {
|
&& !tbSolr8Port.getText().trim().isEmpty()) {
|
||||||
solrConfigured = true;
|
solrConfigured = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if Solr 4 settings are set
|
// check if Solr 4 settings are set
|
||||||
if (!tbSolr4Hostname.getText().trim().isEmpty()
|
if (!tbSolr4Hostname.getText().trim().isEmpty()
|
||||||
&& !tbSolr4Port.getText().trim().isEmpty()) {
|
&& !tbSolr4Port.getText().trim().isEmpty()) {
|
||||||
solrConfigured = true;
|
solrConfigured = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!solrConfigured) {
|
if (!solrConfigured) {
|
||||||
tbOops.setText(SOLR_SERVER_NOT_CONFIGURED_MSG);
|
tbOops.setText(SOLR_SERVER_NOT_CONFIGURED_MSG);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ZK settings are mandatory
|
// ZK settings are mandatory
|
||||||
if (tbZkHostname.getText().trim().isEmpty()) {
|
if (tbZkHostname.getText().trim().isEmpty()) {
|
||||||
tbOops.setText(INVALID_ZK_SERVER_HOST_MSG);
|
tbOops.setText(INVALID_ZK_SERVER_HOST_MSG);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ZK settings are mandatory
|
// ZK settings are mandatory
|
||||||
String zkPort = tbZkPort.getText().trim();
|
String zkPort = tbZkPort.getText().trim();
|
||||||
if (zkPort.isEmpty() || !portNumberIsValid(zkPort)) {
|
if (zkPort.isEmpty() || !portNumberIsValid(zkPort)) {
|
||||||
|
@ -49,7 +49,7 @@ class Installer extends ModuleInstall {
|
|||||||
server.start();
|
server.start();
|
||||||
} catch (SolrServerNoPortException ex) {
|
} catch (SolrServerNoPortException ex) {
|
||||||
logger.log(Level.SEVERE, "Failed to start Keyword Search server: ", ex); //NON-NLS
|
logger.log(Level.SEVERE, "Failed to start Keyword Search server: ", ex); //NON-NLS
|
||||||
if (ex.getPortNumber() == server.getCurrentSolrServerPort()) {
|
if (ex.getPortNumber() == server.getLocalSolrServerPort()) {
|
||||||
reportPortError(ex.getPortNumber());
|
reportPortError(ex.getPortNumber());
|
||||||
} else {
|
} else {
|
||||||
reportStopPortError(ex.getPortNumber());
|
reportStopPortError(ex.getPortNumber());
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Autopsy Forensic Browser
|
* Autopsy Forensic Browser
|
||||||
*
|
*
|
||||||
* Copyright 2011-2019 Basis Technology Corp.
|
* Copyright 2011-2020 Basis Technology Corp.
|
||||||
* Contact: carrier <at> sleuthkit <dot> org
|
* Contact: carrier <at> sleuthkit <dot> org
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -73,7 +73,6 @@ import org.apache.solr.common.SolrInputDocument;
|
|||||||
import org.apache.solr.common.util.NamedList;
|
import org.apache.solr.common.util.NamedList;
|
||||||
import org.openide.modules.InstalledFileLocator;
|
import org.openide.modules.InstalledFileLocator;
|
||||||
import org.openide.modules.Places;
|
import org.openide.modules.Places;
|
||||||
import org.openide.util.Exceptions;
|
|
||||||
import org.openide.util.NbBundle;
|
import org.openide.util.NbBundle;
|
||||||
import org.openide.windows.WindowManager;
|
import org.openide.windows.WindowManager;
|
||||||
import org.sleuthkit.autopsy.casemodule.Case;
|
import org.sleuthkit.autopsy.casemodule.Case;
|
||||||
@ -84,6 +83,7 @@ import org.sleuthkit.autopsy.coreutils.Logger;
|
|||||||
import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil;
|
import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil;
|
||||||
import org.sleuthkit.autopsy.coreutils.ModuleSettings;
|
import org.sleuthkit.autopsy.coreutils.ModuleSettings;
|
||||||
import org.sleuthkit.autopsy.coreutils.PlatformUtil;
|
import org.sleuthkit.autopsy.coreutils.PlatformUtil;
|
||||||
|
import org.sleuthkit.autopsy.coreutils.ThreadUtils;
|
||||||
import org.sleuthkit.autopsy.healthmonitor.HealthMonitor;
|
import org.sleuthkit.autopsy.healthmonitor.HealthMonitor;
|
||||||
import org.sleuthkit.autopsy.healthmonitor.TimingMetric;
|
import org.sleuthkit.autopsy.healthmonitor.TimingMetric;
|
||||||
import org.sleuthkit.autopsy.keywordsearchservice.KeywordSearchServiceException;
|
import org.sleuthkit.autopsy.keywordsearchservice.KeywordSearchServiceException;
|
||||||
@ -249,8 +249,7 @@ public class Server {
|
|||||||
private HttpSolrClient localSolrServer = null;
|
private HttpSolrClient localSolrServer = null;
|
||||||
private SOLR_VERSION localServerVersion = SOLR_VERSION.SOLR8; // start local Solr 8 by default
|
private SOLR_VERSION localServerVersion = SOLR_VERSION.SOLR8; // start local Solr 8 by default
|
||||||
|
|
||||||
// A reference to the Solr server we are currently connected to for the Case.
|
// A reference to the remote/network running Solr instance.
|
||||||
// This could be a local or remote server.
|
|
||||||
private HttpSolrClient remoteSolrServer;
|
private HttpSolrClient remoteSolrServer;
|
||||||
|
|
||||||
private Collection currentCollection;
|
private Collection currentCollection;
|
||||||
@ -385,11 +384,11 @@ public class Server {
|
|||||||
serverAction.addPropertyChangeListener(l);
|
serverAction.addPropertyChangeListener(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
int getCurrentSolrServerPort() {
|
int getLocalSolrServerPort() {
|
||||||
return localSolrServerPort;
|
return localSolrServerPort;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getCurrentSolrStopPort() {
|
int getLocalSolrStopPort() {
|
||||||
return localSolrStopPort;
|
return localSolrStopPort;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1869,13 +1868,12 @@ public class Server {
|
|||||||
private HttpSolrClient queryClient = null;
|
private HttpSolrClient queryClient = null;
|
||||||
private SolrClient indexingClient = null;
|
private SolrClient indexingClient = null;
|
||||||
|
|
||||||
public final int maxBufferSize;
|
private final int maxBufferSize;
|
||||||
public final List<SolrInputDocument> buffer;
|
private final List<SolrInputDocument> buffer;
|
||||||
private final Object bufferLock;
|
private final Object bufferLock;
|
||||||
|
|
||||||
private ScheduledThreadPoolExecutor periodicTasksExecutor = null;
|
private ScheduledThreadPoolExecutor periodicTasksExecutor = null;
|
||||||
private static final long PERIODIC_BATCH_SEND_INTERVAL_MINUTES = 10;
|
private static final long PERIODIC_BATCH_SEND_INTERVAL_MINUTES = 10;
|
||||||
private static final long EXECUTOR_TERMINATION_WAIT_SECS = 30;
|
|
||||||
|
|
||||||
private Collection(String name, Case theCase, Index index) throws TimeoutException, InterruptedException, SolrServerException, IOException {
|
private Collection(String name, Case theCase, Index index) throws TimeoutException, InterruptedException, SolrServerException, IOException {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
@ -1905,7 +1903,7 @@ public class Server {
|
|||||||
logger.log(Level.INFO, "Using Solr document queue size = {0}", maxBufferSize); //NON-NLS
|
logger.log(Level.INFO, "Using Solr document queue size = {0}", maxBufferSize); //NON-NLS
|
||||||
buffer = new ArrayList<>(maxBufferSize);
|
buffer = new ArrayList<>(maxBufferSize);
|
||||||
periodicTasksExecutor = new ScheduledThreadPoolExecutor(1, new ThreadFactoryBuilder().setNameFormat("periodic-batched-document-task-%d").build()); //NON-NLS
|
periodicTasksExecutor = new ScheduledThreadPoolExecutor(1, new ThreadFactoryBuilder().setNameFormat("periodic-batched-document-task-%d").build()); //NON-NLS
|
||||||
periodicTasksExecutor.scheduleWithFixedDelay(new SentBatchedDocumentsTask(), PERIODIC_BATCH_SEND_INTERVAL_MINUTES, PERIODIC_BATCH_SEND_INTERVAL_MINUTES, TimeUnit.MINUTES);
|
periodicTasksExecutor.scheduleWithFixedDelay(new SendBatchedDocumentsTask(), PERIODIC_BATCH_SEND_INTERVAL_MINUTES, PERIODIC_BATCH_SEND_INTERVAL_MINUTES, TimeUnit.MINUTES);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1914,7 +1912,7 @@ public class Server {
|
|||||||
* if the buffer is not full, we want to periodically send the batched documents
|
* if the buffer is not full, we want to periodically send the batched documents
|
||||||
* so that users are able to see them in their keyword searches.
|
* so that users are able to see them in their keyword searches.
|
||||||
*/
|
*/
|
||||||
private final class SentBatchedDocumentsTask implements Runnable {
|
private final class SendBatchedDocumentsTask implements Runnable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -1933,7 +1931,6 @@ public class Server {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
// send the cloned list to Solr
|
// send the cloned list to Solr
|
||||||
logger.log(Level.INFO, "Periodic batched document update"); //NON-NLS
|
|
||||||
sendBufferedDocs(clone);
|
sendBufferedDocs(clone);
|
||||||
} catch (KeywordSearchModuleException ex) {
|
} catch (KeywordSearchModuleException ex) {
|
||||||
logger.log(Level.SEVERE, "Periodic batched document update failed", ex); //NON-NLS
|
logger.log(Level.SEVERE, "Periodic batched document update failed", ex); //NON-NLS
|
||||||
@ -1979,17 +1976,21 @@ public class Server {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void commit() throws SolrServerException {
|
private void commit() throws SolrServerException {
|
||||||
|
|
||||||
|
List<SolrInputDocument> clone;
|
||||||
synchronized (bufferLock) {
|
synchronized (bufferLock) {
|
||||||
try {
|
// Make a clone and release the lock, so that we don't
|
||||||
// we do a manual commit after ingest is complete, so I
|
// hold other ingest threads
|
||||||
// think there is no need to clone the buffer
|
clone = buffer.stream().collect(toList());
|
||||||
sendBufferedDocs(buffer);
|
buffer.clear();
|
||||||
} catch (KeywordSearchModuleException ex) {
|
|
||||||
throw new SolrServerException(NbBundle.getMessage(this.getClass(), "Server.commit.exception.msg"), ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
sendBufferedDocs(clone);
|
||||||
|
} catch (KeywordSearchModuleException ex) {
|
||||||
|
throw new SolrServerException(NbBundle.getMessage(this.getClass(), "Server.commit.exception.msg"), ex);
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
//commit and block
|
//commit and block
|
||||||
indexingClient.commit(true, true);
|
indexingClient.commit(true, true);
|
||||||
@ -2107,14 +2108,7 @@ public class Server {
|
|||||||
try {
|
try {
|
||||||
// stop the periodic batch update task. If the task is already running,
|
// stop the periodic batch update task. If the task is already running,
|
||||||
// allow it to finish.
|
// allow it to finish.
|
||||||
periodicTasksExecutor.shutdown();
|
ThreadUtils.shutDownTaskExecutor(periodicTasksExecutor);
|
||||||
try {
|
|
||||||
while (!periodicTasksExecutor.awaitTermination(EXECUTOR_TERMINATION_WAIT_SECS, TimeUnit.SECONDS)) {
|
|
||||||
logger.log(Level.WARNING, "Waited at least {0} seconds for periodic KWS task executor to shut down, continuing to wait", EXECUTOR_TERMINATION_WAIT_SECS); //NON-NLS
|
|
||||||
}
|
|
||||||
} catch (InterruptedException ex) {
|
|
||||||
logger.log(Level.SEVERE, "Unexpected interrupt while stopping periodic KWS task executor", ex); //NON-NLS
|
|
||||||
}
|
|
||||||
|
|
||||||
// We only unload cores for "single-user" cases.
|
// We only unload cores for "single-user" cases.
|
||||||
if (this.caseType == CaseType.MULTI_USER_CASE) {
|
if (this.caseType == CaseType.MULTI_USER_CASE) {
|
||||||
|
@ -150,10 +150,10 @@ public class SolrSearchService implements KeywordSearchService, AutopsyService {
|
|||||||
try {
|
try {
|
||||||
KeywordSearch.getServer().connectToSolrServer(host, Integer.toString(port));
|
KeywordSearch.getServer().connectToSolrServer(host, Integer.toString(port));
|
||||||
} catch (SolrServerException ex) {
|
} catch (SolrServerException ex) {
|
||||||
logger.log(Level.SEVERE, "Uanble to connect to Solr server. Host: " + host + ", port: " + port, ex);
|
logger.log(Level.SEVERE, "Unable to connect to Solr server. Host: " + host + ", port: " + port, ex);
|
||||||
throw new KeywordSearchServiceException(NbBundle.getMessage(SolrSearchService.class, "SolrConnectionCheck.HostnameOrPort")); //NON-NLS*/
|
throw new KeywordSearchServiceException(NbBundle.getMessage(SolrSearchService.class, "SolrConnectionCheck.HostnameOrPort")); //NON-NLS*/
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
logger.log(Level.SEVERE, "Uanble to connect to Solr server. Host: " + host + ", port: " + port, ex);
|
logger.log(Level.SEVERE, "Unable to connect to Solr server. Host: " + host + ", port: " + port, ex);
|
||||||
String result = NbBundle.getMessage(SolrSearchService.class, "SolrConnectionCheck.HostnameOrPort"); //NON-NLS
|
String result = NbBundle.getMessage(SolrSearchService.class, "SolrConnectionCheck.HostnameOrPort"); //NON-NLS
|
||||||
String message = ex.getCause().getMessage().toLowerCase();
|
String message = ex.getCause().getMessage().toLowerCase();
|
||||||
if (message.startsWith(SERVER_REFUSED_CONNECTION)) {
|
if (message.startsWith(SERVER_REFUSED_CONNECTION)) {
|
||||||
@ -173,10 +173,10 @@ public class SolrSearchService implements KeywordSearchService, AutopsyService {
|
|||||||
}
|
}
|
||||||
throw new KeywordSearchServiceException(result);
|
throw new KeywordSearchServiceException(result);
|
||||||
} catch (NumberFormatException ex) {
|
} catch (NumberFormatException ex) {
|
||||||
logger.log(Level.SEVERE, "Uanble to connect to Solr server. Host: " + host + ", port: " + port, ex);
|
logger.log(Level.SEVERE, "Unable to connect to Solr server. Host: " + host + ", port: " + port, ex);
|
||||||
throw new KeywordSearchServiceException(Bundle.SolrConnectionCheck_Port());
|
throw new KeywordSearchServiceException(Bundle.SolrConnectionCheck_Port());
|
||||||
} catch (IllegalArgumentException ex) {
|
} catch (IllegalArgumentException ex) {
|
||||||
logger.log(Level.SEVERE, "Uanble to connect to Solr server. Host: " + host + ", port: " + port, ex);
|
logger.log(Level.SEVERE, "Unable to connect to Solr server. Host: " + host + ", port: " + port, ex);
|
||||||
throw new KeywordSearchServiceException(ex.getMessage());
|
throw new KeywordSearchServiceException(ex.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user