mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-17 18:17:43 +00:00
Merge pull request #6685 from sleuthkit/tagset_refactor
TagSet refactoring while debugging LE Bundle issue. No logic/public API changes
This commit is contained in:
commit
7f8cbc3406
@ -61,19 +61,19 @@ final public class TagNameDefinition implements Comparable<TagNameDefinition> {
|
||||
private final TskData.FileKnown knownStatus;
|
||||
|
||||
private static final List<TagNameDefinition> STANDARD_TAGS_DEFINITIONS = new ArrayList<>();
|
||||
private static final List<String> OLD_CATEGORY_TAG_NAMES = new ArrayList<>();
|
||||
private static final List<String> PROJECT_VIC_NAMES_NO_LONGER_USED = new ArrayList<>();
|
||||
|
||||
static {
|
||||
STANDARD_TAGS_DEFINITIONS.add(new TagNameDefinition(Bundle.TagNameDefinition_predefTagNames_bookmark_text(), "", TagName.HTML_COLOR.NONE, TskData.FileKnown.UNKNOWN));
|
||||
STANDARD_TAGS_DEFINITIONS.add(new TagNameDefinition(Bundle.TagNameDefinition_predefTagNames_followUp_text(), "", TagName.HTML_COLOR.NONE, TskData.FileKnown.UNKNOWN));
|
||||
STANDARD_TAGS_DEFINITIONS.add(new TagNameDefinition(Bundle.TagNameDefinition_predefTagNames_notableItem_text(), "", TagName.HTML_COLOR.NONE, TskData.FileKnown.BAD));
|
||||
|
||||
OLD_CATEGORY_TAG_NAMES.add("CAT-1: Child Exploitation (Illegal)");
|
||||
OLD_CATEGORY_TAG_NAMES.add("CAT-2: Child Exploitation (Non-Illegal/Age Difficult)");
|
||||
OLD_CATEGORY_TAG_NAMES.add("CAT-3: CGI/Animation (Child Exploitive)");
|
||||
OLD_CATEGORY_TAG_NAMES.add("CAT-4: Exemplar/Comparison (Internal Use Only)");
|
||||
OLD_CATEGORY_TAG_NAMES.add("CAT-5: Non-pertinent");
|
||||
OLD_CATEGORY_TAG_NAMES.add("CAT-0: Uncategorized");
|
||||
PROJECT_VIC_NAMES_NO_LONGER_USED.add("CAT-1: Child Exploitation (Illegal)");
|
||||
PROJECT_VIC_NAMES_NO_LONGER_USED.add("CAT-2: Child Exploitation (Non-Illegal/Age Difficult)");
|
||||
PROJECT_VIC_NAMES_NO_LONGER_USED.add("CAT-3: CGI/Animation (Child Exploitive)");
|
||||
PROJECT_VIC_NAMES_NO_LONGER_USED.add("CAT-4: Exemplar/Comparison (Internal Use Only)");
|
||||
PROJECT_VIC_NAMES_NO_LONGER_USED.add("CAT-5: Non-pertinent");
|
||||
PROJECT_VIC_NAMES_NO_LONGER_USED.add("CAT-0: Uncategorized");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -259,7 +259,7 @@ final public class TagNameDefinition implements Comparable<TagNameDefinition> {
|
||||
*/
|
||||
static synchronized Set<TagNameDefinition> getTagNameDefinitions() {
|
||||
if (needsVersionUpdate()) {
|
||||
updateTagDefinitions();
|
||||
updatePropertyFile();
|
||||
}
|
||||
|
||||
String tagsProperty = ModuleSettings.getConfigSetting(TAGS_SETTINGS_NAME, TAG_NAMES_SETTING_KEY);
|
||||
@ -311,7 +311,7 @@ final public class TagNameDefinition implements Comparable<TagNameDefinition> {
|
||||
/**
|
||||
* Updates the Tag Definition file to the current format.
|
||||
*/
|
||||
private static void updateTagDefinitions() {
|
||||
private static void updatePropertyFile() {
|
||||
Integer version = getPropertyFileVersion();
|
||||
List<TagNameDefinition> definitions = new ArrayList<>();
|
||||
|
||||
@ -355,18 +355,18 @@ final public class TagNameDefinition implements Comparable<TagNameDefinition> {
|
||||
}
|
||||
|
||||
// Remove the standard and Project VIC tags from the list
|
||||
List<String> tagStrings = new ArrayList<>();
|
||||
List<String> tagStringsToKeep = new ArrayList<>();
|
||||
List<String> standardTags = getStandardTagNames();
|
||||
for (TagNameDefinition def : definitions) {
|
||||
if (!standardTags.contains(def.getDisplayName())
|
||||
&& !OLD_CATEGORY_TAG_NAMES.contains(def.getDisplayName())) {
|
||||
tagStrings.add(def.toSettingsFormat());
|
||||
&& !PROJECT_VIC_NAMES_NO_LONGER_USED.contains(def.getDisplayName())) {
|
||||
tagStringsToKeep.add(def.toSettingsFormat());
|
||||
}
|
||||
}
|
||||
|
||||
// Write out the version and the new tag list.
|
||||
ModuleSettings.setConfigSetting(TAGS_SETTINGS_NAME, TAG_SETTING_VERSION_KEY, Integer.toString(TAG_SETTINGS_VERSION));
|
||||
ModuleSettings.setConfigSetting(TAGS_SETTINGS_NAME, TAG_NAMES_SETTING_KEY, String.join(";", tagStrings));
|
||||
ModuleSettings.setConfigSetting(TAGS_SETTINGS_NAME, TAG_NAMES_SETTING_KEY, String.join(";", tagStringsToKeep));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -88,7 +88,7 @@ final public class TagSetDefinition {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of the defined TagSet objects.
|
||||
* Returns a list of configured TagSets (from the user's config folder)
|
||||
*
|
||||
* @return A list of TagSetDefinition objects or empty list if none were
|
||||
* found.
|
||||
|
@ -55,7 +55,9 @@ public class TagsManager implements Closeable {
|
||||
private static final Logger LOGGER = Logger.getLogger(TagsManager.class.getName());
|
||||
private final SleuthkitCase caseDb;
|
||||
|
||||
private static String DEFAULT_TAG_SET_NAME = "Project VIC";
|
||||
// NOTE: This name is also hard coded in Image Gallery and Projet Vic module.
|
||||
// They need to stay in sync
|
||||
private static String PROJECT_VIC_TAG_SET_NAME = "Project VIC";
|
||||
|
||||
private static final Object lock = new Object();
|
||||
|
||||
@ -196,7 +198,7 @@ public class TagsManager implements Closeable {
|
||||
try {
|
||||
List<TagSet> tagSetList = Case.getCurrentCaseThrows().getSleuthkitCase().getTaggingManager().getTagSets();
|
||||
for (TagSet tagSet : tagSetList) {
|
||||
if (tagSet.getName().equals(DEFAULT_TAG_SET_NAME)) {
|
||||
if (tagSet.getName().equals(PROJECT_VIC_TAG_SET_NAME)) {
|
||||
for (TagName tagName : tagSet.getTagNames()) {
|
||||
tagList.add(tagName.getDisplayName());
|
||||
}
|
||||
@ -237,7 +239,7 @@ public class TagsManager implements Closeable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TagSetDefinition file.
|
||||
* Creates a new TagSetDefinition file that will be used for future cases
|
||||
*
|
||||
* @param tagSetDef The tag set definition.
|
||||
*
|
||||
@ -258,23 +260,26 @@ public class TagsManager implements Closeable {
|
||||
TagsManager(SleuthkitCase caseDb) {
|
||||
this.caseDb = caseDb;
|
||||
|
||||
// Add standard tags and the Project VIC default tag set and tags.
|
||||
// Add standard tags and any configured tag sets.
|
||||
TaggingManager taggingMgr = caseDb.getTaggingManager();
|
||||
try {
|
||||
List<TagSet> setList = taggingMgr.getTagSets();
|
||||
if (setList.isEmpty()) {
|
||||
List<TagSet> tagSetsInCase = taggingMgr.getTagSets();
|
||||
if (tagSetsInCase.isEmpty()) {
|
||||
|
||||
// add the standard tag names
|
||||
for (TagNameDefinition def : TagNameDefinition.getStandardTagNameDefinitions()) {
|
||||
caseDb.addOrUpdateTagName(def.getDisplayName(), def.getDescription(), def.getColor(), def.getKnownStatus());
|
||||
}
|
||||
//Assume new case and add tag sets
|
||||
|
||||
//Assume new case and add all tag sets
|
||||
for (TagSetDefinition setDef : TagSetDefinition.readTagSetDefinitions()) {
|
||||
List<TagName> tagNameList = new ArrayList<>();
|
||||
List<TagName> tagNamesInSet = new ArrayList<>();
|
||||
for (TagNameDefinition tagNameDef : setDef.getTagNameDefinitions()) {
|
||||
tagNameList.add(caseDb.addOrUpdateTagName(tagNameDef.getDisplayName(), tagNameDef.getDescription(), tagNameDef.getColor(), tagNameDef.getKnownStatus()));
|
||||
tagNamesInSet.add(caseDb.addOrUpdateTagName(tagNameDef.getDisplayName(), tagNameDef.getDescription(), tagNameDef.getColor(), tagNameDef.getKnownStatus()));
|
||||
}
|
||||
|
||||
if (!tagNameList.isEmpty()) {
|
||||
taggingMgr.addTagSet(setDef.getName(), tagNameList);
|
||||
if (!tagNamesInSet.isEmpty()) {
|
||||
taggingMgr.addTagSet(setDef.getName(), tagNamesInSet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ import org.openide.util.NbBundle;
|
||||
|
||||
/**
|
||||
* Enum to represent the six categories in the DHS image categorization scheme.
|
||||
* NOTE: This appears to not be used anywhere anymore after the ImageGallery refactoring
|
||||
*/
|
||||
@NbBundle.Messages({
|
||||
"Category.one=CAT-1: Child Exploitation (Illegal)",
|
||||
|
Loading…
x
Reference in New Issue
Block a user