mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-13 00:16:16 +00:00
Merge pull request #6026 from rcordovano/6567-tag-name-serialization-fix
6567 tag name serialization fix
This commit is contained in:
commit
a5f99d5e7f
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Autopsy Forensic Browser
|
* Autopsy Forensic Browser
|
||||||
*
|
*
|
||||||
* Copyright 2011-2019 Basis Technology Corp.
|
* Copyright 2013-2020 Basis Technology Corp.
|
||||||
* Contact: carrier <at> sleuthkit <dot> org
|
* Contact: carrier <at> sleuthkit <dot> org
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -139,7 +139,7 @@ abstract class AddTagAction extends AbstractAction implements Presenter.Popup {
|
|||||||
if (!tagNamesMap.isEmpty()) {
|
if (!tagNamesMap.isEmpty()) {
|
||||||
for (Map.Entry<String, TagName> entry : tagNamesMap.entrySet()) {
|
for (Map.Entry<String, TagName> entry : tagNamesMap.entrySet()) {
|
||||||
TagName tagName = entry.getValue();
|
TagName tagName = entry.getValue();
|
||||||
TagSet tagSet = tagName.getTagSet();
|
TagSet tagSet = tagsManager.getTagSet(tagName);
|
||||||
|
|
||||||
// Show custom tags before predefined tags in the menu
|
// Show custom tags before predefined tags in the menu
|
||||||
if (tagSet != null) {
|
if (tagSet != null) {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Autopsy Forensic Browser
|
* Autopsy Forensic Browser
|
||||||
*
|
*
|
||||||
* Copyright 2011-2018 Basis Technology Corp.
|
* Copyright 2013-2020 Basis Technology Corp.
|
||||||
* Contact: carrier <at> sleuthkit <dot> org
|
* Contact: carrier <at> sleuthkit <dot> org
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -23,7 +23,6 @@ import java.awt.Window;
|
|||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -36,7 +35,6 @@ import javax.swing.JComponent;
|
|||||||
import javax.swing.JDialog;
|
import javax.swing.JDialog;
|
||||||
import javax.swing.JList;
|
import javax.swing.JList;
|
||||||
import javax.swing.KeyStroke;
|
import javax.swing.KeyStroke;
|
||||||
import org.openide.util.Exceptions;
|
|
||||||
import org.openide.util.NbBundle;
|
import org.openide.util.NbBundle;
|
||||||
import org.openide.windows.WindowManager;
|
import org.openide.windows.WindowManager;
|
||||||
import org.sleuthkit.autopsy.casemodule.Case;
|
import org.sleuthkit.autopsy.casemodule.Case;
|
||||||
@ -150,7 +148,7 @@ public class GetTagNameAndCommentDialog extends JDialog {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
TagsManager tagsManager = Case.getCurrentCaseThrows().getServices().getTagsManager();
|
TagsManager tagsManager = Case.getCurrentCaseThrows().getServices().getTagsManager();
|
||||||
List<String> standardTagNames = TagsManager.getStandardTagNames();
|
List<String> standardTagNames = TagsManager.getStandardTagNames();
|
||||||
Map<String, TagName> tagNamesMap = new TreeMap<>(tagsManager.getDisplayNamesToTagNamesMap());
|
Map<String, TagName> tagNamesMap = new TreeMap<>(tagsManager.getDisplayNamesToTagNamesMap());
|
||||||
@ -161,7 +159,7 @@ public class GetTagNameAndCommentDialog extends JDialog {
|
|||||||
tagNamesMap.entrySet().stream().map((entry) -> entry.getValue()).forEachOrdered((tagName) -> {
|
tagNamesMap.entrySet().stream().map((entry) -> entry.getValue()).forEachOrdered((tagName) -> {
|
||||||
TagSet tagSet = null;
|
TagSet tagSet = null;
|
||||||
try {
|
try {
|
||||||
tagSet = tagName.getTagSet();
|
tagSet = tagsManager.getTagSet(tagName);
|
||||||
} catch (TskCoreException ex) {
|
} catch (TskCoreException ex) {
|
||||||
Logger.getLogger(GetTagNameAndCommentDialog.class
|
Logger.getLogger(GetTagNameAndCommentDialog.class
|
||||||
.getName()).log(Level.SEVERE, "Failed to get tag set", ex); //NON-NLS
|
.getName()).log(Level.SEVERE, "Failed to get tag set", ex); //NON-NLS
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Autopsy Forensic Browser
|
* Autopsy Forensic Browser
|
||||||
*
|
*
|
||||||
* Copyright 2018 Basis Technology Corp.
|
* Copyright 2018-2020 Basis Technology Corp.
|
||||||
* Contact: carrier <at> sleuthkit <dot> org
|
* Contact: carrier <at> sleuthkit <dot> org
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -131,7 +131,7 @@ abstract class ReplaceTagAction<T extends Tag> extends AbstractAction implements
|
|||||||
if (!tagNamesMap.isEmpty()) {
|
if (!tagNamesMap.isEmpty()) {
|
||||||
for (Map.Entry<String, TagName> entry : tagNamesMap.entrySet()) {
|
for (Map.Entry<String, TagName> entry : tagNamesMap.entrySet()) {
|
||||||
TagName tagName = entry.getValue();
|
TagName tagName = entry.getValue();
|
||||||
TagSet tagSet = tagName.getTagSet();
|
TagSet tagSet = tagsManager.getTagSet(tagName);
|
||||||
|
|
||||||
// Show custom tags before predefined tags in the menu
|
// Show custom tags before predefined tags in the menu
|
||||||
if (tagSet != null) {
|
if (tagSet != null) {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Autopsy Forensic Browser
|
* Autopsy Forensic Browser
|
||||||
*
|
*
|
||||||
* Copyright 2011-2020 Basis Technology Corp.
|
* Copyright 2013-2020 Basis Technology Corp.
|
||||||
* Contact: carrier <at> sleuthkit <dot> org
|
* Contact: carrier <at> sleuthkit <dot> org
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -56,7 +56,7 @@ public class TagsManager implements Closeable {
|
|||||||
private final SleuthkitCase caseDb;
|
private final SleuthkitCase caseDb;
|
||||||
|
|
||||||
private static String DEFAULT_TAG_SET_NAME = "Project VIC";
|
private static String DEFAULT_TAG_SET_NAME = "Project VIC";
|
||||||
|
|
||||||
private static final Object lock = new Object();
|
private static final Object lock = new Object();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
@ -235,16 +235,16 @@ public class TagsManager implements Closeable {
|
|||||||
public static String getNotableTagDisplayName() {
|
public static String getNotableTagDisplayName() {
|
||||||
return TagNameDefinition.getNotableTagDisplayName();
|
return TagNameDefinition.getNotableTagDisplayName();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new TagSetDefinition file.
|
* Creates a new TagSetDefinition file.
|
||||||
*
|
*
|
||||||
* @param tagSetDef The tag set definition.
|
* @param tagSetDef The tag set definition.
|
||||||
*
|
*
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public static void addTagSetDefinition(TagSetDefinition tagSetDef) throws IOException {
|
public static void addTagSetDefinition(TagSetDefinition tagSetDef) throws IOException {
|
||||||
synchronized(lock) {
|
synchronized (lock) {
|
||||||
TagSetDefinition.writeTagSetDefinition(tagSetDef);
|
TagSetDefinition.writeTagSetDefinition(tagSetDef);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -267,20 +267,20 @@ public class TagsManager implements Closeable {
|
|||||||
caseDb.addOrUpdateTagName(def.getDisplayName(), def.getDescription(), def.getColor(), def.getKnownStatus());
|
caseDb.addOrUpdateTagName(def.getDisplayName(), def.getDescription(), def.getColor(), def.getKnownStatus());
|
||||||
}
|
}
|
||||||
//Assume new case and add tag sets
|
//Assume new case and add tag sets
|
||||||
for(TagSetDefinition setDef: TagSetDefinition.readTagSetDefinitions()) {
|
for (TagSetDefinition setDef : TagSetDefinition.readTagSetDefinitions()) {
|
||||||
List<TagName> tagNameList = new ArrayList<>();
|
List<TagName> tagNameList = new ArrayList<>();
|
||||||
for(TagNameDefinition tagNameDef: setDef.getTagNameDefinitions()) {
|
for (TagNameDefinition tagNameDef : setDef.getTagNameDefinitions()) {
|
||||||
tagNameList.add(caseDb.addOrUpdateTagName(tagNameDef.getDisplayName(), tagNameDef.getDescription(), tagNameDef.getColor(), tagNameDef.getKnownStatus()));
|
tagNameList.add(caseDb.addOrUpdateTagName(tagNameDef.getDisplayName(), tagNameDef.getDescription(), tagNameDef.getColor(), tagNameDef.getKnownStatus()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!tagNameList.isEmpty()) {
|
if (!tagNameList.isEmpty()) {
|
||||||
taggingMgr.addTagSet(setDef.getName(), tagNameList);
|
taggingMgr.addTagSet(setDef.getName(), tagNameList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (TskCoreException ex) {
|
} catch (TskCoreException ex) {
|
||||||
LOGGER.log(Level.SEVERE, "Error updating standard tag name and tag set definitions", ex);
|
LOGGER.log(Level.SEVERE, "Error updating standard tag name and tag set definitions", ex);
|
||||||
} catch(IOException ex) {
|
} catch (IOException ex) {
|
||||||
LOGGER.log(Level.SEVERE, "Error loading tag set JSON files", ex);
|
LOGGER.log(Level.SEVERE, "Error loading tag set JSON files", ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -288,28 +288,41 @@ public class TagsManager implements Closeable {
|
|||||||
tagName.saveToCase(caseDb);
|
tagName.saveToCase(caseDb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a list of all tag sets currently in the case database.
|
* Get a list of all tag sets currently in the case database.
|
||||||
*
|
*
|
||||||
* @return A list, possibly empty, of TagSet objects.
|
* @return A list, possibly empty, of TagSet objects.
|
||||||
*
|
*
|
||||||
* @throws TskCoreException
|
* @throws TskCoreException
|
||||||
*/
|
*/
|
||||||
public List<TagSet> getAllTagSets() throws TskCoreException {
|
public List<TagSet> getAllTagSets() throws TskCoreException {
|
||||||
return caseDb.getTaggingManager().getTagSets();
|
return caseDb.getTaggingManager().getTagSets();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the tag set a tag name (tag definition) belongs to, if any.
|
||||||
|
*
|
||||||
|
* @param tagName The tag name.
|
||||||
|
*
|
||||||
|
* @return A TagSet object or null.
|
||||||
|
*
|
||||||
|
* @throws TskCoreException If there is an error querying the case database.
|
||||||
|
*/
|
||||||
|
public TagSet getTagSet(TagName tagName) throws TskCoreException {
|
||||||
|
return caseDb.getTaggingManager().getTagSet(tagName);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a new TagSet to the case database. Tags will be ranked in the order
|
* Add a new TagSet to the case database. Tags will be ranked in the order
|
||||||
* which they are passed to this method.
|
* which they are passed to this method.
|
||||||
*
|
*
|
||||||
* @param name Tag set name.
|
* @param name Tag set name.
|
||||||
* @param tagNameList List of TagName in rank order.
|
* @param tagNameList List of TagName in rank order.
|
||||||
*
|
*
|
||||||
* @return A new TagSet object.
|
* @return A new TagSet object.
|
||||||
*
|
*
|
||||||
* @throws TskCoreException
|
* @throws TskCoreException
|
||||||
*/
|
*/
|
||||||
public TagSet addTagSet(String name, List<TagName> tagNameList) throws TskCoreException {
|
public TagSet addTagSet(String name, List<TagName> tagNameList) throws TskCoreException {
|
||||||
return caseDb.getTaggingManager().addTagSet(name, tagNameList);
|
return caseDb.getTaggingManager().addTagSet(name, tagNameList);
|
||||||
@ -501,7 +514,7 @@ public class TagsManager implements Closeable {
|
|||||||
* name to the case database.
|
* name to the case database.
|
||||||
*/
|
*/
|
||||||
public TagName addTagName(String displayName, String description, TagName.HTML_COLOR color, TskData.FileKnown knownStatus) throws TagNameAlreadyExistsException, TskCoreException {
|
public TagName addTagName(String displayName, String description, TagName.HTML_COLOR color, TskData.FileKnown knownStatus) throws TagNameAlreadyExistsException, TskCoreException {
|
||||||
synchronized(lock) {
|
synchronized (lock) {
|
||||||
try {
|
try {
|
||||||
TagName tagName = caseDb.addOrUpdateTagName(displayName, description, color, knownStatus);
|
TagName tagName = caseDb.addOrUpdateTagName(displayName, description, color, knownStatus);
|
||||||
Set<TagNameDefinition> customTypes = TagNameDefinition.getTagNameDefinitions();
|
Set<TagNameDefinition> customTypes = TagNameDefinition.getTagNameDefinitions();
|
||||||
|
@ -19,6 +19,9 @@
|
|||||||
package org.sleuthkit.autopsy.tags;
|
package org.sleuthkit.autopsy.tags;
|
||||||
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
import org.sleuthkit.autopsy.casemodule.Case;
|
||||||
|
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
|
||||||
|
import org.sleuthkit.autopsy.casemodule.services.TagsManager;
|
||||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||||
import org.sleuthkit.datamodel.TagName;
|
import org.sleuthkit.datamodel.TagName;
|
||||||
import org.sleuthkit.datamodel.TagSet;
|
import org.sleuthkit.datamodel.TagSet;
|
||||||
@ -52,12 +55,13 @@ public final class TagUtils {
|
|||||||
public static String getDecoratedTagDisplayName(TagName tagName) {
|
public static String getDecoratedTagDisplayName(TagName tagName) {
|
||||||
String displayName = tagName.getDisplayName();
|
String displayName = tagName.getDisplayName();
|
||||||
try {
|
try {
|
||||||
TagSet tagSet = tagName.getTagSet();
|
TagsManager tagsManager = Case.getCurrentCaseThrows().getServices().getTagsManager();
|
||||||
|
TagSet tagSet = tagsManager.getTagSet(tagName);
|
||||||
if (tagSet != null) {
|
if (tagSet != null) {
|
||||||
displayName = tagSet.getName() + ": " + displayName;
|
displayName = tagSet.getName() + ": " + displayName;
|
||||||
}
|
}
|
||||||
} catch (TskCoreException ex) {
|
} catch (NoCurrentCaseException | TskCoreException ex) {
|
||||||
logger.log(Level.WARNING, String.format("Failed to get TagSet for TagName (%d)", tagName.getId()));
|
logger.log(Level.SEVERE, String.format("Failed to get TagSet for TagName '%s' (ID=%d)", tagName.getDisplayName(), tagName.getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tagName.getKnownStatus() == TskData.FileKnown.BAD) {
|
if (tagName.getKnownStatus() == TskData.FileKnown.BAD) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user