Check IngestManager to see if ingest is ongoing

This commit is contained in:
Devin148 2012-12-06 14:41:34 -05:00
parent 183d5a448d
commit 331f24abf5
6 changed files with 40 additions and 55 deletions

View File

@ -86,9 +86,6 @@ public class HashDbIngestModule implements IngestModuleAbstractFile {
@Override
public void init(IngestModuleInit initContext) {
services = IngestServices.getDefault();
getPanel().setIngestRunning(true);
HashDbSimplePanel.setIngestRunning(true);
HashDbSearchPanel.getDefault().setIngestRunning(true);
this.services.postMessage(IngestMessage.createMessage(++messageId, IngestMessage.MessageType.INFO, this, "Started"));
this.skCase = Case.getCurrentCase().getSleuthkitCase();
try {
@ -154,10 +151,6 @@ public class HashDbIngestModule implements IngestModuleAbstractFile {
detailsSb.append("</table>");
services.postMessage(IngestMessage.createMessage(++messageId, IngestMessage.MessageType.INFO, this, "Hash Ingest Complete", detailsSb.toString()));
getPanel().setIngestRunning(false);
HashDbSimplePanel.setIngestRunning(false);
HashDbSearchPanel.getDefault().setIngestRunning(false);
}
/**
@ -167,9 +160,6 @@ public class HashDbIngestModule implements IngestModuleAbstractFile {
@Override
public void stop() {
//manager.postMessage(IngestMessage.createMessage(++messageId, IngestMessage.MessageType.INFO, this, "STOP"));
getPanel().setIngestRunning(false);
HashDbSimplePanel.setIngestRunning(false);
HashDbSearchPanel.getDefault().setIngestRunning(false);
}
/**

View File

@ -42,12 +42,13 @@ import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableCellRenderer;
import org.sleuthkit.autopsy.corecomponents.OptionsPanel;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.ingest.IngestManager;
final class HashDbManagementPanel extends javax.swing.JPanel implements OptionsPanel {
private HashSetTableModel hashSetTableModel;
private static final Logger logger = Logger.getLogger(HashDbManagementPanel.class.getName());
private static boolean ingestRunning = false;
private boolean ingestRunning = false;
//keep track of dbs being indexed, since HashDb objects are reloaded,
@ -134,9 +135,10 @@ final class HashDbManagementPanel extends javax.swing.JPanel implements OptionsP
* Don't allow any changes if ingest is running.
* @param running Whether ingest is running or not.
*/
void setIngestRunning(boolean running) {
private void setIngestStatus(boolean running) {
ingestRunning = running;
ingestWarningLabel.setVisible(running);
importButton.setEnabled(!running);
int selection = getSelection();
if(selection != -1) {
@ -493,6 +495,7 @@ final class HashDbManagementPanel extends javax.swing.JPanel implements OptionsP
HashDbXML.getCurrent().reload(); // Reload XML
initUI(null); // Update the UI
hashSetTableModel.resync(); // resync the table
setIngestStatus(IngestManager.getDefault().isIngestRunning()); // check if ingest is running
}
@Override
@ -758,7 +761,7 @@ final class HashDbManagementPanel extends javax.swing.JPanel implements OptionsP
theLabel.setForeground(Color.black);
theButton.setEnabled(false);
}
if (ingestRunning) {
if (IngestManager.getDefault().isIngestRunning()) {
theButton.setEnabled(false);
}
}

View File

@ -91,6 +91,7 @@ class HashDbPanelSearchAction extends CallableSystemAction {
dialog.close();
}
});
panel.refresh();
dialog.display(panel);
}

View File

@ -37,17 +37,17 @@
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="saveBox" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="errorField" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="searchButton" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="cancelButton" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
@ -152,9 +152,6 @@
</Component>
<Component class="javax.swing.JLabel" name="titleLabel">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Tahoma" size="11" style="1"/>
</Property>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/hashdatabase/Bundle.properties" key="HashDbSearchPanel.titleLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>

View File

@ -30,6 +30,7 @@ import javax.swing.table.DefaultTableModel;
import javax.swing.text.AttributeSet;
import javax.swing.text.BadLocationException;
import javax.swing.text.PlainDocument;
import org.sleuthkit.autopsy.ingest.IngestManager;
/**
* Searches for files by md5 hash, based off the hash given in this panel.
@ -37,7 +38,6 @@ import javax.swing.text.PlainDocument;
public class HashDbSearchPanel extends javax.swing.JPanel implements ActionListener {
private static final Logger logger = Logger.getLogger(HashDbSearchPanel.class.getName());
private static HashDbSearchPanel instance;
private static boolean ingestRunning = false;
/**
* @return the default instance of this panel
@ -49,10 +49,31 @@ public class HashDbSearchPanel extends javax.swing.JPanel implements ActionListe
return instance;
}
/**
* Check if ingest is currently running and refresh the panel accordingly.
*/
public void refresh() {
boolean running = IngestManager.getDefault().isIngestRunning();
if(running) {
titleLabel.setForeground(Color.red);
titleLabel.setText("Ingest is ongoing; this service will be unavailable until it finishes.");
} else {
titleLabel.setForeground(Color.black);
titleLabel.setText("Search for files with the following MD5 hash(es):");
}
hashField.setEditable(!running);
searchButton.setEnabled(!running);
addButton.setEnabled(!running);
removeButton.setEnabled(!running);
hashTable.setEnabled(!running);
hashLabel.setEnabled(!running);
saveBox.setEnabled(!running);
}
/**
* Creates new form HashDbSearchPanel
*/
public HashDbSearchPanel() {
private HashDbSearchPanel() {
setName(HashDbPanelSearchAction.ACTION_NAME);
initComponents();
customInit();
@ -103,27 +124,6 @@ public class HashDbSearchPanel extends javax.swing.JPanel implements ActionListe
cancelButton.addActionListener(l);
}
/**
* Don't allow any changes if ingest is running
*/
void setIngestRunning(boolean running) {
ingestRunning = running;
if(running) {
titleLabel.setForeground(Color.red);
titleLabel.setText("Ingest is ongoing; this service will be unavailable until it finishes.");
} else {
titleLabel.setForeground(Color.black);
titleLabel.setText("Search for files with the following MD5 hash(es):");
}
hashField.setEditable(!ingestRunning);
searchButton.setEnabled(!ingestRunning);
addButton.setEnabled(!ingestRunning);
removeButton.setEnabled(!ingestRunning);
hashTable.setEnabled(!ingestRunning);
hashLabel.setEnabled(!ingestRunning);
saveBox.setEnabled(!ingestRunning);
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
@ -182,7 +182,6 @@ public class HashDbSearchPanel extends javax.swing.JPanel implements ActionListe
org.openide.awt.Mnemonics.setLocalizedText(removeButton, org.openide.util.NbBundle.getMessage(HashDbSearchPanel.class, "HashDbSearchPanel.removeButton.text")); // NOI18N
titleLabel.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
org.openide.awt.Mnemonics.setLocalizedText(titleLabel, org.openide.util.NbBundle.getMessage(HashDbSearchPanel.class, "HashDbSearchPanel.titleLabel.text")); // NOI18N
errorField.setForeground(new java.awt.Color(255, 0, 0));
@ -222,9 +221,8 @@ public class HashDbSearchPanel extends javax.swing.JPanel implements ActionListe
.addComponent(saveBox)))
.addGap(0, 0, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(errorField)
.addGap(18, 18, 18)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(searchButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(cancelButton)))

View File

@ -32,6 +32,7 @@ import javax.swing.JOptionPane;
import javax.swing.JTable;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableColumn;
import org.sleuthkit.autopsy.ingest.IngestManager;
/**
*
@ -42,7 +43,6 @@ public class HashDbSimplePanel extends javax.swing.JPanel {
private static final Logger logger = Logger.getLogger(HashDbSimplePanel.class.getName());
private HashTableModel knownBadTableModel;
private HashDb nsrl;
private static boolean ingestRunning = false;
/** Creates new form HashDbSimplePanel */
public HashDbSimplePanel() {
@ -51,10 +51,6 @@ public class HashDbSimplePanel extends javax.swing.JPanel {
customizeComponents();
}
static void setIngestRunning(boolean running) {
ingestRunning = running;
}
private void reloadCalc() {
final HashDbXML xmlHandle = HashDbXML.getCurrent();
final HashDb nsrlDb = xmlHandle.getNSRLSet();
@ -256,7 +252,7 @@ public class HashDbSimplePanel extends javax.swing.JPanel {
@Override
public boolean isCellEditable(int rowIndex, int columnIndex) {
return !ingestRunning && columnIndex == 0;
return !IngestManager.getDefault().isIngestRunning() && columnIndex == 0;
}
@Override