Merge pull request #1455 from eugene7646/services_check

Services check
This commit is contained in:
Richard Cordovano 2015-07-23 11:09:04 -04:00
commit f46d55123f
7 changed files with 123 additions and 62 deletions

View File

@ -192,7 +192,7 @@ MissingImageDialog.confDlg.noFileSel.title=Missing Image
MissingImageDialog.ErrorSettingImage=Error setting image path. Please try again.
NewCaseVisualPanel1.getName.text=Case Info
NewCaseVisualPanel1.caseDirBrowse.selectButton.text=Select
NewCaseVisualPanel1.badCredentials.text=Bad multi-user settings. See Tools, Options, Multi-user.
NewCaseVisualPanel1.badCredentials.text=Bad multi-user settings (see Tools, Options, Multi-user) or services are down.
NewCaseVisualPanel1.MultiUserDisabled.text=Multi-user cases not enabled. See Tools, Options, Multi-user.
NewCaseVisualPanel2.getName.text=Additional Information
NewCaseWizardAction.closeCurCase.confMsg.msg=Do you want to save and close this case and proceed with the new case creation?

View File

@ -29,13 +29,9 @@
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="1" attributes="0">
<Component id="caseDirTextField" alignment="0" max="32767" attributes="1"/>
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="0" pref="58" max="32767" attributes="0"/>
<Component id="lbBadMultiUserSettings" min="-2" pref="372" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
<EmptySpace min="0" pref="227" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="caseDirLabel" min="-2" max="-2" attributes="0"/>
@ -47,6 +43,7 @@
<EmptySpace min="-2" pref="26" max="-2" attributes="0"/>
<Component id="caseNameTextField" max="32767" attributes="0"/>
</Group>
<Component id="lbBadMultiUserSettings" alignment="1" max="32767" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="caseDirBrowseButton" min="-2" max="-2" attributes="0"/>

View File

@ -50,27 +50,7 @@ final class NewCaseVisualPanel1 extends JPanel implements DocumentListener {
this.wizPanel = wizPanel;
caseNameTextField.getDocument().addDocumentListener(this);
caseParentDirTextField.getDocument().addDocumentListener(this);
CaseDbConnectionInfo info = UserPreferences.getDatabaseConnectionInfo();
if (info.getDbType() == DbType.SQLITE) {
rbSingleUserCase.setSelected(true);
rbSingleUserCase.setEnabled(false);
rbMultiUserCase.setEnabled(false);
lbBadMultiUserSettings.setForeground(new java.awt.Color(153, 153, 153)); // Gray
lbBadMultiUserSettings.setText(NbBundle.getMessage(this.getClass(), "NewCaseVisualPanel1.MultiUserDisabled.text"));
} else {
rbSingleUserCase.setEnabled(true);
rbMultiUserCase.setEnabled(true);
if (true == info.canConnect()) {
rbMultiUserCase.setSelected(true); // default to multi-user if available
} else {
// if we cannot connect to the shared database, don't present the option
lbBadMultiUserSettings.setForeground(new java.awt.Color(255, 0, 0)); // Red
lbBadMultiUserSettings.setText(NbBundle.getMessage(this.getClass(), "NewCaseVisualPanel1.badCredentials.text"));
rbSingleUserCase.setSelected(true);
rbSingleUserCase.setEnabled(false);
rbMultiUserCase.setEnabled(false);
}
}
rbMultiUserCase.setSelected(true); // default to multi-user if available
}
/**
@ -208,12 +188,9 @@ final class NewCaseVisualPanel1 extends JPanel implements DocumentListener {
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(caseDirTextField, javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(0, 58, Short.MAX_VALUE)
.addComponent(lbBadMultiUserSettings, javax.swing.GroupLayout.PREFERRED_SIZE, 372, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addComponent(jLabel1)
.addGap(0, 0, Short.MAX_VALUE))
.addGap(0, 227, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addComponent(caseDirLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
@ -221,7 +198,8 @@ final class NewCaseVisualPanel1 extends JPanel implements DocumentListener {
.addGroup(layout.createSequentialGroup()
.addComponent(caseNameLabel)
.addGap(26, 26, 26)
.addComponent(caseNameTextField)))
.addComponent(caseNameTextField))
.addComponent(lbBadMultiUserSettings, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(caseDirBrowseButton)))
.addContainerGap())
@ -324,6 +302,11 @@ final class NewCaseVisualPanel1 extends JPanel implements DocumentListener {
@Override
public void insertUpdate(DocumentEvent e) {
this.wizPanel.fireChangeEvent();
/*
NOTE: verifyMultiUserSettings() is called from here as opposed to updateUI()
because updateUI() is called several times when this wizard is loaded.
*/
verifyMultiUserSettings();
updateUI(e);
}
@ -378,6 +361,40 @@ final class NewCaseVisualPanel1 extends JPanel implements DocumentListener {
warnIfPathIsInvalid(parentDir);
}
/**
* Tests multi-user settings by verifying connectivity to all required
* multi-user services.
*/
private void verifyMultiUserSettings(){
CaseDbConnectionInfo info = UserPreferences.getDatabaseConnectionInfo();
if (info.getDbType() == DbType.SQLITE) {
rbSingleUserCase.setSelected(true);
rbSingleUserCase.setEnabled(false);
rbMultiUserCase.setEnabled(false);
lbBadMultiUserSettings.setForeground(new java.awt.Color(153, 153, 153)); // Gray
lbBadMultiUserSettings.setText(NbBundle.getMessage(this.getClass(), "NewCaseVisualPanel1.MultiUserDisabled.text"));
} else {
rbSingleUserCase.setEnabled(true);
rbMultiUserCase.setEnabled(true);
// multi-user cases must have multi-user database service running
if (info.canConnect()) {
/* NOTE: natural way would be to call lbBadMultiUserSettings.setVisible(false)
but if you do that Netbeans for some reason resizes the entire panel so it
becomes much narrower horizontally.
*/
lbBadMultiUserSettings.setText("");
} else {
// if we cannot connect to the shared database, don't present the option
lbBadMultiUserSettings.setForeground(new java.awt.Color(255, 0, 0)); // Red
lbBadMultiUserSettings.setText(NbBundle.getMessage(this.getClass(), "NewCaseVisualPanel1.badCredentials.text"));
lbBadMultiUserSettings.setVisible(true);
rbSingleUserCase.setSelected(true);
rbSingleUserCase.setEnabled(false);
rbMultiUserCase.setEnabled(false);
}
}
}
/**
* Validates path to selected case output folder. Displays warning if path is invalid.
*

View File

@ -211,6 +211,12 @@ public class ServicesMonitor {
if (service == null) {
throw new ServicesMonitorException(NbBundle.getMessage(ServicesMonitor.class, "ServicesMonitor.nullServiceName.excepton.txt"));
}
// if request is for one of our "core" services - perform an on demand check
// to make sure we have the latest status.
if (servicesList.contains(service)){
checkServiceStatus(service);
}
String status = statusByService.get(service);
if (status == null) {

View File

@ -530,6 +530,31 @@ public class IngestManager {
if (runInteractively && jobsById.size() == 1) {
clearIngestMessageBox();
}
// multi-user cases must have multi-user database service running
if (Case.getCurrentCase().getCaseType() == Case.CaseType.MULTI_USER_CASE) {
try {
if (!servicesMonitor.getServiceStatus(ServicesMonitor.Service.REMOTE_CASE_DATABASE.toString()).equals(ServicesMonitor.ServiceStatus.UP.toString())) {
// display notification if running interactively
if (isRunningInteractively()) {
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
String serviceDisplayName = ServicesMonitor.Service.REMOTE_CASE_DATABASE.getDisplayName();
JOptionPane.showMessageDialog(null,
NbBundle.getMessage(this.getClass(), "IngestManager.cancellingIngest.msgDlg.text"),
NbBundle.getMessage(this.getClass(), "IngestManager.serviceIsDown.msgDlg.text", serviceDisplayName),
JOptionPane.ERROR_MESSAGE);
}
});
}
// abort ingest
return false;
}
} catch (ServicesMonitor.ServicesMonitorException ignore) {
return false;
}
}
if (!ingestMonitor.isRunning()) {
ingestMonitor.start();

View File

@ -106,6 +106,7 @@ KeywordSearchFilterNode.getFileActions.openExternViewActLbl=Open in External Vie
KeywordSearchFilterNode.getFileActions.searchSameMd5=Search for files with the same MD5 hash
KeywordSearchFilterNode.getFileActions.viewInNewWinActionLbl=View in New Window
KeywordSearchIngestModule.init.badInitMsg=Keyword search server was not properly initialized, cannot run keyword search ingest.
KeywordSearchIngestModule.init.verifyConnection=Please verify credentials and connectivity to multi-user keyword search service.
KeywordSearchIngestModule.init.tryStopSolrMsg={0}<br />Please try stopping old java Solr process (if it exists) and restart the application.
KeywordSearchIngestModule.init.noKwInLstMsg=No keywords in keyword list.
KeywordSearchIngestModule.init.onlyIdxKwSkipMsg=Only indexing will be done and and keyword search will be skipped (you can still add keyword lists using the Keyword Lists - Add to Ingest).

View File

@ -25,6 +25,7 @@ import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Level;
import org.openide.util.NbBundle;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil;
import org.sleuthkit.autopsy.coreutils.StringExtract.StringExtractUnicodeTable.SCRIPT;
@ -35,6 +36,7 @@ import org.sleuthkit.autopsy.ingest.IngestMessage.MessageType;
import org.sleuthkit.autopsy.ingest.IngestModuleReferenceCounter;
import org.sleuthkit.autopsy.ingest.IngestServices;
import org.sleuthkit.autopsy.keywordsearch.Ingester.IngesterException;
import org.sleuthkit.autopsy.keywordsearchservice.KeywordSearchService;
import org.sleuthkit.autopsy.modules.filetypeid.FileTypeDetector;
import org.sleuthkit.datamodel.AbstractFile;
import org.sleuthkit.datamodel.TskCoreException;
@ -141,46 +143,59 @@ public final class KeywordSearchIngestModule implements FileIngestModule {
// increment the module reference count
// if first instance of this module for this job then check the server and existence of keywords
if (refCounter.incrementAndGet(jobId) == 1) {
final Server server = KeywordSearch.getServer();
try {
if (!server.isRunning()) {
if (Case.getCurrentCase().getCaseType() == Case.CaseType.MULTI_USER_CASE) {
// for multi-user cases need to verify connection to remore SOLR server
KeywordSearchService kwsService = new SolrSearchService();
if (!kwsService.canConnectToRemoteSolrServer()) {
String msg = NbBundle.getMessage(this.getClass(), "KeywordSearchIngestModule.init.badInitMsg");
logger.log(Level.SEVERE, msg);
String details = NbBundle.getMessage(this.getClass(), "KeywordSearchIngestModule.init.verifyConnection");
services.postMessage(IngestMessage.createErrorMessage(KeywordSearchModuleFactory.getModuleName(), msg, details));
throw new IngestModuleException(msg);
}
} else {
// for single-user cases need to verify connection to local SOLR service
final Server server = KeywordSearch.getServer();
try {
if (!server.isRunning()) {
String msg = NbBundle.getMessage(this.getClass(), "KeywordSearchIngestModule.init.badInitMsg");
logger.log(Level.SEVERE, msg);
String details = NbBundle.getMessage(this.getClass(), "KeywordSearchIngestModule.init.tryStopSolrMsg", msg);
services.postMessage(IngestMessage.createErrorMessage(KeywordSearchModuleFactory.getModuleName(), msg, details));
throw new IngestModuleException(msg);
}
} catch (KeywordSearchModuleException ex) {
logger.log(Level.WARNING, "Error checking if Solr server is running while initializing ingest", ex); //NON-NLS
//this means Solr is not properly initialized
String msg = NbBundle.getMessage(this.getClass(), "KeywordSearchIngestModule.init.badInitMsg");
String details = NbBundle.getMessage(this.getClass(), "KeywordSearchIngestModule.init.tryStopSolrMsg", msg);
services.postMessage(IngestMessage.createErrorMessage(KeywordSearchModuleFactory.getModuleName(), msg, details));
throw new IngestModuleException(msg);
}
} catch (KeywordSearchModuleException ex) {
logger.log(Level.WARNING, "Error checking if Solr server is running while initializing ingest", ex); //NON-NLS
//this means Solr is not properly initialized
String msg = NbBundle.getMessage(this.getClass(), "KeywordSearchIngestModule.init.badInitMsg");
String details = NbBundle.getMessage(this.getClass(), "KeywordSearchIngestModule.init.tryStopSolrMsg", msg);
services.postMessage(IngestMessage.createErrorMessage(KeywordSearchModuleFactory.getModuleName(), msg, details));
throw new IngestModuleException(msg);
}
try {
try {
// make an actual query to verify that server is responding
// we had cases where getStatus was OK, but the connection resulted in a 404
server.queryNumIndexedDocuments();
} catch (KeywordSearchModuleException | NoOpenCoreException ex) {
throw new IngestModuleException(
NbBundle.getMessage(this.getClass(), "KeywordSearchIngestModule.init.exception.errConnToSolr.msg",
ex.getMessage()));
}
// we had cases where getStatus was OK, but the connection resulted in a 404
server.queryNumIndexedDocuments();
} catch (KeywordSearchModuleException | NoOpenCoreException ex) {
throw new IngestModuleException(
NbBundle.getMessage(this.getClass(), "KeywordSearchIngestModule.init.exception.errConnToSolr.msg",
ex.getMessage()));
}
// check if this job has any searchable keywords
List<KeywordList> keywordLists = XmlKeywordSearchList.getCurrent().getListsL();
boolean hasKeywordsForSearch = false;
for (KeywordList keywordList : keywordLists) {
if (settings.keywordListIsEnabled(keywordList.getName()) && !keywordList.getKeywords().isEmpty()) {
hasKeywordsForSearch = true;
break;
// check if this job has any searchable keywords
List<KeywordList> keywordLists = XmlKeywordSearchList.getCurrent().getListsL();
boolean hasKeywordsForSearch = false;
for (KeywordList keywordList : keywordLists) {
if (settings.keywordListIsEnabled(keywordList.getName()) && !keywordList.getKeywords().isEmpty()) {
hasKeywordsForSearch = true;
break;
}
}
if (!hasKeywordsForSearch) {
services.postMessage(IngestMessage.createWarningMessage(KeywordSearchModuleFactory.getModuleName(), NbBundle.getMessage(this.getClass(), "KeywordSearchIngestModule.init.noKwInLstMsg"),
NbBundle.getMessage(this.getClass(), "KeywordSearchIngestModule.init.onlyIdxKwSkipMsg")));
}
}
if (!hasKeywordsForSearch) {
services.postMessage(IngestMessage.createWarningMessage(KeywordSearchModuleFactory.getModuleName(), NbBundle.getMessage(this.getClass(), "KeywordSearchIngestModule.init.noKwInLstMsg"),
NbBundle.getMessage(this.getClass(), "KeywordSearchIngestModule.init.onlyIdxKwSkipMsg")));
}
}
//initialize extractors