mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-12 16:06:15 +00:00
Improved error handling.
This commit is contained in:
parent
3539b6c70e
commit
1912be53e5
@ -21,6 +21,9 @@ package org.sleuthkit.autopsy.centralrepository;
|
|||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import javax.swing.AbstractAction;
|
import javax.swing.AbstractAction;
|
||||||
|
import org.openide.DialogDisplayer;
|
||||||
|
import org.openide.NotifyDescriptor;
|
||||||
|
import org.openide.util.NbBundle;
|
||||||
import org.openide.util.NbBundle.Messages;
|
import org.openide.util.NbBundle.Messages;
|
||||||
import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttribute;
|
import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttribute;
|
||||||
import org.sleuthkit.autopsy.centralrepository.datamodel.EamArtifactUtil;
|
import org.sleuthkit.autopsy.centralrepository.datamodel.EamArtifactUtil;
|
||||||
@ -40,6 +43,7 @@ public final class AddEditCentralRepoCommentAction extends AbstractAction {
|
|||||||
|
|
||||||
private boolean addToDatabase;
|
private boolean addToDatabase;
|
||||||
private CorrelationAttribute correlationAttribute;
|
private CorrelationAttribute correlationAttribute;
|
||||||
|
private String comment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private constructor to create an instance given a CorrelationAttribute.
|
* Private constructor to create an instance given a CorrelationAttribute.
|
||||||
@ -54,8 +58,8 @@ public final class AddEditCentralRepoCommentAction extends AbstractAction {
|
|||||||
/**
|
/**
|
||||||
* Private constructor to create an instance given an AbstractFile.
|
* Private constructor to create an instance given an AbstractFile.
|
||||||
*
|
*
|
||||||
* @param file The file from which a correlation attribute to modify is
|
* @param file The file from which a correlation attribute to modify is
|
||||||
* derived.
|
* derived.
|
||||||
*/
|
*/
|
||||||
public AddEditCentralRepoCommentAction(AbstractFile file) {
|
public AddEditCentralRepoCommentAction(AbstractFile file) {
|
||||||
super(Bundle.AddEditCentralRepoCommentAction_menuItemText_addEditCentralRepoComment());
|
super(Bundle.AddEditCentralRepoCommentAction_menuItemText_addEditCentralRepoComment());
|
||||||
@ -66,26 +70,24 @@ public final class AddEditCentralRepoCommentAction extends AbstractAction {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent event) {
|
|
||||||
addEditCentralRepoComment();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a Add/Edit dialog for the correlation attribute file instance
|
* Create a Add/Edit dialog for the correlation attribute file instance
|
||||||
* comment. The comment will be updated in the database if the file instance
|
* comment. The comment will be updated in the database if the file instance
|
||||||
* exists there, or a new file instance will be added to the database with
|
* exists there, or a new file instance will be added to the database with
|
||||||
* the comment attached otherwise.
|
* the comment attached otherwise.
|
||||||
*
|
*
|
||||||
* The current comment for this instance is returned in case it is needed to
|
* The current comment for this instance is is saved in case it is needed to
|
||||||
* update the display.
|
* update the display. If the comment was not changed either due to the
|
||||||
*
|
* action being canceled or the occurrence of an error, the comment will be
|
||||||
* @return the current comment for this instance
|
* null.
|
||||||
*/
|
*/
|
||||||
public String addEditCentralRepoComment() {
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent event) {
|
||||||
CentralRepoCommentDialog centralRepoCommentDialog = new CentralRepoCommentDialog(correlationAttribute);
|
CentralRepoCommentDialog centralRepoCommentDialog = new CentralRepoCommentDialog(correlationAttribute);
|
||||||
centralRepoCommentDialog.display();
|
centralRepoCommentDialog.display();
|
||||||
|
|
||||||
|
comment = null;
|
||||||
|
|
||||||
if (centralRepoCommentDialog.isCommentUpdated()) {
|
if (centralRepoCommentDialog.isCommentUpdated()) {
|
||||||
EamDb dbManager;
|
EamDb dbManager;
|
||||||
|
|
||||||
@ -97,13 +99,26 @@ public final class AddEditCentralRepoCommentAction extends AbstractAction {
|
|||||||
} else {
|
} else {
|
||||||
dbManager.updateAttributeInstanceComment(correlationAttribute);
|
dbManager.updateAttributeInstanceComment(correlationAttribute);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
comment = centralRepoCommentDialog.getNewComment();
|
||||||
} catch (EamDbException ex) {
|
} catch (EamDbException ex) {
|
||||||
logger.log(Level.SEVERE, "Error adding comment", ex);
|
logger.log(Level.SEVERE, "Error adding comment", ex);
|
||||||
//DLG: Create error popup dialog here.
|
NotifyDescriptor notifyDescriptor = new NotifyDescriptor.Message(
|
||||||
return centralRepoCommentDialog.getOriginalComment();
|
"An error occurred while trying to save the comment to the central repository.",
|
||||||
|
NotifyDescriptor.ERROR_MESSAGE);
|
||||||
|
DialogDisplayer.getDefault().notify(notifyDescriptor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return centralRepoCommentDialog.getNewComment();
|
/**
|
||||||
|
* Retrieve the comment that was last saved. If a comment update was
|
||||||
|
* canceled or an error occurred while attempting to save the comment, the
|
||||||
|
* comment will be null.
|
||||||
|
*
|
||||||
|
* @return The comment.
|
||||||
|
*/
|
||||||
|
public String getComment() {
|
||||||
|
return comment;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -127,9 +127,12 @@ public class DataContentViewerOtherCases extends JPanel implements DataContentVi
|
|||||||
try {
|
try {
|
||||||
OtherOccurrenceNodeData selectedNode = (OtherOccurrenceNodeData) tableModel.getRow(otherCasesTable.getSelectedRow());
|
OtherOccurrenceNodeData selectedNode = (OtherOccurrenceNodeData) tableModel.getRow(otherCasesTable.getSelectedRow());
|
||||||
AddEditCentralRepoCommentAction action = new AddEditCentralRepoCommentAction(selectedNode.createCorrelationAttribute());
|
AddEditCentralRepoCommentAction action = new AddEditCentralRepoCommentAction(selectedNode.createCorrelationAttribute());
|
||||||
String currentComment = action.addEditCentralRepoComment();
|
action.actionPerformed(null);
|
||||||
selectedNode.updateComment(currentComment);
|
String currentComment = action.getComment();
|
||||||
otherCasesTable.repaint();
|
if (currentComment != null) {
|
||||||
|
selectedNode.updateComment(action.getComment());
|
||||||
|
otherCasesTable.repaint();
|
||||||
|
}
|
||||||
} catch (EamDbException ex) {
|
} catch (EamDbException ex) {
|
||||||
logger.log(Level.SEVERE, "Error performing Add/Edit Central Repository Comment action", ex);
|
logger.log(Level.SEVERE, "Error performing Add/Edit Central Repository Comment action", ex);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user