From 9c9a197067b6c6f7a7dca9103d3a3a15d3665e4e Mon Sep 17 00:00:00 2001 From: sidheshenator Date: Wed, 11 Mar 2015 12:32:22 -0400 Subject: [PATCH 1/5] check duplicate tag-file pair before adding to the DB --- .../autopsy/actions/AddContentTagAction.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Core/src/org/sleuthkit/autopsy/actions/AddContentTagAction.java b/Core/src/org/sleuthkit/autopsy/actions/AddContentTagAction.java index aef2d79530..b5c9e1b9fc 100755 --- a/Core/src/org/sleuthkit/autopsy/actions/AddContentTagAction.java +++ b/Core/src/org/sleuthkit/autopsy/actions/AddContentTagAction.java @@ -19,6 +19,7 @@ package org.sleuthkit.autopsy.actions; import java.util.Collection; +import java.util.List; import java.util.logging.Level; import javax.swing.JOptionPane; @@ -28,6 +29,7 @@ import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.datamodel.AbstractFile; import org.sleuthkit.datamodel.Content; +import org.sleuthkit.datamodel.ContentTag; import org.sleuthkit.datamodel.TagName; import org.sleuthkit.datamodel.TskCoreException; @@ -109,7 +111,14 @@ public class AddContentTagAction extends AddTagAction { continue; } } - + // check if the same tag is being added for the same abstract file. + List contentTagList = Case.getCurrentCase().getServices().getTagsManager().getAllContentTags(); + for (ContentTag contentTag : contentTagList) { + if (contentTag.getName().getDisplayName().equals(tagName.getDisplayName()) && contentTag.getContent().getId() == file.getId()) { + // Notify the user that the same tag is being assigned to the same file. + return; + } + } Case.getCurrentCase().getServices().getTagsManager().addContentTag(file, tagName, comment); } catch (TskCoreException ex) { From 182b00d9e9019e4e6dc939f104646993381da0a6 Mon Sep 17 00:00:00 2001 From: sidheshenator Date: Wed, 11 Mar 2015 12:53:49 -0400 Subject: [PATCH 2/5] User notified in case of duplicate tagging attempt --- .../org/sleuthkit/autopsy/actions/AddContentTagAction.java | 5 ++++- Core/src/org/sleuthkit/autopsy/actions/Bundle.properties | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Core/src/org/sleuthkit/autopsy/actions/AddContentTagAction.java b/Core/src/org/sleuthkit/autopsy/actions/AddContentTagAction.java index b5c9e1b9fc..9f2a90cf00 100755 --- a/Core/src/org/sleuthkit/autopsy/actions/AddContentTagAction.java +++ b/Core/src/org/sleuthkit/autopsy/actions/AddContentTagAction.java @@ -27,6 +27,7 @@ import org.openide.util.NbBundle; import org.openide.util.Utilities; import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.coreutils.Logger; +import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil; import org.sleuthkit.datamodel.AbstractFile; import org.sleuthkit.datamodel.Content; import org.sleuthkit.datamodel.ContentTag; @@ -115,7 +116,9 @@ public class AddContentTagAction extends AddTagAction { List contentTagList = Case.getCurrentCase().getServices().getTagsManager().getAllContentTags(); for (ContentTag contentTag : contentTagList) { if (contentTag.getName().getDisplayName().equals(tagName.getDisplayName()) && contentTag.getContent().getId() == file.getId()) { - // Notify the user that the same tag is being assigned to the same file. + MessageNotifyUtil.Message.error(NbBundle.getMessage(this.getClass(), + "AddContentTagAction.tagExists", + file.getName(), tagName.getDisplayName())); return; } } diff --git a/Core/src/org/sleuthkit/autopsy/actions/Bundle.properties b/Core/src/org/sleuthkit/autopsy/actions/Bundle.properties index 6c3e5ce690..ca5c8b3174 100755 --- a/Core/src/org/sleuthkit/autopsy/actions/Bundle.properties +++ b/Core/src/org/sleuthkit/autopsy/actions/Bundle.properties @@ -24,6 +24,7 @@ AddContentTagAction.unableToTag.msg=Unable to tag {0}, not a regular file. AddContentTagAction.cannotApplyTagErr=Cannot Apply Tag AddContentTagAction.unableToTag.msg2=Unable to tag {0}. AddContentTagAction.taggingErr=Tagging Error +AddContentTagAction.tagExists={0} has been tagged as {1}. Cannot reapply the same tag. AddTagAction.quickTag=Quick Tag AddTagAction.noTags=No tags AddTagAction.newTag=New Tag... From 833334d9dc72c4b084f5ecb5758f946a7c7c4525 Mon Sep 17 00:00:00 2001 From: sidheshenator Date: Thu, 12 Mar 2015 09:45:22 -0400 Subject: [PATCH 3/5] used getContentTagsByContent() instead of getAllContentTags() --- .../sleuthkit/autopsy/actions/AddContentTagAction.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/actions/AddContentTagAction.java b/Core/src/org/sleuthkit/autopsy/actions/AddContentTagAction.java index 9f2a90cf00..5ce1babbba 100755 --- a/Core/src/org/sleuthkit/autopsy/actions/AddContentTagAction.java +++ b/Core/src/org/sleuthkit/autopsy/actions/AddContentTagAction.java @@ -113,12 +113,12 @@ public class AddContentTagAction extends AddTagAction { } } // check if the same tag is being added for the same abstract file. - List contentTagList = Case.getCurrentCase().getServices().getTagsManager().getAllContentTags(); + List contentTagList = Case.getCurrentCase().getServices().getTagsManager().getContentTagsByContent(file); for (ContentTag contentTag : contentTagList) { - if (contentTag.getName().getDisplayName().equals(tagName.getDisplayName()) && contentTag.getContent().getId() == file.getId()) { + if (contentTag.getName().getDisplayName().equals(tagName.getDisplayName())) { MessageNotifyUtil.Message.error(NbBundle.getMessage(this.getClass(), - "AddContentTagAction.tagExists", - file.getName(), tagName.getDisplayName())); + "AddContentTagAction.tagExists", + file.getName(), tagName.getDisplayName())); return; } } From cb40a3c6a04301041972438ce532ec1ede40c2ff Mon Sep 17 00:00:00 2001 From: sidheshenator Date: Thu, 12 Mar 2015 10:46:41 -0400 Subject: [PATCH 4/5] Reference to TagsManager saved and reused --- .../org/sleuthkit/autopsy/actions/AddContentTagAction.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/actions/AddContentTagAction.java b/Core/src/org/sleuthkit/autopsy/actions/AddContentTagAction.java index 5ce1babbba..9488089061 100755 --- a/Core/src/org/sleuthkit/autopsy/actions/AddContentTagAction.java +++ b/Core/src/org/sleuthkit/autopsy/actions/AddContentTagAction.java @@ -26,6 +26,7 @@ import javax.swing.JOptionPane; import org.openide.util.NbBundle; import org.openide.util.Utilities; import org.sleuthkit.autopsy.casemodule.Case; +import org.sleuthkit.autopsy.casemodule.services.TagsManager; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil; import org.sleuthkit.datamodel.AbstractFile; @@ -113,7 +114,8 @@ public class AddContentTagAction extends AddTagAction { } } // check if the same tag is being added for the same abstract file. - List contentTagList = Case.getCurrentCase().getServices().getTagsManager().getContentTagsByContent(file); + TagsManager tagsManager = Case.getCurrentCase().getServices().getTagsManager(); + List contentTagList = tagsManager.getContentTagsByContent(file); for (ContentTag contentTag : contentTagList) { if (contentTag.getName().getDisplayName().equals(tagName.getDisplayName())) { MessageNotifyUtil.Message.error(NbBundle.getMessage(this.getClass(), @@ -122,7 +124,7 @@ public class AddContentTagAction extends AddTagAction { return; } } - Case.getCurrentCase().getServices().getTagsManager().addContentTag(file, tagName, comment); + tagsManager.addContentTag(file, tagName, comment); } catch (TskCoreException ex) { Logger.getLogger(AddContentTagAction.class.getName()).log(Level.SEVERE, "Error tagging result", ex); //NON-NLS From 30c36346045e9306659c061098869eb50c131e32 Mon Sep 17 00:00:00 2001 From: sidheshenator Date: Thu, 12 Mar 2015 17:32:07 -0400 Subject: [PATCH 5/5] JOptionPanel.showMessageDialog used for consistency --- .../sleuthkit/autopsy/actions/AddContentTagAction.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/actions/AddContentTagAction.java b/Core/src/org/sleuthkit/autopsy/actions/AddContentTagAction.java index 9488089061..cff35af7c1 100755 --- a/Core/src/org/sleuthkit/autopsy/actions/AddContentTagAction.java +++ b/Core/src/org/sleuthkit/autopsy/actions/AddContentTagAction.java @@ -118,9 +118,13 @@ public class AddContentTagAction extends AddTagAction { List contentTagList = tagsManager.getContentTagsByContent(file); for (ContentTag contentTag : contentTagList) { if (contentTag.getName().getDisplayName().equals(tagName.getDisplayName())) { - MessageNotifyUtil.Message.error(NbBundle.getMessage(this.getClass(), - "AddContentTagAction.tagExists", - file.getName(), tagName.getDisplayName())); + JOptionPane.showMessageDialog(null, + NbBundle.getMessage(this.getClass(), + "AddContentTagAction.tagExists", + file.getName(), tagName.getDisplayName()), + NbBundle.getMessage(this.getClass(), + "AddContentTagAction.cannotApplyTagErr"), + JOptionPane.WARNING_MESSAGE); return; } }