diff --git a/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/datamodel/CategoryManager.java b/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/datamodel/CategoryManager.java index f84f759d37..31be08e71a 100644 --- a/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/datamodel/CategoryManager.java +++ b/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/datamodel/CategoryManager.java @@ -20,20 +20,21 @@ import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheLoader; import com.google.common.cache.LoadingCache; +import com.google.common.eventbus.AsyncEventBus; import com.google.common.eventbus.EventBus; import com.google.common.eventbus.Subscribe; import java.util.Collection; import java.util.Collections; import java.util.List; +import java.util.concurrent.Executors; import java.util.concurrent.atomic.LongAdder; import java.util.logging.Level; import javax.annotation.concurrent.Immutable; +import org.apache.commons.lang3.concurrent.BasicThreadFactory; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.events.ContentTagAddedEvent; import org.sleuthkit.autopsy.events.ContentTagDeletedEvent; import org.sleuthkit.autopsy.imagegallery.ImageGalleryController; -import org.sleuthkit.autopsy.imagegallery.datamodel.Category; -import org.sleuthkit.autopsy.imagegallery.datamodel.DrawableDB; import org.sleuthkit.datamodel.ContentTag; import org.sleuthkit.datamodel.TagName; import org.sleuthkit.datamodel.TskCoreException; @@ -66,7 +67,11 @@ public class CategoryManager { /** * Used to distribute {@link CategoryChangeEvent}s */ - private final EventBus categoryEventBus = new EventBus("Category Event Bus"); + private final EventBus categoryEventBus = new AsyncEventBus(Executors.newSingleThreadExecutor( + new BasicThreadFactory.Builder().namingPattern("Category Event Bus").uncaughtExceptionHandler((Thread t, Throwable e) -> { + LOGGER.log(Level.SEVERE, "uncaught exception in event bus handler", e); + }).build() + )); /** * For performance reasons, keep current category counts in memory. All of diff --git a/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/datamodel/DrawableTagsManager.java b/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/datamodel/DrawableTagsManager.java index 57d7152967..af5a0ebced 100644 --- a/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/datamodel/DrawableTagsManager.java +++ b/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/datamodel/DrawableTagsManager.java @@ -18,19 +18,20 @@ */ package org.sleuthkit.autopsy.imagegallery.datamodel; +import com.google.common.eventbus.AsyncEventBus; import com.google.common.eventbus.EventBus; import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Objects; +import java.util.concurrent.Executors; import java.util.logging.Level; import java.util.stream.Collectors; +import org.apache.commons.lang3.concurrent.BasicThreadFactory; import org.sleuthkit.autopsy.casemodule.services.TagsManager; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.events.ContentTagAddedEvent; import org.sleuthkit.autopsy.events.ContentTagDeletedEvent; -import org.sleuthkit.autopsy.imagegallery.datamodel.Category; -import org.sleuthkit.autopsy.imagegallery.datamodel.DrawableFile; import org.sleuthkit.datamodel.Content; import org.sleuthkit.datamodel.ContentTag; import org.sleuthkit.datamodel.TagName; @@ -42,13 +43,20 @@ import org.sleuthkit.datamodel.TskCoreException; */ public class DrawableTagsManager { + private static final Logger LOGGER = Logger.getLogger(DrawableTagsManager.class.getName()); + private static final String FOLLOW_UP = "Follow Up"; final private Object autopsyTagsManagerLock = new Object(); private TagsManager autopsyTagsManager; /** Used to distribute {@link TagsChangeEvent}s */ - private final EventBus tagsEventBus = new EventBus("Tags Event Bus"); + private final EventBus tagsEventBus = new AsyncEventBus( + Executors.newSingleThreadExecutor( + new BasicThreadFactory.Builder().namingPattern("Tags Event Bus").uncaughtExceptionHandler((Thread t, Throwable e) -> { + LOGGER.log(Level.SEVERE, "uncaught exception in event bus handler", e); + }).build() + )); /** The tag name corresponding to the "built-in" tag "Follow Up" */ private TagName followUpTagName; @@ -130,7 +138,7 @@ public class DrawableTagsManager { .filter(CategoryManager::isCategoryTagName) .collect(Collectors.toSet()); } catch (TskCoreException | IllegalStateException ex) { - Logger.getLogger(DrawableTagsManager.class.getName()).log(Level.WARNING, "couldn't access case", ex); + LOGGER.log(Level.WARNING, "couldn't access case", ex); } return Collections.emptySet(); } @@ -166,7 +174,7 @@ public class DrawableTagsManager { throw new TskCoreException("tagame exists but wasn't found", ex); } } catch (IllegalStateException ex) { - Logger.getLogger(DrawableTagsManager.class.getName()).log(Level.SEVERE, "Case was closed out from underneath", ex); + LOGGER.log(Level.SEVERE, "Case was closed out from underneath", ex); throw new TskCoreException("Case was closed out from underneath", ex); } } diff --git a/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/datamodel/grouping/GroupManager.java b/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/datamodel/grouping/GroupManager.java index ad99d94407..dc27ac136b 100644 --- a/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/datamodel/grouping/GroupManager.java +++ b/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/datamodel/grouping/GroupManager.java @@ -537,15 +537,16 @@ public class GroupManager { @Subscribe public void handleTagAdded(ContentTagAddedEvent evt) { GroupKey groupKey = null; - if (groupBy == DrawableAttribute.TAGS) { - groupKey = new GroupKey(DrawableAttribute.TAGS, evt.getTag().getName()); - } else if (groupBy == DrawableAttribute.CATEGORY) { + if (groupBy == DrawableAttribute.CATEGORY && CategoryManager.isCategoryTagName(evt.getTag().getName())) { groupKey = new GroupKey(DrawableAttribute.CATEGORY, CategoryManager.categoryFromTagName(evt.getTag().getName())); + } else if (groupBy == DrawableAttribute.TAGS && CategoryManager.isNotCategoryTagName(evt.getTag().getName())) { + groupKey = new GroupKey(DrawableAttribute.TAGS, evt.getTag().getName()); + } + if (groupKey != null) { + final long fileID = evt.getTag().getContent().getId(); + DrawableGroup g = getGroupForKey(groupKey); + addFileToGroup(g, groupKey, fileID); } - final long fileID = evt.getTag().getContent().getId(); - DrawableGroup g = getGroupForKey(groupKey); - addFileToGroup(g, groupKey, fileID); - } @SuppressWarnings("AssignmentToMethodParameter") @@ -563,13 +564,16 @@ public class GroupManager { @Subscribe public void handleTagDeleted(ContentTagDeletedEvent evt) { GroupKey groupKey = null; - if (groupBy == DrawableAttribute.TAGS) { - groupKey = new GroupKey(DrawableAttribute.TAGS, evt.getTag().getName()); - } else if (groupBy == DrawableAttribute.CATEGORY) { + if (groupBy == DrawableAttribute.CATEGORY && CategoryManager.isCategoryTagName(evt.getTag().getName())) { groupKey = new GroupKey(DrawableAttribute.CATEGORY, CategoryManager.categoryFromTagName(evt.getTag().getName())); + } else if (groupBy == DrawableAttribute.TAGS && CategoryManager.isNotCategoryTagName(evt.getTag().getName())) { + groupKey = new GroupKey(DrawableAttribute.TAGS, evt.getTag().getName()); + } + + if (groupKey != null) { + final long fileID = evt.getTag().getContent().getId(); + DrawableGroup g = removeFromGroup(groupKey, fileID); } - final long fileID = evt.getTag().getContent().getId(); - DrawableGroup g = removeFromGroup(groupKey, fileID); } @Subscribe