mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-12 07:56:16 +00:00
cleanup Follow Up tag and Category TagNames (prevent short name version from being added, by removing commas)
This commit is contained in:
parent
e1e5e78bd0
commit
edfe858dd8
@ -371,6 +371,7 @@ public final class ImageGalleryController {
|
||||
historyManager.clear();
|
||||
});
|
||||
Category.clearTagNames();
|
||||
TagUtils.clearFollowUpTagName();
|
||||
|
||||
Toolbar.getDefault().reset();
|
||||
groupManager.clear();
|
||||
|
@ -20,10 +20,12 @@ package org.sleuthkit.autopsy.imagegallery;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import java.util.stream.Collectors;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.scene.control.MenuItem;
|
||||
@ -43,34 +45,36 @@ import org.sleuthkit.datamodel.TskCoreException;
|
||||
*/
|
||||
public class TagUtils {
|
||||
|
||||
private static final String follow_Up = "Follow Up";
|
||||
private static final String FOLLOW_UP = "Follow Up";
|
||||
|
||||
private static TagName followUpTagName;
|
||||
|
||||
/**
|
||||
* Use when closing a case to make sure everything is re-initialized in the
|
||||
* next case.
|
||||
*/
|
||||
public static void clearFollowUpTagName() {
|
||||
followUpTagName = null;
|
||||
}
|
||||
|
||||
private final static List<TagListener> listeners = new ArrayList<>();
|
||||
|
||||
synchronized public static TagName getFollowUpTagName() throws TskCoreException {
|
||||
if (followUpTagName == null) {
|
||||
followUpTagName = getTagName(follow_Up);
|
||||
followUpTagName = getTagName(FOLLOW_UP);
|
||||
}
|
||||
return followUpTagName;
|
||||
}
|
||||
|
||||
static public Collection<TagName> getNonCategoryTagNames() {
|
||||
List<TagName> nonCatTagNames = new ArrayList<>();
|
||||
List<TagName> allTagNames;
|
||||
try {
|
||||
allTagNames = Case.getCurrentCase().getServices().getTagsManager().getAllTagNames();
|
||||
for (TagName tn : allTagNames) {
|
||||
if (tn.getDisplayName().startsWith(Category.CATEGORY_PREFIX) == false) {
|
||||
nonCatTagNames.add(tn);
|
||||
}
|
||||
}
|
||||
return Case.getCurrentCase().getServices().getTagsManager().getAllTagNames().stream()
|
||||
.filter(Category::isCategoryTagName)
|
||||
.collect(Collectors.toSet());
|
||||
} catch (TskCoreException | IllegalStateException ex) {
|
||||
Logger.getLogger(TagUtils.class.getName()).log(Level.WARNING, "couldn't access case", ex);
|
||||
}
|
||||
|
||||
return nonCatTagNames;
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
synchronized static public TagName getTagName(String displayName) throws TskCoreException {
|
||||
@ -94,7 +98,7 @@ public class TagUtils {
|
||||
}
|
||||
|
||||
public static void fireChange(Collection<Long> ids) {
|
||||
Set<TagUtils.TagListener> listenersCopy = new HashSet<TagUtils.TagListener>(listeners);
|
||||
Set<TagUtils.TagListener> listenersCopy = new HashSet<>(listeners);
|
||||
synchronized (listeners) {
|
||||
listenersCopy.addAll(listeners);
|
||||
}
|
||||
@ -132,6 +136,7 @@ public class TagUtils {
|
||||
}
|
||||
|
||||
public static interface TagListener {
|
||||
|
||||
public void handleTagsChanged(Collection<Long> ids);
|
||||
}
|
||||
}
|
||||
|
@ -78,6 +78,8 @@ public class DeleteFollowUpTag extends Action {
|
||||
}
|
||||
}
|
||||
IngestServices.getInstance().fireModuleDataEvent(new ModuleDataEvent("TagAction", BlackboardArtifact.ARTIFACT_TYPE.TSK_TAG_FILE)); //NON-NLS
|
||||
|
||||
//make sure rest of ui hears category change.
|
||||
controller.getGroupManager().handleFileUpdate(FileUpdateEvent.newUpdateEvent(Collections.singleton(fileID), DrawableAttribute.TAGS));
|
||||
} catch (TskCoreException ex) {
|
||||
LOGGER.log(Level.SEVERE, "Failed to delete follow up tag.", ex);
|
||||
|
@ -34,16 +34,17 @@ import org.sleuthkit.datamodel.TskCoreException;
|
||||
*/
|
||||
public enum Category implements Comparable<Category> {
|
||||
|
||||
ZERO(Color.LIGHTGREY, 0, "CAT-0, Uncategorized"),
|
||||
ONE(Color.RED, 1, "CAT-1, Child Exploitation (Illegal)"),
|
||||
TWO(Color.ORANGE, 2, "CAT-2, Child Exploitation (Non-Illegal/Age Difficult)"),
|
||||
THREE(Color.YELLOW, 3, "CAT-3, CGI/Animation (Child Exploitive)"),
|
||||
FOUR(Color.BISQUE, 4, "CAT-4, Exemplar/Comparison (Internal Use Only)"),
|
||||
FIVE(Color.GREEN, 5, "CAT-5, Non-pertinent");
|
||||
ZERO(Color.LIGHTGREY, 0, "CAT-0: Uncategorized"),
|
||||
ONE(Color.RED, 1, "CAT-1: Child Exploitation (Illegal)"),
|
||||
TWO(Color.ORANGE, 2, "CAT-2: Child Exploitation (Non-Illegal/Age Difficult)"),
|
||||
THREE(Color.YELLOW, 3, "CAT-3: CGI/Animation (Child Exploitive)"),
|
||||
FOUR(Color.BISQUE, 4, "CAT-4: Exemplar/Comparison (Internal Use Only)"),
|
||||
FIVE(Color.GREEN, 5, "CAT-5: Non-pertinent");
|
||||
|
||||
/** map from displayName to enum value */
|
||||
private static final Map<String, Category> nameMap
|
||||
= Stream.of(values()).collect(Collectors.toMap(Category::getDisplayName,
|
||||
= Stream.of(values()).collect(Collectors.toMap(
|
||||
Category::getDisplayName,
|
||||
Function.identity()));
|
||||
|
||||
public static final String CATEGORY_PREFIX = "CAT-";
|
||||
@ -65,6 +66,10 @@ public enum Category implements Comparable<Category> {
|
||||
Category.FIVE.tagName = null;
|
||||
}
|
||||
|
||||
public static boolean isCategoryTagName(TagName tName) {
|
||||
return nameMap.containsKey(tName.getDisplayName());
|
||||
}
|
||||
|
||||
private TagName tagName;
|
||||
|
||||
private final Color color;
|
||||
|
@ -26,6 +26,7 @@ import java.util.Collection;
|
||||
import java.util.concurrent.atomic.LongAdder;
|
||||
import java.util.logging.Level;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
import org.sleuthkit.autopsy.imagegallery.TagUtils;
|
||||
|
||||
/**
|
||||
* Provides a cached view of the number of files per category, and fires
|
||||
@ -75,6 +76,7 @@ public class CategoryManager {
|
||||
this.db = db;
|
||||
categoryCounts.invalidateAll();
|
||||
Category.clearTagNames();
|
||||
TagUtils.clearFollowUpTagName();
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user