From 17e56c19efc4fe23b302ca12ac33b4038f2317be Mon Sep 17 00:00:00 2001 From: William Schaefer Date: Fri, 10 Aug 2018 12:19:30 -0400 Subject: [PATCH] 4014-more clean up of comments and logging for has comment column code --- Core/src/org/sleuthkit/autopsy/casemodule/Case.java | 10 +++++++--- .../autopsy/casemodule/events/CommentChangedEvent.java | 4 ++-- .../AddEditCentralRepoCommentAction.java | 9 ++++----- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/Case.java b/Core/src/org/sleuthkit/autopsy/casemodule/Case.java index e798cf7733..0328f9d0af 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/Case.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/Case.java @@ -375,6 +375,10 @@ public class Case { */ TAG_DEFINITION_CHANGED, + /** + * An item in the central repository has had its comment modified. The + * old value is null, the new value is string for current comment. + */ CR_COMMENT_CHANGED; }; @@ -1103,7 +1107,7 @@ public class Case { /* * Open the top components (windows within the main application * window). - * + * * Note: If the core windows are not opened here, they will be * opened via the DirectoryTreeTopComponent 'propertyChange()' * method on a DATA_SOURCE_ADDED event. @@ -1536,10 +1540,10 @@ public class Case { eventPublisher.publish(new AutopsyEvent(Events.TAG_DEFINITION_CHANGED.toString(), changedTagName, null)); } - public void notifyCentralRepoCommentChanged(long id){ + public void notifyCentralRepoCommentChanged(long id) { eventPublisher.publish(new CommentChangedEvent(id)); } - + /** * Notifies case event subscribers that an artifact tag has been added. * diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/events/CommentChangedEvent.java b/Core/src/org/sleuthkit/autopsy/casemodule/events/CommentChangedEvent.java index ceac649003..205108a812 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/events/CommentChangedEvent.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/events/CommentChangedEvent.java @@ -12,8 +12,8 @@ public class CommentChangedEvent extends AutopsyEvent implements Serializable { private final long contentID; - public CommentChangedEvent(long id) { - super(Case.Events.CR_COMMENT_CHANGED.toString(), true, false); + public CommentChangedEvent(long id, String newComment) { + super(Case.Events.CR_COMMENT_CHANGED.toString(), null, newComment); contentID = id; } diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/AddEditCentralRepoCommentAction.java b/Core/src/org/sleuthkit/autopsy/centralrepository/AddEditCentralRepoCommentAction.java index 4bafab7ddd..7837c4361c 100755 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/AddEditCentralRepoCommentAction.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/AddEditCentralRepoCommentAction.java @@ -23,8 +23,6 @@ import java.util.logging.Level; import javax.swing.AbstractAction; import org.openide.DialogDisplayer; import org.openide.NotifyDescriptor; -import org.openide.util.Exceptions; -import org.openide.util.NbBundle; import org.openide.util.NbBundle.Messages; import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException; @@ -43,6 +41,7 @@ import org.sleuthkit.datamodel.AbstractFile; public final class AddEditCentralRepoCommentAction extends AbstractAction { private static final Logger logger = Logger.getLogger(AddEditCentralRepoCommentAction.class.getName()); + private static final long serialVersionUID = 1L; private boolean addToDatabase; private CorrelationAttribute correlationAttribute; @@ -110,9 +109,9 @@ public final class AddEditCentralRepoCommentAction extends AbstractAction { comment = centralRepoCommentDialog.getComment(); if (fileId != null) { try { - Case.getCurrentCaseThrows().notifyCentralRepoCommentChanged(fileId); - } catch (NoCurrentCaseException ignored) { - //WJS should this be ignored or is it an issue in multi-user instances + Case.getCurrentCaseThrows().notifyCentralRepoCommentChanged(fileId, comment); + } catch (NoCurrentCaseException ex) { + logger.log(Level.WARNING, "Case not open after changing central repository comment", ex); } } } catch (EamDbException ex) {